params

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package params holds the OP-Stack-specific chain configuration types. Consumers import it as opparams.

This package must stay free of op-core/superchain/bundle, which embeds the generated registry bundle: packages that only need config types (notably op-node/rollup) must not pull the bundle into their build closure. op-core/superchain, which maps registry configs onto these types, imports this package one-way.

Index

Constants

View Source
const (
	// OPMainnetChainID is the chain ID of OP Mainnet, which has pre-Regolith
	// upgrade history that needs special handling when building its config.
	OPMainnetChainID = 10
	// OPMainnetGenesisBlockNum is the Bedrock-migration block of OP Mainnet, which
	// it treats as its genesis block.
	OPMainnetGenesisBlockNum = 105235063
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainConfig

type ChainConfig struct {
	ChainID *big.Int `json:"chainId"`

	BedrockBlock *big.Int `json:"bedrockBlock,omitempty"` // Bedrock switch block (nil = no fork, 0 = already on optimism bedrock)
	RegolithTime *uint64  `json:"regolithTime,omitempty"` // Regolith switch time (nil = no fork, 0 = already on optimism regolith)
	CanyonTime   *uint64  `json:"canyonTime,omitempty"`   // Canyon switch time (nil = no fork, 0 = already on optimism canyon)
	EcotoneTime  *uint64  `json:"ecotoneTime,omitempty"`  // Ecotone switch time (nil = no fork, 0 = already on optimism ecotone)
	FjordTime    *uint64  `json:"fjordTime,omitempty"`    // Fjord switch time (nil = no fork, 0 = already on optimism fjord)
	GraniteTime  *uint64  `json:"graniteTime,omitempty"`  // Granite switch time (nil = no fork, 0 = already on optimism granite)
	HoloceneTime *uint64  `json:"holoceneTime,omitempty"` // Holocene switch time (nil = no fork, 0 = already on optimism holocene)
	IsthmusTime  *uint64  `json:"isthmusTime,omitempty"`  // Isthmus switch time (nil = no fork, 0 = already on optimism isthmus)
	JovianTime   *uint64  `json:"jovianTime,omitempty"`   // Jovian switch time (nil = no fork, 0 = already on optimism jovian)
	KarstTime    *uint64  `json:"karstTime,omitempty"`    // Karst switch time (nil = no fork, 0 = already on optimism karst)
	LagoonTime   *uint64  `json:"lagoonTime,omitempty"`   // Lagoon switch time (nil = no fork, 0 = already on optimism lagoon)

	// Optimism is declared last: the JSON encoding follows the declaration order, and
	// "optimism" is its last key.
	Optimism *OptimismConfig `json:"optimism,omitempty"`
}

ChainConfig is the OP-Stack hardfork schedule and configuration of a chain. It is a standalone type: it does not embed go-ethereum's params.ChainConfig, so it carries only OP-specific state and the predicates below. Code that needs a go-ethereum config for the Ethereum fork schedule converts via GethChainConfig.

func (*ChainConfig) ActivationTime

func (c *ChainConfig) ActivationTime(fork forks.Name) *uint64

ActivationTime returns the activation timestamp of the given timestamp-based OP-Stack fork, or nil if the fork is not scheduled on this chain. It is the single source of truth that the Is<Fork> predicates below delegate to; to add a fork, extend this switch and its SetActivationTime counterpart.

Only forks with a timestamp field on the chain config are covered. Bedrock is block-based — use IsBedrock — and forks without an execution-layer representation here (e.g. Delta) are not handled and cause a panic, mirroring op-geth's config, which has no field for them.

func (*ChainConfig) GethChainConfig

func (c *ChainConfig) GethChainConfig() *gethparams.ChainConfig

GethChainConfig returns the go-ethereum params.ChainConfig with the Ethereum fork schedule of c, derived from the OP fork schedule: Shanghai activates with Canyon, Cancun with Ecotone, Prague with Isthmus, Osaka with Karst. It carries no OP Stack fields, so go-ethereum code reading it applies Ethereum rules: it is fit for the genesis state root and header encoding, not for executing OP Stack blocks or computing OP Stack fees.

func (*ChainConfig) IsBedrock

func (c *ChainConfig) IsBedrock(num *big.Int) bool

IsBedrock returns whether num is at or after the Bedrock fork block.

func (*ChainConfig) IsCanyon

func (c *ChainConfig) IsCanyon(time uint64) bool

IsCanyon returns whether the Canyon fork is active at the given timestamp.

func (*ChainConfig) IsEcotone

func (c *ChainConfig) IsEcotone(time uint64) bool

IsEcotone returns whether the Ecotone fork is active at the given timestamp.

func (*ChainConfig) IsFjord

func (c *ChainConfig) IsFjord(time uint64) bool

IsFjord returns whether the Fjord fork is active at the given timestamp.

func (*ChainConfig) IsForkActive

func (c *ChainConfig) IsForkActive(fork forks.Name, timestamp uint64) bool

IsForkActive returns whether the given timestamp-based fork is active at or after the given timestamp.

func (*ChainConfig) IsGranite

func (c *ChainConfig) IsGranite(time uint64) bool

IsGranite returns whether the Granite fork is active at the given timestamp.

func (*ChainConfig) IsHolocene

func (c *ChainConfig) IsHolocene(time uint64) bool

IsHolocene returns whether the Holocene fork is active at the given timestamp.

func (*ChainConfig) IsIsthmus

func (c *ChainConfig) IsIsthmus(time uint64) bool

IsIsthmus returns whether the Isthmus fork is active at the given timestamp.

func (*ChainConfig) IsJovian

func (c *ChainConfig) IsJovian(time uint64) bool

IsJovian returns whether the Jovian fork is active at the given timestamp.

func (*ChainConfig) IsKarst

func (c *ChainConfig) IsKarst(time uint64) bool

IsKarst returns whether the Karst fork is active at the given timestamp.

func (*ChainConfig) IsLagoon

func (c *ChainConfig) IsLagoon(time uint64) bool

IsLagoon returns whether the Lagoon fork is active at the given timestamp.

func (*ChainConfig) IsRegolith

func (c *ChainConfig) IsRegolith(time uint64) bool

IsRegolith returns whether the Regolith fork is active at the given timestamp.

func (ChainConfig) MarshalJSON added in v1.19.10

func (c ChainConfig) MarshalJSON() ([]byte, error)

MarshalJSON encodes c as a go-ethereum chain config: the Ethereum fork schedule that GethChainConfig derives from c, followed by c's own fields. Ethereum keys are encoded in go-ethereum's declaration order.

func (*ChainConfig) SetActivationTime

func (c *ChainConfig) SetActivationTime(fork forks.Name, timestamp *uint64)

SetActivationTime sets the activation timestamp of the given timestamp-based OP-Stack fork. It is the setter counterpart to ActivationTime; the two switches are the only places that map a fork to its field.

func (*ChainConfig) UnmarshalJSON added in v1.19.10

func (c *ChainConfig) UnmarshalJSON(input []byte) error

UnmarshalJSON decodes a go-ethereum chain config that carries the OP Stack fields. Only the OP Stack fields are kept: the Ethereum fork schedule is derived from them (see GethChainConfig). An Ethereum fork key that contradicts the derivation is rejected, because go-ethereum would build a different chain from the input than from the decoded config; absent and unknown keys are accepted.

type OptimismConfig

type OptimismConfig struct {
	EIP1559Elasticity        uint64  `json:"eip1559Elasticity"`
	EIP1559Denominator       uint64  `json:"eip1559Denominator"`
	EIP1559DenominatorCanyon *uint64 `json:"eip1559DenominatorCanyon,omitempty"`
}

OptimismConfig holds the OP-Stack-specific EIP-1559 parameters of a chain.

The JSON field names mirror op-geth's params.OptimismConfig verbatim: the value is carried as rollup.Config.ChainOpConfig, which is serialised on the wire, so the encoding must stay byte-for-byte identical.

Unlike other op-core types, OptimismConfig keeps its Optimism prefix: it is the type of the ChainConfig.Optimism field, and the type name pairs with the field.

func (*OptimismConfig) String

func (o *OptimismConfig) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

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