Documentation ¶
Index ¶
- Variables
- func NewConfDepth(depth uint64, l1Head func() eth.L1BlockRef, fetcher derive.L1Fetcher) *confDepth
- type Config
- type DerivationPipeline
- type Downloader
- type Driver
- func (s *Driver) BlockRefWithStatus(ctx context.Context, num uint64) (eth.L2BlockRef, *eth.SyncStatus, error)
- func (s *Driver) Close() error
- func (s *Driver) OnL1Finalized(ctx context.Context, finalized eth.L1BlockRef) error
- func (s *Driver) OnL1Head(ctx context.Context, unsafe eth.L1BlockRef) error
- func (s *Driver) OnL1Safe(ctx context.Context, safe eth.L1BlockRef) error
- func (s *Driver) OnUnsafeL2Payload(ctx context.Context, payload *eth.ExecutionPayload) error
- func (s *Driver) ResetDerivationPipeline(ctx context.Context) error
- func (s *Driver) Start() error
- func (s *Driver) SyncStatus(ctx context.Context) (*eth.SyncStatus, error)
- type EngineState
- type L1Blocks
- type L1Chain
- type L1Metrics
- type L1OriginSelector
- type L1OriginSelectorIface
- type L1State
- func (s *L1State) HandleNewL1FinalizedBlock(finalized eth.L1BlockRef)
- func (s *L1State) HandleNewL1HeadBlock(head eth.L1BlockRef)
- func (s *L1State) HandleNewL1SafeBlock(safe eth.L1BlockRef)
- func (s *L1State) L1Finalized() eth.L1BlockRef
- func (s *L1State) L1Head() eth.L1BlockRef
- func (s *L1State) L1Safe() eth.L1BlockRef
- type L1StateIface
- type L2Chain
- type Metrics
- type Network
- type Sequencer
- type SequencerIface
- type SequencerMetrics
- type SyncStatusdeprecated
Constants ¶
This section is empty.
Variables ¶
var UninitializedL1StateErr = errors.New("the L1 Head in L1 State is not initialized yet")
Functions ¶
func NewConfDepth ¶
func NewConfDepth(depth uint64, l1Head func() eth.L1BlockRef, fetcher derive.L1Fetcher) *confDepth
Types ¶
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"` }
type DerivationPipeline ¶
type DerivationPipeline interface { Reset() Step(ctx context.Context) error SetUnsafeHead(head eth.L2BlockRef) AddUnsafePayload(payload *eth.ExecutionPayload) Finalize(ref eth.L1BlockRef) FinalizedL1() eth.L1BlockRef Finalized() eth.L2BlockRef SafeL2Head() eth.L2BlockRef UnsafeL2Head() eth.L2BlockRef Origin() eth.L1BlockRef }
type Downloader ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
func NewDriver ¶
func NewDriver(driverCfg *Config, cfg *rollup.Config, l2 L2Chain, l1 L1Chain, network Network, log log.Logger, snapshotLog log.Logger, metrics Metrics) *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, a context error is returned.
func (*Driver) OnL1Finalized ¶
func (*Driver) OnL1Head ¶
OnL1Head signals the driver that the L1 chain changed the "unsafe" block, also known as head of the chain, or "latest".
func (*Driver) OnL1Safe ¶
OnL1Safe signals the driver that the L1 chain changed the "safe", also known as the justified checkpoint (as seen on L1 beacon-chain).
func (*Driver) OnUnsafeL2Payload ¶
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) Start ¶
Start starts up the state loop. The loop will have been started iff err is not nil.
func (*Driver) SyncStatus ¶
SyncStatus blocks the driver event loop and captures the syncing status. If the event loop is too busy and the context expires, a context error is returned.
type EngineState ¶ added in v0.10.4
type EngineState interface { Finalized() eth.L2BlockRef UnsafeL2Head() eth.L2BlockRef SafeL2Head() eth.L2BlockRef Origin() eth.L1BlockRef }
type L1Blocks ¶
type L1Blocks interface { derive.L1BlockRefByHashFetcher derive.L1BlockRefByNumberFetcher }
type L1Chain ¶
type L1Chain interface { derive.L1Fetcher L1BlockRefByLabel(context.Context, eth.BlockLabel) (eth.L1BlockRef, error) }
type L1Metrics ¶
type L1Metrics interface { RecordL1ReorgDepth(d uint64) RecordL1Ref(name string, ref eth.L1BlockRef) }
type L1OriginSelector ¶
type L1OriginSelector struct {
// contains filtered or unexported fields
}
func NewL1OriginSelector ¶
func (*L1OriginSelector) FindL1Origin ¶
func (los *L1OriginSelector) FindL1Origin(ctx context.Context, l1Head eth.L1BlockRef, l2Head eth.L2BlockRef) (eth.L1BlockRef, error)
FindL1Origin determines what the next L1 Origin should be. The L1 Origin is either the L2 Head's Origin, or the following L1 block if the next L2 block's time is greater than or equal to the L2 Head's Origin.
type L1OriginSelectorIface ¶
type L1OriginSelectorIface interface {
FindL1Origin(ctx context.Context, l1Head eth.L1BlockRef, l2Head eth.L2BlockRef) (eth.L1BlockRef, error)
}
type L1State ¶
type L1State struct {
// contains filtered or unexported fields
}
L1State tracks L1 head, safe and finalized blocks. It is not safe to write and read concurrently.
func (*L1State) HandleNewL1FinalizedBlock ¶
func (s *L1State) HandleNewL1FinalizedBlock(finalized eth.L1BlockRef)
func (*L1State) HandleNewL1HeadBlock ¶
func (s *L1State) HandleNewL1HeadBlock(head eth.L1BlockRef)
func (*L1State) HandleNewL1SafeBlock ¶
func (s *L1State) HandleNewL1SafeBlock(safe eth.L1BlockRef)
func (*L1State) L1Finalized ¶
func (s *L1State) L1Finalized() eth.L1BlockRef
L1Finalized returns either the stored L1 finalized block or an empty block reference if the L1 finalized block has not been initialized yet.
func (*L1State) L1Head ¶
func (s *L1State) L1Head() eth.L1BlockRef
L1Head returns either the stored L1 head or an empty block reference if the L1 Head has not been initialized yet.
func (*L1State) L1Safe ¶
func (s *L1State) L1Safe() eth.L1BlockRef
L1Safe returns either the stored L1 safe block or an empty block reference if the L1 safe block has not been initialized yet.
type L1StateIface ¶
type L1StateIface interface { HandleNewL1HeadBlock(head eth.L1BlockRef) HandleNewL1SafeBlock(safe eth.L1BlockRef) HandleNewL1FinalizedBlock(finalized eth.L1BlockRef) L1Head() eth.L1BlockRef L1Safe() eth.L1BlockRef L1Finalized() eth.L1BlockRef }
type Metrics ¶
type Metrics interface { RecordPipelineReset() RecordSequencingError() RecordPublishingError() RecordDerivationError() RecordReceivedUnsafePayload(payload *eth.ExecutionPayload) RecordL1Ref(name string, ref eth.L1BlockRef) RecordL2Ref(name string, ref eth.L2BlockRef) RecordUnsafePayloadsBuffer(length uint64, memSize uint64, next eth.BlockID) SetDerivationIdle(idle bool) RecordL1ReorgDepth(d uint64) CountSequencedTxs(count int) SequencerMetrics }
type Network ¶
type Network interface { // PublishL2Payload is called by the driver whenever there is a new payload to publish, synchronously with the driver main loop. PublishL2Payload(ctx context.Context, payload *eth.ExecutionPayload) error }
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(log log.Logger, cfg *rollup.Config, l1 Downloader, l2 derive.Engine, engineState EngineState, metrics SequencerMetrics) *Sequencer
func (*Sequencer) CompleteBuildingBlock ¶
CompleteBuildingBlock takes the current block that is being built, and asks the engine to complete the building, seal the block, and persist it as canonical. Warning: the safe and finalized L2 blocks as viewed during the initiation of the block building are reused for completion of the block building. The Execution engine should not change the safe and finalized blocks between start and completion of block building.
func (*Sequencer) PlanNextSequencerAction ¶ added in v0.10.4
func (d *Sequencer) PlanNextSequencerAction(sequenceErr error) (delay time.Duration, seal bool, onto eth.BlockID)
PlanNextSequencerAction returns a desired delay till the next action, and if we should seal the block: - true whenever we need to complete a block - false whenever we need to start a block
func (*Sequencer) StartBuildingBlock ¶
StartBuildingBlock initiates a block building job on top of the given L2 head, safe and finalized blocks, and using the provided l1Origin.
type SequencerIface ¶
type SequencerMetrics ¶ added in v0.10.4
type SyncStatus
deprecated
type SyncStatus = eth.SyncStatus
Deprecated: use eth.SyncStatus instead.