Skip to content

Commit

Permalink
Merge pull request #138 from walldiss/do-not-warn-known-headers
Browse files Browse the repository at this point in the history
fix(verify): report known headers as soft failure
  • Loading branch information
walldiss authored Jan 3, 2024
2 parents 6afe95f + d2c7a7b commit e9205ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 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
6 changes: 5 additions & 1 deletion sync/sync_head.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ 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
}
logF("invalid network header",
"height_of_invalid", newHead.Height(),
"hash_of_invalid", newHead.Hash(),
"height_of_subjective", sbjHead.Height(),
Expand Down

0 comments on commit e9205ab

Please sign in to comment.