RandomAuRa
contract RandomAuRa
Generates and stores random numbers in a RANDAO manner (and controls when they are revealed by AuRa validators) and accumulates a random seed. The random seed is used to form a new validator set by the `ValidatorSet._newValidatorSet` function.
Index
Reference
Modifiers
- onlyBlockReward- modifier onlyBlockReward()- Ensures the caller is the BlockRewardAuRa contract address (EternalStorageProxy proxy contract for BlockRewardAuRa). 
Functions
- _getCoinbase- function _getCoinbase() internal view returns (address)- Returns the current `coinbase` address. Needed mostly for unit tests. - Returns:
- address
 
- _getCurrentBlockNumber- function _getCurrentBlockNumber() internal view returns (uint256)- Returns the current block number. Needed mostly for unit tests. - Returns:
- uint256
 
- collectRoundLength- function collectRoundLength() public view returns (uint256)- Returns the length of the collection round (in blocks). - Returns:
- uint256
 
- commitHash- function commitHash(bytes32 _secretHash, bytes _cipher) external- Called by the validator's node to store a hash and a cipher of the validator's secret on each collection round. The validator's node must use its mining address to call this function. This function can only be called once per collection round (during the `commits phase`). - Modifiers:
- onlyInitialized
- Parameters:
- _secretHash- The Keccak-256 hash of the validator's secret.- _cipher- The cipher of the validator's secret. Can be used by the node to restore the lost secret after the node is restarted (see the `getCipher` getter).
 
- commitHashCallable- function commitHashCallable(address _miningAddress, bytes32 _secretHash) public view returns (bool)- Returns a boolean flag of whether the `commitHash` function can be called at the current block by the specified validator. Used by the `commitHash` function and the `TxPermission` contract. - Parameters:
- _miningAddress- The mining address of the validator which tries to call the `commitHash` function.- _secretHash- The Keccak-256 hash of validator's secret passed to the `commitHash` function.
- Returns:
- bool
 
- commitPhaseLength- function commitPhaseLength() public view returns (uint256)- Returns the length of the commits/reveals phase which is always half of the collection round length. - Returns:
- uint256
 
- currentCollectRound- function currentCollectRound() public view returns (uint256)- Returns the serial number of the current collection round. - Returns:
- uint256
 
- getCipher- function getCipher(uint256 _collectRound, address _miningAddress) public view returns (bytes)- Returns the cipher of the validator's secret for the specified collection round and the specified validator stored by the validator through the `commitHash` function. - Parameters:
- _collectRound- The serial number of the collection round for which the cipher should be retrieved.- _miningAddress- The mining address of validator.
- Returns:
- bytes
 
- getCommit- function getCommit(uint256 _collectRound, address _miningAddress) public view returns (bytes32)- Returns the Keccak-256 hash of the validator's secret for the specified collection round and the specified validator stored by the validator through the `commitHash` function. - Parameters:
- _collectRound- The serial number of the collection round for which the hash should be retrieved.- _miningAddress- The mining address of validator.
- Returns:
- bytes32
 
- initialize- function initialize(uint256 _collectRoundLength, address _validatorSet) external- Initializes the contract at network startup. Must be called by the constructor of the `InitializerAuRa` contract. - Parameters:
- _collectRoundLength- The length of a collection round in blocks.- _validatorSet- The address of the `ValidatorSet` contract.
 
- isCommitPhase- function isCommitPhase() public view returns (bool)- Returns a boolean flag indicating whether the current phase of the current collection round is a `commits phase`. Used by the validator's node to determine if it should commit the hash of the secret during the current collection round. - Returns:
- bool
 
- isCommitted- function isCommitted(uint256 _collectRound, address _miningAddress) public view returns (bool)- Returns a boolean flag indicating whether the specified validator has committed their secret's hash for the specified collection round. - Parameters:
- _collectRound- The serial number of the collection round for which the checkup should be done.- _miningAddress- The mining address of the validator.
- Returns:
- bool
 
- isRevealPhase- function isRevealPhase() public view returns (bool)- Returns a boolean flag indicating whether the current phase of the current collection round is a `reveals phase`. Used by the validator's node to determine if it should reveal the secret during the current collection round. - Returns:
- bool
 
- onFinishCollectRound- function onFinishCollectRound() external- Checks whether the current validators at the end of each collection round revealed their secrets, and removes malicious validators if needed. This function does nothing if the current block is not the last block of the current collection round. Can only be called by the `BlockRewardAuRa` contract (its `reward` function). - Modifiers:
- onlyBlockReward
 
- revealSecret- function revealSecret(uint256 _secret) external- Called by the validator's node to XOR its secret with the current random seed. The validator's node must use its mining address to call this function. This function can only be called once per collection round (during the `reveals phase`). - Modifiers:
- onlyInitialized
- Parameters:
- _secret- The validator's secret.
 
- revealSecretCallable- function revealSecretCallable(address _miningAddress, uint256 _secret) public view returns (bool)- Returns a boolean flag of whether the `revealSecret` function can be called at the current block by the specified validator. Used by the `revealSecret` function and the `TxPermission` contract. - Parameters:
- _miningAddress- The mining address of validator which tries to call the `revealSecret` function.- _secret- The validator's secret passed to the `revealSecret` function.
- Returns:
- bool
 
- revealSkips- function revealSkips(uint256 _stakingEpoch, address _miningAddress) public view returns (uint256)- Returns the number of reveal skips made by the specified validator during the specified staking epoch. - Parameters:
- _stakingEpoch- The serial number of the staking epoch for which the number of skips should be returned.- _miningAddress- The mining address of the validator for which the number of skips should be returned.
- Returns:
- uint256
 
- sentReveal- function sentReveal(uint256 _collectRound, address _miningAddress) public view returns (bool)- Returns a boolean flag of whether the specified validator has revealed their secret for the specified collection round. - Parameters:
- _collectRound- The serial number of the collection round for which the checkup should be done.- _miningAddress- The mining address of the validator.
- Returns:
- bool