Documentation ¶
Index ¶
- Constants
- Variables
- func DisableFeeRewards(stateDB contract.StateDB)
- func EnableAllowFeeRecipients(stateDB contract.StateDB)
- func GetRewardManagerAllowListStatus(stateDB contract.StateDB, address common.Address) allowlist.Role
- func GetStoredRewardAddress(stateDB contract.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 PackSetRewardAddress(addr common.Address) ([]byte, error)
- func SetRewardManagerAllowListStatus(stateDB contract.StateDB, address common.Address, role allowlist.Role)
- func StoreRewardAddress(stateDB contract.StateDB, val common.Address) error
- func UnpackSetRewardAddressInput(input []byte) (common.Address, error)
- type Config
- type InitialRewardConfig
Constants ¶
const ( AllowFeeRecipientsGasCost uint64 = (contract.WriteGasCostPerSlot) + allowlist.ReadAllowListGasCost // write 1 slot + read allow list AreFeeRecipientsAllowedGasCost uint64 = allowlist.ReadAllowListGasCost CurrentRewardAddressGasCost uint64 = allowlist.ReadAllowListGasCost DisableRewardsGasCost uint64 = (contract.WriteGasCostPerSlot) + allowlist.ReadAllowListGasCost // write 1 slot + read allow list SetRewardAddressGasCost uint64 = (contract.WriteGasCostPerSlot) + allowlist.ReadAllowListGasCost // write 1 slot + read allow list )
const ConfigKey = "rewardManagerConfig"
ConfigKey is the key used in json config files to specify this precompile config. must be unique across all precompiles.
Variables ¶
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") // RewardManagerRawABI contains the raw ABI of RewardManager contract. //go:embed contract.abi RewardManagerRawABI string RewardManagerABI = contract.ParseABI(RewardManagerRawABI) RewardManagerPrecompile = createRewardManagerPrecompile() // will be initialized by init function )
Singleton StatefulPrecompiledContract and signatures.
var ContractAddress = common.HexToAddress("0x0200000000000000000000000000000000000004")
var Module = modules.Module{ ConfigKey: ConfigKey, Address: ContractAddress, Contract: RewardManagerPrecompile, Configurator: &configurator{}, }
Functions ¶
func DisableFeeRewards ¶
DisableRewardAddress disables rewards and burns them by sending to Blackhole Address.
func EnableAllowFeeRecipients ¶
EnableAllowFeeRecipients enables fee recipients.
func GetRewardManagerAllowListStatus ¶
func GetRewardManagerAllowListStatus(stateDB contract.StateDB, address common.Address) allowlist.Role
GetRewardManagerAllowListStatus returns the role of [address] for the RewardManager list.
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 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 SetRewardManagerAllowListStatus ¶
func SetRewardManagerAllowListStatus(stateDB contract.StateDB, address common.Address, role allowlist.Role)
SetRewardManagerAllowListStatus sets the permissions of [address] to [role] for the RewardManager list. Assumes [role] has already been verified as valid.
func StoreRewardAddress ¶
StoredRewardAddress stores the given [val] under rewardAddressStorageKey.
Types ¶
type Config ¶
type Config struct { allowlist.AllowListConfig precompileconfig.Upgrade InitialRewardConfig *InitialRewardConfig `json:"initialRewardConfig,omitempty"` }
Config implements the StatefulPrecompileConfig interface while adding in the RewardManager specific precompile config.
func NewConfig ¶
func NewConfig(blockTimestamp *big.Int, admins []common.Address, enableds []common.Address, initialConfig *InitialRewardConfig) *Config
NewConfig 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 NewDisableConfig ¶
NewDisableConfig returns config for a network upgrade at [blockTimestamp] that disables RewardManager.
type InitialRewardConfig ¶
type InitialRewardConfig struct { AllowFeeRecipients bool `json:"allowFeeRecipients"` RewardAddress common.Address `json:"rewardAddress,omitempty"` }
func (*InitialRewardConfig) Configure ¶
func (i *InitialRewardConfig) Configure(state contract.StateDB) error
func (*InitialRewardConfig) Equal ¶
func (i *InitialRewardConfig) Equal(other *InitialRewardConfig) bool
func (*InitialRewardConfig) Verify ¶
func (i *InitialRewardConfig) Verify() error