[RFC-191]: EVM-740 - Move distribute rewards to first block in epoch #1735
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
ValidatorSet
contract on supernet is used as a wrapper around staked tokens by validators onL2
. For governance, it is used as a voting token as well, which makes sense, since we are only allowing validators to propose and vote for governance proposals.But, to be able to use
ValidatorSet
as vote token in governance, we needed to change it to implementERC20VotesUpgradable
implementation, which changed how the contract checkpoints its total supply at a certain point in time, and how it returnstotalSupplyAt
, which is used byRewardPool
contract to accurately distribute rewards.Now
totalSupplyAt
has a check which prevents calling it for the last checkpointed total supply, if they happen in the same block, and because of that, reward distribution failed.This PR moves reward distribution to the first block of epoch. So when an epoch completes, and gets committed (which will checkpoint total supply at
ValidatorSet
contract), the new epoch will start, and in the first block of new epoch, proposer will add the distribute rewards transaction for the previously completed epoch.This has three benefits:
ValidatorSet
as voting token for governance.IMPORTANT NOTE:
Rewards will only be distributed in the first block of an epoch if
governance
fork is enabled. If it is not enabled, rewards will be distributed old way, at epoch ending block.Changes include
Checklist
Testing