diff --git a/contracts/contracts/interfaces/IMevCommitMiddleware.sol b/contracts/contracts/interfaces/IMevCommitMiddleware.sol index 75e0e4f2f..a785c919e 100644 --- a/contracts/contracts/interfaces/IMevCommitMiddleware.sol +++ b/contracts/contracts/interfaces/IMevCommitMiddleware.sol @@ -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); diff --git a/contracts/contracts/validator-registry/middleware/MevCommitMiddleware.sol b/contracts/contracts/validator-registry/middleware/MevCommitMiddleware.sol index 23c214bba..e633f92d1 100644 --- a/contracts/contracts/validator-registry/middleware/MevCommitMiddleware.sol +++ b/contracts/contracts/validator-registry/middleware/MevCommitMiddleware.sol @@ -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); diff --git a/contracts/test/validator-registry/middleware/MevCommitMiddlewareTest.sol b/contracts/test/validator-registry/middleware/MevCommitMiddlewareTest.sol index 9597db01a..be23aa86c 100644 --- a/contracts/test/validator-registry/middleware/MevCommitMiddlewareTest.sol +++ b/contracts/test/validator-registry/middleware/MevCommitMiddlewareTest.sol @@ -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(); diff --git a/contracts/test/validator-registry/middleware/MevCommitMiddlewareTestCont.sol b/contracts/test/validator-registry/middleware/MevCommitMiddlewareTestCont.sol index 9d58bbc85..e59058ede 100644 --- a/contracts/test/validator-registry/middleware/MevCommitMiddlewareTestCont.sol +++ b/contracts/test/validator-registry/middleware/MevCommitMiddlewareTestCont.sol @@ -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); @@ -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); @@ -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); }