Skip to content

Commit

Permalink
feat: un-deprecate pendingWithdrawals mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
0xClandestine committed Oct 25, 2024
1 parent c3f3297 commit 7a96618
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
16 changes: 11 additions & 5 deletions src/contracts/core/DelegationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ contract DelegationManager is
require(tokens.length == withdrawal.strategies.length, InputArrayLengthMismatch());
require(msg.sender == withdrawal.withdrawer, WithdrawerNotCaller());
bytes32 withdrawalRoot = calculateWithdrawalRoot(withdrawal);
require(_stakerQueuedWithdrawalRoots[withdrawal.staker].contains(withdrawalRoot), WithdrawalNotQueued());
require(pendingWithdrawals(withdrawalRoot), WithdrawalNotQueued());

// TODO: is there a cleaner way to do this?
uint32 completableTimestamp = getCompletableTimestamp(withdrawal.startTimestamp);
Expand Down Expand Up @@ -501,6 +501,9 @@ contract DelegationManager is

delete queuedWithdrawals[withdrawalRoot];

// This storage is actively being deprecated, values are only being read or deleted.
delete _legacyPendingWithdrawals[withdrawalRoot];

emit SlashingWithdrawalCompleted(withdrawalRoot);
}

Expand Down Expand Up @@ -786,10 +789,13 @@ contract DelegationManager is
}

/// @inheritdoc IDelegationManager
function pendingWithdrawals(
bytes32 withdrawalRoot
) public view returns (bool) {
return queuedWithdrawals[withdrawalRoot].staker != address(0);
function pendingWithdrawals(bytes32 withdrawalRoot) public view returns (bool) {
// Check if a non-legacy withdrawal is pending.
bool isWithdrawalPending = queuedWithdrawals[withdrawalRoot].staker != address(0);

// NOTE: We must also check legacy storage to ensure that
// withdrawals queued before the slashing release are completable.
return isWithdrawalPending || _legacyPendingWithdrawals[withdrawalRoot];
}

/// @inheritdoc IDelegationManager
Expand Down
7 changes: 4 additions & 3 deletions src/contracts/core/DelegationManagerStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ abstract contract DelegationManagerStorage is IDelegationManager {

/// @notice Returns whether `delegationApprover` has already used the given `salt`.
mapping(address delegationApprover => mapping(bytes32 salt => bool spent)) public delegationApproverSaltIsSpent;

/// @dev Do not remove, deprecated storage.
uint256 private __deprecated_minWithdrawalDelayBlocks;

/// @dev Do not remove, deprecated storage.
mapping(bytes32 withdrawalRoot => bool pending) private __deprecated_pendingWithdrawals;
/// @dev Returns whether a withdrawal is pending for a given `withdrawalRoot`.
/// @dev This variable is actively being deprecated, values should only be read or deleted.
mapping(bytes32 withdrawalRoot => bool pending) internal _legacyPendingWithdrawals;

/// @notice Returns the total number of withdrawals that have been queued for a given `staker`.
/// @dev This only increments (doesn't decrement), and is used to help ensure that otherwise identical withdrawals have unique hashes.
Expand Down

0 comments on commit 7a96618

Please sign in to comment.