Skip to content

Commit

Permalink
rm redundant data in error
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz committed Sep 19, 2024
1 parent 51812b1 commit 8b91b62
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion contracts/contracts/interfaces/IMevCommitMiddleware.sol
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ interface IMevCommitMiddleware {
event SlashRecordCreated(address vault, address operator, uint256 blockNumber, uint256 numInitSlashableRegistered);

/// @notice Emmitted when a validator position is swapped as a part of slashing
event ValidatorPositionSwapped(address vault, address operator, uint256 oldPosition, uint256 newPosition);
event ValidatorPositionSwapped(address vault, address operator, uint256 newPosition);

error OnlySlashOracle(address slashOracle);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,9 @@ contract MevCommitMiddleware is IMevCommitMiddleware, MevCommitMiddlewareStorage
emit SlashRecordCreated(valRecord.vault, valRecord.operator, block.number, numSlashableRegistered);
}
// Swap about to be slashed pubkey with last slashable pubkey in valset.
uint256 oldPosition = _getPositionInValset(pubkey, valRecord.vault, valRecord.operator);
uint256 newPosition = slashRecord.numInitSlashableRegistered - slashRecord.numSlashed; // 1-indexed
_vaultAndOperatorToValset[valRecord.vault][valRecord.operator].swapWithPosition(pubkey, newPosition);
emit ValidatorPositionSwapped(valRecord.vault, valRecord.operator, oldPosition, newPosition);
emit ValidatorPositionSwapped(valRecord.vault, valRecord.operator, newPosition);

++slashRecord.numSlashed;
_slashValidator(blsPubkeys[i], infractionTimestamps[i], valRecord);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ contract MevCommitMiddlewareTest is Test {
event SlashPeriodSecondsSet(uint256 slashPeriodSeconds);
event SlashOracleSet(address slashOracle);
event SlashRecordCreated(address vault, address operator, uint256 blockNumber, uint256 numInitSlashableRegistered);
event ValidatorPositionSwapped(address vault, address operator, uint256 oldPosition, uint256 newPosition);
event ValidatorPositionSwapped(address vault, address operator, uint256 newPosition);

function setUp() public virtual {
networkRegistryMock = new RegistryMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,11 +967,11 @@ contract MevCommitMiddlewareTestCont is MevCommitMiddlewareTest {
vm.expectEmit(true, true, true, true);
emit SlashRecordCreated(address(vault2), operator1, block.number, 3);
vm.expectEmit(true, true, true, true);
emit ValidatorPositionSwapped(address(vault2), operator1, 1, 3);
emit ValidatorPositionSwapped(address(vault2), operator1, 3);
vm.expectEmit(true, true, true, true);
emit ValidatorSlashRequested(sampleValPubkey4, operator1, address(vault2), 0);
vm.expectEmit(true, true, true, true);
emit ValidatorPositionSwapped(address(vault2), operator1, 2, 2);
emit ValidatorPositionSwapped(address(vault2), operator1, 2);
vm.expectEmit(true, true, true, true);
emit ValidatorSlashRequested(sampleValPubkey5, operator1, address(vault2), 1);
mevCommitMiddleware.slashValidators(firstTwoBlsPubkeysFromVault2, timestamps);
Expand Down Expand Up @@ -1052,7 +1052,7 @@ contract MevCommitMiddlewareTestCont is MevCommitMiddlewareTest {
vm.expectEmit(true, true, true, true);
emit SlashRecordCreated(address(vault2), operator1, block.number, 2);
vm.expectEmit(true, true, true, true);
emit ValidatorPositionSwapped(address(vault2), operator1, 1, 2);
emit ValidatorPositionSwapped(address(vault2), operator1, 2);
vm.expectEmit(true, true, true, true);
emit ValidatorSlashRequested(sampleValPubkey6, operator1, address(vault2), 2);
mevCommitMiddleware.slashValidators(pubkeys, timestamps);
Expand All @@ -1062,6 +1062,8 @@ contract MevCommitMiddlewareTestCont is MevCommitMiddlewareTest {
assertEq(slashRecord.numInitSlashableRegistered, 2);
assertEq(slashRecord.numSlashed, 1);

assertFalse(mevCommitMiddleware.isValidatorOptedIn(sampleValPubkey6));

assertEq(mevCommitMiddleware.getPositionInValset(sampleValPubkey5, address(vault2), operator1), 1);
assertEq(mevCommitMiddleware.getPositionInValset(sampleValPubkey6, address(vault2), operator1), 2);
}
Expand Down

0 comments on commit 8b91b62

Please sign in to comment.