Skip to content

Commit aa4ae28

Browse files
authored
fix(sync): subj init death loop (#324)
During subjective init, we verify the head against the tail. However, the tail may be configured to be outside of the trusting window, causing subjective init "deathloop". Once the tail is requested, it is immediately stored as the first-ever header. However, this tail is also a head for a brief moment before the network head gets applied in `incomingNewHead`. And when `verify` inside of it calls `subjectiveHead`, the temporary head tail is considered expired, causing re-requesting of the new head. However, this new head fails verification as it's the same as the network head awaiting to be applied. Then this whole process goes nuts in cycles. This is actually also a solution for the original problem described in #317, but it does not solve the secondary problem in the EDIT section, so we still need to keep #317
1 parent 5c305ad commit aa4ae28

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sync/syncer_head.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,11 @@ func (s *Syncer[H]) incomingNetworkHead(ctx context.Context, head H) error {
232232

233233
// verify verifies given network head candidate.
234234
func (s *Syncer[H]) verify(ctx context.Context, newHead H) error {
235-
sbjHead, _, err := s.subjectiveHead(ctx)
235+
// TODO(@Wondertan): This has to be subjective head.
236+
// But due to an edge case during subjective init, this might be an expired tail
237+
// triggering subjective reinit death loop.
238+
// This can and will be fixed with bsync,
239+
sbjHead, err := s.localHead(ctx)
236240
if err != nil {
237241
log.Errorw("getting subjective head during new network head verification", "err", err)
238242
return err

0 commit comments

Comments
 (0)