ValidatorSetAuRa
contract ValidatorSetAuRa
is IValidatorSetAuRa, ValidatorSetBase
Stores the current validator set and contains the logic for choosing new validators at the beginning of each staking epoch. The logic uses a random seed generated and stored by the `RandomAuRa` contract.
Index
Reference
Events
ReportedMalicious
event ReportedMalicious(address reportingValidator, address maliciousValidator, uint256 blockNumber)
Emitted by the `reportMalicious` function to signal that a specified validator reported misbehavior by a specified malicious validator at a specified block number.
- Parameters:
reportingValidator
- The mining address of the reporting validator.maliciousValidator
- The mining address of the malicious validator.blockNumber
- The block number at which the `maliciousValidator` misbehaved.
Modifiers
onlyBlockRewardContract
modifier onlyBlockRewardContract()
Ensures the caller is the BlockRewardAuRa contract address (EternalStorageProxy proxy contract for the BlockRewardAuRa).
onlyRandomContract
modifier onlyRandomContract()
Ensures the caller is the RandomAuRa contract address (EternalStorageProxy proxy contract for the RandomAuRa).
Functions
_banStart
function _banStart() internal view returns (uint256)
Returns the current block number for the `isValidatorBanned`, `_banUntil`, and `_banValidator` functions.
- Returns:
- uint256
_banUntil
function _banUntil() internal view returns (uint256)
Returns the future block number until which a validator is banned. Used by the `_banValidator` function.
- Returns:
- uint256
_clearReportingCounter
function _clearReportingCounter(address _miningAddress) internal
Updates the total reporting counter (see the `reportingCounterTotal` getter) for the current staking epoch after the specified validator is removed as malicious. The `reportMaliciousCallable` getter uses this counter for reporting checks so it must be up-to-date. Called by the `_removeMaliciousValidatorAuRa` internal function.
- Parameters:
_miningAddress
- The mining address of the removed malicious validator.
_incrementReportingCounter
function _incrementReportingCounter(address _reportingMiningAddress) internal
Increments the reporting counter for the specified validator and the current staking epoch. See the `reportingCounter` and `reportingCounterTotal` getters. Called by the `reportMalicious` function when the validator reports a misbehavior.
- Parameters:
_reportingMiningAddress
- The mining address of reporting validator.
_removeMaliciousValidatorAuRa
function _removeMaliciousValidatorAuRa(address _miningAddress) internal
Removes the specified validator as malicious from the pending validator set and enqueues the updated pending validator set to be dequeued by the `emitInitiateChange` function. Does nothing if the specified validator is already banned, non-removable, or does not exist in the pending validator set.
- Parameters:
_miningAddress
- The mining address of the malicious validator.
maliceReportedForBlock
function maliceReportedForBlock(address _maliciousMiningAddress, uint256 _blockNumber) public view returns (address[])
Returns an array of the validators (their mining addresses) which reported that the specified malicious validator misbehaved at the specified block.
- Parameters:
_maliciousMiningAddress
- The mining address of the malicious validator._blockNumber
- The block number at which the misbehavior was observed.- Returns:
- address[]
newValidatorSet
function newValidatorSet() external returns (bool, uint256)
Implements the logic which forms a new validator set. Calls the internal `_newValidatorSet` function of the base contract. Automatically called by the `BlockRewardAuRa.reward` function on every block.
- Modifiers:
- onlyBlockRewardContract
- Returns:
- `bool called` - A boolean flag indicating whether the internal `_newValidatorSet` function was called. `uint256 poolsToBeElectedLength` - The number of pools ready to be elected (see the `Staking.getPoolsToBeElected` function). Equals `0` if the `called` flag is `false`.
removeMaliciousValidator
function removeMaliciousValidator(address _miningAddress) external
Removes a malicious validator. Called by the `RandomAuRa.onFinishCollectRound` function.
- Modifiers:
- onlyRandomContract
- Parameters:
_miningAddress
- The mining address of the malicious validator.
reportMalicious
function reportMalicious(address _maliciousMiningAddress, uint256 _blockNumber, bytes ) external
Reports that the malicious validator misbehaved at the specified block. Called by the node of each honest validator after the specified validator misbehaved. See https://wiki.parity.io/Validator-Set.html#reporting-contract Can only be called when the `reportMaliciousCallable` getter returns `true`.
- Modifiers:
- onlyInitialized
- Parameters:
_maliciousMiningAddress
- The mining address of the malicious validator._blockNumber
- The block number where the misbehavior was observed.- bytes
reportMaliciousCallable
function reportMaliciousCallable(address _reportingMiningAddress, address _maliciousMiningAddress, uint256 _blockNumber) public view returns (bool, bool)
Returns whether the `reportMalicious` function can be called by the specified validator with the given parameters. Used by the `reportMalicious` function and `TxPermission` contract. Also, returns a boolean flag indicating whether the reporting validator should be removed as malicious due to excessive reporting during the current staking epoch.
- Parameters:
_reportingMiningAddress
- The mining address of the reporting validator which is calling the `reportMalicious` function._maliciousMiningAddress
- The mining address of the malicious validator which is passed to the `reportMalicious` function._blockNumber
- The block number which is passed to the `reportMalicious` function.- Returns:
- `bool callable` - The boolean flag indicating whether the `reportMalicious` function can be called at the moment. `bool removeReportingValidator` - The boolean flag indicating whether the reporting validator should be removed as malicious due to excessive reporting. This flag is only used by the `reportMalicious` function.
reportingCounter
function reportingCounter(address _reportingMiningAddress, uint256 _stakingEpoch) public view returns (uint256)
Returns the number of times the specified validator reported misbehaviors during the specified staking epoch. Used by the `reportMaliciousCallable` getter to determine whether a validator reported too often.
- Parameters:
_reportingMiningAddress
- The mining address of the reporting validator._stakingEpoch
- The serial number of the staking epoch.- Returns:
- uint256
reportingCounterTotal
function reportingCounterTotal(uint256 _stakingEpoch) public view returns (uint256)
Returns how many times all validators reported misbehaviors during the specified staking epoch. Used by the `reportMaliciousCallable` getter to determine whether a validator reported too often.
- Parameters:
_stakingEpoch
- The serial number of the staking epoch.- Returns:
- uint256