Documentation
¶
Index ¶
- Variables
- func IsForkTransition(fork *uint64, parent *uint64, current uint64) bool
- func IsUpgradeActive(id UpgradeID, height uint64) bool
- type ChainConfig
- func (c *ChainConfig) AllowedFeeRecipients() bool
- func (c *ChainConfig) AsGeth() *gethparams.ChainConfig
- func (c *ChainConfig) CheckConfigCompatible(newConfig *ChainConfig, headNumber *big.Int, headTimestamp uint64) *gethparams.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) GetRules(time uint64) GenesisRules
- func (c *ChainConfig) IsDurango(time uint64) bool
- func (c *ChainConfig) IsEVM(time uint64) bool
- func (c *ChainConfig) IsFortuna(time uint64) bool
- func (c *ChainConfig) IsPrecompileEnabled(address common.Address, timestamp uint64) bool
- func (c *ChainConfig) MarshalJSON() ([]byte, error)
- func (c *ChainConfig) UnmarshalJSON(data []byte) error
- func (c *ChainConfig) Verify() error
- type GenesisRules
- type LuxContext
- type NetworkUpgrades
- func (n *NetworkUpgrades) Description() string
- func (n *NetworkUpgrades) Equal(other *NetworkUpgrades) bool
- func (n *NetworkUpgrades) GetGenesisRules(time uint64) GenesisRules
- func (NetworkUpgrades) IsEtna(_ uint64) bool
- func (NetworkUpgrades) IsGenesis(_ 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
- type UpgradeID
Constants ¶
This section is empty.
Variables ¶
var ( 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), } EVMDefaultChainConfig = &ChainConfig{ ChainConfig: &gethparams.ChainConfig{}, FeeConfig: DefaultFeeConfig, NetworkUpgrades: getDefaultNetworkUpgrades(upgrade.GetConfig(constants.MainnetID)), GenesisPrecompiles: Precompiles{}, } TestChainConfig = &ChainConfig{ LuxContext: LuxContext{ConsensusCtx: utils.TestConsensusContext()}, FeeConfig: DefaultFeeConfig, NetworkUpgrades: getDefaultNetworkUpgrades(upgrade.GetConfig(constants.UnitTestID)), GenesisPrecompiles: Precompiles{}, } // All test configs now start with all current upgrades enabled // Only future upgrades (Fortuna, Granite) remain unscheduled TestAllEnabledChainConfig = TestChainConfig // All current upgrades enabled by default )
var FutureUpgrades = map[UpgradeID]uint64{}
FutureUpgrades holds activation heights (or timestamps).
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.
func IsUpgradeActive ¶ added in v0.8.0
IsUpgradeActive reports whether we've hit the activation block.
Types ¶
type ChainConfig ¶
type ChainConfig struct {
*gethparams.ChainConfig // Embedded go-ethereum ChainConfig
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.
}
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) AsGeth ¶ added in v0.8.0
func (c *ChainConfig) AsGeth() *gethparams.ChainConfig
AsGeth returns the embedded *params.ChainConfig
func (*ChainConfig) CheckConfigCompatible ¶
func (c *ChainConfig) CheckConfigCompatible(newConfig *ChainConfig, headNumber *big.Int, headTimestamp uint64) *gethparams.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) GetRules ¶ added in v0.8.1
func (c *ChainConfig) GetRules(time uint64) GenesisRules
GetRules returns the rules for the given timestamp. For v2.0.0, all upgrades are always active.
func (*ChainConfig) IsDurango ¶ added in v0.8.1
func (c *ChainConfig) IsDurango(time uint64) bool
IsDurango returns whether time represents a block with a timestamp after the Durango upgrade time. For v2.0.0, all upgrades are active at genesis, so this always returns true. Implements precompileconfig.ChainConfig interface.
func (*ChainConfig) IsEVM ¶ added in v0.8.1
func (c *ChainConfig) IsEVM(time uint64) bool
IsEVM returns whether time represents a block with a timestamp after the EVM upgrade time. For v2.0.0, all upgrades are active at genesis, so this always returns true.
func (*ChainConfig) IsFortuna ¶ added in v0.8.1
func (c *ChainConfig) IsFortuna(time uint64) bool
IsFortuna returns whether time represents a block with a timestamp after the Fortuna upgrade time. For v2.0.0, all upgrades are active at genesis, so this always returns true.
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 Precompiles field.
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 Precompiles field. Precompiles was presented as an inline object in the JSON. This custom unmarshaler ensures backwards compatibility with the old format.
type GenesisRules ¶ added in v0.8.1
type GenesisRules struct {
// All upgrades are active at genesis for v2.0.0
IsGenesis bool
}
GenesisRules contains the rules for genesis
type LuxContext ¶ added in v0.7.10
LuxContext provides Lux specific context directly into the EVM.
type NetworkUpgrades ¶
type NetworkUpgrades struct {
// GenesisTimestamp is when the genesis network upgrade activates.
// This includes all Ethereum Shanghai upgrades and Lux Warp Messaging.
// For a clean v2.0.0 launch, this is always set to 0 (activated at genesis).
GenesisTimestamp *uint64 `json:"genesisTimestamp,omitempty"`
}
NetworkUpgrades contains timestamps that enable network upgrades. Lux specific network upgrades are also included here. (nil = no fork, 0 = already activated)
func (*NetworkUpgrades) Description ¶
func (n *NetworkUpgrades) Description() string
func (*NetworkUpgrades) Equal ¶
func (n *NetworkUpgrades) Equal(other *NetworkUpgrades) bool
func (*NetworkUpgrades) GetGenesisRules ¶ added in v0.8.1
func (n *NetworkUpgrades) GetGenesisRules(time uint64) GenesisRules
func (NetworkUpgrades) IsEtna ¶
func (NetworkUpgrades) IsEtna(_ uint64) bool
IsEtna returns whether time represents a block with a timestamp after the Etna upgrade time. All past upgrades are always enabled in Lux.
func (NetworkUpgrades) IsGenesis ¶ added in v0.8.1
func (NetworkUpgrades) IsGenesis(_ uint64) bool
IsGenesis returns whether time represents a block with a timestamp after the genesis upgrade time. For v2.0.0, this is always true since genesis is at timestamp 0.
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. For v2.0.0, genesis upgrade is always activated at timestamp 0.
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 (*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 {
// All historic upgrades activated at Lux Genesis
GenesisRules
// 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 interfaces.
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.