Skip to content

Commit

Permalink
adjust logging level for verify errors
Browse files Browse the repository at this point in the history
  • Loading branch information
walldiss committed Dec 21, 2023
1 parent af93eae commit 41e0211
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 5 additions & 2 deletions p2p/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,14 @@ func (ex *Exchange[H]) Head(ctx context.Context, opts ...header.HeadOption[H]) (
headerRespCh <- headers[0]
return
}
log.Errorw("verifying head received from tracked peer", "tracked peer", from,
logF := log.Warnw
if errors.Is(err, header.ErrKnownHeader) {
logF = log.Debugw
}
logF("verifying head received from tracked peer", "tracked peer", from,
"height", headers[0].Height(), "err", err)
headerRespCh <- zero
return

}
}
// request ensures that the result slice will have at least one Header
Expand Down
7 changes: 6 additions & 1 deletion sync/sync_head.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ func (s *Syncer[H]) verify(ctx context.Context, newHead H) (bool, error) {

var verErr *header.VerifyError
if errors.As(err, &verErr) && !verErr.SoftFailure {
log.Errorw("invalid network header",
logF := log.Warnw
if errors.Is(err, header.ErrKnownHeader) {
logF = log.Debugw
log.Level()
}
logF("invalid network header",
"height_of_invalid", newHead.Height(),
"hash_of_invalid", newHead.Hash(),
"height_of_subjective", sbjHead.Height(),
Expand Down
7 changes: 1 addition & 6 deletions verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ func Verify[H Header[H]](trstd, untrstd H, heightThreshold uint64) error {
// general mandatory verification
err := verify[H](trstd, untrstd, heightThreshold)
if err != nil {
verErr := &VerifyError{Reason: err}
if errors.Is(err, ErrKnownHeader) {
// if known, header is not *really* wrong, just already known and we can ignore it
verErr.SoftFailure = true
}
return verErr
return &VerifyError{Reason: err}
}
// user defined verification
err = trstd.Verify(untrstd)
Expand Down

0 comments on commit 41e0211

Please sign in to comment.