Skip to content

Commit

Permalink
statesync: convert snapshot hashes to hex strings for logging (tender…
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwaters authored Sep 26, 2022
1 parent ed68aad commit af5281d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions statesync/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (s *syncer) AddSnapshot(peer p2p.Peer, snapshot *snapshot) (bool, error) {
}
if added {
s.logger.Info("Discovered new snapshot", "height", snapshot.Height, "format", snapshot.Format,
"hash", snapshot.Hash)
"hash", log.NewLazySprintf("%X", snapshot.Hash))
}
return added, nil
}
Expand All @@ -144,7 +144,7 @@ func (s *syncer) SyncAny(discoveryTime time.Duration, retryHook func()) (sm.Stat
}

if discoveryTime > 0 {
s.logger.Info("sync any", "msg", log.NewLazySprintf("Discovering snapshots for %v", discoveryTime))
s.logger.Info("Discovering snapshots", "discoverTime", discoveryTime)
time.Sleep(discoveryTime)
}

Expand Down Expand Up @@ -189,26 +189,26 @@ func (s *syncer) SyncAny(discoveryTime time.Duration, retryHook func()) (sm.Stat
case errors.Is(err, errRetrySnapshot):
chunks.RetryAll()
s.logger.Info("Retrying snapshot", "height", snapshot.Height, "format", snapshot.Format,
"hash", snapshot.Hash)
"hash", log.NewLazySprintf("%X", snapshot.Hash))
continue

case errors.Is(err, errTimeout):
s.snapshots.Reject(snapshot)
s.logger.Error("Timed out waiting for snapshot chunks, rejected snapshot",
"height", snapshot.Height, "format", snapshot.Format, "hash", snapshot.Hash)
"height", snapshot.Height, "format", snapshot.Format, "hash", log.NewLazySprintf("%X", snapshot.Hash))

case errors.Is(err, errRejectSnapshot):
s.snapshots.Reject(snapshot)
s.logger.Info("Snapshot rejected", "height", snapshot.Height, "format", snapshot.Format,
"hash", snapshot.Hash)
"hash", log.NewLazySprintf("%X", snapshot.Hash))

case errors.Is(err, errRejectFormat):
s.snapshots.RejectFormat(snapshot.Format)
s.logger.Info("Snapshot format rejected", "format", snapshot.Format)

case errors.Is(err, errRejectSender):
s.logger.Info("Snapshot senders rejected", "height", snapshot.Height, "format", snapshot.Format,
"hash", snapshot.Hash)
"hash", log.NewLazySprintf("%X", snapshot.Hash))
for _, peer := range s.snapshots.GetPeers(snapshot) {
s.snapshots.RejectPeer(peer.ID())
s.logger.Info("Snapshot sender rejected", "peer", peer.ID())
Expand Down Expand Up @@ -308,7 +308,7 @@ func (s *syncer) Sync(snapshot *snapshot, chunks *chunkQueue) (sm.State, *types.

// Done! 🎉
s.logger.Info("Snapshot restored", "height", snapshot.Height, "format", snapshot.Format,
"hash", snapshot.Hash)
"hash", log.NewLazySprintf("%X", snapshot.Hash))

return state, commit, nil
}
Expand All @@ -317,7 +317,7 @@ func (s *syncer) Sync(snapshot *snapshot, chunks *chunkQueue) (sm.State, *types.
// response, or nil if the snapshot was accepted.
func (s *syncer) offerSnapshot(snapshot *snapshot) error {
s.logger.Info("Offering snapshot to ABCI app", "height", snapshot.Height,
"format", snapshot.Format, "hash", snapshot.Hash)
"format", snapshot.Format, "hash", log.NewLazySprintf("%X", snapshot.Hash))
resp, err := s.conn.OfferSnapshotSync(abci.RequestOfferSnapshot{
Snapshot: &abci.Snapshot{
Height: snapshot.Height,
Expand All @@ -334,7 +334,7 @@ func (s *syncer) offerSnapshot(snapshot *snapshot) error {
switch resp.Result {
case abci.ResponseOfferSnapshot_ACCEPT:
s.logger.Info("Snapshot accepted, restoring", "height", snapshot.Height,
"format", snapshot.Format, "hash", snapshot.Hash)
"format", snapshot.Format, "hash", log.NewLazySprintf("%X", snapshot.Hash))
return nil
case abci.ResponseOfferSnapshot_ABORT:
return errAbort
Expand Down Expand Up @@ -462,7 +462,7 @@ func (s *syncer) requestChunk(snapshot *snapshot, chunk uint32) {
peer := s.snapshots.GetPeer(snapshot)
if peer == nil {
s.logger.Error("No valid peers found for snapshot", "height", snapshot.Height,
"format", snapshot.Format, "hash", snapshot.Hash)
"format", snapshot.Format, "hash", log.NewLazySprintf("%X", snapshot.Hash))
return
}
s.logger.Debug("Requesting snapshot chunk", "height", snapshot.Height,
Expand Down

0 comments on commit af5281d

Please sign in to comment.