Skip to content

Commit 850a82f

Browse files
tac0turtleclaude
andauthored
fix(sync): reduce P2P init timeout and fallback to DA sync (#3037)
Previously, P2P header sync initialization would block for up to 10 minutes retrying when peers were unavailable (e.g., blocked by gater). This prevented DA sync from starting, leaving the node stuck. Changes: - Reduce P2P init timeout from 10 minutes to 30 seconds - Return nil (not error) on timeout to allow startup to continue - DA sync will provide headers and WriteToStoreAndBroadcast lazily initializes the go-header store and syncer - P2P recovers automatically once DA provides trusted headers Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9bc6311 commit 850a82f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pkg/sync/sync_service.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,14 @@ func (syncService *SyncService[H]) initFromP2PWithRetry(ctx context.Context, pee
436436
return true, nil
437437
}
438438

439-
// block with exponential backoff until initialization succeeds or context is canceled.
439+
// block with exponential backoff until initialization succeeds, context is canceled, or timeout.
440+
// If timeout is reached, we return nil to allow startup to continue - DA sync will
441+
// provide headers and WriteToStoreAndBroadcast will lazily initialize the store/syncer.
440442
backoff := 1 * time.Second
441443
maxBackoff := 10 * time.Second
442444

443-
timeoutTimer := time.NewTimer(time.Minute * 10)
445+
p2pInitTimeout := 30 * time.Second
446+
timeoutTimer := time.NewTimer(p2pInitTimeout)
444447
defer timeoutTimer.Stop()
445448

446449
for {
@@ -455,7 +458,10 @@ func (syncService *SyncService[H]) initFromP2PWithRetry(ctx context.Context, pee
455458
case <-ctx.Done():
456459
return ctx.Err()
457460
case <-timeoutTimer.C:
458-
return fmt.Errorf("timeout reached while trying to initialize the store after 10 minutes: %w", err)
461+
syncService.logger.Warn().
462+
Dur("timeout", p2pInitTimeout).
463+
Msg("P2P header sync initialization timed out, deferring to DA sync")
464+
return nil
459465
case <-time.After(backoff):
460466
}
461467

0 commit comments

Comments
 (0)