Documentation
¶
Index ¶
- Variables
- type AltDAIface
- type AttributesHandler
- type Config
- type DerivationPipeline
- type Drain
- type Driver
- func (s *Driver) BlockRefWithStatus(ctx context.Context, num uint64) (eth.L2BlockRef, *eth.SyncStatus, error)
- func (s *Driver) Close() error
- func (s *Driver) ConductorEnabled(ctx context.Context) (bool, error)
- func (s *Driver) OnUnsafeL2Payload(ctx context.Context, payload *eth.ExecutionPayloadEnvelope)
- func (s *Driver) OverrideLeader(ctx context.Context) error
- func (s *Driver) ResetDerivationPipeline(ctx context.Context) error
- func (s *Driver) SdmStatus(ctx context.Context) (apis.SdmStatus, error)
- func (s *Driver) SequencerActive(ctx context.Context) (bool, error)
- func (s *Driver) SetRecoverMode(ctx context.Context, mode bool) error
- func (s *Driver) SetSdmPostExecOptIn(ctx context.Context, enabled bool) error
- func (s *Driver) Start() error
- func (s *Driver) StartSequencer(ctx context.Context, blockHash common.Hash) error
- func (s *Driver) StopSequencer(ctx context.Context) (common.Hash, error)
- func (s *Driver) SyncStatus(ctx context.Context) (*eth.SyncStatus, error)
- type Finalizer
- type L1Chain
- type L1FollowSource
- type L2Chain
- type L2FollowSource
- type Metrics
- type Network
- type SequencerStateListener
- type StepDeriver
- type StepEvent
- type StepSchedulingDeriver
- func (s *StepSchedulingDeriver) AttachEmitter(em event.Emitter)
- func (s *StepSchedulingDeriver) AttemptStep(ctx context.Context)
- func (s *StepSchedulingDeriver) NextDelayedStep() <-chan time.Time
- func (s *StepSchedulingDeriver) NextStep() <-chan struct{}
- func (s *StepSchedulingDeriver) OnEvent(ctx context.Context, ev event.Event) bool
- func (s *StepSchedulingDeriver) RequestStep(ctx context.Context, resetBackoff bool)
- func (s *StepSchedulingDeriver) ResetStepBackoff(ctx context.Context)
- type SyncDeriver
- func (s *SyncDeriver) AttachEmitter(em event.Emitter)
- func (s *SyncDeriver) OnEvent(ctx context.Context, ev event.Event) bool
- func (s *SyncDeriver) OnL1Finalized(ctx context.Context)
- func (s *SyncDeriver) OnL1Unsafe(ctx context.Context)
- func (s *SyncDeriver) OnUnsafeL2Payload(ctx context.Context, envelope *eth.ExecutionPayloadEnvelope)
- func (s *SyncDeriver) ResetSafeDB(ref eth.L2BlockRef)
- func (s *SyncDeriver) SafeDBHeadAtOrAboveL2(ctx context.Context, l2Num uint64) (l2 eth.BlockID, ok bool, err error)
- func (s *SyncDeriver) SafeDBTip(ctx context.Context) (l2 eth.BlockID, ok bool, err error)
- func (s *SyncDeriver) SyncStep()
- type SyncStatusTracker
- type UpstreamFollowSource
Constants ¶
This section is empty.
Variables ¶
var ( ErrSequencerAlreadyStarted = sequencing.ErrSequencerAlreadyStarted ErrSequencerAlreadyStopped = sequencing.ErrSequencerAlreadyStopped )
aliases to not disrupt op-conductor code
Functions ¶
This section is empty.
Types ¶
type AltDAIface ¶
type AltDAIface interface {
// Notify L1 finalized head so AltDA finality is always behind L1
Finalize(ref eth.L1BlockRef)
// Set the engine finalization signal callback
OnFinalizedHeadSignal(f altda.HeadSignalFn)
derive.AltDAInputFetcher
}
type AttributesHandler ¶
type AttributesHandler interface {
// HasAttributes returns if there are any block attributes to process.
// HasAttributes is for EngineQueue testing only, and can be removed when attribute processing is fully independent.
HasAttributes() bool
// SetAttributes overwrites the set of attributes. This may be nil, to clear what may be processed next.
SetAttributes(attributes *derive.AttributesWithParent)
// Proceed runs one attempt of processing attributes, if any.
// Proceed returns io.EOF if there are no attributes to process.
Proceed(ctx context.Context) error
}
type Config ¶
type Config struct {
// VerifierConfDepth is the distance to keep from the L1 head when reading L1 data for L2 derivation.
VerifierConfDepth uint64 `json:"verifier_conf_depth"`
// SequencerConfDepth is the distance to keep from the L1 head as origin when sequencing new L2 blocks.
// If this distance is too large, the sequencer may:
// - not adopt a L1 origin within the allowed time (rollup.Config.MaxSequencerDrift)
// - not adopt a L1 origin that can be included on L1 within the allowed range (rollup.Config.SeqWindowSize)
// and thus fail to produce a block with anything more than deposits.
SequencerConfDepth uint64 `json:"sequencer_conf_depth"`
// SequencerEnabled is true when the driver should sequence new blocks.
SequencerEnabled bool `json:"sequencer_enabled"`
// SequencerStopped is false when the driver should sequence new blocks.
SequencerStopped bool `json:"sequencer_stopped"`
// SdmPostExecOptIn is the persisted operator preference for local SDM/PostExec sequencing.
SdmPostExecOptIn bool `json:"sdm_post_exec_opt_in"`
// SequencerMaxSafeLag is the maximum number of L2 blocks for restricting the distance between L2 safe and unsafe.
// Disabled if 0.
SequencerMaxSafeLag uint64 `json:"sequencer_max_safe_lag"`
// RecoverMode forces the sequencer to select the next L1 Origin exactly, and create an empty block,
// to be compatible with verifiers forcefully generating the same block while catching up the sequencing window timeout.
RecoverMode bool `json:"recover_mode"`
// SequencerSealingDuration is the amount of the time the sequencer allocates to sealing the block
// (i.e. it will fetch the payload from the execution engine this much prior to the block's timestamp).
// If this is <= 0 it is automatically adjusted to 50ms.
SequencerSealingDuration time.Duration `json:"sequencer_sealing_duration"`
// Finalizer contains runtime configuration for finality behavior.
Finalizer *finality.Config `json:"finalizer,omitempty"`
}
type DerivationPipeline ¶
type DerivationPipeline interface {
Reset()
Step(ctx context.Context, pendingSafeHead eth.L2BlockRef) (*derive.AttributesWithParent, error)
Origin() eth.L1BlockRef
DerivationReady() bool
ConfirmEngineReset()
}
type Driver ¶
type Driver struct {
StatusTracker SyncStatusTracker
Finalizer Finalizer
SyncDeriver *SyncDeriver
// contains filtered or unexported fields
}
func NewDriver ¶
func NewDriver( sys event.Registry, drain Drain, driverCfg *Config, cfg *rollup.Config, l1ChainConfig *params.ChainConfig, depSet derive.DependencySet, l2 L2Chain, l1 L1Chain, upstreamFollowSource UpstreamFollowSource, l1Blobs derive.L1BlobsFetcher, network Network, log log.Logger, metrics Metrics, sequencerStateListener sequencing.SequencerStateListener, safeHeadListener rollup.SafeHeadListener, syncCfg *sync.Config, sequencerConductor conductor.SequencerConductor, altDA AltDAIface, superAuthority rollup.SuperAuthority, ) *Driver
NewDriver composes an events handler that tracks L1 state, triggers L2 Derivation, and optionally sequences new L2 blocks.
func (*Driver) BlockRefWithStatus ¶
func (s *Driver) BlockRefWithStatus(ctx context.Context, num uint64) (eth.L2BlockRef, *eth.SyncStatus, error)
BlockRefWithStatus blocks the driver event loop and captures the syncing status, along with an L2 block reference by number consistent with that same status. If the event loop is too busy and the context expires before the request is accepted, a context error is returned with a nil status. Otherwise the returned status is non-nil, including when ref lookup fails with ethereum.NotFound.
func (*Driver) ConductorEnabled ¶
func (*Driver) OnUnsafeL2Payload ¶
func (s *Driver) OnUnsafeL2Payload(ctx context.Context, payload *eth.ExecutionPayloadEnvelope)
func (*Driver) ResetDerivationPipeline ¶
ResetDerivationPipeline forces a reset of the derivation pipeline. It waits for the reset to occur. It simply unblocks the caller rather than fully cancelling the reset request upon a context cancellation.
func (*Driver) SequencerActive ¶
func (*Driver) SetRecoverMode ¶
func (*Driver) SetSdmPostExecOptIn ¶ added in v1.19.1
func (*Driver) Start ¶
Start starts up the state loop. The loop will have been started iff err is not nil.
func (*Driver) StartSequencer ¶
func (*Driver) StopSequencer ¶
func (*Driver) SyncStatus ¶
SyncStatus blocks the driver event loop and captures the syncing status.
type Finalizer ¶
type Finalizer interface {
FinalizedL1() eth.L1BlockRef
OnL1Finalized(x eth.L1BlockRef)
event.Deriver
}
type L1Chain ¶
type L1Chain interface {
derive.L1Fetcher
L1BlockRefByLabel(context.Context, eth.BlockLabel) (eth.L1BlockRef, error)
}
type L1FollowSource ¶
type L1FollowSource interface {
L1BlockRefByNumber(ctx context.Context, num uint64) (eth.L1BlockRef, error)
}
L1FollowSource provides access to L1 block references for upstream following.
type L2FollowSource ¶
type L2FollowSource struct {
// contains filtered or unexported fields
}
func NewL2FollowSource ¶
func NewL2FollowSource(client *sources.FollowClient, l1Source L1FollowSource) *L2FollowSource
func (*L2FollowSource) GetFollowStatus ¶
func (fs *L2FollowSource) GetFollowStatus(ctx context.Context) (*sources.FollowStatus, error)
func (*L2FollowSource) L1BlockRefByNumber ¶
func (fs *L2FollowSource) L1BlockRefByNumber(ctx context.Context, num uint64) (eth.L1BlockRef, error)
type Metrics ¶
type Metrics interface {
RecordPipelineReset()
RecordFollowSourceRequest(result string)
RecordPublishingError()
RecordDerivationError()
RecordL1Ref(name string, ref eth.L1BlockRef)
RecordL2Ref(name string, ref eth.L2BlockRef)
RecordChannelInputBytes(inputCompressedBytes int)
RecordHeadChannelOpened()
RecordChannelTimedOut()
RecordFrame()
RecordDerivedBatches(batchType string)
RecordUnsafePayloadsBuffer(length uint64, memSize uint64, next eth.BlockID)
SetDerivationIdle(idle bool)
SetSequencerState(active bool)
RecordL1ReorgDepth(d uint64)
opnodemetrics.Metricer
metered.L1FetcherMetrics
event.Metrics
sequencing.Metrics
}
type Network ¶
type Network interface {
// SignAndPublishL2Payload is called by the driver whenever there is a new payload to publish, synchronously with the driver main loop.
SignAndPublishL2Payload(ctx context.Context, payload *eth.ExecutionPayloadEnvelope) error
}
type SequencerStateListener ¶
type StepDeriver ¶
type StepSchedulingDeriver ¶
type StepSchedulingDeriver struct {
// contains filtered or unexported fields
}
StepSchedulingDeriver is a deriver that emits StepEvent events. The deriver can be requested to schedule a step with a StepReqEvent.
It is then up to the caller to translate scheduling into StepAttemptEvent emissions, by waiting for NextStep or NextDelayedStep channels (nil if there is nothing to wait for, for channel-merging purposes).
Upon StepAttemptEvent the scheduler will then emit a StepEvent, while maintaining backoff state, to not spam steps.
Backoff can be reset by sending a request with StepReqEvent.ResetBackoff set to true, or by sending a ResetStepBackoffEvent.
func NewStepSchedulingDeriver ¶
func NewStepSchedulingDeriver(log log.Logger) *StepSchedulingDeriver
func (*StepSchedulingDeriver) AttachEmitter ¶
func (s *StepSchedulingDeriver) AttachEmitter(em event.Emitter)
func (*StepSchedulingDeriver) AttemptStep ¶
func (s *StepSchedulingDeriver) AttemptStep(ctx context.Context)
func (*StepSchedulingDeriver) NextDelayedStep ¶
func (s *StepSchedulingDeriver) NextDelayedStep() <-chan time.Time
NextDelayedStep is a temporary channel to await, and if triggered, the caller should emit a StepAttemptEvent to queue up a step while maintaining backoff. The returned channel may be nil, if there is no requested step with delay scheduled.
func (*StepSchedulingDeriver) NextStep ¶
func (s *StepSchedulingDeriver) NextStep() <-chan struct{}
NextStep is a channel to await, and if triggered, the caller should emit a StepAttemptEvent to queue up a step while maintaining backoff.
func (*StepSchedulingDeriver) RequestStep ¶
func (s *StepSchedulingDeriver) RequestStep(ctx context.Context, resetBackoff bool)
func (*StepSchedulingDeriver) ResetStepBackoff ¶
func (s *StepSchedulingDeriver) ResetStepBackoff(ctx context.Context)
type SyncDeriver ¶
type SyncDeriver struct {
// The derivation pipeline is reset whenever we reorg.
// The derivation pipeline determines the new l2Safe.
Derivation DerivationPipeline
SafeHeadNotifs rollup.SafeHeadListener // notified when safe head is updated
// The engine controller is used by the sequencer & Derivation components.
// We will also use it for EL sync in a future PR.
Engine *engine.EngineController
// Sync Mod Config
SyncCfg *sync.Config
Config *rollup.Config
L1 L1Chain
// Track L1 view when new unsafe L1 block is observed
L1Tracker *status.L1Tracker
L2 L2Chain
Emitter event.Emitter
Log log.Logger
Ctx context.Context
StepDeriver StepDeriver
}
func (*SyncDeriver) AttachEmitter ¶
func (s *SyncDeriver) AttachEmitter(em event.Emitter)
func (*SyncDeriver) OnL1Finalized ¶
func (s *SyncDeriver) OnL1Finalized(ctx context.Context)
func (*SyncDeriver) OnL1Unsafe ¶
func (s *SyncDeriver) OnL1Unsafe(ctx context.Context)
func (*SyncDeriver) OnUnsafeL2Payload ¶
func (s *SyncDeriver) OnUnsafeL2Payload(ctx context.Context, envelope *eth.ExecutionPayloadEnvelope)
func (*SyncDeriver) ResetSafeDB ¶ added in v1.19.1
func (s *SyncDeriver) ResetSafeDB(ref eth.L2BlockRef)
ResetSafeDB removes safedb entries at or above ref, keeping the contiguous history below it. Called after EL sync when the recorded safedb tip is not part of the synced chain (e.g. a recent reorg dropped it): trimming to the offset-derived head re-derives only the recent window rather than discarding the whole db. Passing a zero ref clears it entirely.
func (*SyncDeriver) SafeDBHeadAtOrAboveL2 ¶ added in v1.19.1
func (s *SyncDeriver) SafeDBHeadAtOrAboveL2(ctx context.Context, l2Num uint64) (l2 eth.BlockID, ok bool, err error)
SafeDBHeadAtOrAboveL2 returns the L2 safe head the safedb recorded at the first L1 source whose safe head reached at least l2Num, reporting ok=false when the safedb is disabled or has no such entry. Unlike SafeDBTip this returns an actual recorded safe head near the offset, so the caller can check a real stored block hash for canonicity.
func (*SyncDeriver) SafeDBTip ¶ added in v1.19.1
SafeDBTip returns the L2 safe head at the safedb tip, reporting ok=false when the safedb is disabled or empty. Used at EL-sync completion to resume derivation from the safedb tip instead of wiping it.
func (*SyncDeriver) SyncStep ¶
func (s *SyncDeriver) SyncStep()
SyncStep performs the sequence of encapsulated syncing steps. Warning: this sequence will be broken apart as outlined in op-node derivers design doc.
type SyncStatusTracker ¶
type SyncStatusTracker interface {
event.Deriver
SyncStatus() *eth.SyncStatus
L1Head() eth.L1BlockRef
OnL1Unsafe(x eth.L1BlockRef)
OnL1Safe(x eth.L1BlockRef)
OnL1Finalized(x eth.L1BlockRef)
}
type UpstreamFollowSource ¶
type UpstreamFollowSource interface {
L1FollowSource
GetFollowStatus(ctx context.Context) (*sources.FollowStatus, error)
}
UpstreamFollowSource combines L1 and L2 follow sources. L2 following may be optionally disabled.