Skip to content

Commit f490b03

Browse files
committed
wip
1 parent ef512e8 commit f490b03

File tree

5 files changed

+53
-35
lines changed

5 files changed

+53
-35
lines changed

src/interfaces/IInstantSlasher.sol

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ import {ISlasher} from "./ISlasher.sol";
1010
/// @dev Extends base interfaces to provide access controlled slashing functionality
1111
interface IInstantSlasher is ISlasher {
1212
/// @notice Immediately executes a slashing request
13-
/// @param _slashingParams Parameters defining the slashing request including operator and amount
13+
/// @param params Parameters defining the slashing request including operator and amount
1414
/// @dev Can only be called by the authorized slasher
1515
function fulfillSlashingRequest(
16-
IAllocationManager.SlashingParams memory _slashingParams
16+
IAllocationManager.SlashingParams memory params
17+
) external;
18+
19+
/// @notice Immediately executes a slashing request and burns or redistributes shares
20+
/// @param params Parameters defining the slashing request including operator and amount
21+
/// @dev Can only be called by the authorized slasher
22+
function fulfillSlashingRequestAndBurnOrRedistribute(
23+
IAllocationManager.SlashingParams memory params
1724
) external;
1825
}

src/interfaces/IVetoableSlasher.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,11 @@ interface IVetoableSlasher is
8383
function fulfillSlashingRequest(
8484
uint256 slashId
8585
) external;
86+
87+
/// @notice Executes a slashing request after the veto period has passed and burns or redistributes shares
88+
/// @param slashId The ID of the slashing request to fulfill
89+
/// @dev Can only be called by the authorized slasher after the veto period
90+
function fulfillSlashingRequestAndBurnOrRedistribute(
91+
uint256 slashId
92+
) external;
8693
}

src/slashers/InstantSlasher.sol

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@ contract InstantSlasher is IInstantSlasher, SlasherBase {
2222

2323
/// @inheritdoc IInstantSlasher
2424
function fulfillSlashingRequest(
25-
IAllocationManager.SlashingParams calldata _slashingParams
25+
IAllocationManager.SlashingParams calldata params
2626
) external virtual override(IInstantSlasher) onlySlasher {
27-
_fulfillSlashingRequest(_slashingParams);
28-
_updateOperatorStakeWeights(_slashingParams.operator);
27+
_fulfillSlashingRequest(params);
28+
}
29+
30+
/// @inheritdoc IInstantSlasher
31+
function fulfillSlashingRequestAndBurnOrRedistribute(
32+
IAllocationManager.SlashingParams calldata params
33+
) external virtual override onlySlasher {
34+
_fulfillSlashingRequestAndBurnOrRedistribute(params);
2935
}
3036
}

src/slashers/VetoableSlasher.sol

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,18 @@ contract VetoableSlasher is IVetoableSlasher, SlasherBase {
6060
function fulfillSlashingRequest(
6161
uint256 slashId
6262
) external virtual override onlySlasher {
63-
_fulfillSlashingRequestAndMarkAsCompleted(slashId);
63+
IVetoableSlasherTypes.VetoableSlashingRequest storage request = slashingRequests[slashId];
64+
_markAsCompleted(request);
65+
_fulfillSlashingRequest(request.params);
66+
}
67+
68+
/// @inheritdoc IVetoableSlasher
69+
function fulfillSlashingRequestAndBurnOrRedistribute(
70+
uint256 slashId
71+
) external virtual override onlySlasher {
72+
IVetoableSlasherTypes.VetoableSlashingRequest storage request = slashingRequests[slashId];
73+
_markAsCompleted(request);
74+
_fulfillSlashingRequestAndBurnOrRedistribute(request.params);
6475
}
6576

6677
/// @notice Internal function to create and store a new slashing request
@@ -104,22 +115,18 @@ contract VetoableSlasher is IVetoableSlasher, SlasherBase {
104115
emit SlashingRequestCancelled(slashId);
105116
}
106117

107-
/// @notice Internal function to fulfill a slashing request and mark it as completed
108-
/// @param slashId The ID of the slashing request to fulfill
109-
function _fulfillSlashingRequestAndMarkAsCompleted(
110-
uint256 slashId
118+
/// @notice Internal function to mark a slashing request as completed
119+
/// @param request The request to mark as completed
120+
function _markAsCompleted(
121+
IVetoableSlasherTypes.VetoableSlashingRequest storage request
111122
) internal virtual {
112-
IVetoableSlasherTypes.VetoableSlashingRequest storage request = slashingRequests[slashId];
113123
require(block.number >= request.requestBlock + vetoWindowBlocks, VetoPeriodNotPassed());
114124
require(
115125
request.status == IVetoableSlasherTypes.SlashingStatus.Requested,
116126
SlashingRequestIsCancelled()
117127
);
118128

119129
request.status = IVetoableSlasherTypes.SlashingStatus.Completed;
120-
121-
_fulfillSlashingRequest(request.params);
122-
_updateOperatorStakeWeights(request.params.operator);
123130
}
124131

125132
/// @notice Internal function to verify if an account is the veto committee

src/slashers/base/SlasherBase.sol

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,23 @@ abstract contract SlasherBase is SlasherStorage {
3232
) SlasherStorage(_allocationManager, _strategyManager, _registryCoordinator, _slasher) {}
3333

3434
/// @notice Internal function to execute a slashing request
35-
/// @param _params Parameters defining the slashing request including operator, strategies, and amounts
35+
/// @param params Parameters defining the slashing request including operator, strategies, and amounts
3636
/// @dev Calls AllocationManager.slashOperator to perform the actual slashing
3737
function _fulfillSlashingRequest(
38-
IAllocationManager.SlashingParams memory _params
38+
IAllocationManager.SlashingParams memory params
3939
) internal virtual returns (uint256 slashId) {
4040
(slashId,) = allocationManager.slashOperator({
4141
avs: slashingRegistryCoordinator.avs(),
42-
params: _params
42+
params: params
4343
});
4444
emit OperatorSlashed(
45-
slashId,
46-
_params.operator,
47-
_params.operatorSetId,
48-
_params.wadsToSlash,
49-
_params.description
45+
slashId, params.operator, params.operatorSetId, params.wadsToSlash, params.description
5046
);
47+
48+
// Update operator stake weights
49+
address[] memory operators = new address[](1);
50+
operators[0] = params.operator;
51+
slashingRegistryCoordinator.updateOperators(operators);
5152
}
5253

5354
/// @notice Internal function to optionally fulfill burn or redistribution instead of waiting for cron job
@@ -60,10 +61,10 @@ abstract contract SlasherBase is SlasherStorage {
6061

6162
/// @notice Internal function to fulfill a slashing request and burn or redistribute shares
6263
function _fulfillSlashingRequestAndBurnOrRedistribute(
63-
IAllocationManager.SlashingParams memory _params
64+
IAllocationManager.SlashingParams memory params
6465
) internal virtual returns (uint256 slashId) {
65-
slashId = _fulfillSlashingRequest(_params);
66-
_fulfillBurnOrRedistribution(_params.operatorSetId, slashId);
66+
slashId = _fulfillSlashingRequest(params);
67+
_fulfillBurnOrRedistribution(params.operatorSetId, slashId);
6768
}
6869

6970
/// @notice Internal function to verify if an account is the authorized slasher
@@ -74,14 +75,4 @@ abstract contract SlasherBase is SlasherStorage {
7475
) internal view virtual {
7576
require(account == slasher, OnlySlasher());
7677
}
77-
78-
/// @notice Internal function to update stake weights for the given operator
79-
/// @param operator The operator to update
80-
function _updateOperatorStakeWeights(
81-
address operator
82-
) internal virtual {
83-
address[] memory operators = new address[](1);
84-
operators[0] = operator;
85-
slashingRegistryCoordinator.updateOperators(operators);
86-
}
8778
}

0 commit comments

Comments
 (0)