rollup

package
v0.0.0-...-28a9180 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBlockTimeZero                 = errors.New("block time cannot be 0")
	ErrMissingChannelTimeout         = errors.New("channel timeout must be set, this should cover at least a L1 block time")
	ErrInvalidSeqWindowSize          = errors.New("sequencing window size must at least be 2")
	ErrInvalidMaxSeqDrift            = errors.New("maximum sequencer drift must be greater than 0")
	ErrMissingGenesisL2Hash          = errors.New("genesis core hash cannot be empty")
	ErrMissingGenesisL2Time          = errors.New("missing core genesis time")
	ErrMissingGasLimit               = errors.New("missing genesis system config gas limit")
	ErrMissingBatchInboxAddress      = errors.New("missing batch inbox address")
	ErrMissingDepositContractAddress = errors.New("missing deposit contract address")
	ErrMissingL2ChainID              = errors.New("core chain ID must not be nil")
	ErrL2ChainIDNotPositive          = errors.New("core chain ID must be non-zero and positive")
)
View Source
var ErrNilProof = errors.New("output root proof is nil")
View Source
var OPStackSupport = params.ProtocolVersionV0{Build: [8]byte{}, Major: 9, Minor: 0, Patch: 0, PreRelease: 0}.Encode()

Functions

func ComputeL2OutputRoot

func ComputeL2OutputRoot(proofElements *bindings.TypesOutputRootProof) (eth.Bytes32, error)

ComputeL2OutputRoot computes the core output root by hashing an output root proof.

func ComputeL2OutputRootV0

func ComputeL2OutputRootV0(block eth.BlockInfo, storageRoot [32]byte) (eth.Bytes32, error)

func IsValidFork

func IsValidFork(fork ForkName) bool

Types

type AltDAConfig

type AltDAConfig struct {
	// L1 DataAvailabilityChallenge contract proxy address
	DAChallengeAddress common.Address `json:"da_challenge_contract_address,omitempty"`
	// CommitmentType specifies which commitment type can be used. Defaults to Keccak (type 0) if not present
	CommitmentType string `json:"da_commitment_type"`
	// DA challenge window value set on the DAC contract. Used in alt-da mode
	// to compute when a commitment can no longer be challenged.
	DAChallengeWindow uint64 `json:"da_challenge_window"`
	// DA resolve window value set on the DAC contract. Used in alt-da mode
	// to compute when a challenge expires and trigger a reorg if needed.
	DAResolveWindow uint64 `json:"da_resolve_window"`
}

type ChainSpec

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

func NewChainSpec

func NewChainSpec(config *Config) *ChainSpec

func (*ChainSpec) ChannelTimeout

func (s *ChainSpec) ChannelTimeout(t uint64) uint64

ChannelTimeout returns the channel timeout constant.

func (*ChainSpec) CheckForkActivation

func (s *ChainSpec) CheckForkActivation(log log.Logger, block eth.L2BlockRef)

func (*ChainSpec) IsCanyon

func (s *ChainSpec) IsCanyon(t uint64) bool

IsCanyon returns true if t >= canyon_time

func (*ChainSpec) IsFeatMaxSequencerDriftConstant

func (s *ChainSpec) IsFeatMaxSequencerDriftConstant(t uint64) bool

IsFeatMaxSequencerDriftConstant specifies in which fork the max sequencer drift change to a constant will be performed.

func (*ChainSpec) IsHolocene

func (s *ChainSpec) IsHolocene(t uint64) bool

IsHolocene returns true if t >= holocene_time

func (*ChainSpec) IsIsthmus

func (s *ChainSpec) IsIsthmus(t uint64) bool

IsIsthmus returns true if t >= isthmus_time

func (*ChainSpec) L2ChainID

func (s *ChainSpec) L2ChainID() *big.Int

L2ChainID returns the chain ID of the core chain.

func (*ChainSpec) L2GenesisTime

func (s *ChainSpec) L2GenesisTime() uint64

L2GenesisTime returns the genesis time of the core chain.

func (*ChainSpec) MaxChannelBankSize

func (s *ChainSpec) MaxChannelBankSize(t uint64) uint64

MaxChannelBankSize returns the maximum number of bytes the can allocated inside the channel bank before pruning occurs at the given timestamp.

func (*ChainSpec) MaxRLPBytesPerChannel

func (s *ChainSpec) MaxRLPBytesPerChannel(t uint64) uint64

MaxRLPBytesPerChannel returns the maximum amount of bytes that will be read from a channel at a given timestamp.

func (*ChainSpec) MaxSequencerDrift

func (s *ChainSpec) MaxSequencerDrift(t uint64) uint64

MaxSequencerDrift returns the maximum sequencer drift for the given block timestamp. Until Fjord, this was a rollup configuration parameter. Since Fjord, it is a constant, so its effective value should always be queried via the ChainSpec.

type Config

type Config struct {
	// Genesis anchor point of the rollup
	Genesis Genesis `json:"genesis"`
	// Seconds per core block
	BlockTime uint64 `json:"block_time"`
	// Sequencer batches may not be more than MaxSequencerDrift seconds after
	// the L1 timestamp of their L1 origin time.
	//
	// Note: When L1 has many 1 second consecutive blocks, and core grows at fixed 2 seconds,
	// the core time may still grow beyond this difference.
	//
	// With Fjord, the MaxSequencerDrift becomes a constant. Use the ChainSpec
	// instead of reading this rollup configuration field directly to determine
	// the max sequencer drift for a given block based on the block's L1 origin.
	// Chains that activate Fjord at genesis may leave this field empty.
	MaxSequencerDrift uint64 `json:"max_sequencer_drift,omitempty"`
	// Number of epochs (L1 blocks) per sequencing window, including the epoch L1 origin block itself
	SeqWindowSize uint64 `json:"seq_window_size"`
	// Number of L1 blocks between when a channel can be opened and when it must be closed by.
	ChannelTimeoutBedrock uint64 `json:"channel_timeout"`
	// Required to identify the core network and create p2p signatures unique for this chain.
	L2ChainID *big.Int `json:"l2_chain_id"`

	// RegolithTime sets the activation time of the Regolith network-upgrade:
	// a pre-mainnet Bedrock change that addresses findings of the Sherlock contest related to deposit attributes.
	// "Regolith" is the loose deposited rock that sits on top of Bedrock.
	// Active if RegolithTime != nil && core block timestamp >= *RegolithTime, inactive otherwise.
	RegolithTime *uint64 `json:"regolith_time,omitempty"`

	// CanyonTime sets the activation time of the Canyon network upgrade.
	// Active if CanyonTime != nil && core block timestamp >= *CanyonTime, inactive otherwise.
	CanyonTime *uint64 `json:"canyon_time,omitempty"`

	// DeltaTime sets the activation time of the Delta network upgrade.
	// Active if DeltaTime != nil && core block timestamp >= *DeltaTime, inactive otherwise.
	DeltaTime *uint64 `json:"delta_time,omitempty"`

	// EcotoneTime sets the activation time of the Ecotone network upgrade.
	// Active if EcotoneTime != nil && core block timestamp >= *EcotoneTime, inactive otherwise.
	EcotoneTime *uint64 `json:"ecotone_time,omitempty"`

	// FjordTime sets the activation time of the Fjord network upgrade.
	// Active if FjordTime != nil && core block timestamp >= *FjordTime, inactive otherwise.
	FjordTime *uint64 `json:"fjord_time,omitempty"`

	// GraniteTime sets the activation time of the Granite network upgrade.
	// Active if GraniteTime != nil && core block timestamp >= *GraniteTime, inactive otherwise.
	GraniteTime *uint64 `json:"granite_time,omitempty"`

	// HoloceneTime sets the activation time of the Holocene network upgrade.
	// Active if HoloceneTime != nil && core block timestamp >= *HoloceneTime, inactive otherwise.
	HoloceneTime *uint64 `json:"holocene_time,omitempty"`

	// IsthmusTime sets the activation time of the Isthmus network upgrade.
	// Active if IsthmusTime != nil && core block timestamp >= *IsthmusTime, inactive otherwise.
	IsthmusTime *uint64 `json:"isthmus_time,omitempty"`

	// JovianTime sets the activation time of the Jovian network upgrade.
	// Active if JovianTime != nil && core block timestamp >= *JovianTime, inactive otherwise.
	JovianTime *uint64 `json:"jovian_time,omitempty"`

	// InteropTime sets the activation time for an experimental feature-set, activated like a hardfork.
	// Active if InteropTime != nil && core block timestamp >= *InteropTime, inactive otherwise.
	InteropTime *uint64 `json:"interop_time,omitempty"`

	// ChainOpConfig is the OptimismConfig of the execution layer ChainConfig.
	// It is used during safe chain consolidation to translate zero SystemConfig EIP1559
	// parameters to the protocol values, like the execution layer does.
	// If missing, it is loaded by the dn-node from the embedded superchain config at startup.
	ChainOpConfig *params.OptimismConfig `json:"chain_op_config,omitempty"`

	// PectraBlobScheduleTime sets the time until which (but not including) the blob base fee
	// calculations for the L1 Block Info use the pre-Prague=Cancun blob parameters.
	// This feature is optional and if not active, the L1 Block Info calculation uses the Prague
	// blob parameters for the first L1 Prague block, as was intended.
	// This feature (de)activates by L1 origin timestamp, to keep a consistent L1 block info per core
	// epoch.
	PectraBlobScheduleTime *uint64 `json:"pectra_blob_schedule_time,omitempty"`
}

func LoadOPStackRollupConfig

func LoadOPStackRollupConfig(chainID uint64) (*Config, error)

LoadOPStackRollupConfig loads the rollup configuration of the requested chain ID from the superchain-registry. Some chains may require a SystemConfigProvider to retrieve any values not part of the registry.

func (*Config) ActivateAtGenesis

func (c *Config) ActivateAtGenesis(hardfork ForkName)

func (*Config) Check

func (cfg *Config) Check() error

Check verifies that the given configuration makes sense

func (*Config) CheckL2ChainID

func (cfg *Config) CheckL2ChainID(ctx context.Context, client L2Client) error

CheckL2ChainID checks that the configured core chain ID matches the client's chain ID.

func (*Config) CheckL2GenesisBlockHash

func (cfg *Config) CheckL2GenesisBlockHash(ctx context.Context, client L2Client) error

CheckL2GenesisBlockHash checks that the configured core genesis block hash is valid for the given client.

func (*Config) Description

func (c *Config) Description(l2Chains map[string]string) string

Description outputs a banner describing the important parts of rollup configuration in a human-readable form. Optionally provide a mapping of core chain IDs to network names to label the core chain with if not unknown. The config should be config.Check()-ed before creating a description.

func (*Config) ForkchoiceUpdatedVersion

func (c *Config) ForkchoiceUpdatedVersion(attr *eth.PayloadAttributes) eth.EngineAPIMethod

ForkchoiceUpdatedVersion returns the EngineAPIMethod suitable for the chain hard fork version.

func (*Config) GetPayloadVersion

func (c *Config) GetPayloadVersion(timestamp uint64) eth.EngineAPIMethod

GetPayloadVersion returns the EngineAPIMethod suitable for the chain hard fork version.

func (*Config) HasOptimismWithdrawalsRoot

func (cfg *Config) HasOptimismWithdrawalsRoot(timestamp uint64) bool

func (*Config) IsActivationBlock

func (c *Config) IsActivationBlock(oldTime, newTime uint64) ForkName

IsActivationBlock returns the fork which activates at the block with time newTime if the previous block's time is oldTime. It return an empty ForkName if no fork activation takes place between those timestamps. It can be used for both, L1 and core blocks. TODO(12490): Currently only supports Holocene. Will be modularized in a follow-up.

func (*Config) IsCanyon

func (c *Config) IsCanyon(timestamp uint64) bool

IsCanyon returns true if the Canyon hardfork is active at or past the given timestamp.

func (*Config) IsCanyonActivationBlock

func (c *Config) IsCanyonActivationBlock(l2BlockTime uint64) bool

func (*Config) IsDelta

func (c *Config) IsDelta(timestamp uint64) bool

IsDelta returns true if the Delta hardfork is active at or past the given timestamp.

func (*Config) IsDeltaActivationBlock

func (c *Config) IsDeltaActivationBlock(l2BlockTime uint64) bool

func (*Config) IsEcotone

func (c *Config) IsEcotone(timestamp uint64) bool

IsEcotone returns true if the Ecotone hardfork is active at or past the given timestamp.

func (*Config) IsEcotoneActivationBlock

func (c *Config) IsEcotoneActivationBlock(l2BlockTime uint64) bool

IsEcotoneActivationBlock returns whether the specified block is the first block subject to the Ecotone upgrade. Ecotone activation at genesis does not count.

func (*Config) IsFjord

func (c *Config) IsFjord(timestamp uint64) bool

IsFjord returns true if the Fjord hardfork is active at or past the given timestamp.

func (*Config) IsFjordActivationBlock

func (c *Config) IsFjordActivationBlock(l2BlockTime uint64) bool

IsFjordActivationBlock returns whether the specified block is the first block subject to the Fjord upgrade.

func (*Config) IsGranite

func (c *Config) IsGranite(timestamp uint64) bool

IsGranite returns true if the Granite hardfork is active at or past the given timestamp.

func (*Config) IsGraniteActivationBlock

func (c *Config) IsGraniteActivationBlock(l2BlockTime uint64) bool

IsGraniteActivationBlock returns whether the specified block is the first block subject to the Granite upgrade.

func (*Config) IsHolocene

func (c *Config) IsHolocene(timestamp uint64) bool

IsHolocene returns true if the Holocene hardfork is active at or past the given timestamp.

func (*Config) IsHoloceneActivationBlock

func (c *Config) IsHoloceneActivationBlock(l2BlockTime uint64) bool

IsHoloceneActivationBlock returns whether the specified block is the first block subject to the Holocene upgrade.

func (*Config) IsInterop

func (c *Config) IsInterop(timestamp uint64) bool

IsInterop returns true if the Interop hardfork is active at or past the given timestamp.

func (*Config) IsInteropActivationBlock

func (c *Config) IsInteropActivationBlock(l2BlockTime uint64) bool

func (*Config) IsIsthmus

func (c *Config) IsIsthmus(timestamp uint64) bool

IsIsthmus returns true if the Isthmus hardfork is active at or past the given timestamp.

func (*Config) IsIsthmusActivationBlock

func (c *Config) IsIsthmusActivationBlock(l2BlockTime uint64) bool

IsIsthmusActivationBlock returns whether the specified block is the first block subject to the Isthmus upgrade.

func (*Config) IsJovian

func (c *Config) IsJovian(timestamp uint64) bool

IsJovian returns true if the Jovian hardfork is active at or past the given timestamp.

func (*Config) IsJovianActivationBlock

func (c *Config) IsJovianActivationBlock(l2BlockTime uint64) bool

IsJovianActivationBlock returns whether the specified block is the first block subject to the Jovian upgrade.

func (*Config) IsRegolith

func (c *Config) IsRegolith(timestamp uint64) bool

IsRegolith returns true if the Regolith hardfork is active at or past the given timestamp.

func (*Config) IsRegolithActivationBlock

func (c *Config) IsRegolithActivationBlock(l2BlockTime uint64) bool

func (*Config) LogDescription

func (c *Config) LogDescription(log log.Logger, l2Chains map[string]string)

LogDescription outputs a banner describing the important parts of rollup configuration in a log format. Optionally provide a mapping of core chain IDs to network names to label the core chain with if not unknown. The config should be config.Check()-ed before creating a description.

func (*Config) NewPayloadVersion

func (c *Config) NewPayloadVersion(timestamp uint64) eth.EngineAPIMethod

NewPayloadVersion returns the EngineAPIMethod suitable for the chain hard fork version.

func (*Config) ParseRollupConfig

func (c *Config) ParseRollupConfig(in io.Reader) error

func (*Config) SyncLookback

func (c *Config) SyncLookback() uint64

SyncLookback computes the number of blocks to walk back in order to find the correct L1 origin. In alt-da mode longest possible window is challenge + resolve windows.

func (*Config) TargetBlockNumber

func (cfg *Config) TargetBlockNumber(timestamp uint64) (num uint64, err error)

func (*Config) TimestampForBlock

func (cfg *Config) TimestampForBlock(blockNumber uint64) uint64

func (*Config) ValidateL2Config

func (cfg *Config) ValidateL2Config(ctx context.Context, client L2Client, skipL2GenesisBlockHash bool) error

ValidateL2Config checks core config variables for errors.

type CriticalErrorEvent

type CriticalErrorEvent = event.CriticalErrorEvent

CriticalErrorEvent is an alias for event.CriticalErrorEvent

type EngineTemporaryErrorEvent

type EngineTemporaryErrorEvent struct {
	Err error
}

EngineTemporaryErrorEvent identifies a temporary processing issue. It applies to both L1 and core data, often inter-related. This scope will be reduced over time, to only capture core-engine specific temporary errors. See L1TemporaryErrorEvent for L1 related temporary errors.

func (EngineTemporaryErrorEvent) String

func (ev EngineTemporaryErrorEvent) String() string

type Epoch

type Epoch uint64

type ForceResetEvent

type ForceResetEvent struct {
	// LocalUnsafe is optional: the existing chain local-unsafe head will be preserved if this field is zeroed.
	LocalUnsafe eth.L2BlockRef

	CrossUnsafe, LocalSafe, CrossSafe, Finalized eth.L2BlockRef
}

ForceResetEvent forces a reset to a specific local-unsafe/local-safe/finalized starting point. Resets may override local-unsafe, to reset the very end of the chain. Resets may override local-safe, since post-interop we need the local-safe block derivation to continue. Pre-interop both local and cross values should be set the same.

func (ForceResetEvent) String

func (ev ForceResetEvent) String() string

type ForkName

type ForkName string
const (
	Bedrock  ForkName = "bedrock"
	Regolith ForkName = "regolith"
	Canyon   ForkName = "canyon"
	Delta    ForkName = "delta"
	Ecotone  ForkName = "ecotone"
	Fjord    ForkName = "fjord"
	Granite  ForkName = "granite"
	Holocene ForkName = "holocene"
	Isthmus  ForkName = "isthmus"
	Jovian   ForkName = "jovian"
	Interop  ForkName = "interop"
	// ADD NEW FORKS TO AllForks BELOW!
	None ForkName = "none"
)

func ForksFrom

func ForksFrom(fork ForkName) []ForkName

type Genesis

type Genesis struct {
	// The L1 block that the rollup starts *after* (no derived transactions)
	// The L2 block the rollup starts from (no transactions, pre-configured state)
	L2 eth.BlockID `json:"l2"`
	// Timestamp of L2 block
	L2Time uint64 `json:"l2_time"`
	// Initial system configuration values.
	// The L2 genesis block may not include transactions, and thus cannot encode the config values,
	// unlike later L2 blocks.
	SystemConfig eth.SystemConfig `json:"system_config"`
}

type L1Client

type L1Client interface {
	ChainID(context.Context) (*big.Int, error)
	L1BlockRefByNumber(context.Context, uint64) (eth.L1BlockRef, error)
}

type L1TemporaryErrorEvent

type L1TemporaryErrorEvent struct {
	Err error
}

L1TemporaryErrorEvent identifies a temporary issue with the L1 data.

func (L1TemporaryErrorEvent) String

func (ev L1TemporaryErrorEvent) String() string

type L2Client

type L2Client interface {
	ChainID(context.Context) (*big.Int, error)
	L2BlockRefByNumber(context.Context, uint64) (eth.L2BlockRef, error)
}

type ResetEvent

type ResetEvent struct {
	Err error
}

func (ResetEvent) String

func (ev ResetEvent) String() string

type SafeHeadListener

type SafeHeadListener interface {

	// Enabled reports if this safe head listener is actively using the posted data. This allows the engine queue to
	// optionally skip making calls that may be expensive to prepare.
	// Callbacks may still be made if Enabled returns false but are not guaranteed.
	Enabled() bool

	// SafeHeadUpdated indicates that the safe head has been updated in response to processing batch data
	// The l1Block specified is the first L1 block containing all required batch data to derive newSafeHead
	SafeHeadUpdated(newSafeHead eth.L2BlockRef) error

	// SafeHeadReset indicates that the derivation pipeline reset back to the specified safe head
	// The L1 block that made the new safe head safe is unknown.
	SafeHeadReset(resetSafeHead eth.L2BlockRef) error
}

SafeHeadListener is called when the safe head is updated. The safe head may advance by more than one block in a single update The l1Block specified is the first L1 block that includes sufficient information to derive the new safe head

Directories

Path Synopsis
Package derive provides the data transformation functions that take L1 data and turn it into core blocks and results.
Package derive provides the data transformation functions that take L1 data and turn it into core blocks and results.
Package sync is responsible for reconciling L1 and core.
Package sync is responsible for reconciling L1 and core.

Jump to

Keyboard shortcuts

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