Skip to content

Commit

Permalink
test: all tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
ypatil12 committed Oct 16, 2024
1 parent 3f6adfb commit 5f44707
Show file tree
Hide file tree
Showing 19 changed files with 982 additions and 933 deletions.
2 changes: 1 addition & 1 deletion script/configs/local/deploy_from_scratch.anvil.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"allocationManager": {
"init_paused_status": 0,
"DEALLOCATION_DELAY": 900,
"ALLOCATION_DELAY_CONFIGURATION_DELAY": 1200
"ALLOCATION_CONFIGURATION_DELAY": 1200
},
"ethPOSDepositAddress": "0x00000000219ab540356cBB839Cbe05303d7705Fa"
}
2 changes: 1 addition & 1 deletion script/deploy/holesky/M2_Deploy_From_Scratch.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ contract M2_Deploy_Holesky_From_Scratch is ExistingDeploymentParser {
strategyManager,
delegationManager
);
allocationManagerImplementation = new AllocationManager(delegationManager, avsDirectory, DEALLOCATION_DELAY, ALLOCATION_DELAY_CONFIGURATION_DELAY);
allocationManagerImplementation = new AllocationManager(delegationManager, avsDirectory, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);

// Third, upgrade the proxy contracts to point to the implementations
IStrategy[] memory initializeStrategiesToSetDelayBlocks = new IStrategy[](0);
Expand Down
8 changes: 4 additions & 4 deletions script/deploy/local/Deploy_From_Scratch.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ contract DeployFromScratch is Script, Test {

// AllocationManager
uint32 DEALLOCATION_DELAY;
uint32 ALLOCATION_DELAY_CONFIGURATION_DELAY;
uint32 ALLOCATION_CONFIGURATION_DELAY;

// RewardsCoordinator
uint32 REWARDS_COORDINATOR_MAX_REWARDS_DURATION;
Expand Down Expand Up @@ -161,8 +161,8 @@ contract DeployFromScratch is Script, Test {
DEALLOCATION_DELAY = uint32(
stdJson.readUint(config_data, ".allocationManager.DEALLOCATION_DELAY")
);
ALLOCATION_DELAY_CONFIGURATION_DELAY = uint32(
stdJson.readUint(config_data, ".allocationManager.ALLOCATION_DELAY_CONFIGURATION_DELAY")
ALLOCATION_CONFIGURATION_DELAY = uint32(
stdJson.readUint(config_data, ".allocationManager.ALLOCATION_CONFIGURATION_DELAY")
);

// tokens to deploy strategies for
Expand Down Expand Up @@ -252,7 +252,7 @@ contract DeployFromScratch is Script, Test {
REWARDS_COORDINATOR_MAX_FUTURE_LENGTH,
REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP
);
allocationManagerImplementation = new AllocationManager(delegation, avsDirectory, DEALLOCATION_DELAY, ALLOCATION_DELAY_CONFIGURATION_DELAY);
allocationManagerImplementation = new AllocationManager(delegation, avsDirectory, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);

// Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them.
{
Expand Down
2 changes: 1 addition & 1 deletion script/utils/ExistingDeploymentParser.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ contract ExistingDeploymentParser is Script, Test {
// AllocationManager
uint256 ALLOCATION_MANAGER_INIT_PAUSED_STATUS;
uint32 DEALLOCATION_DELAY;
uint32 ALLOCATION_DELAY_CONFIGURATION_DELAY;
uint32 ALLOCATION_CONFIGURATION_DELAY;
// EigenPod
uint64 EIGENPOD_GENESIS_TIME;
uint64 EIGENPOD_MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR;
Expand Down
18 changes: 9 additions & 9 deletions src/test/Delegation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ contract DelegationTests is EigenLayerTestHelper {
delegationApprover: address(0),
__deprecated_stakerOptOutWindowBlocks: 0
});
_testRegisterAsOperator(sender, 0, operatorDetails);
_testRegisterAsOperator(sender, 1, operatorDetails);
}

function testTwoSelfOperatorsRegister() public {
Expand Down Expand Up @@ -92,7 +92,7 @@ contract DelegationTests is EigenLayerTestHelper {
__deprecated_stakerOptOutWindowBlocks: 0
});
if (!delegation.isOperator(operator)) {
_testRegisterAsOperator(operator, 0, operatorDetails);
_testRegisterAsOperator(operator, 1, operatorDetails);
}

uint256 amountBefore = delegation.operatorShares(operator, wethStrat);
Expand Down Expand Up @@ -341,9 +341,9 @@ contract DelegationTests is EigenLayerTestHelper {
delegationApprover: address(0),
__deprecated_stakerOptOutWindowBlocks: 0
});
_testRegisterAsOperator(operator, 0, operatorDetails);
_testRegisterAsOperator(operator, 1, operatorDetails);
cheats.expectRevert(IDelegationManagerErrors.ActivelyDelegated.selector);
_testRegisterAsOperator(operator, 0, operatorDetails);
_testRegisterAsOperator(operator, 1, operatorDetails);
}

/// @notice This function tests to ensure that a staker cannot delegate to an unregistered operator
Expand Down Expand Up @@ -387,9 +387,9 @@ contract DelegationTests is EigenLayerTestHelper {
__deprecated_stakerOptOutWindowBlocks: 0
});
string memory emptyStringForMetadataURI;
delegation.registerAsOperator(operatorDetails, 0, emptyStringForMetadataURI);
delegation.registerAsOperator(operatorDetails, 1, emptyStringForMetadataURI);
cheats.expectRevert(IDelegationManagerErrors.ActivelyDelegated.selector);
delegation.registerAsOperator(operatorDetails, 0, emptyStringForMetadataURI);
delegation.registerAsOperator(operatorDetails, 1, emptyStringForMetadataURI);
cheats.stopPrank();
}

Expand Down Expand Up @@ -423,7 +423,7 @@ contract DelegationTests is EigenLayerTestHelper {
__deprecated_stakerOptOutWindowBlocks: 0
});
string memory emptyStringForMetadataURI;
delegation.registerAsOperator(operatorDetails, 0, emptyStringForMetadataURI);
delegation.registerAsOperator(operatorDetails, 1, emptyStringForMetadataURI);
vm.prank(_staker);
ISignatureUtils.SignatureWithExpiry memory signatureWithExpiry;
delegation.delegateTo(_operator, signatureWithExpiry, bytes32(0));
Expand Down Expand Up @@ -459,7 +459,7 @@ contract DelegationTests is EigenLayerTestHelper {
delegationApprover: address(0),
__deprecated_stakerOptOutWindowBlocks: 0
});
_testRegisterAsOperator(sender, 0, operatorDetails);
_testRegisterAsOperator(sender, 1, operatorDetails);
cheats.startPrank(sender);

cheats.stopPrank();
Expand All @@ -484,7 +484,7 @@ contract DelegationTests is EigenLayerTestHelper {
delegationApprover: address(0),
__deprecated_stakerOptOutWindowBlocks: 0
});
_testRegisterAsOperator(operator, 0, operatorDetails);
_testRegisterAsOperator(operator, 1, operatorDetails);
}

//making additional deposits to the strategies
Expand Down
2 changes: 1 addition & 1 deletion src/test/EigenLayerTestHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ contract EigenLayerTestHelper is EigenLayerDeployer {
delegationApprover: address(0),
__deprecated_stakerOptOutWindowBlocks: 0
});
_testRegisterAsOperator(operator, 0, operatorDetails);
_testRegisterAsOperator(operator, 1, operatorDetails);
}

uint256 amountBefore = delegation.operatorShares(operator, wethStrat);
Expand Down
130 changes: 66 additions & 64 deletions src/test/Withdrawals.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,38 +97,39 @@ contract WithdrawalTests is EigenLayerTestHelper {
cheats.warp(uint32(block.timestamp) + 2 days);
cheats.roll(uint32(block.timestamp) + 2 days);

{
//warp past the serve until time, which is 3 days from the beginning. THis puts us at 4 days past that point
cheats.warp(uint32(block.timestamp) + 4 days);
cheats.roll(uint32(block.timestamp) + 4 days);

uint256 middlewareTimeIndex = 1;
if (withdrawAsTokens) {
_testCompleteQueuedWithdrawalTokens(
depositor,
dataForTestWithdrawal.delegatorStrategies,
tokensArray,
dataForTestWithdrawal.delegatorShares,
delegatedTo,
dataForTestWithdrawal.withdrawer,
dataForTestWithdrawal.nonce,
queuedWithdrawalBlock,
middlewareTimeIndex
);
} else {
_testCompleteQueuedWithdrawalShares(
depositor,
dataForTestWithdrawal.delegatorStrategies,
tokensArray,
dataForTestWithdrawal.delegatorShares,
delegatedTo,
dataForTestWithdrawal.withdrawer,
dataForTestWithdrawal.nonce,
queuedWithdrawalBlock,
middlewareTimeIndex
);
}
}
// TODO: fix this to properly test the withdrawal
// {
// //warp past the serve until time, which is 3 days from the beginning. THis puts us at 4 days past that point
// cheats.warp(uint32(block.timestamp) + 4 days);
// cheats.roll(uint32(block.timestamp) + 4 days);

// uint256 middlewareTimeIndex = 1;
// if (withdrawAsTokens) {
// _testCompleteQueuedWithdrawalTokens(
// depositor,
// dataForTestWithdrawal.delegatorStrategies,
// tokensArray,
// dataForTestWithdrawal.delegatorShares,
// delegatedTo,
// dataForTestWithdrawal.withdrawer,
// dataForTestWithdrawal.nonce,
// queuedWithdrawalBlock,
// middlewareTimeIndex
// );
// } else {
// _testCompleteQueuedWithdrawalShares(
// depositor,
// dataForTestWithdrawal.delegatorStrategies,
// tokensArray,
// dataForTestWithdrawal.delegatorShares,
// delegatedTo,
// dataForTestWithdrawal.withdrawer,
// dataForTestWithdrawal.nonce,
// queuedWithdrawalBlock,
// middlewareTimeIndex
// );
// }
// }
}

/// @notice test staker's ability to undelegate/withdraw from an operator.
Expand Down Expand Up @@ -205,38 +206,39 @@ contract WithdrawalTests is EigenLayerTestHelper {

// prevElement = uint256(uint160(address(generalServiceManager1)));

{
//warp past the serve until time, which is 3 days from the beginning. THis puts us at 4 days past that point
cheats.warp(uint32(block.timestamp) + 4 days);
cheats.roll(uint32(block.number) + 4);

uint256 middlewareTimeIndex = 3;
if (withdrawAsTokens) {
_testCompleteQueuedWithdrawalTokens(
depositor,
dataForTestWithdrawal.delegatorStrategies,
tokensArray,
dataForTestWithdrawal.delegatorShares,
delegatedTo,
dataForTestWithdrawal.withdrawer,
dataForTestWithdrawal.nonce,
queuedWithdrawalBlock,
middlewareTimeIndex
);
} else {
_testCompleteQueuedWithdrawalShares(
depositor,
dataForTestWithdrawal.delegatorStrategies,
tokensArray,
dataForTestWithdrawal.delegatorShares,
delegatedTo,
dataForTestWithdrawal.withdrawer,
dataForTestWithdrawal.nonce,
queuedWithdrawalBlock,
middlewareTimeIndex
);
}
}
// TODO: update this to handle blockNumbers instead of timestamps
// {
// //warp past the serve until time, which is 3 days from the beginning. THis puts us at 4 days past that point
// cheats.warp(uint32(block.timestamp) + 4 days);
// cheats.roll(uint32(block.number) + 4);

// uint256 middlewareTimeIndex = 3;
// if (withdrawAsTokens) {
// _testCompleteQueuedWithdrawalTokens(
// depositor,
// dataForTestWithdrawal.delegatorStrategies,
// tokensArray,
// dataForTestWithdrawal.delegatorShares,
// delegatedTo,
// dataForTestWithdrawal.withdrawer,
// dataForTestWithdrawal.nonce,
// queuedWithdrawalBlock,
// middlewareTimeIndex
// );
// } else {
// _testCompleteQueuedWithdrawalShares(
// depositor,
// dataForTestWithdrawal.delegatorStrategies,
// tokensArray,
// dataForTestWithdrawal.delegatorShares,
// delegatedTo,
// dataForTestWithdrawal.withdrawer,
// dataForTestWithdrawal.nonce,
// queuedWithdrawalBlock,
// middlewareTimeIndex
// );
// }
// }
}

// @notice This function tests to ensure that a delegator can re-delegate to an operator after undelegating.
Expand Down
22 changes: 20 additions & 2 deletions src/test/integration/IntegrationDeployer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
strategyFactory = StrategyFactory(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);
allocationManager = AllocationManager(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);

// Deploy EigenPod Contracts
eigenPodImplementation = new EigenPod(
Expand All @@ -261,6 +264,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
);
avsDirectoryImplementation = new AVSDirectory(delegationManager, DEALLOCATION_DELAY);
strategyFactoryImplementation = new StrategyFactory(strategyManager);
allocationManagerImplementation = new AllocationManager(delegationManager, avsDirectory, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);

// Third, upgrade the proxy contracts to point to the implementations
uint256 withdrawalDelayBlocks = 7 days / 12 seconds;
Expand Down Expand Up @@ -314,6 +318,17 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
0 // initialPausedStatus
)
);
// AllocationManager
eigenLayerProxyAdmin.upgradeAndCall(
ITransparentUpgradeableProxy(payable(address(allocationManager))),
address(allocationManagerImplementation),
abi.encodeWithSelector(
AllocationManager.initialize.selector,
eigenLayerReputedMultisig, // initialOwner
eigenLayerPauserReg,
0 // initialPausedStatus
)
);
// Create base strategy implementation and deploy a few strategies
baseStrategyImplementation = new StrategyBase(strategyManager);

Expand Down Expand Up @@ -351,9 +366,12 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
allTokens.push(NATIVE_ETH);

// Create time machine and beacon chain. Set block time to beacon chain genesis time
cheats.warp(GENESIS_TIME_LOCAL);
// TODO: update if needed to sane timestamp
// cheats.warp(GENESIS_TIME_LOCAL);
cheats.warp(delegationManager.LEGACY_WITHDRAWALS_TIMESTAMP());
timeMachine = new TimeMachine();
beaconChain = new BeaconChainMock(eigenPodManager, GENESIS_TIME_LOCAL);
// beaconChain = new BeaconChainMock(eigenPodManager, GENESIS_TIME_LOCAL);
beaconChain = new BeaconChainMock(eigenPodManager, delegationManager.LEGACY_WITHDRAWALS_TIMESTAMP());
}

/**
Expand Down
Loading

0 comments on commit 5f44707

Please sign in to comment.