Documentation
¶
Overview ¶
Package params holds the OP-Stack-specific chain configuration types. Consumers import it as opparams.
Index ¶
- Constants
- type ChainConfig
- func (c *ChainConfig) ActivationTime(fork forks.Name) *uint64
- func (c *ChainConfig) GethChainConfig() *gethparams.ChainConfig
- func (c *ChainConfig) IsBedrock(num *big.Int) bool
- func (c *ChainConfig) IsCanyon(time uint64) bool
- func (c *ChainConfig) IsEcotone(time uint64) bool
- func (c *ChainConfig) IsFjord(time uint64) bool
- func (c *ChainConfig) IsForkActive(fork forks.Name, timestamp uint64) bool
- func (c *ChainConfig) IsGranite(time uint64) bool
- func (c *ChainConfig) IsHolocene(time uint64) bool
- func (c *ChainConfig) IsIsthmus(time uint64) bool
- func (c *ChainConfig) IsJovian(time uint64) bool
- func (c *ChainConfig) IsKarst(time uint64) bool
- func (c *ChainConfig) IsLagoon(time uint64) bool
- func (c *ChainConfig) IsRegolith(time uint64) bool
- func (c *ChainConfig) SetActivationTime(fork forks.Name, timestamp *uint64)
- type OptimismConfig
Constants ¶
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"`
Optimism *OptimismConfig `json:"optimism,omitempty"`
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)
}
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 — to drive an EVM, genesis, or block processor — converts via GethChainConfig.
func FromSuperchainConfig ¶
func FromSuperchainConfig(chConfig *superchain.ChainConfig) *ChainConfig
FromSuperchainConfig builds an OP-Stack ChainConfig from a superchain registry chain config. It replaces op-geth's params.LoadOPStackChainConfig.
func LoadChainConfigFromChainID ¶
func LoadChainConfigFromChainID(chainID uint64) (*ChainConfig, error)
LoadChainConfigFromChainID loads the OP-Stack ChainConfig for the given L2 chain ID from the embedded superchain registry.
This by-chain-ID convenience lives here, rather than in op-core/superchain, so that op-core/superchain stays a pure registry leaf: op-core/params imports op-core/superchain (one-way), which keeps the two packages free of an import cycle.
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 equivalent go-ethereum params.ChainConfig. It exists for code that drives a go-ethereum EVM, genesis, or block processor and therefore needs the concrete go-ethereum type. The Ethereum fork schedule is derived from the OP fork schedule: Shanghai activates with Canyon, Cancun with Ecotone, Prague with Isthmus, Osaka with Karst.
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) 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.
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.