Skip to content

Commit

Permalink
review suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Dec 5, 2024
1 parent 0e7942f commit 146b81e
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 @@ -160,7 +160,7 @@ func (s *Syncer[H]) incomingNetworkHead(ctx context.Context, head H) error {
}

// verify verifies given network head candidate.
func (s *Syncer[H]) verify(ctx context.Context, newHead H) (bool, error) {
func (s *Syncer[H]) verify(ctx context.Context, newHead H) (isSoft bool, _ error) {
sbjHead, err := s.subjectiveHead(ctx)
if err != nil {
log.Errorw("getting subjective head during validation", "err", err)
Expand Down Expand Up @@ -203,6 +203,8 @@ func (s *Syncer[H]) verify(ctx context.Context, newHead H) (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())

subjHeight := subjHead.Height()

diff := networkHead.Height() - subjHeight
Expand Down Expand Up @@ -238,7 +240,10 @@ 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())

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

// isExpired checks if header is expired against trusting period.
Expand Down

0 comments on commit 146b81e

Please sign in to comment.