Documentation ¶
Index ¶
- Constants
- Variables
- func GetFeeConfigLastChangedAt(stateDB contract.StateDB) *big.Int
- func GetFeeManagerStatus(stateDB contract.StateDB, address common.Address) allowlist.Role
- func GetStoredFeeConfig(stateDB contract.StateDB) commontype.FeeConfig
- func PackFeeConfigChangedEvent(sender common.Address, oldConfig commontype.FeeConfig, ...) ([]common.Hash, []byte, error)
- func PackGetFeeConfig() ([]byte, error)
- func PackGetFeeConfigLastChangedAt() ([]byte, error)
- func PackGetFeeConfigLastChangedAtOutput(blockNumber *big.Int) ([]byte, error)
- func PackGetFeeConfigOutput(output commontype.FeeConfig) ([]byte, error)
- func PackSetFeeConfig(input commontype.FeeConfig) ([]byte, error)
- func SetFeeManagerStatus(stateDB contract.StateDB, address common.Address, role allowlist.Role)
- func StoreFeeConfig(stateDB contract.StateDB, feeConfig commontype.FeeConfig, ...) error
- func UnpackFeeConfigChangedEventData(dataBytes []byte) (commontype.FeeConfig, commontype.FeeConfig, error)
- func UnpackGetFeeConfigLastChangedAtOutput(output []byte) (*big.Int, error)
- func UnpackGetFeeConfigOutput(output []byte, skipLenCheck bool) (commontype.FeeConfig, error)
- func UnpackSetFeeConfigInput(input []byte, useStrictMode bool) (commontype.FeeConfig, error)
- type Config
- type FeeConfigABIStruct
Constants ¶
const ( SetFeeConfigGasCost uint64 = contract.WriteGasCostPerSlot * (numFeeConfigField + 1) // plus one for setting last changed at GetFeeConfigGasCost uint64 = contract.ReadGasCostPerSlot * numFeeConfigField GetLastChangedAtGasCost uint64 = contract.ReadGasCostPerSlot )
const ConfigKey = "feeManagerConfig"
ConfigKey is the key used in json config files to specify this precompile config. must be unique across all precompiles.
const FeeConfigChangedEventGasCost = GetFeeConfigGasCost + contract.LogGas + contract.LogTopicGas*2 + 2*(feeConfigInputLen)*contract.LogDataGas
FeeConfigChangedEventGasCost is the gas cost of a FeeConfigChanged event. It is the base gas cost + the gas cost of the topics (signature, sender) and the gas cost of the non-indexed data len(oldConfig) + len(newConfig).
Variables ¶
var ( // Singleton StatefulPrecompiledContract for setting fee configs by permissioned callers. FeeManagerPrecompile contract.StatefulPrecompiledContract = createFeeManagerPrecompile() ErrCannotChangeFee = errors.New("non-enabled cannot change fee config") ErrInvalidLen = errors.New("invalid input length for fee config Input") // IFeeManagerRawABI contains the raw ABI of FeeManager contract. //go:embed contract.abi FeeManagerRawABI string FeeManagerABI = contract.ParseABI(FeeManagerRawABI) )
var ContractAddress = common.HexToAddress("0x0200000000000000000000000000000000000003")
var Module = modules.Module{ ConfigKey: ConfigKey, Address: ContractAddress, Contract: FeeManagerPrecompile, Configurator: &configurator{}, }
Module is the precompile module. It is used to register the precompile contract.
Functions ¶
func GetFeeManagerStatus ¶
GetFeeManagerStatus returns the role of [address] for the fee config manager list.
func GetStoredFeeConfig ¶
func GetStoredFeeConfig(stateDB contract.StateDB) commontype.FeeConfig
GetStoredFeeConfig returns fee config from contract storage in given state
func PackFeeConfigChangedEvent ¶
func PackFeeConfigChangedEvent(sender common.Address, oldConfig commontype.FeeConfig, newConfig commontype.FeeConfig) ([]common.Hash, []byte, error)
PackFeeConfigChangedEvent packs the event into the appropriate arguments for changeFeeConfig. It returns topic hashes and the encoded non-indexed data.
func PackGetFeeConfig ¶
PackGetFeeConfig packs the include selector (first 4 func signature bytes). This function is mostly used for tests.
func PackGetFeeConfigLastChangedAt ¶
PackGetFeeConfigLastChangedAt packs the include selector (first 4 func signature bytes). This function is mostly used for tests.
func PackGetFeeConfigLastChangedAtOutput ¶
PackGetFeeConfigLastChangedAtOutput attempts to pack given blockNumber of type *big.Int to conform the ABI outputs.
func PackGetFeeConfigOutput ¶
func PackGetFeeConfigOutput(output commontype.FeeConfig) ([]byte, error)
PackGetFeeConfigOutput attempts to pack given [outputStruct] of type GetFeeConfigOutput to conform the ABI outputs.
func PackSetFeeConfig ¶
func PackSetFeeConfig(input commontype.FeeConfig) ([]byte, error)
PackSetFeeConfig packs [inputStruct] of type SetFeeConfigInput into the appropriate arguments for setFeeConfig.
func SetFeeManagerStatus ¶
SetFeeManagerStatus sets the permissions of [address] to [role] for the fee config manager list. assumes [role] has already been verified as valid.
func StoreFeeConfig ¶
func StoreFeeConfig(stateDB contract.StateDB, feeConfig commontype.FeeConfig, blockContext contract.ConfigurationBlockContext) error
StoreFeeConfig stores given [feeConfig] and block number in the [blockContext] to the [stateDB]. A validation on [feeConfig] is done before storing.
func UnpackFeeConfigChangedEventData ¶
func UnpackFeeConfigChangedEventData(dataBytes []byte) (commontype.FeeConfig, commontype.FeeConfig, error)
UnpackFeeConfigChangedEventData attempts to unpack non-indexed [dataBytes].
func UnpackGetFeeConfigLastChangedAtOutput ¶
UnpackGetFeeConfigLastChangedAtOutput attempts to unpack given [output] into the *big.Int type output assumes that [output] does not include selector (omits first 4 func signature bytes)
func UnpackGetFeeConfigOutput ¶
func UnpackGetFeeConfigOutput(output []byte, skipLenCheck bool) (commontype.FeeConfig, error)
UnpackGetFeeConfigOutput attempts to unpack [output] as GetFeeConfigOutput assumes that [output] does not include selector (omits first 4 func signature bytes)
func UnpackSetFeeConfigInput ¶
func UnpackSetFeeConfigInput(input []byte, useStrictMode bool) (commontype.FeeConfig, error)
UnpackSetFeeConfigInput attempts to unpack [input] as SetFeeConfigInput assumes that [input] does not include selector (omits first 4 func signature bytes) if [useStrictMode] is true, it will return an error if the length of [input] is not [feeConfigInputLen]
Types ¶
type Config ¶
type Config struct { allowlist.AllowListConfig // Config for the fee config manager allow list precompileconfig.Upgrade InitialFeeConfig *commontype.FeeConfig `json:"initialFeeConfig,omitempty"` // initial fee config to be immediately activated }
Config implements the StatefulPrecompileConfig interface while adding in the FeeManager specific precompile config.
func NewConfig ¶
func NewConfig(blockTimestamp *uint64, admins []common.Address, enableds []common.Address, managers []common.Address, initialConfig *commontype.FeeConfig) *Config
NewConfig returns a config for a network upgrade at [blockTimestamp] that enables FeeManager with the given [admins], [enableds] and [managers] as members of the allowlist with [initialConfig] as initial fee config if specified.
func NewDisableConfig ¶
NewDisableConfig returns config for a network upgrade at [blockTimestamp] that disables FeeManager.
func (*Config) Equal ¶
func (c *Config) Equal(cfg precompileconfig.Config) bool
Equal returns true if [cfg] is a [*FeeManagerConfig] and it has been configured identical to [c].
func (*Config) Key ¶
Key returns the key for the FeeManager precompileconfig. This should be the same key as used in the precompile module.
func (*Config) Verify ¶
func (c *Config) Verify(chainConfig precompileconfig.ChainConfig) error
Verify tries to verify Config and returns an error accordingly.
type FeeConfigABIStruct ¶
type FeeConfigABIStruct struct { GasLimit *big.Int TargetBlockRate *big.Int MinBaseFee *big.Int TargetGas *big.Int BaseFeeChangeDenominator *big.Int MinBlockGasCost *big.Int MaxBlockGasCost *big.Int BlockGasCostStep *big.Int }
FeeConfigABIStruct is the ABI struct for FeeConfig type.