Skip to content

Commit

Permalink
Merge branch 'slashing-magnitudes-fixes' into delegate-shares-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenmikem authored Feb 5, 2025
2 parents bfa0c7f + 38f5faa commit c5d71cf
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/contracts/core/DelegationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ contract DelegationManager is
sharesToDecrease: operatorSharesSlashed
});

// Emit event for operator shares being slashed
emit OperatorSharesSlashed(operator, strategy, totalDepositSharesToBurn);

IShareManager shareManager = _getShareManager(strategy);
// NOTE: for beaconChainETHStrategy, increased burnable shares currently have no mechanism for burning
shareManager.increaseBurnableShares(strategy, totalDepositSharesToBurn);
Expand Down
3 changes: 3 additions & 0 deletions src/contracts/interfaces/IDelegationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ interface IDelegationManagerEvents is IDelegationManagerTypes {

/// @notice Emitted when a queued withdrawal is completed
event SlashingWithdrawalCompleted(bytes32 withdrawalRoot);

/// @notice Emitted whenever an operator's shares are slashed for a given strategy
event OperatorSharesSlashed(address indexed operator, IStrategy strategy, uint256 totalSlashedShares);
}

/**
Expand Down
44 changes: 44 additions & 0 deletions src/test/unit/DelegationUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6622,6 +6622,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
sharesToBurn: sharesToBurn
})
);

// Assert OperatorSharesSlashed event was emitted with correct params
cheats.expectEmit(true, true, true, true, address(delegationManager));
emit OperatorSharesSlashed(operator, strategyMock, sharesToBurn);

cheats.prank(address(allocationManagerMock));
delegationManager.slashOperatorShares({
operator: operator,
Expand Down Expand Up @@ -6708,6 +6713,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
sharesToBurn: sharesToBurn
})
);

// Assert OperatorSharesSlashed event was emitted with correct params
cheats.expectEmit(true, true, true, true, address(delegationManager));
emit OperatorSharesSlashed(operator, strategyMock, sharesToBurn);

cheats.prank(address(allocationManagerMock));
delegationManager.slashOperatorShares({
operator: operator,
Expand Down Expand Up @@ -6790,6 +6800,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
sharesToBurn: sharesToBurn
})
);

// Assert OperatorSharesSlashed event was emitted with correct params
cheats.expectEmit(true, true, true, true, address(delegationManager));
emit OperatorSharesSlashed(operator, strategyMock, sharesToBurn);

cheats.prank(address(allocationManagerMock));
delegationManager.slashOperatorShares({
operator: operator,
Expand Down Expand Up @@ -6887,6 +6902,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
sharesToBurn: sharesToBurn
})
);

// Assert OperatorSharesSlashed event was emitted with correct params
cheats.expectEmit(true, true, true, true, address(delegationManager));
emit OperatorSharesSlashed(operator, strategyMock, sharesToBurn);

cheats.prank(address(allocationManagerMock));
delegationManager.slashOperatorShares({
operator: operator,
Expand Down Expand Up @@ -6971,6 +6991,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
sharesToBurn: sharesToBurn
})
);

// Assert OperatorSharesSlashed event was emitted with correct params
cheats.expectEmit(true, true, true, true, address(delegationManager));
emit OperatorSharesSlashed(operator, strategyMock, sharesToBurn);

cheats.prank(address(allocationManagerMock));
delegationManager.slashOperatorShares({
operator: operator,
Expand Down Expand Up @@ -7025,6 +7050,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
sharesToBurn: sharesToBurn
})
);

// Assert OperatorSharesSlashed event was emitted with correct params
cheats.expectEmit(true, true, true, true, address(delegationManager));
emit OperatorSharesSlashed(operator, strategyMock, sharesToBurn);

cheats.prank(address(allocationManagerMock));
delegationManager.slashOperatorShares({
operator: operator,
Expand Down Expand Up @@ -7129,6 +7159,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
sharesToBurn: 0
})
);

// Assert OperatorSharesSlashed event was emitted with correct params
cheats.expectEmit(true, true, true, true, address(delegationManager));
emit OperatorSharesSlashed(operator, strategyMock, 0);

cheats.prank(address(allocationManagerMock));
delegationManager.slashOperatorShares({
operator: operator,
Expand Down Expand Up @@ -7205,6 +7240,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
_setOperatorMagnitude(operator, beaconChainETHStrategy, newMagnitude);
cheats.expectEmit(true, true, true, true, address(delegationManager));
emit OperatorSharesDecreased(operator, address(0), beaconChainETHStrategy, sharesToDecrease);

// Assert OperatorSharesSlashed event was emitted with correct params
cheats.expectEmit(true, true, true, true, address(delegationManager));
emit OperatorSharesSlashed(operator, beaconChainETHStrategy, sharesToDecrease);

cheats.prank(address(allocationManagerMock));
delegationManager.slashOperatorShares({
operator: operator,
Expand Down Expand Up @@ -7254,6 +7294,10 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
newOperatorMagnitude -= slashMagnitude;
_setOperatorMagnitude(defaultOperator, strategyMock, newOperatorMagnitude);

// Assert OperatorSharesSlashed event was emitted with correct params
cheats.expectEmit(true, true, true, true, address(delegationManager));
emit OperatorSharesSlashed(defaultOperator, strategyMock, 44440000449046438731194137360795695);

cheats.prank(address(allocationManagerMock));
delegationManager.slashOperatorShares(
defaultOperator, strategyMock, newOperatorMagnitude + slashMagnitude, newOperatorMagnitude
Expand Down

0 comments on commit c5d71cf

Please sign in to comment.