Skip to content
Merged
Changes from 4 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 cannot retrieve non-finalized L1 blocks.
// OpNode periodically fetches the latest safe and finalized L1 blocks every epoch (6.4 minutes),
// but immediately after startup, these values are not yet available.
// In some cases, this can cause the sequencer to get stuck because sequencer fails to retrieve 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