Documentation
¶
Index ¶
- Constants
- Variables
- func GetExtra(c *ChainConfig) *extras.ChainConfig
- func GetRulesExtra(r Rules) *extras.Rules
- func RegisterExtras()
- func SetEthUpgrades(c *ChainConfig) error
- func VersionWithCommit(gitCommit, gitDate string) string
- func WithTempRegisteredExtras(lock libevm.ExtrasLock, fn func() error) error
- type ChainConfig
- type ChainConfigWithUpgradesJSON
- type Rules
- type RulesExtra
- func (r RulesExtra) ActivePrecompiles(existing []common.Address) []common.Address
- func (RulesExtra) CanCreateContract(_ *libevm.AddressContext, gas uint64, _ libevm.StateReader) (uint64, error)
- func (RulesExtra) CanExecuteTransaction(_ common.Address, _ *common.Address, _ libevm.StateReader) error
- func (RulesExtra) MinimumGasConsumption(x uint64) uint64
- func (r RulesExtra) PrecompileOverride(addr common.Address) (libevm.PrecompiledContract, bool)
Constants ¶
const ( Wei = 1 GWei = 1e9 Ether = 1e18 )
These are the multipliers for ether denominations. Example: To get the wei value of an amount in 'gwei', use
new(big.Int).Mul(value, big.NewInt(params.GWei))
const ( // BloomBitsBlocks is the number of blocks a single bloom bit section vector // contains on the server side. BloomBitsBlocks uint64 = 4096 // BloomBitsBlocksClient is the number of blocks a single bloom bit section vector // contains on the light client side BloomBitsBlocksClient uint64 = 32768 // BloomConfirms is the number of confirmation blocks before a bloom section is // considered probably final and its rotated bits are calculated. BloomConfirms = 256 // CHTFrequency is the block frequency for creating CHTs CHTFrequency = 32768 // BloomTrieFrequency is the block frequency for creating BloomTrie on both // server/client sides. BloomTrieFrequency = 32768 // HelperTrieConfirmations is the number of confirmations before a client is expected // to have the given HelperTrie available. HelperTrieConfirmations = 2048 // HelperTrieProcessConfirmations is the number of confirmations before a HelperTrie // is generated HelperTrieProcessConfirmations = 256 // CheckpointFrequency is the block frequency for creating checkpoint CheckpointFrequency = 32768 // CheckpointProcessConfirmations is the number before a checkpoint is generated CheckpointProcessConfirmations = 256 // FullImmutabilityThreshold is the number of blocks after which a chain segment is // considered immutable (i.e. soft finality). It is used by the downloader as a // hard limit against deep ancestors, by the blockchain against deep reorgs, by // the freezer as the cutoff threshold and by clique as the snapshot trust limit. FullImmutabilityThreshold = 90000 // LightImmutabilityThreshold is the number of blocks after which a header chain // segment is considered immutable for light client(i.e. soft finality). It is used by // the downloader as a hard limit against deep ancestors, by the blockchain against deep // reorgs, by the light pruner as the pruning validity guarantee. LightImmutabilityThreshold = 30000 )
const ( // Avalanche Stateful Precompile Params // Gas price for native asset balance lookup. Based on the cost of an SLOAD operation since native // asset balances are kept in state storage. AssetBalanceApricot uint64 = 2100 // Gas price for native asset call. This gas price reflects the additional work done for the native // asset transfer itself, which is a write to state storage. The cost of creating a new account and // normal value transfer is assessed separately from this cost. AssetCallApricot uint64 = 20000 )
const ( VersionMajor = 1 // Major version component of the current release VersionMinor = 13 // Minor version component of the current release VersionPatch = 14 // Patch version component of the current release VersionMeta = "stable" // Version metadata to append to the version string )
const InvalidateDelegateUnix = 1754107200
invalidateDelegateTime is the Unix timestamp for August 2nd, 2025, midnight Eastern Time (August 2nd, 2025, 04:00 UTC)
const ( // TODO: Value to pass to geth's Rules by default where the appropriate // context is not available in the avalanche code. (similar to context.TODO()) IsMergeTODO = true )
Variables ¶
var ( // AvalancheMainnetChainID ... AvalancheMainnetChainID = big.NewInt(43114) // AvalancheFujiChainID ... AvalancheFujiChainID = big.NewInt(43113) // AvalancheLocalChainID ... AvalancheLocalChainID = big.NewInt(43112) )
Avalanche ChainIDs
var ( TestChainConfig, TestLaunchConfig, TestApricotPhase1Config, TestApricotPhase2Config, TestApricotPhase3Config, TestApricotPhase4Config, TestApricotPhase5Config, TestApricotPhasePre6Config, TestApricotPhase6Config, TestApricotPhasePost6Config, TestBanffChainConfig, TestCortinaChainConfig, TestDurangoChainConfig, TestEtnaChainConfig, TestFortunaChainConfig, TestGraniteChainConfig, TestHeliconChainConfig *ChainConfig TestRules Rules )
var P256VerifyAddress = common.BytesToAddress([]byte{0x1, 0x00})
P256VerifyAddress is the address of the p256 signature verification precompile
var PrecompiledContractsApricotPhase2 = map[common.Address]vm.PrecompiledContract{ nativeasset.GenesisContractAddr: makePrecompile(&nativeasset.DeprecatedContract{}), nativeasset.NativeAssetBalanceAddr: makePrecompile(&nativeasset.NativeAssetBalance{GasCost: AssetBalanceApricot}), nativeasset.NativeAssetCallAddr: makePrecompile(&nativeasset.NativeAssetCall{GasCost: AssetCallApricot, CallNewAccountGas: ethparams.CallNewAccountGas}), }
var PrecompiledContractsApricotPhase6 = map[common.Address]vm.PrecompiledContract{ nativeasset.GenesisContractAddr: makePrecompile(&nativeasset.DeprecatedContract{}), nativeasset.NativeAssetBalanceAddr: makePrecompile(&nativeasset.NativeAssetBalance{GasCost: AssetBalanceApricot}), nativeasset.NativeAssetCallAddr: makePrecompile(&nativeasset.NativeAssetCall{GasCost: AssetCallApricot, CallNewAccountGas: ethparams.CallNewAccountGas}), }
var PrecompiledContractsApricotPhasePre6 = map[common.Address]vm.PrecompiledContract{ nativeasset.GenesisContractAddr: makePrecompile(&nativeasset.DeprecatedContract{}), nativeasset.NativeAssetBalanceAddr: makePrecompile(&nativeasset.DeprecatedContract{}), nativeasset.NativeAssetCallAddr: makePrecompile(&nativeasset.DeprecatedContract{}), }
var PrecompiledContractsBanff = map[common.Address]vm.PrecompiledContract{ nativeasset.GenesisContractAddr: makePrecompile(&nativeasset.DeprecatedContract{}), nativeasset.NativeAssetBalanceAddr: makePrecompile(&nativeasset.DeprecatedContract{}), nativeasset.NativeAssetCallAddr: makePrecompile(&nativeasset.DeprecatedContract{}), }
var PrecompiledContractsGranite = map[common.Address]vm.PrecompiledContract{ nativeasset.GenesisContractAddr: makePrecompile(&nativeasset.DeprecatedContract{}), nativeasset.NativeAssetBalanceAddr: makePrecompile(&nativeasset.DeprecatedContract{}), nativeasset.NativeAssetCallAddr: makePrecompile(&nativeasset.DeprecatedContract{}), P256VerifyAddress: &vm.P256Verify{}, }
var Version = func() string { return fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch) }()
Version holds the textual version string.
var VersionWithMeta = func() string { v := Version if VersionMeta != "" { v += "-" + VersionMeta } return v }()
VersionWithMeta holds the textual version string including the metadata.
Functions ¶
func GetExtra ¶
func GetExtra(c *ChainConfig) *extras.ChainConfig
func GetRulesExtra ¶
func RegisterExtras ¶
func RegisterExtras()
RegisterExtras registers hooks and payloads with libevm. It MUST NOT be called more than once and therefore is only allowed to be used in tests and `package main`, to avoid polluting other packages that transitively depend on this one but don't need registration.
Without a call to RegisterExtras, much of the functionality of this package will work, and most will simply panic.
func SetEthUpgrades ¶
func SetEthUpgrades(c *ChainConfig) error
SetEthUpgrades enables Ethereum network upgrades using the same time as the Avalanche network upgrade that enables them.
func VersionWithCommit ¶
func WithTempRegisteredExtras ¶
func WithTempRegisteredExtras(lock libevm.ExtrasLock, fn func() error) error
WithTempRegisteredExtras runs `fn` with temporary registration otherwise equivalent to a call to RegisterExtras, but limited to the life of `fn`.
This function is not intended for direct use. Use `evm.WithTempRegisteredLibEVMExtras()` instead as it calls this along with all other temporary-registration functions.
Types ¶
type ChainConfig ¶
type ChainConfig = ethparams.ChainConfig
ChainConfig is the core config which determines the blockchain settings.
ChainConfig is stored in the database on a per block basis. This means that any network, identified by its genesis block, can have its own set of configuration options.
func Copy ¶
func Copy(c *ChainConfig) ChainConfig
func WithExtra ¶
func WithExtra(c *ChainConfig, extra *extras.ChainConfig) *ChainConfig
WithExtra sets the extra payload on `c` and returns the modified argument.
type ChainConfigWithUpgradesJSON ¶
type ChainConfigWithUpgradesJSON struct {
ChainConfig
UpgradeConfig extras.UpgradeConfig `json:"upgrades,omitempty"`
}
func ToWithUpgradesJSON ¶
func ToWithUpgradesJSON(c *ChainConfig) *ChainConfigWithUpgradesJSON
ToWithUpgradesJSON converts the ChainConfig to ChainConfigWithUpgradesJSON with upgrades explicitly displayed. ChainConfig does not include upgrades in its JSON output. This is a workaround for showing upgrades in the JSON output.
func (ChainConfigWithUpgradesJSON) MarshalJSON ¶
func (cu ChainConfigWithUpgradesJSON) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler. This is a workaround for the fact that the embedded ChainConfig struct has a MarshalJSON method, which prevents the default JSON marshalling from working for UpgradeConfig. TODO: consider removing this method by allowing external tag for the embedded ChainConfig struct.
func (*ChainConfigWithUpgradesJSON) UnmarshalJSON ¶
func (cu *ChainConfigWithUpgradesJSON) UnmarshalJSON(input []byte) error
type Rules ¶
Rules wraps ChainConfig and is merely syntactic sugar or can be used for functions that do not have or require information about the block.
Rules is a one time interface meaning that it shouldn't be used in between transition phases.
type RulesExtra ¶
func (RulesExtra) ActivePrecompiles ¶
func (r RulesExtra) ActivePrecompiles(existing []common.Address) []common.Address
func (RulesExtra) CanCreateContract ¶
func (RulesExtra) CanCreateContract(_ *libevm.AddressContext, gas uint64, _ libevm.StateReader) (uint64, error)
func (RulesExtra) CanExecuteTransaction ¶
func (RulesExtra) CanExecuteTransaction(_ common.Address, _ *common.Address, _ libevm.StateReader) error
func (RulesExtra) MinimumGasConsumption ¶
func (RulesExtra) MinimumGasConsumption(x uint64) uint64
MinimumGasConsumption is a no-op.
func (RulesExtra) PrecompileOverride ¶
func (r RulesExtra) PrecompileOverride(addr common.Address) (libevm.PrecompiledContract, bool)