sequencing

package
v1.19.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: MIT, MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidL1Origin      = fmt.Errorf("origin-selector: currentL1Origin.Hash != l2Head.L1Origin.Hash")
	ErrNextL1OriginOrphaned = fmt.Errorf("origin-selector: nextL1Origin.ParentHash != currentL1Origin.Hash")
	ErrNextL1OriginRequired = fmt.Errorf("origin-selector: nextL1Origin not supplied but required to satisfy constraints")
)
View Source
var (
	ErrSequencerAlreadyStarted = errors.New("sequencer already running")
	ErrSequencerAlreadyStopped = errors.New("sequencer not running")
)
View Source
var ErrSequencerNotEnabled = errors.New("sequencer is not enabled")

Functions

This section is empty.

Types

type AsyncGossiper

type AsyncGossiper interface {
	Gossip(payload *eth.ExecutionPayloadEnvelope)
	Get() *eth.ExecutionPayloadEnvelope
	Clear()
	Stop()
	Start()
}

type BuildingState

type BuildingState struct {
	Onto eth.L2BlockRef
	Info eth.PayloadInfo

	Started time.Time

	// Set once known
	Ref eth.L2BlockRef
}

type DisabledSequencer

type DisabledSequencer struct{}

func (DisabledSequencer) Active

func (ds DisabledSequencer) Active() bool

func (DisabledSequencer) Close

func (ds DisabledSequencer) Close()

func (DisabledSequencer) ConductorEnabled

func (ds DisabledSequencer) ConductorEnabled(ctx context.Context) bool

func (DisabledSequencer) Init

func (ds DisabledSequencer) Init(ctx context.Context, active bool) error

func (DisabledSequencer) OnEvent

func (ds DisabledSequencer) OnEvent(ctx context.Context, ev event.Event) bool

func (DisabledSequencer) OverrideLeader

func (ds DisabledSequencer) OverrideLeader(ctx context.Context) error

func (DisabledSequencer) RunAction added in v1.19.5

func (ds DisabledSequencer) RunAction()

func (DisabledSequencer) RunLoop added in v1.19.5

func (ds DisabledSequencer) RunLoop(ctx context.Context)

func (DisabledSequencer) SetMaxSafeLag

func (ds DisabledSequencer) SetMaxSafeLag(ctx context.Context, v uint64) error

func (DisabledSequencer) SetRecoverMode

func (ds DisabledSequencer) SetRecoverMode(mode bool)

func (DisabledSequencer) Start

func (ds DisabledSequencer) Start(ctx context.Context, head common.Hash) error

func (DisabledSequencer) Stop

func (ds DisabledSequencer) Stop(ctx context.Context) (hash common.Hash, err error)

type L1OriginSelector

type L1OriginSelector struct {
	// contains filtered or unexported fields
}

func NewL1OriginSelector

func NewL1OriginSelector(ctx context.Context, log log.Logger, cfg *rollup.Config, l1 L1Blocks) *L1OriginSelector

func (*L1OriginSelector) CurrentAndNextOrigin

func (los *L1OriginSelector) CurrentAndNextOrigin(ctx context.Context, l2Head eth.L2BlockRef) (eth.L1BlockRef, eth.L1BlockRef, error)

CurrentAndNextOrigin returns the current cached values for the current L1 origin for the supplied l2Head, and its successor. It only performs a fetch to L1 if the cache is invalid. The cache can be updated asynchronously by other methods on L1OriginSelector. The returned currentOrigin should _always_ be non-empty, because it is populated from l2Head whose l1Origin is first specified in the rollup.Config.Genesis.L1 and progressed to non-empty values thereafter.

func (*L1OriginSelector) FindL1Origin

func (los *L1OriginSelector) FindL1Origin(ctx context.Context, l2Head eth.L2BlockRef) (eth.L1BlockRef, error)

FindL1Origin determines what the L1 Origin for the next L2 Block should be. It wraps the FindL1OriginOfNextL2Block function and handles caching and network requests.

func (*L1OriginSelector) OnEvent

func (los *L1OriginSelector) OnEvent(ctx context.Context, ev event.Event) bool

func (*L1OriginSelector) ResetOrigins

func (los *L1OriginSelector) ResetOrigins()

func (*L1OriginSelector) SetRecoverMode

func (los *L1OriginSelector) SetRecoverMode(enabled bool)

type L1OriginSelectorIface

type L1OriginSelectorIface interface {
	FindL1Origin(ctx context.Context, l2Head eth.L2BlockRef) (eth.L1BlockRef, error)
	SetRecoverMode(bool)
}

type Metrics

type Metrics interface {
	SetSequencerState(active bool)
	RecordSequencerInconsistentL1Origin(from eth.BlockID, to eth.BlockID)
	RecordSequencerReset()
	RecordSequencingError()
}

type Sequencer

type Sequencer struct {
	// contains filtered or unexported fields
}

Sequencer implements the sequencing interface of the driver: it starts and completes block building jobs.

func NewSequencer

func NewSequencer(driverCtx context.Context, log log.Logger, rollupCfg *rollup.Config,
	sealingDuration time.Duration,
	attributesBuilder derive.AttributesBuilder,
	l1OriginSelector L1OriginSelectorIface,
	listener SequencerStateListener,
	conductor conductor.SequencerConductor,
	asyncGossip AsyncGossiper,
	metrics Metrics,
	eng SequencerEngine,
) *Sequencer

func (*Sequencer) Active

func (d *Sequencer) Active() bool

func (*Sequencer) AttachEmitter

func (d *Sequencer) AttachEmitter(em event.Emitter)

func (*Sequencer) Building added in v1.19.5

func (d *Sequencer) Building() BuildingState

Building returns the block-building job the sequencer currently has in flight. The zero value means no job is in flight.

func (*Sequencer) Close

func (d *Sequencer) Close()

func (*Sequencer) ConductorEnabled

func (d *Sequencer) ConductorEnabled(ctx context.Context) bool

func (*Sequencer) Init

func (d *Sequencer) Init(ctx context.Context, active bool) error

func (*Sequencer) NextAction

func (d *Sequencer) NextAction() (t time.Time, ok bool)

func (*Sequencer) OnEvent

func (d *Sequencer) OnEvent(ctx context.Context, ev event.Event) bool

OnEvent implements event.Deriver. It never blocks and never mutates sequencer state: accepted events are appended to the inbox log and replayed in arrival order on the sequencer goroutine.

func (*Sequencer) OverrideLeader

func (d *Sequencer) OverrideLeader(ctx context.Context) error

func (*Sequencer) RunAction added in v1.19.5

func (d *Sequencer) RunAction()

RunAction performs one sequencer action: it processes a payload left in the async-gossip buffer, seals the pending block-building job, or starts a new build. Engine interactions happen as direct synchronous calls, not events.

func (*Sequencer) RunLoop added in v1.19.5

func (d *Sequencer) RunLoop(ctx context.Context)

RunLoop runs the sequencer scheduling loop: it replays ingested events and runs the next sequencer action when its scheduled time arrives, until ctx is canceled. Event ingestion and RPC start/stop interrupt the wait via the wake channel.

func (*Sequencer) SetMaxSafeLag

func (d *Sequencer) SetMaxSafeLag(ctx context.Context, v uint64) error

func (*Sequencer) SetRecoverMode

func (d *Sequencer) SetRecoverMode(mode bool)

func (*Sequencer) Start

func (d *Sequencer) Start(ctx context.Context, head common.Hash) error

func (*Sequencer) Stop

func (d *Sequencer) Stop(ctx context.Context) (common.Hash, error)

type SequencerEngine added in v1.19.5

type SequencerEngine interface {
	// RequestForkchoiceUpdate requests the engine to emit a ForkchoiceUpdateEvent,
	// for when no L2 head data is available yet.
	RequestForkchoiceUpdate(ctx context.Context)

	// StartBuild starts a block-building job, returning the payload info and build
	// metadata. Errors: engine.ErrStaleBuild if the parent is no longer the unsafe
	// head (a forkchoice update has been requested, so waiting for the next head
	// update is the way forward), engine.ErrBuildInvalid if the engine rejected the
	// attributes, otherwise a temporary, reset, or critical failure for which the
	// matching event has been emitted.
	StartBuild(ctx context.Context, attrs *derive.AttributesWithParent) (*engine.BuildStartResult, error)

	// SealBuild retrieves a built payload via GetPayload, returning the sealed
	// envelope and block ref. Emits no events. Errors wrap engine.ErrSealExpired
	// (job timed out or is unknown; the same attributes may be rebuilt) or
	// engine.ErrSealInvalid (payload contents rejected), or are
	// engine.ErrStaleBuild when the sealed block no longer extends the unsafe head.
	SealBuild(ctx context.Context, info eth.PayloadInfo, buildStarted time.Time) (*engine.SealResult, error)

	// ProcessPayload inserts a payload via NewPayload, updates the unsafe head, and
	// finalizes via forkchoice update, emitting UnsafeUpdateEvent on success.
	// Errors: engine.ErrStaleBuild if the payload no longer extends the unsafe head
	// and engine.ErrPayloadDenied if the SuperAuthority denied it, both emitting
	// nothing; engine.ErrPayloadInvalid if the engine rejected the block; otherwise
	// a temporary failure whose EngineTemporaryErrorEvent has been emitted.
	ProcessPayload(ctx context.Context, envelope *eth.ExecutionPayloadEnvelope, ref eth.L2BlockRef, buildStarted time.Time) error
}

SequencerEngine provides direct-call methods for the sequencer to interact with the engine controller, bypassing the event system for latency-critical block production. The event system is still used for derivation.

Outcomes reach the caller as return values: none of these methods emit the build-lifecycle events their event-driven counterparts do (BuildStartedEvent, BuildSealedEvent, PayloadSuccessEvent, or the seal-error events). Two classes of event are still emitted, and callers must not treat either as their own recovery signal:

  • state notifications other subsystems depend on (ForkchoiceUpdateEvent, UnsafeUpdateEvent);
  • engine-internal recovery the caller cannot perform itself (BuildInvalidEvent, PayloadInvalidEvent), plus the generic EngineTemporaryErrorEvent / ResetEvent / CriticalErrorEvent signals that other subsystems act on.

type SequencerIface

type SequencerIface interface {
	event.Deriver
	// RunAction performs one sequencer action: start, seal, or (re)process a
	// block. Engine calls inside it use the sequencer's own lifetime context, so
	// it takes none. Called from the sequencer goroutine, or directly by tests.
	RunAction()
	// RunLoop runs the sequencer scheduling loop, and blocks until ctx is canceled.
	RunLoop(ctx context.Context)
	Active() bool
	Init(ctx context.Context, active bool) error
	Start(ctx context.Context, head common.Hash) error
	Stop(ctx context.Context) (hash common.Hash, err error)
	SetMaxSafeLag(ctx context.Context, v uint64) error
	OverrideLeader(ctx context.Context) error
	ConductorEnabled(ctx context.Context) bool
	SetRecoverMode(mode bool)
	Close()
}

type SequencerStateListener

type SequencerStateListener interface {
	SequencerStarted() error
	SequencerStopped() error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL