Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateFunctionSelector(functionSignature string) []byte
- func Configure(chainConfig ChainConfig, blockContext BlockContext, ...)
- func DisableFeeRewards(stateDB StateDB)
- func EnableAllowFeeRecipients(stateDB StateDB)
- func GetFeeConfigLastChangedAt(stateDB StateDB) *big.Int
- func GetStoredFeeConfig(stateDB StateDB) commontype.FeeConfig
- func GetStoredRewardAddress(stateDB StateDB) (common.Address, bool)
- func PackAllowFeeRecipients() ([]byte, error)
- func PackAreFeeRecipientsAllowed() ([]byte, error)
- func PackAreFeeRecipientsAllowedOutput(isAllowed bool) ([]byte, error)
- func PackCurrentRewardAddress() ([]byte, error)
- func PackCurrentRewardAddressOutput(rewardAddress common.Address) ([]byte, error)
- func PackDisableRewards() ([]byte, error)
- func PackFeeConfig(feeConfig commontype.FeeConfig) ([]byte, error)
- func PackGetFeeConfigInput() []byte
- func PackGetLastChangedAtInput() []byte
- func PackMintInput(address common.Address, amount *big.Int) ([]byte, error)
- func PackModifyAllowList(address common.Address, role AllowListRole) ([]byte, error)
- func PackReadAllowList(address common.Address) []byte
- func PackSetFeeConfig(feeConfig commontype.FeeConfig) ([]byte, error)
- func PackSetRewardAddress(addr common.Address) ([]byte, error)
- func ReservedAddress(addr common.Address) bool
- func SetContractDeployerAllowListStatus(stateDB StateDB, address common.Address, role AllowListRole)
- func SetContractNativeMinterStatus(stateDB StateDB, address common.Address, role AllowListRole)
- func SetFeeConfigManagerStatus(stateDB StateDB, address common.Address, role AllowListRole)
- func SetRewardManagerAllowListStatus(stateDB StateDB, address common.Address, role AllowListRole)
- func SetTxAllowListStatus(stateDB StateDB, address common.Address, role AllowListRole)
- func StoreFeeConfig(stateDB StateDB, feeConfig commontype.FeeConfig, blockContext BlockContext) error
- func StoreRewardAddress(stateDB StateDB, val common.Address) error
- func UnpackFeeConfigInput(input []byte) (commontype.FeeConfig, error)
- func UnpackMintInput(input []byte) (common.Address, *big.Int, error)
- func UnpackSetRewardAddressInput(input []byte) (common.Address, error)
- type AddressRange
- type AllowListConfig
- type AllowListRole
- func GetContractDeployerAllowListStatus(stateDB StateDB, address common.Address) AllowListRole
- func GetContractNativeMinterStatus(stateDB StateDB, address common.Address) AllowListRole
- func GetFeeConfigManagerStatus(stateDB StateDB, address common.Address) AllowListRole
- func GetRewardManagerAllowListStatus(stateDB StateDB, address common.Address) AllowListRole
- func GetTxAllowListStatus(stateDB StateDB, address common.Address) AllowListRole
- type BlockContext
- type ChainConfig
- type ContractDeployerAllowListConfig
- func (c *ContractDeployerAllowListConfig) Address() common.Address
- func (c *ContractDeployerAllowListConfig) Configure(_ ChainConfig, state StateDB, _ BlockContext)
- func (c *ContractDeployerAllowListConfig) Contract() StatefulPrecompiledContract
- func (c *ContractDeployerAllowListConfig) Equal(s StatefulPrecompileConfig) bool
- func (c *ContractDeployerAllowListConfig) String() string
- type ContractNativeMinterConfig
- func (c *ContractNativeMinterConfig) Address() common.Address
- func (c *ContractNativeMinterConfig) Configure(_ ChainConfig, state StateDB, _ BlockContext)
- func (c *ContractNativeMinterConfig) Contract() StatefulPrecompiledContract
- func (c *ContractNativeMinterConfig) Equal(s StatefulPrecompileConfig) bool
- func (c *ContractNativeMinterConfig) String() string
- func (c *ContractNativeMinterConfig) Verify() error
- type FeeConfigManagerConfig
- func (c *FeeConfigManagerConfig) Address() common.Address
- func (c *FeeConfigManagerConfig) Configure(chainConfig ChainConfig, state StateDB, blockContext BlockContext)
- func (c *FeeConfigManagerConfig) Contract() StatefulPrecompiledContract
- func (c *FeeConfigManagerConfig) Equal(s StatefulPrecompileConfig) bool
- func (c *FeeConfigManagerConfig) String() string
- func (c *FeeConfigManagerConfig) Verify() error
- type InitialRewardConfig
- type PrecompileAccessibleState
- type RewardManagerConfig
- func (c *RewardManagerConfig) Address() common.Address
- func (c *RewardManagerConfig) Configure(chainConfig ChainConfig, state StateDB, _ BlockContext)
- func (c *RewardManagerConfig) Contract() StatefulPrecompiledContract
- func (c *RewardManagerConfig) Equal(s StatefulPrecompileConfig) bool
- func (c *RewardManagerConfig) String() string
- func (c *RewardManagerConfig) Verify() error
- type RunStatefulPrecompileFunc
- type StateDB
- type StatefulPrecompileConfig
- type StatefulPrecompiledContract
- type TxAllowListConfig
- func (c *TxAllowListConfig) Address() common.Address
- func (c *TxAllowListConfig) Configure(_ ChainConfig, state StateDB, _ BlockContext)
- func (c *TxAllowListConfig) Contract() StatefulPrecompiledContract
- func (c *TxAllowListConfig) Equal(s StatefulPrecompileConfig) bool
- func (c *TxAllowListConfig) String() string
- type UpgradeableConfig
Constants ¶
const ( SetAdminFuncKey = "setAdmin" SetEnabledFuncKey = "setEnabled" SetNoneFuncKey = "setNone" ReadAllowListFuncKey = "readAllowList" ModifyAllowListGasCost = writeGasCostPerSlot ReadAllowListGasCost = readGasCostPerSlot )
const ( SetFeeConfigGasCost = writeGasCostPerSlot * (numFeeConfigField + 1) // plus one for setting last changed at GetFeeConfigGasCost = readGasCostPerSlot * numFeeConfigField GetLastChangedAtGasCost = readGasCostPerSlot )
const ( AllowFeeRecipientsGasCost uint64 = (writeGasCostPerSlot) + ReadAllowListGasCost // write 1 slot + read allow list AreFeeRecipientsAllowedGasCost uint64 = readGasCostPerSlot CurrentRewardAddressGasCost uint64 = readGasCostPerSlot DisableRewardsGasCost uint64 = (writeGasCostPerSlot) + ReadAllowListGasCost // write 1 slot + read allow list SetRewardAddressGasCost uint64 = (writeGasCostPerSlot) + ReadAllowListGasCost // write 1 slot + read allow list // RewardManagerRawABI contains the raw ABI of RewardManager contract. RewardManagerRawABI = "" /* 1590-byte string literal not displayed */ )
const (
MintGasCost = 30_000
)
Variables ¶
var ( // No role assigned - this is equivalent to common.Hash{} and deletes the key from the DB when set AllowListNoRole = AllowListRole(common.BigToHash(common.Big0)) // Enabled - allowed to use state-changing precompile functions without modifying status of other admins or enableds AllowListEnabled = AllowListRole(common.BigToHash(common.Big1)) // Admin - allowed to modify both the admin and enabled list, as well as to use state-changing precompile functions AllowListAdmin = AllowListRole(common.BigToHash(common.Big2)) // Error returned when an invalid write is attempted ErrCannotModifyAllowList = errors.New("non-admin cannot modify allow list") )
var ( ContractDeployerAllowListAddress = common.HexToAddress("0x0200000000000000000000000000000000000000") ContractNativeMinterAddress = common.HexToAddress("0x0200000000000000000000000000000000000001") TxAllowListAddress = common.HexToAddress("0x0200000000000000000000000000000000000002") FeeConfigManagerAddress = common.HexToAddress("0x0200000000000000000000000000000000000003") RewardManagerAddress = common.HexToAddress("0x0200000000000000000000000000000000000004") UsedAddresses = []common.Address{ ContractDeployerAllowListAddress, ContractNativeMinterAddress, TxAllowListAddress, FeeConfigManagerAddress, RewardManagerAddress, } )
Designated addresses of stateful precompiles Note: it is important that none of these addresses conflict with each other or any other precompiles in core/vm/contracts.go. The first stateful precompiles were added in coreth to support nativeAssetCall and nativeAssetBalance. New stateful precompiles originating in coreth will continue at this prefix, so we reserve this range in subnet-evm so that they can be migrated into subnet-evm without issue. These start at the address: 0x0100000000000000000000000000000000000000 and will increment by 1. Optional precompiles implemented in subnet-evm start at 0x0200000000000000000000000000000000000000 and will increment by 1 from here to reduce the risk of conflicts. For forks of subnet-evm, users should start at 0x0300000000000000000000000000000000000000 to ensure that their own modifications do not conflict with stateful precompiles that may be added to subnet-evm in the future.
var ( ErrCannotAllowFeeRecipients = errors.New("non-enabled cannot call allowFeeRecipients") ErrCannotAreFeeRecipientsAllowed = errors.New("non-enabled cannot call areFeeRecipientsAllowed") ErrCannotCurrentRewardAddress = errors.New("non-enabled cannot call currentRewardAddress") ErrCannotDisableRewards = errors.New("non-enabled cannot call disableRewards") ErrCannotSetRewardAddress = errors.New("non-enabled cannot call setRewardAddress") ErrCannotEnableBothRewards = errors.New("cannot enable both fee recipients and reward address at the same time") ErrEmptyRewardAddress = errors.New("reward address cannot be empty") RewardManagerABI abi.ABI // will be initialized by init function RewardManagerPrecompile StatefulPrecompiledContract // will be initialized by init function )
Singleton StatefulPrecompiledContract and signatures.
Functions ¶
func CalculateFunctionSelector ¶
CalculateFunctionSelector returns the 4 byte function selector that results from [functionSignature] Ex. the function setBalance(addr address, balance uint256) should be passed in as the string: "setBalance(address,uint256)"
func Configure ¶
func Configure(chainConfig ChainConfig, blockContext BlockContext, precompileConfig StatefulPrecompileConfig, state StateDB)
Configure sets the nonce and code to non-empty values then calls Configure on [precompileConfig] to make the necessary state update to enable the StatefulPrecompile. Assumes that [precompileConfig] is non-nil.
func DisableFeeRewards ¶
func DisableFeeRewards(stateDB StateDB)
DisableRewardAddress disables rewards and burns them by sending to Blackhole Address.
func EnableAllowFeeRecipients ¶
func EnableAllowFeeRecipients(stateDB StateDB)
EnableAllowFeeRecipients enables fee recipients.
func GetStoredFeeConfig ¶
func GetStoredFeeConfig(stateDB StateDB) commontype.FeeConfig
GetStoredFeeConfig returns fee config from contract storage in given state
func GetStoredRewardAddress ¶
GetStoredRewardAddress returns the current value of the address stored under rewardAddressStorageKey. Returns an empty address and true if allow fee recipients is enabled, otherwise returns current reward address and false.
func PackAllowFeeRecipients ¶
PackAllowFeeRecipients packs the function selector (first 4 func signature bytes). This function is mostly used for tests.
func PackAreFeeRecipientsAllowed ¶
PackAreFeeRecipientsAllowed packs the include selector (first 4 func signature bytes). This function is mostly used for tests.
func PackAreFeeRecipientsAllowedOutput ¶
PackAreFeeRecipientsAllowedOutput attempts to pack given isAllowed of type bool to conform the ABI outputs.
func PackCurrentRewardAddress ¶
PackCurrentRewardAddress packs the include selector (first 4 func signature bytes). This function is mostly used for tests.
func PackCurrentRewardAddressOutput ¶
PackCurrentRewardAddressOutput attempts to pack given rewardAddress of type common.Address to conform the ABI outputs.
func PackDisableRewards ¶
PackDisableRewards packs the include selector (first 4 func signature bytes). This function is mostly used for tests.
func PackFeeConfig ¶
func PackFeeConfig(feeConfig commontype.FeeConfig) ([]byte, error)
PackFeeConfig packs [feeConfig] without the selector into the appropriate arguments for fee config operations.
func PackGetFeeConfigInput ¶
func PackGetFeeConfigInput() []byte
PackGetFeeConfigInput packs the getFeeConfig signature
func PackGetLastChangedAtInput ¶
func PackGetLastChangedAtInput() []byte
PackGetLastChangedAtInput packs the getFeeConfigLastChangedAt signature
func PackMintInput ¶
PackMintInput packs [address] and [amount] into the appropriate arguments for minting operation. Assumes that [amount] can be represented by 32 bytes.
func PackModifyAllowList ¶
func PackModifyAllowList(address common.Address, role AllowListRole) ([]byte, error)
PackModifyAllowList packs [address] and [role] into the appropriate arguments for modifying the allow list. Note: [role] is not packed in the input value returned, but is instead used as a selector for the function selector that should be encoded in the input.
func PackReadAllowList ¶
PackReadAllowList packs [address] into the input data to the read allow list function
func PackSetFeeConfig ¶
func PackSetFeeConfig(feeConfig commontype.FeeConfig) ([]byte, error)
PackSetFeeConfig packs [feeConfig] with the selector into the appropriate arguments for setting fee config operations.
func PackSetRewardAddress ¶
PackSetRewardAddress packs [addr] of type common.Address into the appropriate arguments for setRewardAddress. the packed bytes include selector (first 4 func signature bytes). This function is mostly used for tests.
func ReservedAddress ¶
UsedAddress returns true if [addr] is in a reserved range for custom precompiles
func SetContractDeployerAllowListStatus ¶
func SetContractDeployerAllowListStatus(stateDB StateDB, address common.Address, role AllowListRole)
SetContractDeployerAllowListStatus sets the permissions of [address] to [role] for the contract deployer allow list. assumes [role] has already been verified as valid.
func SetContractNativeMinterStatus ¶
func SetContractNativeMinterStatus(stateDB StateDB, address common.Address, role AllowListRole)
SetContractNativeMinterStatus sets the permissions of [address] to [role] for the minter list. assumes [role] has already been verified as valid.
func SetFeeConfigManagerStatus ¶
func SetFeeConfigManagerStatus(stateDB StateDB, address common.Address, role AllowListRole)
SetFeeConfigManagerStatus sets the permissions of [address] to [role] for the fee config manager list. assumes [role] has already been verified as valid.
func SetRewardManagerAllowListStatus ¶
func SetRewardManagerAllowListStatus(stateDB StateDB, address common.Address, role AllowListRole)
SetRewardManagerAllowListStatus sets the permissions of [address] to [role] for the RewardManager list. Assumes [role] has already been verified as valid.
func SetTxAllowListStatus ¶
func SetTxAllowListStatus(stateDB StateDB, address common.Address, role AllowListRole)
SetTxAllowListStatus sets the permissions of [address] to [role] for the tx allow list. assumes [role] has already been verified as valid.
func StoreFeeConfig ¶
func StoreFeeConfig(stateDB StateDB, feeConfig commontype.FeeConfig, blockContext BlockContext) error
StoreFeeConfig stores given [feeConfig] and block number in the [blockContext] to the [stateDB]. A validation on [feeConfig] is done before storing.
func StoreRewardAddress ¶
StoredRewardAddress stores the given [val] under rewardAddressStorageKey.
func UnpackFeeConfigInput ¶
func UnpackFeeConfigInput(input []byte) (commontype.FeeConfig, error)
UnpackFeeConfigInput attempts to unpack [input] into the arguments to the fee config precompile assumes that [input] does not include selector (omits first 4 bytes in PackSetFeeConfigInput)
func UnpackMintInput ¶
UnpackMintInput attempts to unpack [input] into the arguments to the mint precompile assumes that [input] does not include selector (omits first 4 bytes in PackMintInput)
Types ¶
type AddressRange ¶
AddressRange represents a continuous range of addresses
type AllowListConfig ¶
type AllowListConfig struct { AllowListAdmins []common.Address `json:"adminAddresses"` EnabledAddresses []common.Address `json:"enabledAddresses"` // initial enabled addresses }
AllowListConfig specifies the initial set of allow list admins.
func (*AllowListConfig) Configure ¶
func (c *AllowListConfig) Configure(state StateDB, precompileAddr common.Address)
Configure initializes the address space of [precompileAddr] by initializing the role of each of the addresses in [AllowListAdmins].
func (*AllowListConfig) Equal ¶
func (c *AllowListConfig) Equal(other *AllowListConfig) bool
Equal returns true iff [other] has the same admins in the same order in its allow list.
func (*AllowListConfig) Verify ¶
func (c *AllowListConfig) Verify() error
Verify returns an error if there is an overlapping address between admin and enabled roles
type AllowListRole ¶
Enum constants for valid AllowListRole
func GetContractDeployerAllowListStatus ¶
func GetContractDeployerAllowListStatus(stateDB StateDB, address common.Address) AllowListRole
GetContractDeployerAllowListStatus returns the role of [address] for the contract deployer allow list.
func GetContractNativeMinterStatus ¶
func GetContractNativeMinterStatus(stateDB StateDB, address common.Address) AllowListRole
GetContractNativeMinterStatus returns the role of [address] for the minter list.
func GetFeeConfigManagerStatus ¶
func GetFeeConfigManagerStatus(stateDB StateDB, address common.Address) AllowListRole
GetFeeConfigManagerStatus returns the role of [address] for the fee config manager list.
func GetRewardManagerAllowListStatus ¶
func GetRewardManagerAllowListStatus(stateDB StateDB, address common.Address) AllowListRole
GetRewardManagerAllowListStatus returns the role of [address] for the RewardManager list.
func GetTxAllowListStatus ¶
func GetTxAllowListStatus(stateDB StateDB, address common.Address) AllowListRole
GetTxAllowListStatus returns the role of [address] for the contract deployer allow list.
func (AllowListRole) IsAdmin ¶
func (s AllowListRole) IsAdmin() bool
IsAdmin returns true if [s] indicates the permission to modify the allow list.
func (AllowListRole) IsEnabled ¶
func (s AllowListRole) IsEnabled() bool
IsEnabled returns true if [s] indicates that it has permission to access the resource.
func (AllowListRole) IsNoRole ¶
func (s AllowListRole) IsNoRole() bool
IsNoRole returns true if [s] indicates no specific role.
func (AllowListRole) Valid ¶
func (s AllowListRole) Valid() bool
Valid returns true iff [s] represents a valid role.
type BlockContext ¶
BlockContext defines an interface that provides information to a stateful precompile about the block that activates the upgrade. The precompile can access this information to initialize its state.
type ChainConfig ¶
type ChainConfig interface { // GetFeeConfig returns the original FeeConfig that was set in the genesis. GetFeeConfig() commontype.FeeConfig // AllowedFeeRecipients returns true if fee recipients are allowed in the genesis. AllowedFeeRecipients() bool }
ChainContext defines an interface that provides information to a stateful precompile about the chain configuration. The precompile can access this information to initialize its state.
type ContractDeployerAllowListConfig ¶
type ContractDeployerAllowListConfig struct { AllowListConfig UpgradeableConfig }
ContractDeployerAllowListConfig wraps AllowListConfig and uses it to implement the StatefulPrecompileConfig interface while adding in the contract deployer specific precompile address.
func NewContractDeployerAllowListConfig ¶
func NewContractDeployerAllowListConfig(blockTimestamp *big.Int, admins []common.Address, enableds []common.Address) *ContractDeployerAllowListConfig
NewContractDeployerAllowListConfig returns a config for a network upgrade at [blockTimestamp] that enables ContractDeployerAllowList with [admins] and [enableds] as members of the allowlist.
func NewDisableContractDeployerAllowListConfig ¶
func NewDisableContractDeployerAllowListConfig(blockTimestamp *big.Int) *ContractDeployerAllowListConfig
NewDisableContractDeployerAllowListConfig returns config for a network upgrade at [blockTimestamp] that disables ContractDeployerAllowList.
func (*ContractDeployerAllowListConfig) Address ¶
func (c *ContractDeployerAllowListConfig) Address() common.Address
Address returns the address of the contract deployer allow list.
func (*ContractDeployerAllowListConfig) Configure ¶
func (c *ContractDeployerAllowListConfig) Configure(_ ChainConfig, state StateDB, _ BlockContext)
Configure configures [state] with the desired admins based on [c].
func (*ContractDeployerAllowListConfig) Contract ¶
func (c *ContractDeployerAllowListConfig) Contract() StatefulPrecompiledContract
Contract returns the singleton stateful precompiled contract to be used for the allow list.
func (*ContractDeployerAllowListConfig) Equal ¶
func (c *ContractDeployerAllowListConfig) Equal(s StatefulPrecompileConfig) bool
Equal returns true if [s] is a *ContractDeployerAllowListConfig and it has been configured identical to [c].
func (*ContractDeployerAllowListConfig) String ¶
func (c *ContractDeployerAllowListConfig) String() string
String returns a string representation of the ContractDeployerAllowListConfig.
type ContractNativeMinterConfig ¶
type ContractNativeMinterConfig struct { AllowListConfig UpgradeableConfig InitialMint map[common.Address]*math.HexOrDecimal256 `json:"initialMint,omitempty"` // initial mint config to be immediately minted }
ContractNativeMinterConfig wraps AllowListConfig and uses it to implement the StatefulPrecompileConfig interface while adding in the ContractNativeMinter specific precompile address.
func NewContractNativeMinterConfig ¶
func NewContractNativeMinterConfig(blockTimestamp *big.Int, admins []common.Address, enableds []common.Address, initialMint map[common.Address]*math.HexOrDecimal256) *ContractNativeMinterConfig
NewContractNativeMinterConfig returns a config for a network upgrade at [blockTimestamp] that enables ContractNativeMinter with the given [admins] and [enableds] as members of the allowlist. Also mints balances according to [initialMint] when the upgrade activates.
func NewDisableContractNativeMinterConfig ¶
func NewDisableContractNativeMinterConfig(blockTimestamp *big.Int) *ContractNativeMinterConfig
NewDisableContractNativeMinterConfig returns config for a network upgrade at [blockTimestamp] that disables ContractNativeMinter.
func (*ContractNativeMinterConfig) Address ¶
func (c *ContractNativeMinterConfig) Address() common.Address
Address returns the address of the native minter contract.
func (*ContractNativeMinterConfig) Configure ¶
func (c *ContractNativeMinterConfig) Configure(_ ChainConfig, state StateDB, _ BlockContext)
Configure configures [state] with the desired admins based on [c].
func (*ContractNativeMinterConfig) Contract ¶
func (c *ContractNativeMinterConfig) Contract() StatefulPrecompiledContract
Contract returns the singleton stateful precompiled contract to be used for the native minter.
func (*ContractNativeMinterConfig) Equal ¶
func (c *ContractNativeMinterConfig) Equal(s StatefulPrecompileConfig) bool
Equal returns true if [s] is a *ContractNativeMinterConfig and it has been configured identical to [c].
func (*ContractNativeMinterConfig) String ¶
func (c *ContractNativeMinterConfig) String() string
String returns a string representation of the ContractNativeMinterConfig.
func (*ContractNativeMinterConfig) Verify ¶
func (c *ContractNativeMinterConfig) Verify() error
type FeeConfigManagerConfig ¶
type FeeConfigManagerConfig struct { AllowListConfig // Config for the fee config manager allow list UpgradeableConfig InitialFeeConfig *commontype.FeeConfig `json:"initialFeeConfig,omitempty"` // initial fee config to be immediately activated }
FeeConfigManagerConfig wraps AllowListConfig and uses it to implement the StatefulPrecompileConfig interface while adding in the FeeConfigManager specific precompile address.
func NewDisableFeeManagerConfig ¶
func NewDisableFeeManagerConfig(blockTimestamp *big.Int) *FeeConfigManagerConfig
NewDisableFeeManagerConfig returns config for a network upgrade at [blockTimestamp] that disables FeeConfigManager.
func NewFeeManagerConfig ¶
func NewFeeManagerConfig(blockTimestamp *big.Int, admins []common.Address, enableds []common.Address, initialConfig *commontype.FeeConfig) *FeeConfigManagerConfig
NewFeeManagerConfig returns a config for a network upgrade at [blockTimestamp] that enables FeeConfigManager with the given [admins] and [enableds] as members of the allowlist with [initialConfig] as initial fee config if specified.
func (*FeeConfigManagerConfig) Address ¶
func (c *FeeConfigManagerConfig) Address() common.Address
Address returns the address of the fee config manager contract.
func (*FeeConfigManagerConfig) Configure ¶
func (c *FeeConfigManagerConfig) Configure(chainConfig ChainConfig, state StateDB, blockContext BlockContext)
Configure configures [state] with the desired admins based on [c].
func (*FeeConfigManagerConfig) Contract ¶
func (c *FeeConfigManagerConfig) Contract() StatefulPrecompiledContract
Contract returns the singleton stateful precompiled contract to be used for the fee manager.
func (*FeeConfigManagerConfig) Equal ¶
func (c *FeeConfigManagerConfig) Equal(s StatefulPrecompileConfig) bool
Equal returns true if [s] is a *FeeConfigManagerConfig and it has been configured identical to [c].
func (*FeeConfigManagerConfig) String ¶
func (c *FeeConfigManagerConfig) String() string
String returns a string representation of the FeeConfigManagerConfig.
func (*FeeConfigManagerConfig) Verify ¶
func (c *FeeConfigManagerConfig) Verify() error
type InitialRewardConfig ¶
type InitialRewardConfig struct { AllowFeeRecipients bool `json:"allowFeeRecipients"` RewardAddress common.Address `json:"rewardAddress,omitempty"` }
func (*InitialRewardConfig) Configure ¶
func (i *InitialRewardConfig) Configure(state StateDB)
func (*InitialRewardConfig) Equal ¶
func (c *InitialRewardConfig) Equal(other *InitialRewardConfig) bool
func (*InitialRewardConfig) Verify ¶
func (i *InitialRewardConfig) Verify() error
type PrecompileAccessibleState ¶
type PrecompileAccessibleState interface { GetStateDB() StateDB GetBlockContext() BlockContext GetSnowContext() *snow.Context CallFromPrecompile(caller common.Address, addr common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, leftOverGas uint64, err error) }
PrecompileAccessibleState defines the interface exposed to stateful precompile contracts
type RewardManagerConfig ¶
type RewardManagerConfig struct { AllowListConfig UpgradeableConfig InitialRewardConfig *InitialRewardConfig `json:"initialRewardConfig,omitempty"` }
RewardManagerConfig implements the StatefulPrecompileConfig interface while adding in the RewardManager specific precompile config.
func NewDisableRewardManagerConfig ¶
func NewDisableRewardManagerConfig(blockTimestamp *big.Int) *RewardManagerConfig
NewDisableRewardManagerConfig returns config for a network upgrade at [blockTimestamp] that disables RewardManager.
func NewRewardManagerConfig ¶
func NewRewardManagerConfig(blockTimestamp *big.Int, admins []common.Address, enableds []common.Address, initialConfig *InitialRewardConfig) *RewardManagerConfig
NewRewardManagerConfig returns a config for a network upgrade at [blockTimestamp] that enables RewardManager with the given [admins] and [enableds] as members of the allowlist with [initialConfig] as initial rewards config if specified.
func (*RewardManagerConfig) Address ¶
func (c *RewardManagerConfig) Address() common.Address
Address returns the address of the RewardManager. Addresses reside under the precompile/params.go Select a non-conflicting address and set it in the params.go.
func (*RewardManagerConfig) Configure ¶
func (c *RewardManagerConfig) Configure(chainConfig ChainConfig, state StateDB, _ BlockContext)
Configure configures [state] with the initial configuration.
func (*RewardManagerConfig) Contract ¶
func (c *RewardManagerConfig) Contract() StatefulPrecompiledContract
Contract returns the singleton stateful precompiled contract to be used for RewardManager.
func (*RewardManagerConfig) Equal ¶
func (c *RewardManagerConfig) Equal(s StatefulPrecompileConfig) bool
Equal returns true if [s] is a *RewardManagerConfig and it has been configured identical to [c].
func (*RewardManagerConfig) String ¶
func (c *RewardManagerConfig) String() string
String returns a string representation of the RewardManagerConfig.
func (*RewardManagerConfig) Verify ¶
func (c *RewardManagerConfig) Verify() error
type StateDB ¶
type StateDB interface { GetState(common.Address, common.Hash) common.Hash SetState(common.Address, common.Hash, common.Hash) SetCode(common.Address, []byte) SetNonce(common.Address, uint64) GetNonce(common.Address) uint64 GetBalance(common.Address) *big.Int AddBalance(common.Address, *big.Int) SubBalance(common.Address, *big.Int) CreateAccount(common.Address) Exist(common.Address) bool AddLog(addr common.Address, topics []common.Hash, data []byte, blockNumber uint64) Suicide(common.Address) bool Finalise(deleteEmptyObjects bool) }
StateDB is the interface for accessing EVM state
type StatefulPrecompileConfig ¶
type StatefulPrecompileConfig interface { // Address returns the address where the stateful precompile is accessible. Address() common.Address // Timestamp returns the timestamp at which this stateful precompile should be enabled. // 1) 0 indicates that the precompile should be enabled from genesis. // 2) n indicates that the precompile should be enabled in the first block with timestamp >= [n]. // 3) nil indicates that the precompile is never enabled. Timestamp() *big.Int // IsDisabled returns true if this network upgrade should disable the precompile. IsDisabled() bool // Equal returns true if the provided argument configures the same precompile with the same parameters. Equal(StatefulPrecompileConfig) bool // Configure is called on the first block where the stateful precompile should be enabled. // This allows the stateful precompile to configure its own state via [StateDB] and [BlockContext] as necessary. // This function must be deterministic since it will impact the EVM state. If a change to the // config causes a change to the state modifications made in Configure, then it cannot be safely // made to the config after the network upgrade has gone into effect. // // Configure is called on the first block where the stateful precompile should be enabled. This // provides the config the ability to set its initial state and should only modify the state within // its own address space. Configure(ChainConfig, StateDB, BlockContext) // Contract returns a thread-safe singleton that can be used as the StatefulPrecompiledContract when // this config is enabled. Contract() StatefulPrecompiledContract // Verify is called on startup and an error is treated as fatal. Configure can assume the Config has passed verification. Verify() error fmt.Stringer }
StatefulPrecompileConfig defines the interface for a stateful precompile to
type StatefulPrecompiledContract ¶
type StatefulPrecompiledContract interface { // Run executes the precompiled contract. Run(accessibleState PrecompileAccessibleState, caller common.Address, addr common.Address, input []byte, suppliedGas uint64, readOnly bool) (ret []byte, remainingGas uint64, err error) }
StatefulPrecompiledContract is the interface for executing a precompiled contract
var ( // Singleton StatefulPrecompiledContract for minting native assets by permissioned callers. ContractNativeMinterPrecompile StatefulPrecompiledContract = createNativeMinterPrecompile(ContractNativeMinterAddress) ErrCannotMint = errors.New("non-enabled cannot mint") )
var ( // Singleton StatefulPrecompiledContract for setting fee configs by permissioned callers. FeeConfigManagerPrecompile StatefulPrecompiledContract = createFeeConfigManagerPrecompile(FeeConfigManagerAddress) ErrCannotChangeFee = errors.New("non-enabled cannot change fee config") )
var ( // Singleton StatefulPrecompiledContract for W/R access to the contract deployer allow list. TxAllowListPrecompile StatefulPrecompiledContract = createAllowListPrecompile(TxAllowListAddress) ErrSenderAddressNotAllowListed = errors.New("cannot issue transaction from non-allow listed address") )
var ( // Singleton StatefulPrecompiledContract for W/R access to the contract deployer allow list. ContractDeployerAllowListPrecompile StatefulPrecompiledContract = createAllowListPrecompile(ContractDeployerAllowListAddress) )
type TxAllowListConfig ¶
type TxAllowListConfig struct { AllowListConfig UpgradeableConfig }
TxAllowListConfig wraps AllowListConfig and uses it to implement the StatefulPrecompileConfig interface while adding in the TxAllowList specific precompile address.
func NewDisableTxAllowListConfig ¶
func NewDisableTxAllowListConfig(blockTimestamp *big.Int) *TxAllowListConfig
NewDisableTxAllowListConfig returns config for a network upgrade at [blockTimestamp] that disables TxAllowList.
func NewTxAllowListConfig ¶
func NewTxAllowListConfig(blockTimestamp *big.Int, admins []common.Address, enableds []common.Address) *TxAllowListConfig
NewTxAllowListConfig returns a config for a network upgrade at [blockTimestamp] that enables TxAllowList with the given [admins] and [enableds] as members of the allowlist.
func (*TxAllowListConfig) Address ¶
func (c *TxAllowListConfig) Address() common.Address
Address returns the address of the contract deployer allow list.
func (*TxAllowListConfig) Configure ¶
func (c *TxAllowListConfig) Configure(_ ChainConfig, state StateDB, _ BlockContext)
Configure configures [state] with the desired admins based on [c].
func (*TxAllowListConfig) Contract ¶
func (c *TxAllowListConfig) Contract() StatefulPrecompiledContract
Contract returns the singleton stateful precompiled contract to be used for the allow list.
func (*TxAllowListConfig) Equal ¶
func (c *TxAllowListConfig) Equal(s StatefulPrecompileConfig) bool
Equal returns true if [s] is a *TxAllowListConfig and it has been configured identical to [c].
func (*TxAllowListConfig) String ¶
func (c *TxAllowListConfig) String() string
String returns a string representation of the TxAllowListConfig.
type UpgradeableConfig ¶
type UpgradeableConfig struct { BlockTimestamp *big.Int `json:"blockTimestamp"` Disable bool `json:"disable,omitempty"` }
UpgradeableConfig contains the timestamp for the upgrade along with a boolean [Disable]. If [Disable] is set, the upgrade deactivates the precompile and resets its storage.
func (*UpgradeableConfig) Equal ¶
func (c *UpgradeableConfig) Equal(other *UpgradeableConfig) bool
Equal returns true iff [other] has the same blockTimestamp and has the same on value for the Disable flag.
func (*UpgradeableConfig) IsDisabled ¶
func (c *UpgradeableConfig) IsDisabled() bool
IsDisabled returns true if the network upgrade deactivates the precompile.
func (*UpgradeableConfig) Timestamp ¶
func (c *UpgradeableConfig) Timestamp() *big.Int
Timestamp returns the timestamp this network upgrade goes into effect.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Defines the interface for the configuration and execution of a precompile contract
|
Defines the interface for the configuration and execution of a precompile contract |
contracts
|
|
Defines the stateless interface for unmarshalling an arbitrary config of a precompile
|
Defines the stateless interface for unmarshalling an arbitrary config of a precompile |
Module to facilitate the registration of precompiles and their configuration.
|
Module to facilitate the registration of precompiles and their configuration. |