Skip to content

Commit

Permalink
chore: check return value of IEnumerableSet.add
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz committed Nov 7, 2024
1 parent eb1e2cd commit 9c39370
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
21 changes: 21 additions & 0 deletions contracts-abi/abi/MevCommitMiddleware.abi
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,27 @@
"name": "FailedInnerCall",
"inputs": []
},
{
"type": "error",
"name": "FailedToAddValidatorToValset",
"inputs": [
{
"name": "blsPubkey",
"type": "bytes",
"internalType": "bytes"
},
{
"name": "vault",
"type": "address",
"internalType": "address"
},
{
"name": "operator",
"type": "address",
"internalType": "address"
}
]
},
{
"type": "error",
"name": "FullRestakeDelegatorNotSupported",
Expand Down

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions contracts/contracts/interfaces/IMevCommitMiddleware.sol
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ interface IMevCommitMiddleware {

error VaultNotReadyToDeregister(address vault, uint256 currentTimestamp, uint256 deregRequestTimestamp);

error FailedToAddValidatorToValset(bytes blsPubkey, address vault, address operator);

error SlashAmountMustBeNonZero(address vault);

error InvalidVaultEpochDuration(address vault, uint256 vaultEpochDurationSec, uint256 slashPeriodSec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ contract MevCommitMiddleware is IMevCommitMiddleware, MevCommitMiddlewareStorage
vault: vault,
operator: operator
});
_vaultAndOperatorToValset[vault][operator].add(blsPubkey);
bool success = _vaultAndOperatorToValset[vault][operator].add(blsPubkey);
require(success, FailedToAddValidatorToValset(blsPubkey, vault, operator)); // This error would indicate state corruption.
uint256 position = _getPositionInValset(blsPubkey, vault, operator);
emit ValRecordAdded(blsPubkey, operator, vault, position);
}
Expand Down

0 comments on commit 9c39370

Please sign in to comment.