Election
Celo0x8d6677192144292870907e3fa8a5527fe55a7ff6
Proxy implementation: 0xbd7d392bb2ef07063256e875f363d4fb2931780e
Solidity v0.5.13+commit.5b0b510c
Overview
Read Functions
Parameters
| Name | Type | Description |
|---|---|---|
| — | address |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool |
Parameters
| Name | Type | Description |
|---|---|---|
| — | address |
Returns
| Name | Type | Description |
|---|---|---|
| totalVotes | uint256 |
Returns whether or not a group can receive the specified number of votes.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The address of the group. |
| value | uint256 | The number of votes. |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool | Whether or not a group can receive the specified number of votes. |
Checks a BLS proof of possession.
Parameters
| Name | Type | Description |
|---|---|---|
| sender | address | The address signed by the BLS key to generate the proof of possession. |
| blsKey | bytes | The BLS public key that the validator is using for consensus, should pass proof of possession. 48 bytes. |
| blsPop | bytes | The BLS public key proof-of-possession, which consists of a signature on the account address. 96 bytes. |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool | True upon success. |
Parameters
| Name | Type | Description |
|---|---|---|
| minElectableValidators | uint256 | |
| maxElectableValidators | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| — | address[] |
Parameters
| Name | Type | Description |
|---|---|---|
| minElectableValidators | uint256 | |
| maxElectableValidators | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| — | address[] |
Returns a list of elected validators with seats allocated to groups via the D'Hondt method.
Returns
| Name | Type | Description |
|---|---|---|
| — | address[] | The list of elected validators. |
Returns a list of elected validator signers with seats allocated to groups via the D'Hondt method.
Returns
| Name | Type | Description |
|---|---|---|
| — | address[] | The list of elected validator signers. |
Returns
| Name | Type | Description |
|---|---|---|
| value | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| min | uint256 | |
| max | uint256 |
calculate a * b^x for fractions a, b to `decimals` precision
Parameters
| Name | Type | Description |
|---|---|---|
| aNumerator | uint256 | Numerator of first fraction |
| aDenominator | uint256 | Denominator of first fraction |
| bNumerator | uint256 | Numerator of exponentiated fraction |
| bDenominator | uint256 | Denominator of exponentiated fraction |
| exponent | uint256 | exponent to raise b to |
| _decimals | uint256 | precision |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | Numerator of the computed quantity (not reduced). |
| — | uint256 | Denominator of the computed quantity (not reduced). |
Returns the total active vote units made for `group`.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The address of the validator group. |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The total active vote units made for `group`. |
Returns the active vote units for `group` made by `account`.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The address of the validator group. |
| account | address | The address of the voting account. |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The active vote units for `group` made by `account`. |
Returns the active votes received across all groups.
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The active votes received across all groups. |
Returns the active votes made for `group`.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The address of the validator group. |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The active votes made for `group`. |
Returns the active votes for `group` made by `account`.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The address of the validator group. |
| account | address | The address of the voting account. |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The active votes for `group` made by `account`. |
Parses block number out of header.
Parameters
| Name | Type | Description |
|---|---|---|
| header | bytes | RLP encoded header |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | Block number. |
Returns the address of the contract imposing the block.
Returns
| Name | Type | Description |
|---|---|---|
| blockedBy | address |
Returns get current validator signers using the precompiles.
Returns
| Name | Type | Description |
|---|---|---|
| — | address[] | List of current validator signers. |
Gets the election threshold.
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | Threshold value as unwrapped fraction. |
Returns the minimum and maximum number of validators that can be elected.
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The minimum number of validators that can be elected. |
| — | uint256 | The maximum number of validators that can be elected. |
Returns the list of validator groups eligible to elect validators.
Returns
| Name | Type | Description |
|---|---|---|
| — | address[] | The list of validator groups eligible to elect validators. |
Returns the epoch number at a block.
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | Current epoch number. |
Returns the epoch number at a block.
Parameters
| Name | Type | Description |
|---|---|---|
| blockNumber | uint256 | Block number where epoch number is calculated. |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | Epoch number. |
Returns the current epoch size in blocks.
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The current epoch size in blocks. |
Returns whether or not a group is eligible to receive votes.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool | Whether or not a group is eligible to receive votes. |
Returns the amount of rewards that voters for `group` are due at the end of an epoch.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The group to calculate epoch rewards for. |
| totalEpochRewards | uint256 | The total amount of rewards going to all voters. |
| groupScore | uint256 | The score of the group. |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The amount of rewards that voters for `group` are due at the end of an epoch. |
Returns the groups that `account` has voted for.
Parameters
| Name | Type | Description |
|---|---|---|
| account | address | The address of the account casting votes. |
Returns
| Name | Type | Description |
|---|---|---|
| — | address[] | The groups that `account` has voted for. |
Returns the number of votes that a group can receive.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The address of the group. |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The number of votes that a group can receive. |
Gets the parent seal bitmap from the header at the given block number.
Parameters
| Name | Type | Description |
|---|---|---|
| blockNumber | uint256 | Block number to retrieve. Must be within 4 epochs of the current number. |
Returns
| Name | Type | Description |
|---|---|---|
| — | bytes32 | Bitmap parent seal with set bits at indices corresponding to signing validators. |
Returns the pending votes made for `group`.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The address of the validator group. |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The pending votes made for `group`. |
Returns the pending votes for `group` made by `account`.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The address of the validator group. |
| account | address | The address of the voting account. |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The pending votes for `group` made by `account`. |
Returns the total votes received across all groups.
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The total votes received across all groups. |
Returns the total number of votes cast by an account.
Parameters
| Name | Type | Description |
|---|---|---|
| account | address | The address of the account. |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The total number of votes cast by an account. |
Returns list of all validator groups and the number of votes they've received.
Returns
| Name | Type | Description |
|---|---|---|
| groups | address[] | List of all validator groups |
| values | uint256[] | Number of votes each validator group received. |
Returns the total votes made for `group`.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The address of the validator group. |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The total votes made for `group`. |
Returns the total votes for `group` made by `account`.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The address of the validator group. |
| account | address | The address of the voting account. |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | The total votes for `group` made by `account`. |
Verifies the BLS signature on the header and returns the seal bitmap. The validator set used for verification is retrieved based on the parent hash field of the header. If the parent hash is not in the blockchain, verification fails.
Parameters
| Name | Type | Description |
|---|---|---|
| header | bytes | RLP encoded header |
Returns
| Name | Type | Description |
|---|---|---|
| — | bytes32 | Bitmap parent seal with set bits at indices correspoinding to signing validators. |
Returns the storage, major, minor, and patch version of the contract.
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | Storage version of the contract. |
| — | uint256 | Major version of the contract. |
| — | uint256 | Minor version of the contract. |
| — | uint256 | Patch version of the contract. |
Returns whether or not an account's votes for the specified group can be activated.
Parameters
| Name | Type | Description |
|---|---|---|
| account | address | The account with pending votes. |
| group | address | The validator group that `account` has pending votes for. |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool | Whether or not `account` has activatable votes for `group`. |
Computes hash of header.
Parameters
| Name | Type | Description |
|---|---|---|
| header | bytes | RLP encoded header |
Returns
| Name | Type | Description |
|---|---|---|
| — | bytes32 | Header hash. |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool |
Checks if the contract is currently blocked.
Returns
| Name | Type | Description |
|---|---|---|
| — | bool | Returns true if the contract is blocked, otherwise false. |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 |
Returns the minimum number of required signers for a given block number.
Parameters
| Name | Type | Description |
|---|---|---|
| blockNumber | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 |
Computes byzantine quorum from current validator set size
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | Byzantine quorum of validators. |
Gets the size of the current elected validator set.
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | Size of the current elected validator set. |
Gets the size of the validator set that must sign the given block number.
Parameters
| Name | Type | Description |
|---|---|---|
| blockNumber | uint256 | Block number to retrieve the validator set from. |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | Size of the validator set. |
Returns
| Name | Type | Description |
|---|---|---|
| — | address |
Returns
| Name | Type | Description |
|---|---|---|
| — | address |
Gets a validator address from the current validator set.
Parameters
| Name | Type | Description |
|---|---|---|
| index | uint256 | Index of requested validator in the validator set. |
Returns
| Name | Type | Description |
|---|---|---|
| — | address | Address of validator at the requested index. |
Gets a validator signer address from the current validator set.
Parameters
| Name | Type | Description |
|---|---|---|
| index | uint256 | Index of requested validator in the validator set. |
Returns
| Name | Type | Description |
|---|---|---|
| — | address | Address of validator signer at the requested index. |
Gets a validator signer address from the validator set at the given block number.
Parameters
| Name | Type | Description |
|---|---|---|
| index | uint256 | Index of requested validator in the validator set. |
| blockNumber | uint256 | Block number to retrieve the validator set from. |
Returns
| Name | Type | Description |
|---|---|---|
| — | address | Address of validator signer at the requested index. |
Write Functions
Converts `account`'s pending votes for `group` to active votes.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The validator group to vote for. |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool | True upon success. |
Converts `account`'s pending votes for `group` to active votes.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The validator group to vote for. |
| account | address | The validateor group account's pending votes to active votes |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool | True upon success. |
Distributes epoch rewards to voters for `group` in the form of active votes.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The group whose voters will receive rewards. |
| value | uint256 | The amount of rewards to distribute to voters for the group. |
| lesser | address | The group receiving fewer votes than `group` after the rewards are added. |
| greater | address | The group receiving more votes than `group` after the rewards are added. |
Reduces the total amount of `account`'s voting gold by `value` by iterating over all groups voted for by account.
Parameters
| Name | Type | Description |
|---|---|---|
| account | address | Address to revoke votes from. |
| value | uint256 | Maximum amount of votes to revoke. |
| lessers | address[] | The groups receiving fewer votes than the i'th `group`, or 0 if the i'th `group` has the fewest votes of any validator group. |
| greaters | address[] | The groups receivier more votes than the i'th `group`, or 0 if the i'th `group` has the most votes of any validator group. |
| indices | uint256[] | The indices of the i'th group in the account's voting list. |
Returns
| Name | Type | Description |
|---|---|---|
| — | uint256 | Number of votes successfully decremented. |
Used in place of the constructor to allow the contract to be upgradable via proxy.
Parameters
| Name | Type | Description |
|---|---|---|
| registryAddress | address | The address of the registry core smart contract. |
| minElectableValidators | uint256 | The minimum number of validators that can be elected. |
| maxElectableValidators | uint256 | |
| _maxNumGroupsVotedFor | uint256 | The maximum number of groups that an account can vote for at once. |
| _electabilityThreshold | uint256 | The minimum ratio of votes a group needs before its members can be elected. |
Marks a group eligible for electing validators.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The address of the validator group. |
| lesser | address | The address of the group that has received fewer votes than this group. |
| greater | address | The address of the group that has received more votes than this group. |
Marks a group ineligible for electing validators.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The address of the validator group. |
Revokes `value` active votes for `group`
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The validator group to revoke votes from. |
| value | uint256 | The number of votes to revoke. |
| lesser | address | The group receiving fewer votes than the group for which the vote was revoked, or 0 if that group has the fewest votes of any validator group. |
| greater | address | The group receiving more votes than the group for which the vote was revoked, or 0 if that group has the most votes of any validator group. |
| index | uint256 | The index of the group in the account's voting list. |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool | True upon success. |
Revokes all active votes for `group`
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The validator group to revoke votes from. |
| lesser | address | The group receiving fewer votes than the group for which the vote was revoked, or 0 if that group has the fewest votes of any validator group. |
| greater | address | The group receiving more votes than the group for which the vote was revoked, or 0 if that group has the most votes of any validator group. |
| index | uint256 | The index of the group in the account's voting list. |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool | True upon success. |
Revokes `value` pending votes for `group`
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The validator group to revoke votes from. |
| value | uint256 | The number of votes to revoke. |
| lesser | address | The group receiving fewer votes than the group for which the vote was revoked, or 0 if that group has the fewest votes of any validator group. |
| greater | address | The group receiving more votes than the group for which the vote was revoked, or 0 if that group has the most votes of any validator group. |
| index | uint256 | The index of the group in the account's voting list. |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool | True upon success. |
Allows to turn on/off voting over maxNumGroupsVotedFor. Once this is turned on and account voted for more than maxNumGroupsVotedFor, it is account's obligation to run updateTotalVotesByAccountForGroup once a day. If not run, voting power of account will not reflect rewards awarded.
Parameters
| Name | Type | Description |
|---|---|---|
| flag | bool | The on/off flag. |
Sets the address of the blocking contract.
Parameters
| Name | Type | Description |
|---|---|---|
| _blockedBy | address | The address of the contract that will determine if this contract is blocked. |
Sets the electability threshold.
Parameters
| Name | Type | Description |
|---|---|---|
| threshold | uint256 | Electability threshold as unwrapped Fraction. |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool | True upon success. |
Updates the minimum and maximum number of validators that can be elected.
Parameters
| Name | Type | Description |
|---|---|---|
| min | uint256 | The minimum number of validators that can be elected. |
| max | uint256 | The maximum number of validators that can be elected. |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool | True upon success. |
Updates the maximum number of groups an account can be voting for at once.
Parameters
| Name | Type | Description |
|---|---|---|
| _maxNumGroupsVotedFor | uint256 | The maximum number of groups an account can vote for. |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool | True upon success. |
Updates the address pointing to a Registry contract.
Parameters
| Name | Type | Description |
|---|---|---|
| registryAddress | address | The address of a registry contract for routing to other contracts. |
Parameters
| Name | Type | Description |
|---|---|---|
| newOwner | address |
Counts and caches account's votes for group.
Parameters
| Name | Type | Description |
|---|---|---|
| account | address | The address of the voting account. |
| group | address | The address of the validator group. |
Increments the number of total and pending votes for `group`.
Parameters
| Name | Type | Description |
|---|---|---|
| group | address | The validator group to vote for. |
| value | uint256 | The amount of gold to use to vote. |
| lesser | address | The group receiving fewer votes than `group`, or 0 if `group` has the fewest votes of any validator group. |
| greater | address | The group receiving more votes than `group`, or 0 if `group` has the most votes of any validator group. |
Returns
| Name | Type | Description |
|---|---|---|
| — | bool | True upon success. |
Events
| Name | Type | Indexed | Description |
|---|---|---|---|
| account | address | ✓ | |
| flag | bool |
| Name | Type | Indexed | Description |
|---|---|---|---|
| _blockedBy | address | ✓ |
| Name | Type | Indexed | Description |
|---|---|---|---|
| electabilityThreshold | uint256 |
| Name | Type | Indexed | Description |
|---|---|---|---|
| min | uint256 | ||
| max | uint256 |
| Name | Type | Indexed | Description |
|---|---|---|---|
| group | address | ✓ | |
| value | uint256 |
| Name | Type | Indexed | Description |
|---|---|---|---|
| maxNumGroupsVotedFor | uint256 |
| Name | Type | Indexed | Description |
|---|---|---|---|
| previousOwner | address | ✓ | |
| newOwner | address | ✓ |
| Name | Type | Indexed | Description |
|---|---|---|---|
| registryAddress | address | ✓ |
| Name | Type | Indexed | Description |
|---|---|---|---|
| account | address | ✓ | |
| group | address | ✓ | |
| value | uint256 | ||
| units | uint256 |
| Name | Type | Indexed | Description |
|---|---|---|---|
| group | address | ✓ |
| Name | Type | Indexed | Description |
|---|---|---|---|
| group | address | ✓ |
| Name | Type | Indexed | Description |
|---|---|---|---|
| account | address | ✓ | |
| group | address | ✓ | |
| value | uint256 |
| Name | Type | Indexed | Description |
|---|---|---|---|
| account | address | ✓ | |
| group | address | ✓ | |
| value | uint256 | ||
| units | uint256 |
| Name | Type | Indexed | Description |
|---|---|---|---|
| account | address | ✓ | |
| group | address | ✓ | |
| value | uint256 |