Skip to content

Commit

Permalink
fix: overflow (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0aa0 authored Jul 26, 2024
1 parent 3b96caf commit 17b1f44
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/EjectionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ contract EjectionManager is IEjectionManager, OwnableUpgradeable{
*/
function amountEjectableForQuorum(uint8 _quorumNumber) public view returns (uint256) {
uint256 cutoffTime = block.timestamp - quorumEjectionParams[_quorumNumber].rateLimitWindow;
uint256 totalEjectable = quorumEjectionParams[_quorumNumber].ejectableStakePercent * stakeRegistry.getCurrentTotalStake(_quorumNumber) / BIPS_DENOMINATOR;
uint256 totalEjectable = uint256(quorumEjectionParams[_quorumNumber].ejectableStakePercent) * uint256(stakeRegistry.getCurrentTotalStake(_quorumNumber)) / uint256(BIPS_DENOMINATOR);
uint256 totalEjected;
uint256 i;
if (stakeEjectedForQuorum[_quorumNumber].length == 0) {
Expand Down
12 changes: 12 additions & 0 deletions test/unit/EjectionManagerUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,18 @@ contract EjectionManagerUnitTests is MockAVSDeployer {
ejectionManager.setEjector(address(0), true);
}

function test_Overflow_Regression() public {
cheats.prank(registryCoordinatorOwner);
ejectionManager.setQuorumEjectionParams(0, IEjectionManager.QuorumEjectionParams({
rateLimitWindow: 7 days,
ejectableStakePercent: 9999
}));

stakeRegistry.recordTotalStakeUpdate(1, 2_000_000_000 * 1 ether);

ejectionManager.amountEjectableForQuorum(1);
}

function _registerOperaters(uint8 numOperators, uint96 stake) internal {
for (uint i = 0; i < numOperators; i++) {
BN254.G1Point memory pubKey = BN254.hashToG1(keccak256(abi.encodePacked(i)));
Expand Down

0 comments on commit 17b1f44

Please sign in to comment.