Skip to content

Commit d96438b

Browse files
committed
fix: use bool for newlyregistered
1 parent e067fde commit d96438b

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/contracts/core/AllocationManager.sol

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,17 @@ contract AllocationManager is
237237

238238
/// @inheritdoc IAllocationManager
239239
function setAllocationDelay(address operator, uint32 delay) external {
240-
/// If the caller is the delegationManager, the allocation configuration delay is 0
240+
/// If the caller is the delegationManager, the operator is newly registered
241241
/// This results in *newly-registered* operators in the core protocol to have their allocation delay effective after 1 block
242-
uint32 allocationConfigurationDelay;
242+
bool newlyRegistered;
243243
if (msg.sender != address(delegation)) {
244244
require(_checkCanCall(operator), InvalidCaller());
245245
require(delegation.isOperator(operator), InvalidOperator());
246-
allocationConfigurationDelay = ALLOCATION_CONFIGURATION_DELAY;
246+
newlyRegistered = false;
247+
} else {
248+
newlyRegistered = true;
247249
}
248-
_setAllocationDelay(operator, delay, allocationConfigurationDelay);
250+
_setAllocationDelay(operator, delay, newlyRegistered);
249251
}
250252

251253
/// @inheritdoc IAllocationManager
@@ -507,9 +509,9 @@ contract AllocationManager is
507509
* allocating magnitude to an operator set, and the magnitude becoming slashable.
508510
* @param operator The operator to set the delay on behalf of.
509511
* @param delay The allocation delay in blocks.
510-
* @param allocationConfigurationDelay The delay after which the allocation delay takes effect. 0 if the operator is newly registered, otherwise ALLOCATION_CONFIGURATION_DELAY.
512+
* @param newlyRegistered Whether the operator is newly registered in the core protocol.
511513
*/
512-
function _setAllocationDelay(address operator, uint32 delay, uint32 allocationConfigurationDelay) internal {
514+
function _setAllocationDelay(address operator, uint32 delay, bool newlyRegistered) internal {
513515
AllocationDelayInfo memory info = _allocationDelayInfo[operator];
514516

515517
// If there is a pending delay that can be applied now, set it
@@ -519,7 +521,14 @@ contract AllocationManager is
519521
}
520522

521523
info.pendingDelay = delay;
522-
info.effectBlock = uint32(block.number) + allocationConfigurationDelay + 1;
524+
525+
/// If the caller is the delegationManager, the operator is newly registered
526+
/// This results in *newly-registered* operators in the core protocol to have their allocation delay effective after 1 block
527+
if (newlyRegistered) {
528+
info.effectBlock = uint32(block.number) + 1;
529+
} else {
530+
info.effectBlock = uint32(block.number) + ALLOCATION_CONFIGURATION_DELAY + 1;
531+
}
523532

524533
_allocationDelayInfo[operator] = info;
525534
emit AllocationDelaySet(operator, delay, info.effectBlock);

0 commit comments

Comments
 (0)