Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pending dealloc bug #757

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion script/configs/local/deploy_from_scratch.anvil.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
"OPERATOR_SET_MAX_RETROACTIVE_LENGTH": 2592000
},
"allocationManager": {
"init_paused_status": 0
"init_paused_status": 0,
"DEALLOCATION_DELAY": 900,
"ALLOCATION_DELAY_CONFIGURATION_DELAY": 1200
},
"ethPOSDepositAddress": "0x00000000219ab540356cBB839Cbe05303d7705Fa"
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ contract Upgrade_Testnet_RewardsCoordinator is Deploy_Test_RewardsCoordinator, T
rewardsCoordinatorImplementation = new RewardsCoordinator(
delegationManager,
strategyManager,
avsDirectory,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
REWARDS_COORDINATOR_MAX_FUTURE_LENGTH,
REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP
REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP,
REWARDS_COORDINATOR_OPERATOR_SET_GENESIS_REWARDS_TIMESTAMP,
REWARDS_COORDINATOR_OPERATOR_SET_MAX_RETROACTIVE_LENGTH
);
vm.stopBroadcast();

Expand Down
31 changes: 13 additions & 18 deletions src/contracts/core/AllocationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -736,33 +736,28 @@ contract AllocationManager is
* @param operator the operator to get the pending deallocations for
* @param strategy the strategy to get the pending deallocations for
* @param operatorSets the operatorSets to get the pending deallocations for
* @return pendingMagnitudeDiff the pending difference in deallocations for each operatorSet
* @return timestamps the timestamps for each pending deallocation
* @return pendingMagnitudes the latest pending deallocation
*/
function getPendingDeallocations(
address operator,
IStrategy strategy,
OperatorSet[] calldata operatorSets
) external view returns (uint64[] memory, uint32[] memory) {
uint64[] memory pendingMagnitudeDiff = new uint64[](operatorSets.length);
uint32[] memory timestamps = new uint32[](operatorSets.length);
) external view returns (PendingFreeMagnitude[] memory) {
PendingFreeMagnitude[] memory pendingMagnitudes = new PendingFreeMagnitude[](operatorSets.length);
for (uint256 i = 0; i < operatorSets.length; ++i) {
uint256[] memory indices =
uint256[] storage deallocationIndices =
_queuedDeallocationIndices[operator][strategy][_encodeOperatorSet(operatorSets[i])];
uint256 length = indices.length;
uint256 deallocationIndex = indices[length - 1];
PendingFreeMagnitude memory latestPendingMagnitude =
_pendingFreeMagnitude[operator][strategy][deallocationIndex];
if (latestPendingMagnitude.completableTimestamp > block.timestamp) {
pendingMagnitudeDiff[i] = latestPendingMagnitude.magnitudeDiff;
timestamps[i] = latestPendingMagnitude.completableTimestamp;
} else {
// There is no pending deallocation, so we set the pending magnitude and timestamp to 0
pendingMagnitudeDiff[i] = 0;
timestamps[i] = 0;

if (deallocationIndices.length > 0) {
uint256 deallocationIndex = deallocationIndices[deallocationIndices.length - 1];
PendingFreeMagnitude storage latestPendingMagnitude =
_pendingFreeMagnitude[operator][strategy][deallocationIndex];
if (latestPendingMagnitude.completableTimestamp > block.timestamp) {
pendingMagnitudes[i] = latestPendingMagnitude;
}
}
}
return (pendingMagnitudeDiff, timestamps);
return pendingMagnitudes;
}

// /**
Expand Down
5 changes: 2 additions & 3 deletions src/contracts/interfaces/IAllocationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,13 @@ interface IAllocationManager is ISignatureUtils {
* @param operator the operator to get the pending deallocations for
* @param strategy the strategy to get the pending deallocations for
* @param operatorSets the operatorSets to get the pending deallocations for
* @return pendingMagnitudeDiff the pending difference in deallocations for each operatorSet
* @return timestamps the timestamps for each pending deallocation
* @return pendingMagnitudes the latest pending deallocation
*/
function getPendingDeallocations(
address operator,
IStrategy strategy,
OperatorSet[] calldata operatorSets
) external view returns (uint64[] memory, uint32[] memory);
) external view returns (PendingFreeMagnitude[] memory);

/**
* @notice operator is slashable by operatorSet if currently registered OR last deregistered within 21 days
Expand Down
Loading