Documentation
¶
Index ¶
- Variables
- func IsForkTransition(fork *uint64, parent *uint64, current uint64) bool
- type ChainConfig
- func (c *ChainConfig) AllowedFeeRecipients() bool
- func (c *ChainConfig) CheckConfigCompatible(newConfig *ethparams.ChainConfig, headNumber *big.Int, headTimestamp uint64) *ethparams.ConfigCompatError
- func (c *ChainConfig) CheckConfigForkOrder() error
- func (c *ChainConfig) Description() string
- func (c *ChainConfig) EnabledStatefulPrecompiles(blockTimestamp uint64) Precompiles
- func (c *ChainConfig) GetActivatingPrecompileConfigs(address common.Address, from *uint64, to uint64, upgrades []PrecompileUpgrade) []precompileconfig.Config
- func (c *ChainConfig) GetActivatingStateUpgrades(from *uint64, to uint64, upgrades []StateUpgrade) []StateUpgrade
- func (c *ChainConfig) GetActivePrecompileConfig(address common.Address, timestamp uint64) precompileconfig.Config
- func (c *ChainConfig) GetFeeConfig() commontype.FeeConfig
- func (c *ChainConfig) GetPrecompileAddress(configKey string) common.Address
- func (c *ChainConfig) IsPrecompileEnabled(address common.Address, timestamp uint64) bool
- func (c *ChainConfig) MarshalJSON() ([]byte, error)
- func (c *ChainConfig) SetAllGenesisPrecompiles()
- func (c *ChainConfig) UnmarshalJSON(data []byte) error
- func (c *ChainConfig) Verify() error
- type LuxContext
- type LuxRules
- type NetworkUpgrades
- func (n *NetworkUpgrades) Description() string
- func (n *NetworkUpgrades) Equal(other *NetworkUpgrades) bool
- func (n *NetworkUpgrades) GetLuxRules(time uint64) LuxRules
- func (n NetworkUpgrades) IsDurango(time uint64) bool
- func (n NetworkUpgrades) IsEVM(time uint64) bool
- func (n NetworkUpgrades) IsEtna(time uint64) bool
- func (n *NetworkUpgrades) IsFortuna(time uint64) bool
- func (n *NetworkUpgrades) IsGranite(time uint64) bool
- func (n *NetworkUpgrades) Override(o *NetworkUpgrades)
- func (n *NetworkUpgrades) SetDefaults(agoUpgrades upgrade.Config)
- type PrecompileUpgrade
- type Precompiles
- type Rules
- type StateUpgrade
- type StateUpgradeAccount
- type UpgradeConfig
Constants ¶
This section is empty.
Variables ¶
var ( // TODO: UnscheduledActivationTime seems to be removed from upgrade package UnscheduledActivationTime = time.Unix(1<<63-1, 0) // Max time value InitiallyActiveTime = time.Unix(0, 0) // Unix epoch // LegacyWarpAddress is the historical warp precompile address used in C-Chain // and legacy Subnet-EVM chains. New chains should use the LP-aligned address (0x16201). LegacyWarpAddress = common.HexToAddress("0x0200000000000000000000000000000000000005") DefaultFeeConfig = commontype.FeeConfig{ GasLimit: big.NewInt(8_000_000), TargetBlockRate: 2, MinBaseFee: big.NewInt(25_000_000_000), TargetGas: big.NewInt(15_000_000), BaseFeeChangeDenominator: big.NewInt(36), MinBlockGasCost: big.NewInt(0), MaxBlockGasCost: big.NewInt(1_000_000), BlockGasCostStep: big.NewInt(200_000), } // TestFeeConfig uses minimal fees for backward compatibility with tests TestFeeConfig = commontype.FeeConfig{ GasLimit: big.NewInt(8_000_000), TargetBlockRate: 2, MinBaseFee: big.NewInt(1), TargetGas: big.NewInt(15_000_000), BaseFeeChangeDenominator: big.NewInt(36), MinBlockGasCost: big.NewInt(0), MaxBlockGasCost: big.NewInt(1_000_000), BlockGasCostStep: big.NewInt(200_000), } EVMDefaultChainConfig = &ChainConfig{ FeeConfig: DefaultFeeConfig, NetworkUpgrades: GetDefaultNetworkUpgrades(), GenesisPrecompiles: Precompiles{}, } TestChainConfig = &ChainConfig{ FeeConfig: TestFeeConfig, NetworkUpgrades: GetDefaultNetworkUpgrades(), GenesisPrecompiles: Precompiles{}, } TestPreEVMChainConfig = copyAndSet(TestChainConfig, func(c *ChainConfig) { c.NetworkUpgrades = NetworkUpgrades{ EVMTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime), DurangoTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime), EtnaTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime), FortunaTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime), } }) TestEVMChainConfig = copyAndSet(TestChainConfig, func(c *ChainConfig) { c.NetworkUpgrades = NetworkUpgrades{ EVMTimestamp: utils.NewUint64(0), DurangoTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime), EtnaTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime), FortunaTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime), } }) TestDurangoChainConfig = copyAndSet(TestChainConfig, func(c *ChainConfig) { c.NetworkUpgrades = NetworkUpgrades{ EVMTimestamp: utils.NewUint64(0), DurangoTimestamp: utils.TimeToNewUint64(InitiallyActiveTime), EtnaTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime), FortunaTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime), } }) TestEtnaChainConfig = copyAndSet(TestChainConfig, func(c *ChainConfig) { c.NetworkUpgrades = NetworkUpgrades{ EVMTimestamp: utils.NewUint64(0), DurangoTimestamp: utils.TimeToNewUint64(InitiallyActiveTime), EtnaTimestamp: utils.TimeToNewUint64(InitiallyActiveTime), FortunaTimestamp: utils.TimeToNewUint64(UnscheduledActivationTime), } }) TestFortunaChainConfig = copyAndSet(TestChainConfig, func(c *ChainConfig) { c.NetworkUpgrades = NetworkUpgrades{ EVMTimestamp: utils.NewUint64(0), DurangoTimestamp: utils.TimeToNewUint64(InitiallyActiveTime), EtnaTimestamp: utils.TimeToNewUint64(InitiallyActiveTime), FortunaTimestamp: utils.TimeToNewUint64(InitiallyActiveTime), } }) TestGraniteChainConfig = copyAndSet(TestChainConfig, func(c *ChainConfig) { c.NetworkUpgrades = NetworkUpgrades{ EVMTimestamp: utils.NewUint64(0), DurangoTimestamp: utils.TimeToNewUint64(InitiallyActiveTime), EtnaTimestamp: utils.TimeToNewUint64(InitiallyActiveTime), FortunaTimestamp: utils.TimeToNewUint64(InitiallyActiveTime), GraniteTimestamp: utils.TimeToNewUint64(InitiallyActiveTime), } }) )
Functions ¶
func IsForkTransition ¶
IsForkTransition returns true if `fork` activates during the transition from `parent` to `current`. Taking `parent` as a pointer allows for us to pass nil when checking forks that activate during genesis. Note: `parent` and `current` can be either both timestamp values, or both block number values, since this function works for both block number and timestamp activated forks.
Types ¶
type ChainConfig ¶
type ChainConfig struct {
NetworkUpgrades // Config for timestamps that enable network upgrades.
LuxContext `json:"-"` // Lux specific context set during VM initialization. Not serialized.
FeeConfig commontype.FeeConfig `json:"feeConfig"` // Set the configuration for the dynamic fee algorithm
AllowFeeRecipients bool `json:"allowFeeRecipients,omitempty"` // Allows fees to be collected by block builders.
GenesisPrecompiles Precompiles `json:"-"` // Config for enabling precompiles from genesis. JSON encode/decode will be handled by the custom marshaler/unmarshaler.
UpgradeConfig `json:"-"` // Config specified in upgradeBytes (lux network upgrades or enable/disabling precompiles). Not serialized.
// AddressBook provides per-chain address overrides for precompile addresses.
// This allows historical chains (e.g., C-Chain) to use legacy addresses
// (like 0x0200...0005 for warp) while new chains use LP-aligned addresses.
// Resolution order: AddressBook[configKey] -> module.Address (compiled-in default)
AddressBook map[string]common.Address `json:"addressBook,omitempty"`
}
func (*ChainConfig) AllowedFeeRecipients ¶
func (c *ChainConfig) AllowedFeeRecipients() bool
AllowedFeeRecipients returns the original AllowedFeeRecipients parameter contained in the genesis ChainConfig. Implements precompile.ChainConfig interface.
func (*ChainConfig) CheckConfigCompatible ¶
func (c *ChainConfig) CheckConfigCompatible(newConfig *ethparams.ChainConfig, headNumber *big.Int, headTimestamp uint64) *ethparams.ConfigCompatError
func (*ChainConfig) CheckConfigForkOrder ¶
func (c *ChainConfig) CheckConfigForkOrder() error
func (*ChainConfig) Description ¶
func (c *ChainConfig) Description() string
func (*ChainConfig) EnabledStatefulPrecompiles ¶
func (c *ChainConfig) EnabledStatefulPrecompiles(blockTimestamp uint64) Precompiles
EnabledStatefulPrecompiles returns current stateful precompile configs that are enabled at [blockTimestamp].
func (*ChainConfig) GetActivatingPrecompileConfigs ¶
func (c *ChainConfig) GetActivatingPrecompileConfigs(address common.Address, from *uint64, to uint64, upgrades []PrecompileUpgrade) []precompileconfig.Config
GetActivatingPrecompileConfigs returns all precompile upgrades configured to activate during the state transition from a block with timestamp [from] to a block with timestamp [to].
func (*ChainConfig) GetActivatingStateUpgrades ¶
func (c *ChainConfig) GetActivatingStateUpgrades(from *uint64, to uint64, upgrades []StateUpgrade) []StateUpgrade
GetActivatingStateUpgrades returns all state upgrades configured to activate during the state transition from a block with timestamp [from] to a block with timestamp [to].
func (*ChainConfig) GetActivePrecompileConfig ¶
func (c *ChainConfig) GetActivePrecompileConfig(address common.Address, timestamp uint64) precompileconfig.Config
GetActivePrecompileConfig returns the most recent precompile config corresponding to [address]. If none have occurred, returns nil.
func (*ChainConfig) GetFeeConfig ¶
func (c *ChainConfig) GetFeeConfig() commontype.FeeConfig
GetFeeConfig returns the original FeeConfig contained in the genesis ChainConfig. Implements precompile.ChainConfig interface.
func (*ChainConfig) GetPrecompileAddress ¶ added in v0.8.33
func (c *ChainConfig) GetPrecompileAddress(configKey string) common.Address
GetPrecompileAddress returns the address for a precompile given its config key. Resolution order:
- AddressBook[configKey] if present (per-chain override)
- Module's compiled-in Address (default)
This allows historical chains (e.g., C-Chain with warp at 0x0200...0005) to use legacy addresses while new chains use LP-aligned addresses (0x16201).
func (*ChainConfig) IsPrecompileEnabled ¶
func (c *ChainConfig) IsPrecompileEnabled(address common.Address, timestamp uint64) bool
IsPrecompileEnabled returns whether precompile with `address` is enabled at `timestamp`.
func (*ChainConfig) MarshalJSON ¶
func (c *ChainConfig) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of c. This is a custom marshaler to handle the GenesisPrecompiles field.
GenesisPrecompiles is serialized under an explicit "genesisPrecompiles" key with deterministic key ordering (sorted alphabetically) to ensure consistent hash computation across different Go versions and map iteration orders.
func (*ChainConfig) SetAllGenesisPrecompiles ¶ added in v0.8.33
func (c *ChainConfig) SetAllGenesisPrecompiles()
SetAllGenesisPrecompiles populates GenesisPrecompiles with default configs for all registered precompile modules (timestamp = 0). This ensures deterministic genesis hash when "all precompiles active at genesis" is the intended state. Call this when building genesis configs for new chains.
func (*ChainConfig) UnmarshalJSON ¶
func (c *ChainConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the JSON-encoded data and stores the result in the object pointed to by c. This is a custom unmarshaler to handle the GenesisPrecompiles field.
The genesisPrecompiles field is now stored under an explicit "genesisPrecompiles" key to ensure deterministic serialization. For backwards compatibility, we also check for inline precompile configs at the root level.
IMPORTANT: Explicit is authoritative. If "genesisPrecompiles" is missing or empty, it means NO precompiles are enabled at genesis - we do NOT fall back to defaults.
type LuxContext ¶ added in v0.7.10
LuxContext provides Lux specific context directly into the EVM.
type NetworkUpgrades ¶
type NetworkUpgrades struct {
// EVMTimestamp is a placeholder that activates Lux Upgrades prior to ApricotPhase6
EVMTimestamp *uint64 `json:"evmTimestamp,omitempty"`
// Durango activates the Shanghai Execution Spec Upgrade from Ethereum (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md#included-eips)
// and Lux Warp Messaging.
// Note: EIP-4895 is excluded since withdrawals are not relevant to the Lux C-Chain or Chains running the EVM.
DurangoTimestamp *uint64 `json:"durangoTimestamp,omitempty"`
// Placeholder for EtnaTimestamp
EtnaTimestamp *uint64 `json:"etnaTimestamp,omitempty"`
// Fortuna has no effect on EVM by itself, but is included for completeness.
FortunaTimestamp *uint64 `json:"fortunaTimestamp,omitempty"`
// Granite is a placeholder for the next upgrade.
GraniteTimestamp *uint64 `json:"graniteTimestamp,omitempty"`
}
NetworkUpgrades contains timestamps that enable network upgrades. Lux specific network upgrades are also included here. (nil = no fork, 0 = already activated)
func GetDefaultNetworkUpgrades ¶ added in v0.8.4
func GetDefaultNetworkUpgrades() NetworkUpgrades
GetDefaultNetworkUpgrades returns default network upgrades
func GetNetworkUpgrades ¶ added in v0.8.4
func GetNetworkUpgrades(agoUpgrade upgrade.Config) NetworkUpgrades
GetNetworkUpgrades returns the network upgrades for the specified luxd upgrades. Nil values are used to indicate optional upgrades. The function respects the upgrade times from the config - if an upgrade is scheduled at or after UnscheduledActivationTime, it is considered not scheduled. InitiallyActiveTime is treated as "activated at genesis (timestamp 0)".
func (*NetworkUpgrades) Description ¶
func (n *NetworkUpgrades) Description() string
func (*NetworkUpgrades) Equal ¶
func (n *NetworkUpgrades) Equal(other *NetworkUpgrades) bool
func (*NetworkUpgrades) GetLuxRules ¶ added in v0.7.10
func (n *NetworkUpgrades) GetLuxRules(time uint64) LuxRules
func (NetworkUpgrades) IsDurango ¶
func (n NetworkUpgrades) IsDurango(time uint64) bool
IsDurango returns whether time represents a block with a timestamp after the Durango upgrade time.
func (NetworkUpgrades) IsEVM ¶ added in v0.7.10
func (n NetworkUpgrades) IsEVM(time uint64) bool
IsEVM returns whether time represents a block with a timestamp after the EVM upgrade time.
func (NetworkUpgrades) IsEtna ¶
func (n NetworkUpgrades) IsEtna(time uint64) bool
IsEtna returns whether time represents a block with a timestamp after the Etna upgrade time.
func (*NetworkUpgrades) IsFortuna ¶
func (n *NetworkUpgrades) IsFortuna(time uint64) bool
IsFortuna returns whether time represents a block with a timestamp after the Fortuna upgrade time.
func (*NetworkUpgrades) IsGranite ¶
func (n *NetworkUpgrades) IsGranite(time uint64) bool
IsGranite returns whether time represents a block with a timestamp after the Granite upgrade time.
func (*NetworkUpgrades) Override ¶
func (n *NetworkUpgrades) Override(o *NetworkUpgrades)
func (*NetworkUpgrades) SetDefaults ¶
func (n *NetworkUpgrades) SetDefaults(agoUpgrades upgrade.Config)
SetDefaults sets the default values for the network upgrades. This overrides deactivating the network upgrade by providing a timestamp of nil value.
type PrecompileUpgrade ¶
type PrecompileUpgrade struct {
precompileconfig.Config
}
PrecompileUpgrade is a helper struct embedded in UpgradeConfig. It is used to unmarshal the json into the correct precompile config type based on the key. Keys are defined in each precompile module, and registered in precompile/registry/registry.go.
func (*PrecompileUpgrade) MarshalJSON ¶
func (u *PrecompileUpgrade) MarshalJSON() ([]byte, error)
MarshalJSON marshal the precompile config into json based on the precompile key. Ex: {"feeManagerConfig": {...}} where "feeManagerConfig" is the key
func (*PrecompileUpgrade) UnmarshalJSON ¶
func (u *PrecompileUpgrade) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the json into the correct precompile config type based on the key. Keys are defined in each precompile module, and registered in precompile/registry/registry.go. Ex: {"feeManagerConfig": {...}} where "feeManagerConfig" is the key
type Precompiles ¶
type Precompiles map[string]precompileconfig.Config
func AllGenesisPrecompiles ¶ added in v0.8.33
func AllGenesisPrecompiles() Precompiles
AllGenesisPrecompiles returns a new Precompiles map populated with default genesis configs for all registered precompile modules (timestamp = 0). This is the authoritative source for "all precompiles active at genesis".
func (Precompiles) MarshalJSONDeterministic ¶ added in v0.8.33
func (ccp Precompiles) MarshalJSONDeterministic() ([]byte, error)
MarshalJSONDeterministic returns the JSON encoding of the Precompiles map with keys sorted alphabetically to ensure deterministic output. This is critical for genesis hash consistency across builds.
func (*Precompiles) UnmarshalJSON ¶
func (ccp *Precompiles) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the JSON-encoded data into the ChainConfigPrecompiles. ChainConfigPrecompiles is a map of precompile module keys to their configuration.
type Rules ¶
type Rules struct {
// Rules for Lux releases
LuxRules
// Precompiles maps addresses to stateful precompiled contracts that are enabled
// for this rule set.
// Note: none of these addresses should conflict with the address space used by
// any existing precompiles.
Precompiles map[common.Address]precompileconfig.Config
// Predicaters maps addresses to stateful precompile Predicaters
// that are enabled for this rule set.
Predicaters map[common.Address]precompileconfig.Predicater
// AccepterPrecompiles map addresses to stateful precompile accepter functions
// that are enabled for this rule set.
AccepterPrecompiles map[common.Address]precompileconfig.Accepter
}
func (*Rules) IsPrecompileEnabled ¶
IsPrecompileEnabled returns true if the precompile at `addr` is enabled for this rule set.
func (*Rules) PredicatersExist ¶
type StateUpgrade ¶
type StateUpgrade struct {
BlockTimestamp *uint64 `json:"blockTimestamp,omitempty"`
// map from account address to the modification to be made to the account.
StateUpgradeAccounts map[common.Address]StateUpgradeAccount `json:"accounts"`
}
StateUpgrade describes the modifications to be made to the state during a state upgrade.
func (*StateUpgrade) Equal ¶
func (s *StateUpgrade) Equal(other *StateUpgrade) bool
type StateUpgradeAccount ¶
type StateUpgradeAccount struct {
Code hexutil.Bytes `json:"code,omitempty"`
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
BalanceChange *math.HexOrDecimal256 `json:"balanceChange,omitempty"`
}
StateUpgradeAccount describes the modifications to be made to an account during a state upgrade.
type UpgradeConfig ¶
type UpgradeConfig struct {
// Config for timestamps that enable network upgrades.
NetworkUpgradeOverrides *NetworkUpgrades `json:"networkUpgradeOverrides,omitempty"`
// Config for modifying state as a network upgrade.
StateUpgrades []StateUpgrade `json:"stateUpgrades,omitempty"`
// Config for enabling and disabling precompiles as network upgrades.
PrecompileUpgrades []PrecompileUpgrade `json:"precompileUpgrades,omitempty"`
}
UpgradeConfig includes the following configs that may be specified in upgradeBytes: - Timestamps that enable lux network upgrades, - Enabling or disabling precompiles as network upgrades.