Skip to content

Commit 5c1e1ac

Browse files
ypatil12claude
andcommitted
fix: update allocation delay fields immediately for newly registered operators
Addresses audit finding L-01: State inconsistency for new operator allocation delay. When a new operator registers and their allocation delay is set via DelegationManager, _setAllocationDelay now also updates info.delay and info.isSet immediately, not just pendingDelay. This ensures storage consistency where the raw AllocationDelayInfo struct reflects the effective delay immediately. Changes: - AllocationManager._setAllocationDelay(): Set delay and isSet when newlyRegistered=true - IAllocationManager: Updated NatSpec for AllocationDelayInfo struct - AllocationManagerHarness: Added getAllocationDelayInfoRaw() for testing raw storage - Unit tests: Added tests verifying storage consistency - Docs: Updated setAllocationDelay effects 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e9bb4b0 commit 5c1e1ac

File tree

12 files changed

+67
-16
lines changed

12 files changed

+67
-16
lines changed

docs/core/AllocationManager.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -990,8 +990,8 @@ The allocation delay's primary purpose is to give stakers delegated to an operat
990990

991991
*Effects*:
992992
* Sets the operator's `pendingDelay` to the proposed `delay`, and save the `effectBlock` at which the `pendingDelay` can be activated
993-
* If a newly registered operator in core, `effectBlock = uint32(block.number)`, allowing operators to allocate slashable stake immediately after registration
994-
* Else, `effectBlock = uint32(block.number) + ALLOCATION_CONFIGURATION_DELAY + 1`
993+
* For newly registered operators (called by DelegationManager): Sets `delay`, `isSet`, and `pendingDelay` immediately with `effectBlock = uint32(block.number)`, ensuring storage consistency and allowing operators to allocate slashable stake immediately after registration.
994+
* For existing operators: Sets `pendingDelay` and `effectBlock = uint32(block.number) + ALLOCATION_CONFIGURATION_DELAY + 1`. The `delay` and `isSet` fields are updated when the pending delay is applied.
995995
* If the operator has a `pendingDelay`, and if the `effectBlock` has passed, sets the operator's `delay` to the `pendingDelay` value
996996
* This also sets the `isSet` boolean to `true` to indicate that the operator's `delay`, even if 0, was set intentionally
997997
* Emits an `AllocationDelaySet` event

pkg/bindings/AllocationManager/binding.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bindings/AllocationManagerView/binding.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bindings/CrossChainRegistry/binding.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bindings/DelegationManager/binding.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bindings/KeyRegistrar/binding.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bindings/RewardsCoordinator/binding.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bindings/StrategyManager/binding.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/contracts/core/AllocationManager.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,9 @@ contract AllocationManager is
605605
/// If the caller is the delegationManager, the operator is newly registered
606606
/// This results in *newly-registered* operators in the core protocol to have their allocation delay effective immediately
607607
if (newlyRegistered) {
608-
// The delay takes effect immediately
608+
// Update delay and isSet immediately for storage consistency
609+
info.delay = delay;
610+
info.isSet = true;
609611
info.effectBlock = uint32(block.number);
610612
} else {
611613
// Wait the entire configuration delay before the delay takes effect

src/contracts/interfaces/IAllocationManager.sol

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,11 @@ interface IAllocationManagerTypes {
9393
uint32 effectBlock;
9494
}
9595

96-
/// @notice Struct containing allocation delay metadata for a given operator.
97-
/// @param delay Current allocation delay
98-
/// @param isSet Whether the operator has initially set an allocation delay. Note that this could be false but the
99-
/// block.number >= effectBlock in which we consider their delay to be configured and active.
100-
/// @param pendingDelay The delay that will take effect after `effectBlock`
101-
/// @param effectBlock The block number after which a pending delay will take effect
96+
/// @notice Allocation delay configuration for an operator.
97+
/// @param delay The current effective allocation delay. Updated immediately for newly registered operators.
98+
/// @param isSet Whether the allocation delay has been configured. True immediately for newly registered operators.
99+
/// @param pendingDelay The allocation delay that will become effective at effectBlock.
100+
/// @param effectBlock The block number at which pendingDelay becomes the effective delay.
102101
struct AllocationDelayInfo {
103102
uint32 delay;
104103
bool isSet;

0 commit comments

Comments
 (0)