mirror of
https://github.com/tendermint/tendermint.git
synced 2026-07-29 11:32:56 +00:00
statesync: improve e2e test outcomes (#6378)
I believe that this, in my testing seems to help the e2e state-sync tests complete more reliably, by fixing some potential, range-related slice building, as well as the way the test app hashes snapshots. Additionally, and I'm not sure if we want to do this, but I added this hook to the reactor that re-sends the request for snapshots during the retry. This helps in tests prevent systems from getting stuck, but I think in reality, it might create more traffic, and operators would just restart a state-syncing node to get a similar effect.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -88,11 +87,10 @@ func (s *SnapshotStore) Create(state *State) (abci.Snapshot, error) {
|
||||
if err != nil {
|
||||
return abci.Snapshot{}, err
|
||||
}
|
||||
hash := sha256.Sum256(bz)
|
||||
snapshot := abci.Snapshot{
|
||||
Height: state.Height,
|
||||
Format: 1,
|
||||
Hash: hash[:],
|
||||
Hash: hashItems(state.Values),
|
||||
Chunks: byteChunks(bz),
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(s.dir, fmt.Sprintf("%v.json", state.Height)), bz, 0644)
|
||||
@@ -111,10 +109,9 @@ func (s *SnapshotStore) Create(state *State) (abci.Snapshot, error) {
|
||||
func (s *SnapshotStore) List() ([]*abci.Snapshot, error) {
|
||||
s.RLock()
|
||||
defer s.RUnlock()
|
||||
snapshots := []*abci.Snapshot{}
|
||||
for _, snapshot := range s.metadata {
|
||||
s := snapshot // copy to avoid pointer to range variable
|
||||
snapshots = append(snapshots, &s)
|
||||
snapshots := make([]*abci.Snapshot, len(s.metadata))
|
||||
for idx := range s.metadata {
|
||||
snapshots[idx] = &s.metadata[idx]
|
||||
}
|
||||
return snapshots, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user