Skip to content

Commit

Permalink
cleanup, test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidu28 committed Oct 10, 2023
1 parent abc94f0 commit 882e5d8
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/contracts/pods/EigenPod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ contract EigenPod is IEigenPod, Initializable, ReentrancyGuardUpgradeable, Eigen
uint64 withdrawalAmountGwei,
ValidatorInfo memory validatorInfo
) internal returns (VerifiedWithdrawal memory) {
emit log("HELLO");
VerifiedWithdrawal memory verifiedWithdrawal;
uint256 withdrawalAmountWei;

Expand Down
64 changes: 63 additions & 1 deletion src/test/EigenPod.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants {
IDelayedWithdrawalRouter public delayedWithdrawalRouter;
IETHPOSDeposit public ethPOSDeposit;
IBeacon public eigenPodBeacon;
EPInternalFunctions public podInternalFunctionTester;

BeaconChainOracleMock public beaconChainOracle;
MiddlewareRegistryMock public generalReg1;
ServiceManagerMock public generalServiceManager1;
Expand Down Expand Up @@ -155,6 +157,12 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants {
MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR,
RESTAKED_BALANCE_OFFSET_GWEI
);
podInternalFunctionTester = new EPInternalFunctions(ethPOSDeposit,
delayedWithdrawalRouter,
IEigenPodManager(podManagerAddress),
MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR,
RESTAKED_BALANCE_OFFSET_GWEI
);
eigenPodBeacon = new UpgradeableBeacon(address(podImplementation));

// this contract is deployed later to keep its address the same (for these tests)
Expand Down Expand Up @@ -237,7 +245,9 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants {
strategyManager
);

cheats.deal(address(podOwner), 5*stakeAmount);
cheats.deal(address(podOwner), 5*stakeAmount);

emit log("WHT is happ");

fuzzedAddressMapping[address(0)] = true;
fuzzedAddressMapping[address(eigenLayerProxyAdmin)] = true;
Expand All @@ -247,6 +257,7 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants {
fuzzedAddressMapping[address(slasher)] = true;
fuzzedAddressMapping[address(generalServiceManager1)] = true;
fuzzedAddressMapping[address(generalReg1)] = true;
emit log("WHT is happ");
}

function testStaking() public {
Expand Down Expand Up @@ -456,6 +467,19 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants {
return newPod;
}

function testProcessFullWithdrawalForLessThanMaxRestakedBalance(uint64 withdrawalAmount) public {
cheats.assume(withdrawalAmount > 0 && withdrawalAmount < MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR);
IEigenPod.ValidatorInfo memory validatorInfo = IEigenPod.ValidatorInfo({
validatorIndex: 0,
restakedBalanceGwei: 0,
mostRecentBalanceUpdateTimestamp: 0,
status: IEigenPod.VALIDATOR_STATUS.ACTIVE
});
uint64 balanceBefore = podInternalFunctionTester.withdrawableRestakedExecutionLayerGwei();
podInternalFunctionTester.processFullWithdrawal(0, bytes32(0), 0, podOwner, withdrawalAmount, validatorInfo);
require(podInternalFunctionTester.withdrawableRestakedExecutionLayerGwei() - balanceBefore == withdrawalAmount, "withdrawableRestakedExecutionLayerGwei hasn't been updated correctly");
}

/**
* @notice this test is to ensure that a full withdrawal can be made once a validator has processed their first full withrawal
* This is specifically for the case where a validator has redeposited into their exited validator and needs to prove another withdrawal
Expand Down Expand Up @@ -1457,4 +1481,42 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants {
) public view {
BeaconChainProofs.verifyWithdrawal(beaconStateRoot, withdrawalFields, proofs);
}
}

contract EPInternalFunctions is EigenPod {

constructor(
IETHPOSDeposit _ethPOS,
IDelayedWithdrawalRouter _delayedWithdrawalRouter,
IEigenPodManager _eigenPodManager,
uint64 _MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR,
uint64 _RESTAKED_BALANCE_OFFSET_GWEI
) EigenPod(
_ethPOS,
_delayedWithdrawalRouter,
_eigenPodManager,
_MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR,
_RESTAKED_BALANCE_OFFSET_GWEI
) {
emit log("CONTRUCTOR");
}

function processFullWithdrawal(
uint40 validatorIndex,
bytes32 validatorPubkeyHash,
uint64 withdrawalHappenedTimestamp,
address recipient,
uint64 withdrawalAmountGwei,
ValidatorInfo memory validatorInfo
) public {
emit log_named_uint("withdrawalAmountGwei", withdrawalAmountGwei);
_processFullWithdrawal(
validatorIndex,
validatorPubkeyHash,
withdrawalHappenedTimestamp,
recipient,
withdrawalAmountGwei,
validatorInfo
);
}
}

0 comments on commit 882e5d8

Please sign in to comment.