Skip to content

Commit

Permalink
Remove _validateQuorumNumerator in favor of special case
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmichalis committed Feb 11, 2025
1 parent 4abc00b commit 9bd755f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ abstract contract GovernorVotesQuorumFraction is GovernorVotes {
* - New numerator must be smaller or equal to the denominator.
*/
function updateQuorumNumerator(uint256 newQuorumNumerator) external virtual onlyGovernance {
_validateQuorumNumerator(newQuorumNumerator);
_updateQuorumNumerator(newQuorumNumerator);
}

Expand All @@ -118,9 +117,4 @@ abstract contract GovernorVotesQuorumFraction is GovernorVotes {

emit QuorumNumeratorUpdated(oldQuorumNumerator, newQuorumNumerator);
}

/**
* @dev Run additional optional quorum numerator validation in proposals.
*/
function _validateQuorumNumerator(uint256 newQuorumNumerator) internal view virtual {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,16 @@ abstract contract GovernorVotesSuperQuorumFraction is GovernorVotesQuorumFractio
}

/**
* @dev Overrides the quorum numerator validation in proposals to ensure the super
* @dev Overrides {GovernorVotesQuorumFraction._updateQuorumNumerator} to ensure the super
* quorum numerator is bigger than the quorum numerator.
*/
function _validateQuorumNumerator(uint256 newQuorumNumerator) internal view virtual override {
function _updateQuorumNumerator(uint256 newQuorumNumerator) internal virtual override {
uint256 superQuorumNumerator_ = superQuorumNumerator();
if (newQuorumNumerator >= superQuorumNumerator_) {
// Ignoring a super quorum of 0as it is the initial value when the contract is deployed.
if (superQuorumNumerator_ != 0 && newQuorumNumerator >= superQuorumNumerator_) {
revert GovernorInvalidQuorumTooLarge(newQuorumNumerator, superQuorumNumerator_);
}
super._updateQuorumNumerator(newQuorumNumerator);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ contract GovernorHandler is GovernorVotesSuperQuorumFractionMock {
}

function updateQuorumNumerator(uint256 newQuorumNumerator) external override {
_validateQuorumNumerator(newQuorumNumerator);
_updateQuorumNumerator(newQuorumNumerator);
}
}
Expand Down

0 comments on commit 9bd755f

Please sign in to comment.