BlockRewardBase
contract BlockRewardBase
is OwnedEternalStorage, IBlockReward
The base contract for the BlockRewardAuRa and BlockRewardHBBFT contracts.
Index
- AddedReceiver
- MintedNative
- _dequeueExtraReceiver
- _enqueueExtraReceiver
- _mintNativeCoins
- _setMinted
- _setSnapshot
- addBridgeNativeFeeReceivers
- addBridgeTokenFeeReceivers
- addExtraReceiver
- ercToErcBridgesAllowed
- ercToNativeBridgesAllowed
- extraReceiversQueueSize
- getBridgeNativeFee
- getBridgeTokenFee
- initialize
- isInitialized
- isRewarding
- isSnapshotting
- mintedForAccount
- mintedForAccountInBlock
- mintedInBlock
- mintedTotally
- mintedTotallyByBridge
- nativeToErcBridgesAllowed
- onlyErcToNativeBridge
- onlyInitialized
- onlySystem
- onlyXToErcBridge
- setErcToErcBridgesAllowed
- setErcToNativeBridgesAllowed
- setNativeToErcBridgesAllowed
- snapshotRewardPercents
- snapshotStakers
- snapshotStakingAddresses
- snapshotTotalStakeAmount
- validatorSetContract
Reference
Events
- AddedReceiver- event AddedReceiver(uint256 amount, address receiver, address bridge)- Emitted by the `addExtraReceiver` function. - Parameters:
- amount- The amount of native coins which must be minted for the `receiver` by the `erc-to-native` `bridge` with the `reward` function.- receiver- The address for which the `amount` of native coins must be minted.- bridge- The bridge address which called the `addExtraReceiver` function.
 
- MintedNative- event MintedNative(address[] receivers, uint256[] rewards)- Emitted by the `_mintNativeCoins` function which is called by the `reward` function. This event is only used by the unit tests because the `reward` function cannot emit events. - Parameters:
- receivers- The array of receiver addresses for which native coins are minted. The length of this array is equal to the length of the `rewards` array.- rewards- The array of amounts minted for the relevant `receivers`. The length of this array is equal to the length of the `receivers` array.
 
Modifiers
- onlyErcToNativeBridge- modifier onlyErcToNativeBridge()- Ensures the caller is the `erc-to-native` bridge contract address. 
- onlyInitialized- modifier onlyInitialized()- Ensures the `initialize` function was called before. 
- onlySystem- modifier onlySystem()- Ensures the caller is the SYSTEM_ADDRESS. See https://wiki.parity.io/Block-Reward-Contract.html. 
- onlyXToErcBridge- modifier onlyXToErcBridge()- Ensures the caller is the `erc-to-erc` or `native-to-erc` bridge contract address. 
Functions
- _dequeueExtraReceiver- function _dequeueExtraReceiver() internal returns (uint256, address, address)- Dequeues the information about the native coins receiver enqueued with the `addExtraReceiver` function by the `erc-to-native` bridge. This function is used by `_mintNativeCoins`. - Returns:
- `uint256 amount` - The amount to be minted for the `receiver` address. `address receiver` - The address for which the `amount` is minted. `address bridge` - The address of the bridge contract which called the `addExtraReceiver` function.
 
- _enqueueExtraReceiver- function _enqueueExtraReceiver(uint256 _amount, address _receiver, address _bridge) internal- Enqueues the information about the receiver of native coins which must be minted for the specified `erc-to-native` bridge. This function is used by the `addExtraReceiver` function. - Parameters:
- _amount- The amount of native coins which must be minted for the `_receiver` address.- _receiver- The address for which the `_amount` of native coins must be minted.- _bridge- The address of the bridge contract which requested the minting of native coins.
 
- _mintNativeCoins- function _mintNativeCoins(address[] _receivers, uint256[] _rewards, uint256 _queueLimit) internal returns (address[], uint256[])- Joins two native coin receiver elements into a single set and returns the result to the `reward` function: the first element comes from the `erc-to-native` bridge fee distribution (or from native coins fixed distribution), the second from the `erc-to-native` bridge when native coins are minted for the specified addresses. Dequeues the addresses enqueued with the `addExtraReceiver` function by the `erc-to-native` bridge. Accumulates minting statistics for the `erc-to-native` bridges. - Parameters:
- _receivers- The array of native coin receivers formed by the `_distributeRewards` function.- _rewards- The array of native coin amounts to be minted for the corresponding `_receivers`. The size of this array is equal to the size of the `_receivers` array.- _queueLimit- Max number of addresses which can be dequeued from the queue formed by the `addExtraReceiver` function.
- Returns:
- address[]
- uint256[]
 
- _setMinted- function _setMinted(uint256 _amount, address _account, address _bridge) internal- Accumulates minting statistics for the `erc-to-native` bridge. This function is used by the `_mintNativeCoins` function. - Parameters:
- _amount- The amount minted for the `_account` address.- _account- The address for which the `_amount` is minted.- _bridge- The address of the bridge contract which called the `addExtraReceiver` function.
 
- _setSnapshot- function _setSnapshot(address _stakingAddress, IStaking _stakingContract, uint256 _offset) internal- Calculates the reward coefficient for each pool's staker and saves it so it can be used at the end of the staking epoch for the reward distribution phase. Specifies a section of the coefficients' snapshot thus limiting the coefficient calculations for each block. This function is called by the `reward` function at the beginning of the staking epoch. - Parameters:
- _stakingAddress- The staking address of a pool for which the snapshot must be done.- _stakingContract- The address of the `Staking` contract.- _offset- The section of the delegator array to snapshot at the current block. The `_offset` range is [0, DELEGATORS_ALIQUOT - 1]. The `_offset` value is set based on the `DELEGATORS_ALIQUOT` constant - see the code of the `reward` function.
 
- addBridgeNativeFeeReceivers- function addBridgeNativeFeeReceivers(uint256 _amount) external- Called by the `erc-to-native` bridge contract when a portion of the bridge fee should be distributed to participants (validators and their delegators) in native coins. The specified amount is used by the `_distributeRewards` function. - Modifiers:
- onlyErcToNativeBridge
- Parameters:
- _amount- The fee amount distributed to participants.
 
- addBridgeTokenFeeReceivers- function addBridgeTokenFeeReceivers(uint256 _amount) external- Called by the `erc-to-erc` or `native-to-erc` bridge contract when a portion of the bridge fee should be distributed to participants in staking tokens. The specified amount is used by the `_distributeRewards` function. - Modifiers:
- onlyXToErcBridge
- Parameters:
- _amount- The fee amount distributed to participants.
 
- addExtraReceiver- function addExtraReceiver(uint256 _amount, address _receiver) external- Called by the `erc-to-native` bridge contract when the bridge needs to mint a specified amount of native coins for a specified address using the `reward` function. - Modifiers:
- onlyErcToNativeBridge
- Parameters:
- _amount- The amount of native coins which must be minted for the `_receiver` address.- _receiver- The address for which the `_amount` of native coins must be minted.
 
- ercToErcBridgesAllowed- function ercToErcBridgesAllowed() public view returns (address[])- Returns the array of `erc-to-erc` bridge addresses set by the `setErcToErcBridgesAllowed` setter. - Returns:
- address[]
 
- ercToNativeBridgesAllowed- function ercToNativeBridgesAllowed() public view returns (address[])- Returns the array of `erc-to-native` bridge addresses set by the `setErcToNativeBridgesAllowed` setter. - Returns:
- address[]
 
- extraReceiversQueueSize- function extraReceiversQueueSize() public view returns (uint256)- Returns the current size of the address queue created by the `addExtraReceiver` function. - Returns:
- uint256
 
- getBridgeNativeFee- function getBridgeNativeFee() public view returns (uint256)- Returns the current total fee amount of native coins accumulated by the `addBridgeNativeFeeReceivers` function. - Returns:
- uint256
 
- getBridgeTokenFee- function getBridgeTokenFee() public view returns (uint256)- Returns the current total fee amount of staking tokens accumulated by the `addBridgeTokenFeeReceivers` function. - Returns:
- uint256
 
- initialize- function initialize(address _validatorSet) external- Initializes the contract at network startup. Must be called by the constructor of the `Initializer` contract. - Parameters:
- _validatorSet- The address of the `ValidatorSet` contract.
 
- isInitialized- function isInitialized() public view returns (bool)- Returns a boolean flag indicating if the `initialize` function has been called. - Returns:
- bool
 
- isRewarding- function isRewarding() public view returns (bool)- Returns a boolean flag indicating if the reward process is occuring for the current block. The value of this boolean flag is changed by the `_distributeRewards` function. - Returns:
- bool
 
- isSnapshotting- function isSnapshotting() public view returns (bool)- Returns a boolean flag indicating if the snapshotting process is occuring for the current block. The value of this boolean flag is changed by the `reward` function. - Returns:
- bool
 
- mintedForAccount- function mintedForAccount(address _account) public view returns (uint256)- Returns the total amount of native coins minted for the specified address by the `erc-to-native` bridges through the `addExtraReceiver` function. - Parameters:
- _account- The address for which the getter must return the minted amount.
- Returns:
- uint256
 
- mintedForAccountInBlock- function mintedForAccountInBlock(address _account, uint256 _blockNumber) public view returns (uint256)- Returns the amount of native coins minted at the specified block for the specified address by the `erc-to-native` bridges through the `addExtraReceiver` function. - Parameters:
- _account- The address for which the getter must return the amount minted at the `_blockNumber`.- _blockNumber- The block number for which the getter must return the amount minted for the `_account`.
- Returns:
- uint256
 
- mintedInBlock- function mintedInBlock(uint256 _blockNumber) public view returns (uint256)- Returns the total amount of native coins minted at the specified block by the `erc-to-native` bridges through the `addExtraReceiver` function. - Parameters:
- _blockNumber- The block number for which the getter must return the minted amount.
- Returns:
- uint256
 
- mintedTotally- function mintedTotally() public view returns (uint256)- Returns the total amount of native coins minted by the `erc-to-native` bridges through the `addExtraReceiver` function. - Returns:
- uint256
 
- mintedTotallyByBridge- function mintedTotallyByBridge(address _bridge) public view returns (uint256)- Returns the total amount of native coins minted by the specified `erc-to-native` bridge through the `addExtraReceiver` function. - Parameters:
- _bridge- The address of the bridge contract.
- Returns:
- uint256
 
- nativeToErcBridgesAllowed- function nativeToErcBridgesAllowed() public view returns (address[])- Returns the array of `native-to-erc` bridge addresses which were set by the `setNativeToErcBridgesAllowed` setter. - Returns:
- address[]
 
- setErcToErcBridgesAllowed- function setErcToErcBridgesAllowed(address[] _bridgesAllowed) external- Sets the array of `erc-to-erc` bridge addresses which are allowed to call some of the functions with the `onlyXToErcBridge` modifier. This setter can only be called by the `owner`. - Modifiers:
- onlyOwner onlyInitialized
- Parameters:
- _bridgesAllowed- The array of bridge addresses.
 
- setErcToNativeBridgesAllowed- function setErcToNativeBridgesAllowed(address[] _bridgesAllowed) external- Sets the array of `erc-to-native` bridge addresses which are allowed to call some of the functions with the `onlyErcToNativeBridge` modifier. This setter can only be called by the `owner`. - Modifiers:
- onlyOwner onlyInitialized
- Parameters:
- _bridgesAllowed- The array of bridge addresses.
 
- setNativeToErcBridgesAllowed- function setNativeToErcBridgesAllowed(address[] _bridgesAllowed) external- Sets the array of `native-to-erc` bridge addresses which are allowed to call some of the functions with the `onlyXToErcBridge` modifier. This setter can only be called by the `owner`. - Modifiers:
- onlyOwner onlyInitialized
- Parameters:
- _bridgesAllowed- The array of bridge addresses.
 
- snapshotRewardPercents- function snapshotRewardPercents(address _validatorStakingAddress) public view returns (uint256[])- Returns an array of reward coefficients which corresponds to the array of stakers for a specified validator and the current staking epoch. The size of the returned array is the same as the size of the staker array returned by the `snapshotStakers` getter. The reward coefficients are calculated by the `_setSnapshot` function at the beginning of the staking epoch and then used by the `_distributeRewards` function at the end of the staking epoch. - Parameters:
- _validatorStakingAddress- The staking address of the validator pool for which the getter must return the coefficient array.
- Returns:
- uint256[]
 
- snapshotStakers- function snapshotStakers(address _validatorStakingAddress) public view returns (address[])- Returns an array of stakers for the specified validator and the current staking epoch snapshotted at the beginning of the staking epoch by the `_setSnapshot` function. This array is used by the `_distributeRewards` function at the end of the staking epoch. - Parameters:
- _validatorStakingAddress- The staking address of the validator pool for which the getter must return the array of stakers.
- Returns:
- address[]
 
- snapshotStakingAddresses- function snapshotStakingAddresses() public view returns (address[])- Returns an array of the pools snapshotted by the `_setSnapshot` function at the beginning of the current staking epoch. The getter returns the staking addresses of the pools. - Returns:
- address[]
 
- snapshotTotalStakeAmount- function snapshotTotalStakeAmount() public view returns (uint256)- Returns the total amount staked during the previous staking epoch. This value is used by the `_distributeRewards` function at the end of the current staking epoch to calculate the inflation amount for the staking token in the current staking epoch. - Returns:
- uint256
 
- validatorSetContract- function validatorSetContract() public view returns (IValidatorSet)- Returns the address of the `ValidatorSet` contract. - Returns:
- IValidatorSet