engine

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEngineSyncing = errors.New("engine is syncing")
View Source
var ErrNoFCUNeeded = errors.New("no FCU call was needed")
View Source
var Kinds = []Kind{
	Geth,
	Reth,
	Erigon,
}

Functions

func ForceEngineReset

func ForceEngineReset(ec ResetEngineControl, x ForceEngineResetEvent)

ForceEngineReset is not to be used. The op-program needs it for now, until event processing is adopted there.

func ValidEngineKind

func ValidEngineKind(value Kind) bool

Types

type BlockInsertionErrType

type BlockInsertionErrType uint
const (
	// BlockInsertOK indicates that the payload was successfully executed and appended to the canonical chain.
	BlockInsertOK BlockInsertionErrType = iota
	// BlockInsertTemporaryErr indicates that the insertion failed but may succeed at a later time without changes to the payload.
	BlockInsertTemporaryErr
	// BlockInsertPrestateErr indicates that the pre-state to insert the payload could not be prepared, e.g. due to missing chain data.
	BlockInsertPrestateErr
	// BlockInsertPayloadErr indicates that the payload was invalid and cannot become canonical.
	BlockInsertPayloadErr
)

type BuildCancelEvent

type BuildCancelEvent struct {
	Info  eth.PayloadInfo
	Force bool
}

func (BuildCancelEvent) String

func (ev BuildCancelEvent) String() string

type BuildInvalidEvent

type BuildInvalidEvent struct {
	Attributes *derive.AttributesWithParent
	Err        error
}

BuildInvalidEvent is an internal engine event, to post-process upon invalid attributes. Not for temporary processing problems.

func (BuildInvalidEvent) String

func (ev BuildInvalidEvent) String() string

type BuildSealEvent

type BuildSealEvent struct {
	Info         eth.PayloadInfo
	BuildStarted time.Time
	// if payload should be promoted to safe (must also be pending safe, see DerivedFrom)
	IsLastInSpan bool
	// payload is promoted to pending-safe if non-zero
	DerivedFrom eth.L1BlockRef
}

func (BuildSealEvent) String

func (ev BuildSealEvent) String() string

type BuildSealedEvent

type BuildSealedEvent struct {
	// if payload should be promoted to safe (must also be pending safe, see DerivedFrom)
	IsLastInSpan bool
	// payload is promoted to pending-safe if non-zero
	DerivedFrom eth.L1BlockRef

	Info     eth.PayloadInfo
	Envelope *eth.ExecutionPayloadEnvelope
	Ref      eth.L2BlockRef
}

BuildSealedEvent is emitted by the engine when a payload finished building, but is not locally inserted as canonical block yet

func (BuildSealedEvent) String

func (ev BuildSealedEvent) String() string

type BuildStartEvent

type BuildStartEvent struct {
	Attributes *derive.AttributesWithParent
}

func (BuildStartEvent) String

func (ev BuildStartEvent) String() string

type BuildStartedEvent

type BuildStartedEvent struct {
	Info eth.PayloadInfo

	BuildStarted time.Time

	Parent eth.L2BlockRef

	// if payload should be promoted to safe (must also be pending safe, see DerivedFrom)
	IsLastInSpan bool
	// payload is promoted to pending-safe if non-zero
	DerivedFrom eth.L1BlockRef
}

func (BuildStartedEvent) String

func (ev BuildStartedEvent) String() string

type EngDeriver

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

func NewEngDeriver

func NewEngDeriver(log log.Logger, ctx context.Context, cfg *rollup.Config,
	metrics Metrics, ec *EngineController) *EngDeriver

func (*EngDeriver) AttachEmitter

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

func (*EngDeriver) OnEvent

func (d *EngDeriver) OnEvent(ev event.Event) bool

type Engine

type Engine interface {
	ExecEngine
	derive.L2Source
}

type EngineController

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

func NewEngineController

func NewEngineController(engine ExecEngine, log log.Logger, metrics derive.Metrics,
	rollupCfg *rollup.Config, syncCfg *sync.Config, emitter event.Emitter) *EngineController

func (*EngineController) BackupUnsafeL2Head

func (e *EngineController) BackupUnsafeL2Head() eth.L2BlockRef

func (*EngineController) Finalized

func (e *EngineController) Finalized() eth.L2BlockRef

func (*EngineController) InsertUnsafePayload

func (e *EngineController) InsertUnsafePayload(ctx context.Context, envelope *eth.ExecutionPayloadEnvelope, ref eth.L2BlockRef) error

func (*EngineController) IsEngineSyncing

func (e *EngineController) IsEngineSyncing() bool

func (*EngineController) PendingSafeL2Head

func (e *EngineController) PendingSafeL2Head() eth.L2BlockRef

func (*EngineController) SafeL2Head

func (e *EngineController) SafeL2Head() eth.L2BlockRef

func (*EngineController) SetBackupUnsafeL2Head

func (e *EngineController) SetBackupUnsafeL2Head(r eth.L2BlockRef, triggerReorg bool)

SetBackupUnsafeL2Head implements LocalEngineControl.

func (*EngineController) SetFinalizedHead

func (e *EngineController) SetFinalizedHead(r eth.L2BlockRef)

SetFinalizedHead implements LocalEngineControl.

func (*EngineController) SetPendingSafeL2Head

func (e *EngineController) SetPendingSafeL2Head(r eth.L2BlockRef)

SetPendingSafeL2Head implements LocalEngineControl.

func (*EngineController) SetSafeHead

func (e *EngineController) SetSafeHead(r eth.L2BlockRef)

SetSafeHead implements LocalEngineControl.

func (*EngineController) SetUnsafeHead

func (e *EngineController) SetUnsafeHead(r eth.L2BlockRef)

SetUnsafeHead implements LocalEngineControl.

func (*EngineController) TryBackupUnsafeReorg

func (e *EngineController) TryBackupUnsafeReorg(ctx context.Context) (bool, error)

TryBackupUnsafeReorg attempts to reorg(restore) unsafe head to backupUnsafeHead. If succeeds, update current forkchoice state to the rollup node.

func (*EngineController) TryUpdateEngine

func (e *EngineController) TryUpdateEngine(ctx context.Context) error

TryUpdateEngine attempts to update the engine with the current forkchoice state of the rollup node, this is a no-op if the nodes already agree on the forkchoice state.

func (*EngineController) UnsafeL2Head

func (e *EngineController) UnsafeL2Head() eth.L2BlockRef

type EngineResetConfirmedEvent

type EngineResetConfirmedEvent struct {
	Unsafe, Safe, Finalized eth.L2BlockRef
}

func (EngineResetConfirmedEvent) String

func (ev EngineResetConfirmedEvent) String() string

type EngineResetDeriver

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

func NewEngineResetDeriver

func NewEngineResetDeriver(ctx context.Context, log log.Logger, cfg *rollup.Config,
	l1 sync.L1Chain, l2 sync.L2Chain, syncCfg *sync.Config) *EngineResetDeriver

func (*EngineResetDeriver) AttachEmitter

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

func (*EngineResetDeriver) OnEvent

func (d *EngineResetDeriver) OnEvent(ev event.Event) bool

type EngineState

type EngineState interface {
	Finalized() eth.L2BlockRef
	UnsafeL2Head() eth.L2BlockRef
	SafeL2Head() eth.L2BlockRef
}

EngineState provides a read-only interface of the forkchoice state properties of the L2 Engine.

type ExecEngine

type ExecEngine interface {
	GetPayload(ctx context.Context, payloadInfo eth.PayloadInfo) (*eth.ExecutionPayloadEnvelope, error)
	ForkchoiceUpdate(ctx context.Context, state *eth.ForkchoiceState, attr *eth.PayloadAttributes) (*eth.ForkchoiceUpdatedResult, error)
	NewPayload(ctx context.Context, payload *eth.ExecutionPayload, parentBeaconBlockRoot *common.Hash) (*eth.PayloadStatusV1, error)
	L2BlockRefByLabel(ctx context.Context, label eth.BlockLabel) (eth.L2BlockRef, error)
}

type ForceEngineResetEvent

type ForceEngineResetEvent struct {
	Unsafe, Safe, Finalized eth.L2BlockRef
}

func (ForceEngineResetEvent) String

func (ev ForceEngineResetEvent) String() string

type ForkchoiceRequestEvent

type ForkchoiceRequestEvent struct {
}

ForkchoiceRequestEvent signals to the engine that it should emit an artificial forkchoice-update event, to signal the latest forkchoice to other derivers. This helps decouple derivers from the actual engine state, while also not making the derivers wait for a forkchoice update at random.

func (ForkchoiceRequestEvent) String

func (ev ForkchoiceRequestEvent) String() string

type ForkchoiceUpdateEvent

type ForkchoiceUpdateEvent struct {
	UnsafeL2Head, SafeL2Head, FinalizedL2Head eth.L2BlockRef
}

func (ForkchoiceUpdateEvent) String

func (ev ForkchoiceUpdateEvent) String() string

type InvalidPayloadAttributesEvent

type InvalidPayloadAttributesEvent struct {
	Attributes *derive.AttributesWithParent
	Err        error
}

InvalidPayloadAttributesEvent is a signal to external derivers that the attributes were invalid.

func (InvalidPayloadAttributesEvent) String

type Kind

type Kind string

Kind identifies the engine client's kind, used to control the behavior of optimism in different engine clients.

const (
	Geth   Kind = "geth"
	Reth   Kind = "reth"
	Erigon Kind = "erigon"
)

func (*Kind) Clone

func (kind *Kind) Clone() any

func (*Kind) Set

func (kind *Kind) Set(value string) error

func (Kind) String

func (kind Kind) String() string

func (Kind) SupportsPostFinalizationELSync

func (kind Kind) SupportsPostFinalizationELSync() bool

type LocalEngineControl

type LocalEngineControl interface {
	LocalEngineState
	ResetEngineControl
}

type LocalEngineState

type LocalEngineState interface {
	EngineState

	PendingSafeL2Head() eth.L2BlockRef
	BackupUnsafeL2Head() eth.L2BlockRef
}

type Metrics

type Metrics interface {
	CountSequencedTxs(count int)

	RecordSequencerBuildingDiffTime(duration time.Duration)
	RecordSequencerSealingTime(duration time.Duration)
}

type PayloadInvalidEvent

type PayloadInvalidEvent struct {
	Envelope *eth.ExecutionPayloadEnvelope
	Err      error
}

func (PayloadInvalidEvent) String

func (ev PayloadInvalidEvent) String() string

type PayloadProcessEvent

type PayloadProcessEvent struct {
	// if payload should be promoted to safe (must also be pending safe, see DerivedFrom)
	IsLastInSpan bool
	// payload is promoted to pending-safe if non-zero
	DerivedFrom eth.L1BlockRef

	Envelope *eth.ExecutionPayloadEnvelope
	Ref      eth.L2BlockRef
}

func (PayloadProcessEvent) String

func (ev PayloadProcessEvent) String() string

type PayloadSealExpiredErrorEvent

type PayloadSealExpiredErrorEvent struct {
	Info eth.PayloadInfo
	Err  error

	IsLastInSpan bool
	DerivedFrom  eth.L1BlockRef
}

PayloadSealExpiredErrorEvent identifies a form of failed payload-sealing that is not coupled to the attributes themselves, but rather the build-job process. The user should re-attempt by starting a new build process. The payload-sealing job should not be re-attempted, as it most likely expired, timed out, or referenced an otherwise invalidated block-building job identifier.

func (PayloadSealExpiredErrorEvent) String

type PayloadSealInvalidEvent

type PayloadSealInvalidEvent struct {
	Info eth.PayloadInfo
	Err  error

	IsLastInSpan bool
	DerivedFrom  eth.L1BlockRef
}

PayloadSealInvalidEvent identifies a permanent in-consensus problem with the payload sealing.

func (PayloadSealInvalidEvent) String

func (ev PayloadSealInvalidEvent) String() string

type PayloadSuccessEvent

type PayloadSuccessEvent struct {
	// if payload should be promoted to safe (must also be pending safe, see DerivedFrom)
	IsLastInSpan bool
	// payload is promoted to pending-safe if non-zero
	DerivedFrom eth.L1BlockRef

	Envelope *eth.ExecutionPayloadEnvelope
	Ref      eth.L2BlockRef
}

func (PayloadSuccessEvent) String

func (ev PayloadSuccessEvent) String() string

type PendingSafeRequestEvent

type PendingSafeRequestEvent struct {
}

func (PendingSafeRequestEvent) String

func (ev PendingSafeRequestEvent) String() string

type PendingSafeUpdateEvent

type PendingSafeUpdateEvent struct {
	PendingSafe eth.L2BlockRef
	Unsafe      eth.L2BlockRef // tip, added to the signal, to determine if there are existing blocks to consolidate
}

func (PendingSafeUpdateEvent) String

func (ev PendingSafeUpdateEvent) String() string

type ProcessAttributesEvent

type ProcessAttributesEvent struct {
	Attributes *derive.AttributesWithParent
}

ProcessAttributesEvent signals to immediately process the attributes.

func (ProcessAttributesEvent) String

func (ev ProcessAttributesEvent) String() string

type ProcessUnsafePayloadEvent

type ProcessUnsafePayloadEvent struct {
	Envelope *eth.ExecutionPayloadEnvelope
}

func (ProcessUnsafePayloadEvent) String

func (ev ProcessUnsafePayloadEvent) String() string

type PromoteFinalizedEvent

type PromoteFinalizedEvent struct {
	Ref eth.L2BlockRef
}

PromoteFinalizedEvent signals that a block can be marked as finalized.

func (PromoteFinalizedEvent) String

func (ev PromoteFinalizedEvent) String() string

type PromotePendingSafeEvent

type PromotePendingSafeEvent struct {
	Ref         eth.L2BlockRef
	Safe        bool
	DerivedFrom eth.L1BlockRef
}

PromotePendingSafeEvent signals that a block can be marked as pending-safe, and/or safe.

func (PromotePendingSafeEvent) String

func (ev PromotePendingSafeEvent) String() string

type ResetEngineControl

type ResetEngineControl interface {
	SetUnsafeHead(eth.L2BlockRef)
	SetSafeHead(eth.L2BlockRef)
	SetFinalizedHead(eth.L2BlockRef)
	SetBackupUnsafeL2Head(block eth.L2BlockRef, triggerReorg bool)
	SetPendingSafeL2Head(eth.L2BlockRef)
}

type ResetEngineRequestEvent

type ResetEngineRequestEvent struct{}

ResetEngineRequestEvent requests the EngineResetDeriver to walk the L2 chain backwards until it finds a plausible unsafe head, and find an L2 safe block that is guaranteed to still be from the L1 chain.

func (ResetEngineRequestEvent) String

func (ev ResetEngineRequestEvent) String() string

type SafeDerivedEvent

type SafeDerivedEvent struct {
	Safe        eth.L2BlockRef
	DerivedFrom eth.L1BlockRef
}

SafeDerivedEvent signals that a block was determined to be safe, and derived from the given L1 block

func (SafeDerivedEvent) String

func (ev SafeDerivedEvent) String() string

type TryBackupUnsafeReorgEvent

type TryBackupUnsafeReorgEvent struct {
}

func (TryBackupUnsafeReorgEvent) String

func (ev TryBackupUnsafeReorgEvent) String() string

type TryUpdateEngineEvent

type TryUpdateEngineEvent struct {
}

func (TryUpdateEngineEvent) String

func (ev TryUpdateEngineEvent) String() string

Jump to

Keyboard shortcuts

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