Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions op-node/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,33 @@ func (n *OpNode) Start(ctx context.Context) error {
return err
}
log.Info("Rollup node started")

// If n.cfg.Driver.SequencerUseFinalized is true, sequencer does not fetch non-finalized L1 blocks.
// The OpNode periodically fetches the latest safe and finalized L1 block heights (1 epoch ≒ 6.4 minutes by default),
// but these values are not available immediately after startup until the first polling occurs.
// In some cases, this can cause the sequencer to get stuck because it fails to retrieve the next L1 block.
// To prevent this, fetch and initialize the latest safe and finalized L1 block references at startup.
if n.cfg.Driver.SequencerUseFinalized {
reqCtx, reqCancel := context.WithTimeout(ctx, time.Second*20)
defer reqCancel()

safeRef, err := n.l1Source.L1BlockRefByLabel(reqCtx, eth.Safe)
if err != nil {
return fmt.Errorf("failed to fetch L1 safe head: %w", err)
}
if safeRef != (eth.L1BlockRef{}) {
n.OnNewL1Safe(reqCtx, safeRef)
}

finalizedRef, err := n.l1Source.L1BlockRefByLabel(reqCtx, eth.Finalized)
if err != nil {
return fmt.Errorf("failed to fetch L1 finalized head: %w", err)
}
if finalizedRef != (eth.L1BlockRef{}) {
n.OnNewL1Finalized(reqCtx, finalizedRef)
}
}

return nil
}

Expand Down