From 0377c996868fef7a65cf5388baf6c2c2ab967258 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Thu, 5 Dec 2024 17:01:13 +0100 Subject: [PATCH] more review suggestions --- sync/sync_head.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sync/sync_head.go b/sync/sync_head.go index c50cc6c..e56a9c5 100644 --- a/sync/sync_head.go +++ b/sync/sync_head.go @@ -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() @@ -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 @@ -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()),