Skip to content

Commit

Permalink
VoteWeighter MAX_QUORUM_COUNT constant
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0aa0 committed Oct 12, 2023
1 parent c4dce15 commit 42f57f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/contracts/middleware/VoteWeigherBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ contract VoteWeigherBase is VoteWeigherBaseStorage {
StrategyAndWeightingMultiplier[] memory _strategiesConsideredAndMultipliers
) internal {
uint16 quorumCountMem = quorumCount;
require(quorumCountMem < 192, "VoteWeigherBase._createQuorum: number of quorums cannot 192");
require(quorumCountMem < MAX_QUORUM_COUNT, "VoteWeigherBase._createQuorum: number of quorums cannot exceed MAX_QUORUM_COUNT");
uint8 quorumNumber = uint8(quorumCountMem);
// increment quorumCount
quorumCount = quorumCountMem + 1;
Expand Down
2 changes: 2 additions & 0 deletions src/contracts/middleware/VoteWeigherBaseStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ abstract contract VoteWeigherBaseStorage is Initializable, IVoteWeigher {
uint8 public constant MAX_WEIGHING_FUNCTION_LENGTH = 32;
/// @notice Constant used as a divisor in dealing with BIPS amounts.
uint256 internal constant MAX_BIPS = 10000;
/// @notice The maximum number of quorums that the VoteWeigher is considering.
uint8 public constant MAX_QUORUM_COUNT = 192;

/// @notice The address of the Delegation contract for EigenLayer.
IDelegationManager public immutable delegation;
Expand Down
9 changes: 5 additions & 4 deletions src/test/unit/VoteWeigherBaseUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,17 @@ contract VoteWeigherBaseUnitTests is Test {
voteWeigher.createQuorum(strategiesAndWeightingMultipliers);
}

function testCreateQuorum_MoreThan192Quorums_Reverts() public {
function testCreateQuorum_MoreThanMaxQuorums_Reverts() public {
IVoteWeigher.StrategyAndWeightingMultiplier[] memory strategiesAndWeightingMultipliers = _defaultStrategiesAndWeightingMultipliers();
uint256 maxQuorums = voteWeigher.MAX_QUORUM_COUNT();

cheats.startPrank(serviceManagerOwner);
for (uint i = 0; i < 192; i++) {
for (uint i = 0; i < maxQuorums; i++) {
voteWeigher.createQuorum(strategiesAndWeightingMultipliers);
}
assertEq(voteWeigher.quorumCount(), 192);
assertEq(voteWeigher.quorumCount(), maxQuorums);

cheats.expectRevert("VoteWeigherBase._createQuorum: number of quorums cannot 192");
cheats.expectRevert("VoteWeigherBase._createQuorum: number of quorums cannot exceed MAX_QUORUM_COUNT");
voteWeigher.createQuorum(strategiesAndWeightingMultipliers);
}

Expand Down

0 comments on commit 42f57f9

Please sign in to comment.