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 PackFeeRecipientsAllowedEvent(sender common.Address) ([]common.Hash, []byte, error)
- func PackRewardAddressChangedEvent(sender common.Address, oldRewardAddress common.Address, ...) ([]common.Hash, []byte, error)
- func PackRewardsDisabledEvent(sender common.Address) ([]common.Hash, []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)
- func UnpackSetRewardAddressInput(input []byte, useStrictMode bool) (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 ( // FeeRecipientsAllowedEventGasCost is the gas cost of the FeeRecipientsAllowed event. // It is calculated as the gas cost of the log operation + the gas cost of 2 topic hashes (signature + sender). FeeRecipientsAllowedEventGasCost = contract.LogGas + contract.LogTopicGas*2 // RewardAddressChangedEventGasCost is the gas cost of the RewardAddressChanged event. // It is calculated as the gas cost of the log operation + the gas cost of 3 topic hashes (signature + sender + oldRewardAddress). // + the gas cost of reading old reward address. RewardAddressChangedEventGasCost = contract.LogGas + contract.LogTopicGas*4 + contract.ReadGasCostPerSlot // RewardsDisabledEventGasCost is the gas cost of the RewardsDisabled event. // It is calculated as the gas cost of the log operation + the gas cost of 2 topic hashes (signature + sender). RewardsDisabledEventGasCost = contract.LogGas + contract.LogTopicGas*2 )
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{}, }
Module is the precompile module. It is used to register the precompile contract.
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 PackFeeRecipientsAllowedEvent ¶ added in v0.5.11
PackFeeRecipientsAllowedEvent packs the event into the appropriate arguments for FeeRecipientsAllowed. It returns topic hashes and the encoded non-indexed data.
func PackRewardAddressChangedEvent ¶ added in v0.5.11
func PackRewardAddressChangedEvent(sender common.Address, oldRewardAddress common.Address, newRewardAddress common.Address) ([]common.Hash, []byte, error)
PackRewardAddressChangedEvent packs the event into the appropriate arguments for RewardAddressChanged. It returns topic hashes and the encoded non-indexed data.
func PackRewardsDisabledEvent ¶ added in v0.5.11
PackRewardsDisabledEvent packs the event into the appropriate arguments for RewardsDisabled. It returns topic hashes and the encoded non-indexed data.
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.
func UnpackSetRewardAddressInput ¶
UnpackSetRewardAddressInput attempts to unpack [input] into the common.Address type argument 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 divisible by 32
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 *uint64, admins []common.Address, enableds []common.Address, managers []common.Address, initialConfig *InitialRewardConfig) *Config
NewConfig returns a config for a network upgrade at [blockTimestamp] that enables RewardManager with the given [admins], [enableds] and [managers] 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.
func (*Config) Equal ¶
func (c *Config) Equal(cfg precompileconfig.Config) bool
Equal returns true if [cfg] is a [*RewardManagerConfig] and it has been configured identical to [c].
func (*Config) Key ¶
Key returns the key for the Contract 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 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