-
Notifications
You must be signed in to change notification settings - Fork 11.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a governor module to protect against late quorum #2973
Add a governor module to protect against late quorum #2973
Conversation
Note: if proposal details become packed as part of a breaking release (proposed in #2962), commit #ff0d213 should be reverted for gas optimization. |
c6c2a62
to
718df6b
Compare
@@ -110,24 +110,34 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor { | |||
* @dev See {IGovernor-state}. | |||
*/ | |||
function state(uint256 proposalId) public view virtual override returns (ProposalState) { | |||
ProposalCore memory proposal = _proposals[proposalId]; | |||
ProposalCore storage proposal = _proposals[proposalId]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this is more gas effective in the current format, where proposal is not packed and uses 3 slots. If proposal are packed in an upcoming breaking change, then this should be changed back to memory.
) internal virtual override returns (uint256) { | ||
uint256 result = super._castVote(proposalId, account, support, reason); | ||
|
||
Timers.BlockNumber storage extension = _extendedVoteEnd[proposalId]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're using three different names for essentially the same concept: extension, extended vote end, extended deadline. And then extension also refers to the number of blocks that are added.
I wish we could find a more unified naming scheme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried renaming variables and contract to make everything clearer. Let me know what you think
Very good work! |
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This PR adds a new governor module that fixes an issue described by @Arachnid.
In cases where voters' participation is low, and quorum is far from being reached, voters might not be incentivized to participate for a proposal that they don't think will reach the quorum anyway. This would allow a "whale" voter to take over the vote at the end of the voting period. The whale would have enough tokens to reach the quorum and impose its result, leaving no time for voters to react.
This module ensures a minimal voting delay after quorum is reached. If quorum is reached late, then the proposal deadline will be extended to ensure this minimal post-quorum voting duration.
PR Checklist