Skip to content

Commit

Permalink
remove middlewareIndex param
Browse files Browse the repository at this point in the history
  • Loading branch information
yield-farmer-1 committed Feb 13, 2025
1 parent d6f6582 commit a79cb1e
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 61 deletions.
11 changes: 2 additions & 9 deletions src/StakingNode.sol
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,9 @@ contract StakingNode is IStakingNode, StakingNodeEvents, ReentrancyGuardUpgradea
* number of blocks have passed since withdrawal was queued.
* @param withdrawals The Withdrawals to complete. This withdrawalRoot (keccak hash of the Withdrawal) must match the
* the withdrawal created as part of the queueWithdrawals call.
* @param middlewareTimesIndexes The middlewareTimesIndex parameter has to do
* with the Slasher, which currently does nothing. As of M2, this parameter
* has no bearing on anything and can be ignored
*/
function completeQueuedWithdrawals(
IDelegationManager.Withdrawal[] memory withdrawals,
uint256[] memory middlewareTimesIndexes
IDelegationManager.Withdrawal[] memory withdrawals
) external onlyStakingNodesWithdrawer onlyWhenSynchronized {

uint256 totalWithdrawableShares = 0;
Expand Down Expand Up @@ -481,11 +477,9 @@ contract StakingNode is IStakingNode, StakingNodeEvents, ReentrancyGuardUpgradea
/**
* @notice Completes queued withdrawals with receiveAsTokens set to false
* @param withdrawals Array of withdrawals to complete
* @param middlewareTimesIndexes Array of middleware times indexes
*/
function completeQueuedWithdrawalsAsShares(
IDelegationManager.Withdrawal[] calldata withdrawals,
uint256[] calldata middlewareTimesIndexes
IDelegationManager.Withdrawal[] calldata withdrawals
) external onlyDelegator onlyWhenSynchronized {
uint256 totalWithdrawalAmount = 0;

Expand All @@ -509,7 +503,6 @@ contract StakingNode is IStakingNode, StakingNodeEvents, ReentrancyGuardUpgradea
delegationManager.completeQueuedWithdrawals(
withdrawals,
tokens,
// middlewareTimesIndexes,
receiveAsTokens
);

Expand Down
6 changes: 2 additions & 4 deletions src/WithdrawalsProcessor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,13 @@ contract WithdrawalsProcessor is Initializable, AccessControlUpgradeable, IWithd
* @notice Bundles the completion of queued withdrawals and processing of principal withdrawals for a single node
* @param withdrawalAction The withdrawal action containing node ID and withdrawal amounts
* @param withdrawals Array of withdrawals to complete
* @param middlewareTimesIndexes Array of middleware times indexes for the withdrawals
*/
function completeAndProcessWithdrawalsForNode(
IStakingNodesManager.WithdrawalAction memory withdrawalAction,
IDelegationManager.Withdrawal[] memory withdrawals,
uint256[] memory middlewareTimesIndexes
IDelegationManager.Withdrawal[] memory withdrawals
) external onlyRole(WITHDRAWAL_MANAGER_ROLE) {
// Complete queued withdrawals
stakingNodesManager.nodes(withdrawalAction.nodeId).completeQueuedWithdrawals(withdrawals, middlewareTimesIndexes);
stakingNodesManager.nodes(withdrawalAction.nodeId).completeQueuedWithdrawals(withdrawals);

// Process principal withdrawal
IStakingNodesManager.WithdrawalAction[] memory actions = new IStakingNodesManager.WithdrawalAction[](1);
Expand Down
14 changes: 2 additions & 12 deletions src/interfaces/IStakingNode.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ import {IEigenPod} from "lib/eigenlayer-contracts/src/contracts/interfaces/IEige
import {ISignatureUtils} from "lib/eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol";
import {IDelegationManager} from "lib/eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol";

struct WithdrawalCompletionParams {
uint256 middlewareTimesIndex;
uint256 amount;
uint32 withdrawalStartBlock;
address delegatedAddress;
uint96 nonce;
}

interface IStakingEvents {
/// @notice Emitted when a user stakes ETH and receives ynETH.
/// @param staker The address of the user staking ETH.
Expand Down Expand Up @@ -79,13 +71,11 @@ interface IStakingNode {
) external returns (bytes32[] memory fullWithdrawalRoots);

function completeQueuedWithdrawals(
IDelegationManager.Withdrawal[] memory withdrawals,
uint256[] memory middlewareTimesIndexes
IDelegationManager.Withdrawal[] memory withdrawals
) external;

function completeQueuedWithdrawalsAsShares(
IDelegationManager.Withdrawal[] calldata withdrawals,
uint256[] calldata middlewareTimesIndexes
IDelegationManager.Withdrawal[] calldata withdrawals
) external;

function getInitializedVersion() external view returns (uint64);
Expand Down
20 changes: 6 additions & 14 deletions test/integration/StakingNode.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {IStrategy} from "lib/eigenlayer-contracts/src/contracts/interfaces/IStra
import {StakingNodeTestBase, IEigenPodSimplified} from "./StakingNodeTestBase.sol";
import {IRewardsCoordinator} from "lib/eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol";
import {SlashingLib} from "lib/eigenlayer-contracts/src/contracts/libraries/SlashingLib.sol";
import {console} from "forge-std/console.sol";

contract StakingNodeEigenPod is StakingNodeTestBase {

Expand Down Expand Up @@ -249,11 +250,11 @@ contract StakingNodeDelegation is StakingNodeTestBase {

vm.expectRevert();
vm.prank(actors.ops.STAKING_NODES_WITHDRAWER);
stakingNodeInstance.completeQueuedWithdrawals(new IDelegationManager.Withdrawal[](1), new uint256[](1));
stakingNodeInstance.completeQueuedWithdrawals(new IDelegationManager.Withdrawal[](1));

vm.expectRevert();
vm.prank(actors.admin.STAKING_NODES_DELEGATOR);
stakingNodeInstance.completeQueuedWithdrawalsAsShares(new IDelegationManager.Withdrawal[](1), new uint256[](1));
stakingNodeInstance.completeQueuedWithdrawalsAsShares(new IDelegationManager.Withdrawal[](1));
}

function testDelegateUndelegateAndDelegateAgain() public {
Expand Down Expand Up @@ -427,11 +428,8 @@ contract StakingNodeDelegation is StakingNodeTestBase {

// complete queued withdrawals
{
uint256[] memory middlewareTimesIndexes = new uint256[](calculatedWithdrawals.length);
// all is zeroed out by default
middlewareTimesIndexes[0] = 0;
vm.prank(actors.admin.STAKING_NODES_DELEGATOR);
stakingNodeInstance.completeQueuedWithdrawalsAsShares(calculatedWithdrawals, middlewareTimesIndexes);
stakingNodeInstance.completeQueuedWithdrawalsAsShares(calculatedWithdrawals);
}

finalQueuedShares = stakingNodeInstance.getQueuedSharesAmount();
Expand Down Expand Up @@ -528,11 +526,8 @@ contract StakingNodeDelegation is StakingNodeTestBase {

// complete queued withdrawals
{
uint256[] memory middlewareTimesIndexes = new uint256[](calculatedWithdrawals.length);
// all is zeroed out by default
middlewareTimesIndexes[0] = 0;
vm.prank(actors.admin.STAKING_NODES_DELEGATOR);
stakingNodeInstance.completeQueuedWithdrawalsAsShares(calculatedWithdrawals, middlewareTimesIndexes);
stakingNodeInstance.completeQueuedWithdrawalsAsShares(calculatedWithdrawals);
}

finalQueuedShares = stakingNodeInstance.getQueuedSharesAmount();
Expand Down Expand Up @@ -660,11 +655,8 @@ contract StakingNodeDelegation is StakingNodeTestBase {

// complete queued withdrawals
{
uint256[] memory middlewareTimesIndexes = new uint256[](calculatedWithdrawals.length);
// all is zeroed out by default
middlewareTimesIndexes[0] = 0;
vm.prank(actors.admin.STAKING_NODES_DELEGATOR);
stakingNodeInstance.completeQueuedWithdrawalsAsShares(calculatedWithdrawals, middlewareTimesIndexes);
stakingNodeInstance.completeQueuedWithdrawalsAsShares(calculatedWithdrawals);
}

uint256 finalQueuedShares = stakingNodeInstance.getQueuedSharesAmount();
Expand Down
10 changes: 2 additions & 8 deletions test/integration/StakingNodeTestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,12 @@ contract StakingNodeTestBase is IntegrationBaseTest {

// complete queued withdrawals
{
uint256[] memory _middlewareTimesIndexes = new uint256[](_withdrawals.length);
// all is zeroed out by defailt
_middlewareTimesIndexes[0] = 0;
IStakingNode _node = stakingNodesManager.nodes(nodeId);
vm.startPrank(actors.ops.STAKING_NODES_WITHDRAWER);
if (shouldExpectRevert) {
vm.expectRevert();
}
_node.completeQueuedWithdrawals(_withdrawals, _middlewareTimesIndexes);
_node.completeQueuedWithdrawals(_withdrawals);
vm.stopPrank();
}
}
Expand All @@ -126,11 +123,8 @@ contract StakingNodeTestBase is IntegrationBaseTest {

// complete queued withdrawals
{
uint256[] memory _middlewareTimesIndexes = new uint256[](_withdrawals.length);
// all is zeroed out by defailt
_middlewareTimesIndexes[0] = 0;
vm.startPrank(actors.admin.STAKING_NODES_DELEGATOR);
stakingNodesManager.nodes(nodeId).completeQueuedWithdrawalsAsShares(_withdrawals, _middlewareTimesIndexes);
stakingNodesManager.nodes(nodeId).completeQueuedWithdrawalsAsShares(_withdrawals);
vm.stopPrank();
}
}
Expand Down
4 changes: 1 addition & 3 deletions test/scenarios/fork/ynETH/Withdrawals.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,8 @@ contract M3WithdrawalsTest is Base {

// complete queued withdrawals
{
uint256[] memory _middlewareTimesIndexes = new uint256[](1);
_middlewareTimesIndexes[0] = 0;
vm.startPrank(actors.ops.STAKING_NODES_WITHDRAWER);
stakingNodesManager.nodes(nodeId).completeQueuedWithdrawals(_withdrawals, _middlewareTimesIndexes);
stakingNodesManager.nodes(nodeId).completeQueuedWithdrawals(_withdrawals);
vm.stopPrank();

// check that queuedSharesAmount is 0, and withdrawnETH is 32 ETH (AMOUNT), and staking pod balance is 32 ETH (AMOUNT)
Expand Down
14 changes: 3 additions & 11 deletions test/scenarios/fork/ynETH/WithdrawalsScenarioTestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ contract WithdrawalsScenarioTestBase is Base {

// complete queued withdrawals
{
uint256[] memory _middlewareTimesIndexes = new uint256[](_withdrawals.length);
// all is zeroed out by defailt
_middlewareTimesIndexes[0] = 0;
vm.startPrank(actors.ops.STAKING_NODES_WITHDRAWER);
stakingNodesManager.nodes(nodeId).completeQueuedWithdrawals(_withdrawals, _middlewareTimesIndexes);
stakingNodesManager.nodes(nodeId).completeQueuedWithdrawals(_withdrawals);
vm.stopPrank();
}
}
Expand All @@ -92,11 +89,8 @@ contract WithdrawalsScenarioTestBase is Base {

// complete queued withdrawals
{
uint256[] memory _middlewareTimesIndexes = new uint256[](_withdrawals.length);
// all is zeroed out by defailt
_middlewareTimesIndexes[0] = 0;
vm.startPrank(actors.admin.STAKING_NODES_DELEGATOR);
stakingNodesManager.nodes(nodeId).completeQueuedWithdrawalsAsShares(_withdrawals, _middlewareTimesIndexes);
stakingNodesManager.nodes(nodeId).completeQueuedWithdrawalsAsShares(_withdrawals);
vm.stopPrank();
}
}
Expand Down Expand Up @@ -127,12 +121,10 @@ contract WithdrawalsScenarioTestBase is Base {


{
uint256[] memory _middlewareTimesIndexes = new uint256[](_withdrawals.length);
vm.prank(actors.ops.WITHDRAWAL_MANAGER);
withdrawalsProcessor.completeAndProcessWithdrawalsForNode(
withdrawalAction,
_withdrawals,
_middlewareTimesIndexes
_withdrawals
);
}
}
Expand Down

0 comments on commit a79cb1e

Please sign in to comment.