Skip to content
Merged
Changes from 9 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 use non-finalized L1 blocks as L1 origin
// 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()

finalizedRef, err := n.l1Source.L1BlockRefByLabel(reqCtx, eth.Finalized)
if err != nil {
log.Warn("failed to fetch L1 block", "label", eth.Finalized, "err", err)
}
if finalizedRef != (eth.L1BlockRef{}) {
n.OnNewL1Finalized(reqCtx, finalizedRef)
}

safeRef, err := n.l1Source.L1BlockRefByLabel(reqCtx, eth.Safe)
if err != nil {
log.Warn("failed to fetch L1 block", "label", eth.Safe, "err", err)
}
if safeRef != (eth.L1BlockRef{}) {
n.OnNewL1Safe(reqCtx, safeRef)
}
}

return nil
}

Expand Down