From ebb1201e3622953e073b7491de1891ed23343c2f Mon Sep 17 00:00:00 2001 From: Alex <18387287+wadealexc@users.noreply.github.com> Date: Thu, 25 Apr 2024 15:51:20 -0400 Subject: [PATCH] feat: remove all use of the delayed withdrawal router (#524) * modify activateRestaking flow to use checkpointing * remove withdrawNonBeaconChainETHBalanceWei in favor of checkpointing --- script/deploy/mainnet/M2Deploy.s.sol | 1 - src/contracts/interfaces/IEigenPod.sol | 9 -- src/contracts/pods/EigenPod.sol | 74 +++++------ src/contracts/pods/EigenPodStorage.sol | 2 +- src/test/EigenPod.t.sol | 174 ++++++++++++------------- src/test/unit/EigenPodUnit.t.sol | 154 +++++++++++----------- 6 files changed, 197 insertions(+), 217 deletions(-) diff --git a/script/deploy/mainnet/M2Deploy.s.sol b/script/deploy/mainnet/M2Deploy.s.sol index c445fb801..c86fb67e8 100644 --- a/script/deploy/mainnet/M2Deploy.s.sol +++ b/script/deploy/mainnet/M2Deploy.s.sol @@ -451,7 +451,6 @@ contract M2Deploy is Script, Test { // Check updated storage values require(eigenPod.hasRestaked(), "eigenPod.hasRestaked not set to true"); require(address(eigenPod).balance == 0, "eigenPod balance not 0 after activating restaking"); - require(eigenPod.nonBeaconChainETHBalanceWei() == 0, "non beacon chain eth balance not 0"); require( eigenPod.mostRecentWithdrawalTimestamp() == block.timestamp, "eigenPod.mostRecentWithdrawalTimestamp not updated" diff --git a/src/contracts/interfaces/IEigenPod.sol b/src/contracts/interfaces/IEigenPod.sol index a38f116b1..7c5e50a69 100644 --- a/src/contracts/interfaces/IEigenPod.sol +++ b/src/contracts/interfaces/IEigenPod.sol @@ -79,9 +79,6 @@ interface IEigenPod { /// @notice the amount of execution layer ETH in this contract that is staked in EigenLayer (i.e. withdrawn from beaconchain but not EigenLayer), function withdrawableRestakedExecutionLayerGwei() external view returns (uint64); - /// @notice any ETH deposited into the EigenPod contract via the `receive` fallback function - function nonBeaconChainETHBalanceWei() external view returns (uint256); - /// @notice Used to initialize the pointers to contracts crucial to the pod's functionality, in beacon proxy construction from EigenPodManager function initialize(address owner) external; @@ -152,12 +149,6 @@ interface IEigenPod { */ function activateRestaking() external; - /// @notice Called by the pod owner to withdraw the balance of the pod when `hasRestaked` is set to false - function withdrawBeforeRestaking() external; - - /// @notice Called by the pod owner to withdraw the nonBeaconChainETHBalanceWei - function withdrawNonBeaconChainETHBalanceWei(address recipient, uint256 amountToWithdraw) external; - /// @notice called by owner of a pod to remove any ERC20s deposited in the pod function recoverTokens(IERC20[] memory tokenList, uint256[] memory amountsToWithdraw, address recipient) external; } diff --git a/src/contracts/pods/EigenPod.sol b/src/contracts/pods/EigenPod.sol index cc0b1b43d..601f77f2b 100644 --- a/src/contracts/pods/EigenPod.sol +++ b/src/contracts/pods/EigenPod.sol @@ -153,7 +153,6 @@ contract EigenPod is /// @notice payable fallback function that receives ether deposited to the eigenpods contract receive() external payable { - nonBeaconChainETHBalanceWei += msg.value; emit NonBeaconChainETHReceived(msg.value); } @@ -163,7 +162,7 @@ contract EigenPod is * change in ACTIVE validator balance is tracked, and any validators with 0 balance are marked `WITHDRAWN`. * @dev Once finalized, the pod owner is awarded shares corresponding to: * - the total change in their ACTIVE validator balances - * - any ETH in the pod not already awarded shares. + * - any ETH in the pod not already awarded shares * @dev A checkpoint cannot be created if the pod already has an outstanding checkpoint. If * this is the case, the pod owner MUST complete the existing checkpoint before starting a new one. */ @@ -362,20 +361,6 @@ contract EigenPod is _startCheckpoint(); } - /// @notice Called by the pod owner to withdraw the nonBeaconChainETHBalanceWei - function withdrawNonBeaconChainETHBalanceWei( - address recipient, - uint256 amountToWithdraw - ) external onlyEigenPodOwner onlyWhenNotPaused(PAUSED_NON_PROOF_WITHDRAWALS) { - require( - amountToWithdraw <= nonBeaconChainETHBalanceWei, - "EigenPod.withdrawnonBeaconChainETHBalanceWei: amountToWithdraw is greater than nonBeaconChainETHBalanceWei" - ); - nonBeaconChainETHBalanceWei -= amountToWithdraw; - emit NonBeaconChainETHWithdrawn(recipient, amountToWithdraw); - _sendETH_AsDelayedWithdrawal(recipient, amountToWithdraw); - } - /// @notice called by owner of a pod to remove any ERC20s deposited in the pod function recoverTokens( IERC20[] memory tokenList, @@ -403,14 +388,9 @@ contract EigenPod is hasNeverRestaked { hasRestaked = true; - _processWithdrawalBeforeRestaking(podOwner); emit RestakingActivated(podOwner); - } - - /// @notice Called by the pod owner to withdraw the balance of the pod when `hasRestaked` is set to false - function withdrawBeforeRestaking() external onlyEigenPodOwner hasNeverRestaked { - _processWithdrawalBeforeRestaking(podOwner); + _startCheckpoint(); } /// @notice Called by EigenPodManager when the owner wants to create another ETH validator. @@ -565,27 +545,47 @@ contract EigenPod is return balanceDeltaGwei; } + /** + * @dev Initiate a checkpoint proof by snapshotting both the pod's ETH balance and the + * current block's parent block root. After providing a checkpoint proof for each of the + * pod's ACTIVE validators, the pod's ETH balance is awarded shares and can be withdrawn. + * @dev ACTIVE validators are validators with verified withdrawal credentials (See + * `verifyWithdrawalCredentials` for details) + * @dev If the pod does not have any ACTIVE validators, the checkpoint is automatically + * finalized. + * @dev Once started, a checkpoint MUST be completed! It is not possible to start a + * checkpoint if the existing one is incomplete. + */ function _startCheckpoint() internal { require( currentCheckpointTimestamp == 0, "EigenPod._startCheckpoint: must finish previous checkpoint before starting another" ); - // Snapshot pod balance at the start of the checkpoint. Once the checkpoint is finalized, - // this amount will be added to the total validator balance delta and credited as shares. - uint256 podBalanceWei = - address(this).balance - - nonBeaconChainETHBalanceWei - - (withdrawableRestakedExecutionLayerGwei * GWEI_TO_WEI); - + // Snapshot pod balance at the start of the checkpoint, subtracting pod balance that has + // previously been credited with shares. Once the checkpoint is finalized, `podBalanceGwei` + // will be added to the total validator balance delta and credited as shares. + // + // Note: On finalization, `podBalanceGwei` is added to `withdrawableRestakedExecutionLayerGwei` + // to denote that it has been credited with shares. Because this value is denominated in gwei, + // `podBalanceGwei` is also converted to a gwei amount here. This means that any sub-gwei amounts + // sent to the pod are not credited with shares and are therefore not withdrawable. + // This can be addressed by topping up a pod's balance to a value divisible by 1 gwei. + uint256 podBalanceGwei = + (address(this).balance / GWEI_TO_WEI) - withdrawableRestakedExecutionLayerGwei; + + // Create checkpoint using the previous block's root for proofs, and the current + // `activeValidatorCount` as the number of checkpoint proofs needed to finalize + // the checkpoint. Checkpoint memory checkpoint = Checkpoint({ beaconBlockRoot: _getParentBlockRoot(uint64(block.timestamp)), - podBalanceGwei: podBalanceWei / GWEI_TO_WEI, + podBalanceGwei: podBalanceGwei, balanceDeltasGwei: 0, proofsRemaining: activeValidatorCount }); - // Place checkpoint in storage + // Place checkpoint in storage. If `proofsRemaining` is 0, the checkpoint + // is automatically finalized. currentCheckpointTimestamp = uint64(block.timestamp); _updateCheckpoint(checkpoint); @@ -596,7 +596,7 @@ contract EigenPod is * @dev Finish progress on a checkpoint and store it in state. * @dev If the checkpoint has no proofs remaining, it is finalized: * - a share delta is calculated and sent to the `EigenPodManager` - * - the checkpointed `podBalance` is added to `withdrawableRestakedExecutionLayerGwei` + * - the checkpointed `podBalanceGwei` is added to `withdrawableRestakedExecutionLayerGwei` * - `lastCheckpointTimestamp` is updated * - `currentCheckpoint` and `currentCheckpointTimestamp` are deleted */ @@ -621,20 +621,10 @@ contract EigenPod is } } - function _processWithdrawalBeforeRestaking(address _podOwner) internal { - mostRecentWithdrawalTimestamp = uint32(block.timestamp); - nonBeaconChainETHBalanceWei = 0; - _sendETH_AsDelayedWithdrawal(_podOwner, address(this).balance); - } - function _sendETH(address recipient, uint256 amountWei) internal { Address.sendValue(payable(recipient), amountWei); } - function _sendETH_AsDelayedWithdrawal(address recipient, uint256 amountWei) internal { - delayedWithdrawalRouter.createDelayedWithdrawal{value: amountWei}(podOwner, recipient); - } - /// @notice Query the 4788 oracle to get the parent block root of the slot with the given `timestamp` /// @param timestamp of the block for which the parent block root will be returned. MUST correspond /// to an existing slot within the last 24 hours. If the slot at `timestamp` was skipped, this method diff --git a/src/contracts/pods/EigenPodStorage.sol b/src/contracts/pods/EigenPodStorage.sol index 897fef60e..41a2e3b24 100644 --- a/src/contracts/pods/EigenPodStorage.sol +++ b/src/contracts/pods/EigenPodStorage.sol @@ -28,7 +28,7 @@ abstract contract EigenPodStorage is IEigenPod { mapping(bytes32 => ValidatorInfo) internal _validatorPubkeyHashToInfo; /// @notice This variable tracks any ETH deposited into this contract via the `receive` fallback function - uint256 public nonBeaconChainETHBalanceWei; + uint256 internal __deprecated_nonBeaconChainETHBalanceWei; /// @notice This variable tracks the total amount of partial withdrawals claimed via merkle proofs prior to a switch to ZK proofs for claiming partial withdrawals uint64 __deprecated_sumOfPartialWithdrawalsClaimedGwei; diff --git a/src/test/EigenPod.t.sol b/src/test/EigenPod.t.sol index dd642a611..001fbf86e 100644 --- a/src/test/EigenPod.t.sol +++ b/src/test/EigenPod.t.sol @@ -273,39 +273,39 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants { cheats.stopPrank(); } - function testWithdrawBeforeRestaking() public { - testStaking(); - IEigenPod pod = eigenPodManager.getPod(podOwner); + // function testWithdrawBeforeRestaking() public { + // testStaking(); + // IEigenPod pod = eigenPodManager.getPod(podOwner); - //simulate that hasRestaked is set to false, so that we can test withdrawBeforeRestaking for pods deployed before M2 activation - cheats.store(address(pod), bytes32(uint256(52)), bytes32(uint256(1))); - require(pod.hasRestaked() == false, "Pod should not be restaked"); + // //simulate that hasRestaked is set to false, so that we can test withdrawBeforeRestaking for pods deployed before M2 activation + // cheats.store(address(pod), bytes32(uint256(52)), bytes32(uint256(1))); + // require(pod.hasRestaked() == false, "Pod should not be restaked"); - // simulate a withdrawal - cheats.deal(address(pod), stakeAmount); - cheats.startPrank(podOwner); - cheats.expectEmit(true, true, true, true, address(delayedWithdrawalRouter)); - emit DelayedWithdrawalCreated( - podOwner, - podOwner, - stakeAmount, - delayedWithdrawalRouter.userWithdrawalsLength(podOwner) - ); + // // simulate a withdrawal + // cheats.deal(address(pod), stakeAmount); + // cheats.startPrank(podOwner); + // cheats.expectEmit(true, true, true, true, address(delayedWithdrawalRouter)); + // emit DelayedWithdrawalCreated( + // podOwner, + // podOwner, + // stakeAmount, + // delayedWithdrawalRouter.userWithdrawalsLength(podOwner) + // ); - uint timestampBeforeTx = pod.mostRecentWithdrawalTimestamp(); + // uint timestampBeforeTx = pod.mostRecentWithdrawalTimestamp(); - pod.withdrawBeforeRestaking(); + // pod.withdrawBeforeRestaking(); - require(_getLatestDelayedWithdrawalAmount(podOwner) == stakeAmount, "Payment amount should be stake amount"); - require( - pod.mostRecentWithdrawalTimestamp() == uint64(block.timestamp), - "Most recent withdrawal block number not updated" - ); - require( - pod.mostRecentWithdrawalTimestamp() > timestampBeforeTx, - "Most recent withdrawal block number not updated" - ); - } + // require(_getLatestDelayedWithdrawalAmount(podOwner) == stakeAmount, "Payment amount should be stake amount"); + // require( + // pod.mostRecentWithdrawalTimestamp() == uint64(block.timestamp), + // "Most recent withdrawal block number not updated" + // ); + // require( + // pod.mostRecentWithdrawalTimestamp() > timestampBeforeTx, + // "Most recent withdrawal block number not updated" + // ); + // } function testDeployEigenPodWithoutActivateRestaking() public { // ./solidityProofGen -newBalance=32000115173 "ValidatorFieldsProof" 302913 true "data/withdrawal_proof_goerli/goerli_block_header_6399998.json" "data/withdrawal_proof_goerli/goerli_slot_6399998.json" "withdrawal_credential_proof_302913.json" @@ -344,69 +344,69 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants { cheats.stopPrank(); } - function testWithdrawNonBeaconChainETHBalanceWei() public { - IEigenPod pod = testDeployAndVerifyNewEigenPod(); + // function testWithdrawNonBeaconChainETHBalanceWei() public { + // IEigenPod pod = testDeployAndVerifyNewEigenPod(); - cheats.deal(address(podOwner), 10 ether); - emit log_named_address("Pod:", address(pod)); + // cheats.deal(address(podOwner), 10 ether); + // emit log_named_address("Pod:", address(pod)); - uint256 balanceBeforeDeposit = pod.nonBeaconChainETHBalanceWei(); + // uint256 balanceBeforeDeposit = pod.nonBeaconChainETHBalanceWei(); - (bool sent, ) = payable(address(pod)).call{value: 1 ether}(""); + // (bool sent, ) = payable(address(pod)).call{value: 1 ether}(""); - require(sent == true, "not sent"); + // require(sent == true, "not sent"); - uint256 balanceAfterDeposit = pod.nonBeaconChainETHBalanceWei(); + // uint256 balanceAfterDeposit = pod.nonBeaconChainETHBalanceWei(); - require( - balanceBeforeDeposit < balanceAfterDeposit - && (balanceAfterDeposit - balanceBeforeDeposit) == 1 ether, - "increment checks" - ); + // require( + // balanceBeforeDeposit < balanceAfterDeposit + // && (balanceAfterDeposit - balanceBeforeDeposit) == 1 ether, + // "increment checks" + // ); - cheats.startPrank(podOwner, podOwner); - cheats.expectEmit(true, true, true, true, address(pod)); - emit NonBeaconChainETHWithdrawn(podOwner, 1 ether); - pod.withdrawNonBeaconChainETHBalanceWei( - podOwner, - 1 ether - ); + // cheats.startPrank(podOwner, podOwner); + // cheats.expectEmit(true, true, true, true, address(pod)); + // emit NonBeaconChainETHWithdrawn(podOwner, 1 ether); + // pod.withdrawNonBeaconChainETHBalanceWei( + // podOwner, + // 1 ether + // ); - uint256 balanceAfterWithdrawal = pod.nonBeaconChainETHBalanceWei(); + // uint256 balanceAfterWithdrawal = pod.nonBeaconChainETHBalanceWei(); - require( - balanceAfterWithdrawal < balanceAfterDeposit - && balanceAfterWithdrawal == balanceBeforeDeposit, - "decrement checks" - ); + // require( + // balanceAfterWithdrawal < balanceAfterDeposit + // && balanceAfterWithdrawal == balanceBeforeDeposit, + // "decrement checks" + // ); - cheats.stopPrank(); - } + // cheats.stopPrank(); + // } - function testWithdrawFromPod() public { - IEigenPod pod = eigenPodManager.getPod(podOwner); - cheats.startPrank(podOwner); + // function testWithdrawFromPod() public { + // IEigenPod pod = eigenPodManager.getPod(podOwner); + // cheats.startPrank(podOwner); - cheats.expectEmit(true, true, true, true, address(pod)); - emit EigenPodStaked(pubkey); + // cheats.expectEmit(true, true, true, true, address(pod)); + // emit EigenPodStaked(pubkey); - eigenPodManager.stake{value: stakeAmount}(pubkey, signature, depositDataRoot); - cheats.stopPrank(); + // eigenPodManager.stake{value: stakeAmount}(pubkey, signature, depositDataRoot); + // cheats.stopPrank(); - cheats.deal(address(pod), stakeAmount); + // cheats.deal(address(pod), stakeAmount); - // this is testing if pods deployed before M2 that do not have hasRestaked initialized to true, will revert - cheats.store(address(pod), bytes32(uint256(52)), bytes32(uint256(1))); + // // this is testing if pods deployed before M2 that do not have hasRestaked initialized to true, will revert + // cheats.store(address(pod), bytes32(uint256(52)), bytes32(uint256(1))); - cheats.startPrank(podOwner); - uint256 userWithdrawalsLength = delayedWithdrawalRouter.userWithdrawalsLength(podOwner); - // cheats.expectEmit(true, true, true, true, address(delayedWithdrawalRouter)); - //cheats.expectEmit(true, true, true, true); - emit DelayedWithdrawalCreated(podOwner, podOwner, stakeAmount, userWithdrawalsLength); - pod.withdrawBeforeRestaking(); - cheats.stopPrank(); - require(address(pod).balance == 0, "Pod balance should be 0"); - } + // cheats.startPrank(podOwner); + // uint256 userWithdrawalsLength = delayedWithdrawalRouter.userWithdrawalsLength(podOwner); + // // cheats.expectEmit(true, true, true, true, address(delayedWithdrawalRouter)); + // //cheats.expectEmit(true, true, true, true); + // emit DelayedWithdrawalCreated(podOwner, podOwner, stakeAmount, userWithdrawalsLength); + // pod.withdrawBeforeRestaking(); + // cheats.stopPrank(); + // require(address(pod).balance == 0, "Pod balance should be 0"); + // } // function testFullWithdrawalProof() public { // setJSON("./src/test/test-data/fullWithdrawalProof_Latest.json"); @@ -1059,20 +1059,20 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants { cheats.stopPrank(); } - function testCallWithdrawBeforeRestakingFromNonOwner(address nonPodOwner) external fuzzedAddress(nonPodOwner) { - cheats.assume(nonPodOwner != podOwner); - testStaking(); - IEigenPod pod = eigenPodManager.getPod(podOwner); + // function testCallWithdrawBeforeRestakingFromNonOwner(address nonPodOwner) external fuzzedAddress(nonPodOwner) { + // cheats.assume(nonPodOwner != podOwner); + // testStaking(); + // IEigenPod pod = eigenPodManager.getPod(podOwner); - // this is testing if pods deployed before M2 that do not have hasRestaked initialized to true, will revert - cheats.store(address(pod), bytes32(uint256(52)), bytes32(0)); - require(pod.hasRestaked() == false, "Pod should not be restaked"); + // // this is testing if pods deployed before M2 that do not have hasRestaked initialized to true, will revert + // cheats.store(address(pod), bytes32(uint256(52)), bytes32(0)); + // require(pod.hasRestaked() == false, "Pod should not be restaked"); - //simulate a withdrawal - cheats.startPrank(nonPodOwner); - cheats.expectRevert(bytes("EigenPod.onlyEigenPodOwner: not podOwner")); - pod.withdrawBeforeRestaking(); - } + // //simulate a withdrawal + // cheats.startPrank(nonPodOwner); + // cheats.expectRevert(bytes("EigenPod.onlyEigenPodOwner: not podOwner")); + // pod.withdrawBeforeRestaking(); + // } /* test deprecated since this is checked on the EigenPodManager level, rather than the EigenPod level TODO: @Sidu28 - check whether we have adequate coverage of the correct function diff --git a/src/test/unit/EigenPodUnit.t.sol b/src/test/unit/EigenPodUnit.t.sol index a34a6bb2c..0e74b61da 100644 --- a/src/test/unit/EigenPodUnit.t.sol +++ b/src/test/unit/EigenPodUnit.t.sol @@ -177,35 +177,35 @@ contract EigenPodUnitTests_PodOwnerFunctions is EigenPodUnitTests, IEigenPodEven Withdraw Non Beacon Chain ETH Tests *******************************************************************************/ - function testFuzz_withdrawNonBeaconChainETH_revert_notPodOwner(address invalidCaller) public { - cheats.assume(invalidCaller != podOwner); + // function testFuzz_withdrawNonBeaconChainETH_revert_notPodOwner(address invalidCaller) public { + // cheats.assume(invalidCaller != podOwner); - cheats.prank(invalidCaller); - cheats.expectRevert("EigenPod.onlyEigenPodOwner: not podOwner"); - eigenPod.withdrawNonBeaconChainETHBalanceWei(invalidCaller, 1 ether); - } + // cheats.prank(invalidCaller); + // cheats.expectRevert("EigenPod.onlyEigenPodOwner: not podOwner"); + // eigenPod.withdrawNonBeaconChainETHBalanceWei(invalidCaller, 1 ether); + // } - function test_withdrawNonBeaconChainETH_revert_tooMuchWithdrawn() public { - // Send EigenPod 0.9 ether - _seedPodWithETH(0.9 ether); + // function test_withdrawNonBeaconChainETH_revert_tooMuchWithdrawn() public { + // // Send EigenPod 0.9 ether + // _seedPodWithETH(0.9 ether); - // Withdraw 1 ether - cheats.expectRevert("EigenPod.withdrawnonBeaconChainETHBalanceWei: amountToWithdraw is greater than nonBeaconChainETHBalanceWei"); - eigenPod.withdrawNonBeaconChainETHBalanceWei(podOwner, 1 ether); - } + // // Withdraw 1 ether + // cheats.expectRevert("EigenPod.withdrawnonBeaconChainETHBalanceWei: amountToWithdraw is greater than nonBeaconChainETHBalanceWei"); + // eigenPod.withdrawNonBeaconChainETHBalanceWei(podOwner, 1 ether); + // } - function testFuzz_withdrawNonBeaconChainETH(uint256 ethAmount) public { - _seedPodWithETH(ethAmount); - assertEq(eigenPod.nonBeaconChainETHBalanceWei(), ethAmount, "Incorrect amount incremented in receive function"); + // function testFuzz_withdrawNonBeaconChainETH(uint256 ethAmount) public { + // _seedPodWithETH(ethAmount); + // assertEq(eigenPod.nonBeaconChainETHBalanceWei(), ethAmount, "Incorrect amount incremented in receive function"); - cheats.expectEmit(true, true, true, true); - emit NonBeaconChainETHWithdrawn(podOwner, ethAmount); - eigenPod.withdrawNonBeaconChainETHBalanceWei(podOwner, ethAmount); + // cheats.expectEmit(true, true, true, true); + // emit NonBeaconChainETHWithdrawn(podOwner, ethAmount); + // eigenPod.withdrawNonBeaconChainETHBalanceWei(podOwner, ethAmount); - // Checks - assertEq(address(eigenPod).balance, 0, "Incorrect amount withdrawn from eigenPod"); - assertEq(address(delayedWithdrawalRouterMock).balance, ethAmount, "Incorrect amount set to delayed withdrawal router"); - } + // // Checks + // assertEq(address(eigenPod).balance, 0, "Incorrect amount withdrawn from eigenPod"); + // assertEq(address(delayedWithdrawalRouterMock).balance, ethAmount, "Incorrect amount set to delayed withdrawal router"); + // } /******************************************************************************* Recover Tokens Tests @@ -270,19 +270,19 @@ contract EigenPodUnitTests_PodOwnerFunctions is EigenPodUnitTests, IEigenPodEven eigenPod.activateRestaking(); } - function testFuzz_activateRestaking(uint256 ethAmount) public hasNotRestaked { - // Seed some ETH - _seedPodWithETH(ethAmount); + // function testFuzz_activateRestaking(uint256 ethAmount) public hasNotRestaked { + // // Seed some ETH + // _seedPodWithETH(ethAmount); - // Activate restaking - vm.expectEmit(true, true, true, true); - emit RestakingActivated(podOwner); - eigenPod.activateRestaking(); + // // Activate restaking + // vm.expectEmit(true, true, true, true); + // emit RestakingActivated(podOwner); + // eigenPod.activateRestaking(); - // Checks - assertTrue(eigenPod.hasRestaked(), "hasRestaked incorrectly set"); - _assertWithdrawalProcessed(ethAmount); - } + // // Checks + // assertTrue(eigenPod.hasRestaked(), "hasRestaked incorrectly set"); + // _assertWithdrawalProcessed(ethAmount); + // } /** * This is a regression test for a bug (EIG-14) found by Hexens. Lets say podOwner sends 32 ETH to the EigenPod, @@ -293,67 +293,67 @@ contract EigenPodUnitTests_PodOwnerFunctions is EigenPodUnitTests, IEigenPodEven * And simply withdraw the 32ETH because nonBeaconChainETHBalanceWei is 32ETH. This was an issue because * nonBeaconChainETHBalanceWei was never zeroed out in _processWithdrawalBeforeRestaking */ - function test_regression_validatorBalance_cannotBeRemoved_viaNonBeaconChainETHBalanceWei() external hasNotRestaked { - // Assert that the pod has not restaked - assertFalse(eigenPod.hasRestaked(), "hasRestaked should be false"); + // function test_regression_validatorBalance_cannotBeRemoved_viaNonBeaconChainETHBalanceWei() external hasNotRestaked { + // // Assert that the pod has not restaked + // assertFalse(eigenPod.hasRestaked(), "hasRestaked should be false"); - // Simulate podOwner sending 32 ETH to eigenPod - _seedPodWithETH(32 ether); - assertEq(eigenPod.nonBeaconChainETHBalanceWei(), 32 ether, "nonBeaconChainETHBalanceWei should be 32 ETH"); + // // Simulate podOwner sending 32 ETH to eigenPod + // _seedPodWithETH(32 ether); + // assertEq(eigenPod.nonBeaconChainETHBalanceWei(), 32 ether, "nonBeaconChainETHBalanceWei should be 32 ETH"); - // Pod owner calls withdrawBeforeRestaking, sending 32 ETH to owner - eigenPod.withdrawBeforeRestaking(); - assertEq(address(eigenPod).balance, 0, "eigenPod balance should be 0"); - assertEq(address(delayedWithdrawalRouterMock).balance, 32 ether, "withdrawal router balance should be 32 ETH"); + // // Pod owner calls withdrawBeforeRestaking, sending 32 ETH to owner + // eigenPod.withdrawBeforeRestaking(); + // assertEq(address(eigenPod).balance, 0, "eigenPod balance should be 0"); + // assertEq(address(delayedWithdrawalRouterMock).balance, 32 ether, "withdrawal router balance should be 32 ETH"); - // Upgrade from m1 to m2 + // // Upgrade from m1 to m2 - // Activate restaking on the pod - eigenPod.activateRestaking(); + // // Activate restaking on the pod + // eigenPod.activateRestaking(); - // Simulate a withdrawal by increasing eth balance without code execution - cheats.deal(address(eigenPod), 32 ether); + // // Simulate a withdrawal by increasing eth balance without code execution + // cheats.deal(address(eigenPod), 32 ether); - // Try calling withdrawNonBeaconChainETHBalanceWei, should fail since `nonBeaconChainETHBalanceWei` - // was set to 0 when calling `_processWithdrawalBeforeRestaking` from `activateRestaking` - cheats.expectRevert("EigenPod.withdrawnonBeaconChainETHBalanceWei: amountToWithdraw is greater than nonBeaconChainETHBalanceWei"); - eigenPod.withdrawNonBeaconChainETHBalanceWei(podOwner, 32 ether); - } + // // Try calling withdrawNonBeaconChainETHBalanceWei, should fail since `nonBeaconChainETHBalanceWei` + // // was set to 0 when calling `_processWithdrawalBeforeRestaking` from `activateRestaking` + // cheats.expectRevert("EigenPod.withdrawnonBeaconChainETHBalanceWei: amountToWithdraw is greater than nonBeaconChainETHBalanceWei"); + // eigenPod.withdrawNonBeaconChainETHBalanceWei(podOwner, 32 ether); + // } /******************************************************************************* Withdraw Before Restaking Tests *******************************************************************************/ - function testFuzz_withdrawBeforeRestaking_revert_notPodOwner(address invalidCaller) public filterFuzzedAddressInputs(invalidCaller) { - cheats.assume(invalidCaller != podOwner); + // function testFuzz_withdrawBeforeRestaking_revert_notPodOwner(address invalidCaller) public filterFuzzedAddressInputs(invalidCaller) { + // cheats.assume(invalidCaller != podOwner); - cheats.prank(invalidCaller); - cheats.expectRevert("EigenPod.onlyEigenPodOwner: not podOwner"); - eigenPod.withdrawBeforeRestaking(); - } + // cheats.prank(invalidCaller); + // cheats.expectRevert("EigenPod.onlyEigenPodOwner: not podOwner"); + // eigenPod.withdrawBeforeRestaking(); + // } - function test_withdrawBeforeRestaking_revert_alreadyRestaked() public { - cheats.expectRevert("EigenPod.hasNeverRestaked: restaking is enabled"); - eigenPod.withdrawBeforeRestaking(); - } + // function test_withdrawBeforeRestaking_revert_alreadyRestaked() public { + // cheats.expectRevert("EigenPod.hasNeverRestaked: restaking is enabled"); + // eigenPod.withdrawBeforeRestaking(); + // } - function testFuzz_withdrawBeforeRestaking(uint256 ethAmount) public hasNotRestaked { - // Seed some ETH - _seedPodWithETH(ethAmount); + // function testFuzz_withdrawBeforeRestaking(uint256 ethAmount) public hasNotRestaked { + // // Seed some ETH + // _seedPodWithETH(ethAmount); - // Withdraw - eigenPod.withdrawBeforeRestaking(); + // // Withdraw + // eigenPod.withdrawBeforeRestaking(); - // Checks - _assertWithdrawalProcessed(ethAmount); - } + // // Checks + // _assertWithdrawalProcessed(ethAmount); + // } // Helpers - function _assertWithdrawalProcessed(uint256 amount) internal { - assertEq(eigenPod.mostRecentWithdrawalTimestamp(), uint32(block.timestamp), "Incorrect mostRecentWithdrawalTimestamp"); - assertEq(eigenPod.nonBeaconChainETHBalanceWei(), 0, "Incorrect nonBeaconChainETHBalanceWei"); - assertEq(address(delayedWithdrawalRouterMock).balance, amount, "Incorrect amount sent to delayed withdrawal router"); - } + // function _assertWithdrawalProcessed(uint256 amount) internal { + // assertEq(eigenPod.mostRecentWithdrawalTimestamp(), uint32(block.timestamp), "Incorrect mostRecentWithdrawalTimestamp"); + // assertEq(eigenPod.nonBeaconChainETHBalanceWei(), 0, "Incorrect nonBeaconChainETHBalanceWei"); + // assertEq(address(delayedWithdrawalRouterMock).balance, amount, "Incorrect amount sent to delayed withdrawal router"); + // } function _seedPodWithETH(uint256 ethAmount) internal { cheats.deal(address(this), ethAmount);