extras

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: GPL-3.0, LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TestChainConfig = &ChainConfig{
		NetworkUpgrades: NetworkUpgrades{
			ApricotPhase1BlockTimestamp:     utils.NewUint64(0),
			ApricotPhase2BlockTimestamp:     utils.NewUint64(0),
			ApricotPhase3BlockTimestamp:     utils.NewUint64(0),
			ApricotPhase4BlockTimestamp:     utils.NewUint64(0),
			ApricotPhase5BlockTimestamp:     utils.NewUint64(0),
			ApricotPhasePre6BlockTimestamp:  utils.NewUint64(0),
			ApricotPhase6BlockTimestamp:     utils.NewUint64(0),
			ApricotPhasePost6BlockTimestamp: utils.NewUint64(0),
			BanffBlockTimestamp:             utils.NewUint64(0),
			CortinaBlockTimestamp:           utils.NewUint64(0),
			DurangoBlockTimestamp:           utils.NewUint64(0),
			EtnaTimestamp:                   utils.NewUint64(0),
			FortunaTimestamp:                utils.NewUint64(0),
			GraniteTimestamp:                utils.NewUint64(0),
		},
	}

	TestLaunchConfig = &ChainConfig{}

	TestApricotPhase1Config = copyAndSet(TestLaunchConfig, func(c *ChainConfig) {
		c.NetworkUpgrades.ApricotPhase1BlockTimestamp = utils.NewUint64(0)
	})

	TestApricotPhase2Config = copyAndSet(TestApricotPhase1Config, func(c *ChainConfig) {
		c.NetworkUpgrades.ApricotPhase2BlockTimestamp = utils.NewUint64(0)
	})

	TestApricotPhase3Config = copyAndSet(TestApricotPhase2Config, func(c *ChainConfig) {
		c.NetworkUpgrades.ApricotPhase3BlockTimestamp = utils.NewUint64(0)
	})

	TestApricotPhase4Config = copyAndSet(TestApricotPhase3Config, func(c *ChainConfig) {
		c.NetworkUpgrades.ApricotPhase4BlockTimestamp = utils.NewUint64(0)
	})

	TestApricotPhase5Config = copyAndSet(TestApricotPhase4Config, func(c *ChainConfig) {
		c.NetworkUpgrades.ApricotPhase5BlockTimestamp = utils.NewUint64(0)
	})

	TestApricotPhasePre6Config = copyAndSet(TestApricotPhase5Config, func(c *ChainConfig) {
		c.NetworkUpgrades.ApricotPhasePre6BlockTimestamp = utils.NewUint64(0)
	})

	TestApricotPhase6Config = copyAndSet(TestApricotPhasePre6Config, func(c *ChainConfig) {
		c.NetworkUpgrades.ApricotPhase6BlockTimestamp = utils.NewUint64(0)
	})

	TestApricotPhasePost6Config = copyAndSet(TestApricotPhase6Config, func(c *ChainConfig) {
		c.NetworkUpgrades.ApricotPhasePost6BlockTimestamp = utils.NewUint64(0)
	})

	TestBanffChainConfig = copyAndSet(TestApricotPhasePost6Config, func(c *ChainConfig) {
		c.NetworkUpgrades.BanffBlockTimestamp = utils.NewUint64(0)
	})

	TestCortinaChainConfig = copyAndSet(TestBanffChainConfig, func(c *ChainConfig) {
		c.NetworkUpgrades.CortinaBlockTimestamp = utils.NewUint64(0)
	})

	TestDurangoChainConfig = copyAndSet(TestCortinaChainConfig, func(c *ChainConfig) {
		c.NetworkUpgrades.DurangoBlockTimestamp = utils.NewUint64(0)
	})

	TestEtnaChainConfig = copyAndSet(TestDurangoChainConfig, func(c *ChainConfig) {
		c.NetworkUpgrades.EtnaTimestamp = utils.NewUint64(0)
	})

	TestFortunaChainConfig = copyAndSet(TestEtnaChainConfig, func(c *ChainConfig) {
		c.NetworkUpgrades.FortunaTimestamp = utils.NewUint64(0)
	})

	TestGraniteChainConfig = copyAndSet(TestFortunaChainConfig, func(c *ChainConfig) {
		c.NetworkUpgrades.GraniteTimestamp = utils.NewUint64(0)
	})
)

Functions

func IsForkTransition

func IsForkTransition(fork *uint64, parent *uint64, current uint64) bool

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 AvalancheContext

type AvalancheContext struct {
	SnowCtx *snow.Context
}

AvalancheContext provides Avalanche specific context directly into the EVM.

type AvalancheRules

type AvalancheRules struct {
	IsApricotPhase1, IsApricotPhase2, IsApricotPhase3, IsApricotPhase4, IsApricotPhase5 bool
	IsApricotPhasePre6, IsApricotPhase6, IsApricotPhasePost6                            bool
	IsBanff                                                                             bool
	IsCortina                                                                           bool
	IsDurango                                                                           bool
	IsEtna                                                                              bool
	IsFortuna                                                                           bool
	IsGranite                                                                           bool
}

type ChainConfig

type ChainConfig struct {
	NetworkUpgrades // Config for timestamps that enable network upgrades.

	AvalancheContext `json:"-"` // Avalanche specific context set during VM initialization. Not serialized.

	UpgradeConfig `json:"-"` // Config specified in upgradeBytes (avalanche network upgrades or enable/disabling precompiles). Not serialized.
}

func (*ChainConfig) CheckConfigCompatible

func (c *ChainConfig) CheckConfigCompatible(newcfg_ *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) 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) 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.

func (*ChainConfig) Verify

func (c *ChainConfig) Verify() error

Verify verifies chain config.

type NetworkUpgrades

type NetworkUpgrades struct {
	ApricotPhase1BlockTimestamp *uint64 `json:"apricotPhase1BlockTimestamp,omitempty"` // Apricot Phase 1 Block Timestamp
	// Apricot Phase 2 Block Timestamp includes a modified version of the Berlin
	// Hard Fork.
	ApricotPhase2BlockTimestamp *uint64 `json:"apricotPhase2BlockTimestamp,omitempty"`
	// Apricot Phase 3 introduces dynamic fees and a modified version of the
	// London Hard Fork.
	ApricotPhase3BlockTimestamp *uint64 `json:"apricotPhase3BlockTimestamp,omitempty"`
	// Apricot Phase 4 introduces the notion of a block fee to the dynamic fee
	// algorithm.
	ApricotPhase4BlockTimestamp *uint64 `json:"apricotPhase4BlockTimestamp,omitempty"`
	// Apricot Phase 5 introduces a batch of atomic transactions with a maximum
	// atomic gas limit per block.
	ApricotPhase5BlockTimestamp *uint64 `json:"apricotPhase5BlockTimestamp,omitempty"`
	// Apricot Phase Pre-6 deprecates the NativeAssetCall precompile (soft).
	ApricotPhasePre6BlockTimestamp *uint64 `json:"apricotPhasePre6BlockTimestamp,omitempty"`
	// Apricot Phase 6 deprecates the NativeAssetBalance and NativeAssetCall
	// precompiles.
	ApricotPhase6BlockTimestamp *uint64 `json:"apricotPhase6BlockTimestamp,omitempty"`
	// Apricot Phase Post-6 deprecates the NativeAssetCall precompile (soft).
	ApricotPhasePost6BlockTimestamp *uint64 `json:"apricotPhasePost6BlockTimestamp,omitempty"`
	// Banff restricts import/export transactions to AVAX.
	BanffBlockTimestamp *uint64 `json:"banffBlockTimestamp,omitempty"`
	// Cortina increases the block gas limit to 15M.
	CortinaBlockTimestamp *uint64 `json:"cortinaBlockTimestamp,omitempty"`
	// Durango activates Avalanche Warp Messaging and the Shanghai Execution
	// Spec Upgrade (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md#included-eips).
	//
	// Note: EIP-4895 is excluded since withdrawals are not relevant to the
	// Avalanche C-Chain or Subnets running the EVM.
	DurangoBlockTimestamp *uint64 `json:"durangoBlockTimestamp,omitempty"`
	// Etna activates Cancun (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/cancun.md#included-eips)
	// and reduces the min base fee.
	// Note: EIP-4844 BlobTxs are not enabled in the mempool and blocks are not
	// allowed to contain them. For details see https://github.com/avalanche-foundation/ACPs/pull/131
	EtnaTimestamp *uint64 `json:"etnaTimestamp,omitempty"`
	// Fortuna modifies the gas price mechanism based on ACP-176
	FortunaTimestamp *uint64 `json:"fortunaTimestamp,omitempty"`
	// Granite is a placeholder for the next upgrade.
	GraniteTimestamp *uint64 `json:"graniteTimestamp,omitempty"`
}

NetworkUpgrades tracks the timestamps of all the Avalanche upgrades.

For each upgrade, a nil value means the fork hasn't happened and is not scheduled. A pointer to 0 means the fork has already activated.

func GetNetworkUpgrades

func GetNetworkUpgrades(agoUpgrade upgrade.Config) NetworkUpgrades

func (NetworkUpgrades) Description

func (n NetworkUpgrades) Description() string

func (*NetworkUpgrades) Equal

func (n *NetworkUpgrades) Equal(other *NetworkUpgrades) bool

func (*NetworkUpgrades) GetAvalancheRules

func (n *NetworkUpgrades) GetAvalancheRules(timestamp uint64) AvalancheRules

func (NetworkUpgrades) IsApricotPhase1

func (n NetworkUpgrades) IsApricotPhase1(time uint64) bool

IsApricotPhase1 returns whether time represents a block with a timestamp after the Apricot Phase 1 upgrade time.

func (NetworkUpgrades) IsApricotPhase2

func (n NetworkUpgrades) IsApricotPhase2(time uint64) bool

IsApricotPhase2 returns whether time represents a block with a timestamp after the Apricot Phase 2 upgrade time.

func (*NetworkUpgrades) IsApricotPhase3

func (n *NetworkUpgrades) IsApricotPhase3(time uint64) bool

IsApricotPhase3 returns whether time represents a block with a timestamp after the Apricot Phase 3 upgrade time.

func (NetworkUpgrades) IsApricotPhase4

func (n NetworkUpgrades) IsApricotPhase4(time uint64) bool

IsApricotPhase4 returns whether time represents a block with a timestamp after the Apricot Phase 4 upgrade time.

func (NetworkUpgrades) IsApricotPhase5

func (n NetworkUpgrades) IsApricotPhase5(time uint64) bool

IsApricotPhase5 returns whether time represents a block with a timestamp after the Apricot Phase 5 upgrade time.

func (NetworkUpgrades) IsApricotPhase6

func (n NetworkUpgrades) IsApricotPhase6(time uint64) bool

IsApricotPhase6 returns whether time represents a block with a timestamp after the Apricot Phase 6 upgrade time.

func (NetworkUpgrades) IsApricotPhasePost6

func (n NetworkUpgrades) IsApricotPhasePost6(time uint64) bool

IsApricotPhasePost6 returns whether time represents a block with a timestamp after the Apricot Phase 6 Post upgrade time.

func (NetworkUpgrades) IsApricotPhasePre6

func (n NetworkUpgrades) IsApricotPhasePre6(time uint64) bool

IsApricotPhasePre6 returns whether time represents a block with a timestamp after the Apricot Phase Pre 6 upgrade time.

func (NetworkUpgrades) IsBanff

func (n NetworkUpgrades) IsBanff(time uint64) bool

IsBanff returns whether time represents a block with a timestamp after the Banff upgrade time.

func (NetworkUpgrades) IsCortina

func (n NetworkUpgrades) IsCortina(time uint64) bool

IsCortina returns whether time represents a block with a timestamp after the Cortina upgrade time.

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) 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.

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 {
	// Rules for Avalanche releases
	AvalancheRules

	// 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

func (r *Rules) IsPrecompileEnabled(addr common.Address) bool

IsPrecompileEnabled returns true if the precompile at `addr` is enabled for this rule set.

func (*Rules) PredicaterExists

func (r *Rules) PredicaterExists(addr common.Address) bool

func (*Rules) PredicatersExist

func (r *Rules) PredicatersExist() bool

type UpgradeConfig

type UpgradeConfig struct {
	// 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 avalanche network upgrades, - Enabling or disabling precompiles as network upgrades.

Jump to

Keyboard shortcuts

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