Skip to content

Commit 3871d2e

Browse files
authored
chore: address redistribution nits (#1420)
**Motivation:** Redistribution nits from @nadir-akhtar **Modifications:** - Reduce diff - Style updates - Clearer comments **Result:** Cleaner code
1 parent c020f15 commit 3871d2e

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

src/contracts/core/AllocationManager.sol

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ contract AllocationManager is
214214
for (uint256 i = 0; i < params.operatorSetIds.length; i++) {
215215
// Check the operator set exists and the operator is registered to it
216216
OperatorSet memory operatorSet = OperatorSet(params.avs, params.operatorSetIds[i]);
217-
require(_operatorSets[operatorSet.avs].contains(operatorSet.id), InvalidOperatorSet());
217+
require(_operatorSets[params.avs].contains(operatorSet.id), InvalidOperatorSet());
218218
require(registrationStatus[params.operator][operatorSet.key()].registered, NotMemberOfSet());
219219

220220
// Remove operator from operator set
@@ -287,7 +287,7 @@ contract AllocationManager is
287287
IStrategy[] calldata strategies
288288
) external checkCanCall(avs) {
289289
OperatorSet memory operatorSet = OperatorSet(avs, operatorSetId);
290-
require(_operatorSets[operatorSet.avs].contains(operatorSet.id), InvalidOperatorSet());
290+
require(_operatorSets[avs].contains(operatorSet.id), InvalidOperatorSet());
291291
for (uint256 i = 0; i < strategies.length; i++) {
292292
_addStrategyToOperatorSet(
293293
operatorSet, strategies[i], isRedistributingOperatorSet(OperatorSet(avs, operatorSetId))
@@ -302,7 +302,7 @@ contract AllocationManager is
302302
IStrategy[] calldata strategies
303303
) external checkCanCall(avs) {
304304
OperatorSet memory operatorSet = OperatorSet(avs, operatorSetId);
305-
require(_operatorSets[operatorSet.avs].contains(operatorSet.id), InvalidOperatorSet());
305+
require(_operatorSets[avs].contains(operatorSet.id), InvalidOperatorSet());
306306
bytes32 operatorSetKey = operatorSet.key();
307307
for (uint256 i = 0; i < strategies.length; i++) {
308308
require(_operatorSetStrategies[operatorSetKey].remove(address(strategies[i])), StrategyNotInOperatorSet());
@@ -315,6 +315,14 @@ contract AllocationManager is
315315
* INTERNAL FUNCTIONS
316316
*
317317
*/
318+
319+
/**
320+
* @dev Slashes an operator.
321+
* @param params The slashing parameters. See IAllocationManager.sol#slashOperator for specifics.
322+
* @param operatorSet The operator set from which the operator is being slashed.
323+
* @return slashId The operator set's unique identifier for the slash.
324+
* @return shares The number of shares to be burned or redistributed for each strategy that was slashed.
325+
*/
318326
function _slashOperator(
319327
SlashingParams calldata params,
320328
OperatorSet memory operatorSet
@@ -323,7 +331,7 @@ contract AllocationManager is
323331
shares = new uint256[](params.strategies.length);
324332

325333
// Increment the slash count for the operator set.
326-
slashId = ++_slashCount[operatorSet.key()];
334+
slashId = ++_slashIds[operatorSet.key()];
327335

328336
// For each strategy in the operator set, slash any existing allocation
329337
for (uint256 i = 0; i < params.strategies.length; i++) {
@@ -1001,15 +1009,17 @@ contract AllocationManager is
10011009
function getSlashCount(
10021010
OperatorSet memory operatorSet
10031011
) external view returns (uint256) {
1004-
return _slashCount[operatorSet.key()];
1012+
return _slashIds[operatorSet.key()];
10051013
}
10061014

10071015
/// @inheritdoc IAllocationManager
10081016
function isOperatorRedistributable(
10091017
address operator
10101018
) external view returns (bool) {
10111019
// Get the registered and allocated sets for the operator.
1012-
// We get both sets, since upon deregistration the operator is removed from RegisteredSets, but is still allocated.
1020+
// We get both sets, since:
1021+
// - Upon registration the operator allocation will be pending to a redistributing operator set, and as such not yet in RegisteredSets.
1022+
// - Upon deregistration the operator is removed from RegisteredSets, but is still allocated.
10131023
OperatorSet[] memory registeredSets = getRegisteredSets(operator);
10141024
OperatorSet[] memory allocatedSets = getAllocatedSets(operator);
10151025

src/contracts/core/AllocationManagerStorage.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,12 @@ abstract contract AllocationManagerStorage is IAllocationManager {
101101
/// @notice Returns the number of slashes for a given operator set.
102102
/// @dev This is also used as a unique slash identifier.
103103
/// @dev This tracks the number of slashes after the redistribution release.
104-
mapping(bytes32 operatorSetKey => uint256 slashId) internal _slashCount;
104+
mapping(bytes32 operatorSetKey => uint256 slashId) internal _slashIds;
105105

106106
/// @notice Returns the address where slashed funds will be sent for a given operator set.
107107
/// @dev For redistributing Operator Sets, returns the configured redistribution address set during Operator Set creation.
108-
/// For non-redistributing or non-existing operator sets, returns `address(0)`.
108+
/// For non-redistributing or non-existing operator sets, the public getter for this function `getRedistributionRecipient`
109+
/// returns `DEFAULT_BURN_ADDRESS`
109110
mapping(bytes32 operatorSetKey => address redistributionAddr) internal _redistributionRecipients;
110111

111112
// Construction

src/contracts/core/SlashEscrowFactory.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ contract SlashEscrowFactory is Initializable, SlashEscrowFactoryStorage, Ownable
151151

152152
/**
153153
*
154-
* PAUSABLE ACTIONS
154+
* PAUSER/UNPAUSER ACTIONS
155155
*
156156
*/
157157

@@ -209,6 +209,8 @@ contract SlashEscrowFactory is Initializable, SlashEscrowFactoryStorage, Ownable
209209
require(!isEscrowPaused(operatorSet, slashId), IPausable.CurrentlyPaused());
210210

211211
// Assert that the escrow delay has elapsed
212+
// `getEscrowCompleteBlock` returns the block number at which the escrow can be released, so
213+
// we require that the current block number is greater than OR equal to the complete block.
212214
require(block.number >= getEscrowCompleteBlock(operatorSet, slashId), EscrowDelayNotElapsed());
213215
}
214216

0 commit comments

Comments
 (0)