Skip to content

Commit

Permalink
more review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Dec 5, 2024
1 parent 146b81e commit 0377c99
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sync/sync_head.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (s *Syncer[H]) verify(ctx context.Context, newHead H) (isSoft bool, _ error
// subjectiveHead.
// A non-nil error is returned when networkHead can't be verified.
func (s *Syncer[H]) verifyBifurcating(ctx context.Context, subjHead, networkHead H) error {
log.Warnw("sync: header bifurcation started", "height", networkHead.Height(), "hash", networkHead.Hash().String())
log.Warnw("header bifurcation started", "height", networkHead.Height(), "hash", networkHead.Hash().String())

subjHeight := subjHead.Height()

Expand All @@ -218,6 +218,11 @@ func (s *Syncer[H]) verifyBifurcating(ctx context.Context, subjHead, networkHead
}

if err := header.Verify(subjHead, candidateHeader); err != nil {
var verErr *header.VerifyError
if errors.As(err, &verErr) && !verErr.SoftFailure {
return err
}

// candidate failed, go deeper in 1st half.
diff = diff / 2
continue
Expand All @@ -238,7 +243,7 @@ func (s *Syncer[H]) verifyBifurcating(ctx context.Context, subjHead, networkHead
}

s.metrics.failedBifurcation(ctx, int64(networkHead.Height()), networkHead.Hash().String())
log.Warnw("sync: header validation against subjHead", "height", networkHead.Height(), "hash", networkHead.Hash().String())
log.Warnw("header validation against subjHead", "height", networkHead.Height(), "hash", networkHead.Hash().String())

return &header.VerifyError{
Reason: fmt.Errorf("sync: header validation against subjHead height:%d hash:%x", networkHead.Height(), networkHead.Hash().String()),
Expand Down

0 comments on commit 0377c99

Please sign in to comment.