Skip to content

Commit

Permalink
rename now → clock
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Jan 5, 2023
1 parent 28be477 commit 937a4ed
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions EIPS/eip-5805.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Both timestamps, block numbers, and other possible modes use the same external i

### Methods

#### now
#### clock

This function returns the current timepoint. It could be `block.timestamp`, `block.number` (or any other **non-decreasing** function) depending on the mode the contract is operating on.

Expand All @@ -61,7 +61,7 @@ This function returns the current timepoint. It could be `block.timestamp`, `blo
This function is thus optional, and its absence should be considered as a marker of the contract operating using block number. (This makes this EIP compatible with pre-existing voting contracts)

```yaml
- name: now
- name: clock
type: function
stateMutability: view
inputs: []
Expand Down Expand Up @@ -92,7 +92,7 @@ This function MUST be implemented

#### getPastVotes

This function returns the historical voting weight of an account. This corresponds to all the voting power delegated to it at a specific timepoint. The timepoint parameter should match the operating mode of the contract. This function SHOULD only serve past checkpoints that are immutable. Calling this function with a timepoint that is greater or equal to `now()` SHOULD revert. For any timepoint that is strictly smaller than `now()`, the value returned by `getPastVotes` should be constant.
This function returns the historical voting weight of an account. This corresponds to all the voting power delegated to it at a specific timepoint. The timepoint parameter should match the operating mode of the contract. This function SHOULD only serve past checkpoints that are immutable. Calling this function with a timepoint that is greater or equal to `clock()` SHOULD revert. For any timepoint that is strictly smaller than `clock()`, the value returned by `getPastVotes` should be constant.

As tokens delegated to `address(0)` should not be counted/snapshoted, `getPastVotes(0,x)` SHOULD always return `0` (for all values of `x`).

Expand Down Expand Up @@ -345,7 +345,7 @@ interface IERC_XXXX {
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);
function now() external view returns (uint256);
function clock() external view returns (uint256);
function getVotes(address account) external view returns (uint256);
function getPastVotes(address account, uint256 timepoint) external view returns (uint256);
function delegates(address account) external view returns (address);
Expand All @@ -358,11 +358,11 @@ interface IERC_XXXX {

### Expected properties

- The `now()` function MUST be non-decreasing.
- For all timepoints `t < now()`, `getVotes(address(0))` and `getPastVotes(address(0), t)` SHOULD return 0.
- The `clock()` function MUST be non-decreasing.
- For all timepoints `t < clock()`, `getVotes(address(0))` and `getPastVotes(address(0), t)` SHOULD return 0.
- For all accounts `a != 0`, `getVotes(a)` SHOULD be the sum of the "balances" of all the accounts that delegate to `a`.
- For all accounts `a != 0` and all timestamp `t < now()`, `getPastVotes(a, t)` SHOULD be the sum of the "balances" of all the accounts that delegated to `a` when `now()` overtook `t`.
- For all accounts `a`, `getPastVotes(a, t)` MUST be constant after `t < now()` is reached.
- For all accounts `a != 0` and all timestamp `t < clock()`, `getPastVotes(a, t)` SHOULD be the sum of the "balances" of all the accounts that delegated to `a` when `clock()` overtook `t`.
- For all accounts `a`, `getPastVotes(a, t)` MUST be constant after `t < clock()` is reached.
- For all accounts `a`, the action of changing the delegate from `b` to `c` MUST not increase the current voting power of `b` (`getVotes(b)`) and MUST not decrease the current voting power of `c` (`getVotes(c)`).

## Rationale
Expand All @@ -381,13 +381,13 @@ EIP-712 typed messages are included because of its widespread adoption in many w

Compound and OpenZeppelin already provide implementations of voting tokens. The delegation-related methods are shared between the two implementations and this EIP. For the vote lookup, this EIP uses OpenZeppelin's implementation (with return type uint256) as Compound's implementation causes significant restrictions of the acceptable values (return type is uint96).

Both implementations use `block.number` for their checkpoints and do not implement the `now()` method, which is compatible with this EIP.
Both implementations use `block.number` for their checkpoints and do not implement the `clock()` method, which is compatible with this EIP.

Existing governors, that are currently compatible with OpenZeppelin's implementation will be compatible with the "block number mode" of this EIP.

## Security Considerations

Before doing a lookup, one should check the return value of `now()` and make sure that the parameters of the lookup are consistent. Performing a lookup using a timestamp argument on a contract that uses block numbers will very likely cause a revert. On the other end, performing a lookup using a block number argument on a contract that uses timestamps will likely return 0.
Before doing a lookup, one should check the return value of `clock()` and make sure that the parameters of the lookup are consistent. Performing a lookup using a timestamp argument on a contract that uses block numbers will very likely cause a revert. On the other end, performing a lookup using a block number argument on a contract that uses timestamps will likely return 0.

Though the signer of a `Delegation` may have a certain party in mind to submit their transaction, another party can always front-run this transaction and call `delegateBySig` before the intended party. The result is the same for the `Delegation` signer, however.

Expand Down

0 comments on commit 937a4ed

Please sign in to comment.