feemanager

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: GPL-3.0, LGPL-3.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	SetFeeConfigGasCost     uint64 = contract.WriteGasCostPerSlot * (numFeeConfigField + 1) // plus one for setting last changed at
	GetFeeConfigGasCost     uint64 = contract.ReadGasCostPerSlot * numFeeConfigField
	GetLastChangedAtGasCost uint64 = contract.ReadGasCostPerSlot
)
View Source
const ConfigKey = "feeManagerConfig"

ConfigKey is the key used in json config files to specify this precompile config. must be unique across all precompiles.

View Source
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

View Source
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)
)
View Source
var ContractAddress = common.HexToAddress("0x0200000000000000000000000000000000000003")
View Source
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 GetFeeConfigLastChangedAt

func GetFeeConfigLastChangedAt(stateDB contract.StateDB) *big.Int

func GetFeeManagerStatus

func GetFeeManagerStatus(stateDB contract.StateDB, address common.Address) allowlist.Role

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 added in v0.5.11

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 added in v0.5.11

func PackGetFeeConfig() ([]byte, error)

PackGetFeeConfig packs the include selector (first 4 func signature bytes). This function is mostly used for tests.

func PackGetFeeConfigLastChangedAt added in v0.5.11

func PackGetFeeConfigLastChangedAt() ([]byte, error)

PackGetFeeConfigLastChangedAt packs the include selector (first 4 func signature bytes). This function is mostly used for tests.

func PackGetFeeConfigLastChangedAtOutput added in v0.5.11

func PackGetFeeConfigLastChangedAtOutput(blockNumber *big.Int) ([]byte, error)

PackGetFeeConfigLastChangedAtOutput attempts to pack given blockNumber of type *big.Int to conform the ABI outputs.

func PackGetFeeConfigOutput added in v0.5.11

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

func SetFeeManagerStatus(stateDB contract.StateDB, address common.Address, role allowlist.Role)

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 added in v0.5.11

func UnpackFeeConfigChangedEventData(dataBytes []byte) (commontype.FeeConfig, commontype.FeeConfig, error)

UnpackFeeConfigChangedEventData attempts to unpack non-indexed [dataBytes].

func UnpackGetFeeConfigLastChangedAtOutput added in v0.5.11

func UnpackGetFeeConfigLastChangedAtOutput(output []byte) (*big.Int, error)

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 added in v0.5.11

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 added in v0.5.11

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

func NewDisableConfig(blockTimestamp *uint64) *Config

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

func (*Config) Key() string

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 added in v0.5.11

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.

Jump to

Keyboard shortcuts

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