Skip to content

Commit a3b4b0d

Browse files
authored
fix(block): halt on invalid blocks and wait on unavailable execution client (#2719)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/ --> ## Overview aggregator: we halt on invalid blocks only and unavailable execution client in the aggregator flow. all other errors should be intermittent so retrying is fine. syncer: in the syncer, the availability of the execution client is less important (block time isn't relevant), so we can retry. <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. Ex: Closes #<issue number> -->
1 parent 1f3212b commit a3b4b0d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

block/internal/executing/executor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ func (e *Executor) produceBlock() error {
362362
header.Signature = signature
363363

364364
if err := e.validateBlock(currentState, header, data); err != nil {
365+
e.sendCriticalError(fmt.Errorf("failed to validate block: %w", err))
365366
return fmt.Errorf("failed to validate block: %w", err)
366367
}
367368

block/internal/syncing/syncer.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ type p2pHandler interface {
3030
ProcessDataRange(ctx context.Context, fromHeight, toHeight uint64) []common.DAHeightEvent
3131
}
3232

33-
// maxRetriesBeforeHalt is the maximum number of retries against the execution client before halting the syncer.
34-
const maxRetriesBeforeHalt = 3
33+
const (
34+
// maxRetriesBeforeHalt is the maximum number of retries against the execution client before halting the syncer.
35+
maxRetriesBeforeHalt = 3
36+
// maxRetriesTimeout is the maximum time to wait for a retry before halting the syncer.
37+
maxRetriesTimeout = time.Second * 10
38+
)
3539

3640
// Syncer handles block synchronization from DA and P2P sources.
3741
type Syncer struct {
@@ -494,6 +498,7 @@ func (s *Syncer) applyBlock(header types.Header, data *types.Data, currentState
494498
return types.State{}, fmt.Errorf("failed to execute transactions: %w", err)
495499
}
496500

501+
time.Sleep(maxRetriesTimeout) // sleep before retrying
497502
return types.State{}, fmt.Errorf("failed to execute transactions (retry %d / %d): %w", s.retriesBeforeHalt[header.Height()], maxRetriesBeforeHalt, err)
498503
}
499504
delete(s.retriesBeforeHalt, header.Height())

0 commit comments

Comments
 (0)