From 951a9018b221eae7817e90fbbffefb6f239db90c Mon Sep 17 00:00:00 2001 From: wadealexc Date: Mon, 13 Jan 2025 19:45:12 +0000 Subject: [PATCH] test: remove unneeded logic from integration test setup --- src/test/integration/IntegrationBase.t.sol | 12 +- .../integration/IntegrationDeployer.t.sol | 609 ++++++------------ .../integration/mocks/BeaconChainMock.t.sol | 3 + 3 files changed, 195 insertions(+), 429 deletions(-) diff --git a/src/test/integration/IntegrationBase.t.sol b/src/test/integration/IntegrationBase.t.sol index 852352e910..eeea43720e 100644 --- a/src/test/integration/IntegrationBase.t.sol +++ b/src/test/integration/IntegrationBase.t.sol @@ -147,6 +147,10 @@ abstract contract IntegrationBase is IntegrationDeployer { emit log("_upgradeEigenLayerContracts: upgrading mainnet to slashing"); _upgradeMainnetContracts(); + // Unpause EigenPodManager + cheats.prank(eigenLayerPauserReg.unpauser()); + eigenPodManager.unpause(0); + // Bump block.timestamp forward to allow verifyWC proofs for migrated pods emit log("advancing block time to start of next epoch:"); @@ -154,14 +158,6 @@ abstract contract IntegrationBase is IntegrationDeployer { emit log("======"); - isUpgraded = true; - emit log("_upgradeEigenLayerContracts: slashing upgrade complete"); - } else if (forkType == HOLESKY) { - require(!isUpgraded, "_upgradeEigenLayerContracts: already performed slashing upgrade"); - - emit log("_upgradeEigenLayerContracts: upgrading holesky to slashing"); - _upgradeHoleskyContracts(); - isUpgraded = true; emit log("_upgradeEigenLayerContracts: slashing upgrade complete"); } diff --git a/src/test/integration/IntegrationDeployer.t.sol b/src/test/integration/IntegrationDeployer.t.sol index 4f5b07cd7b..e71cccd1e3 100644 --- a/src/test/integration/IntegrationDeployer.t.sol +++ b/src/test/integration/IntegrationDeployer.t.sol @@ -30,20 +30,6 @@ import "src/test/integration/users/User_M2.t.sol"; import "script/utils/ExistingDeploymentParser.sol"; -// DelegationManager -uint8 constant PAUSED_NEW_DELEGATION = 0; -uint8 constant PAUSED_ENTER_WITHDRAWAL_QUEUE = 1; -uint8 constant PAUSED_EXIT_WITHDRAWAL_QUEUE = 2; -// StrategyManager -uint8 constant PAUSED_DEPOSITS = 0; -// EigenpodManager -uint8 constant PAUSED_NEW_EIGENPODS = 0; -uint8 constant PAUSED_WITHDRAW_RESTAKED_ETH = 1; -uint8 constant PAUSED_EIGENPODS_VERIFY_CREDENTIALS = 2; -uint8 constant PAUSED_EIGENPODS_VERIFY_BALANCE_UPDATE = 3; -uint8 constant PAUSED_EIGENPODS_VERIFY_WITHDRAWAL = 4; -uint8 constant PAUSED_NON_PROOF_WITHDRAWALS = 5; - IStrategy constant beaconChainETHStrategy = IStrategy(0xbeaC0eeEeeeeEEeEeEEEEeeEEeEeeeEeeEEBEaC0); abstract contract IntegrationDeployer is ExistingDeploymentParser { @@ -51,21 +37,18 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { // Fork ids for specific fork tests bool isUpgraded; - uint mainnetForkBlock = 20_847_130; // Post PI upgrade - uint mainnetForkId; - uint holeskyForkBLock = 1_213_950; - uint holeskyForkId; - uint64 constant DENEB_FORK_TIMESTAMP = 1_705_473_120; + uint mainnetForkBlock = 21_616_692; // Post Protocol Council upgrade // Beacon chain genesis time when running locally // Multiple of 12 for sanity's sake uint64 constant GENESIS_TIME_LOCAL = 1 hours * 12; uint64 constant GENESIS_TIME_MAINNET = 1_606_824_023; + uint64 BEACON_GENESIS_TIME; // set after forkType is decided - uint8 constant NUM_LST_STRATS = 32; - - TimeMachine public timeMachine; + // Beacon chain deposit contract. The BeaconChainMock contract etchs ETHPOSDepositMock code here. + IETHPOSDeposit constant DEPOSIT_CONTRACT = IETHPOSDeposit(0x00000000219ab540356cBB839Cbe05303d7705Fa); + uint8 constant NUM_LST_STRATS = 32; // Lists of strategies used in the system // // When we select random user assets, we use the `assetType` to determine @@ -79,11 +62,10 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { mapping(address => bool) public tokensNotTested; // Mock Contracts to deploy - ETHPOSDepositMock ethPOSDeposit; + TimeMachine public timeMachine; BeaconChainMock public beaconChain; // Admin Addresses - address eigenLayerReputedMultisig = address(this); // admin address address constant pauser = address(555); address constant unpauser = address(556); @@ -96,9 +78,6 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { // Set only once in setUp, if FORK_MAINNET env is set uint forkType; - // Constants - uint64 constant MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR = 32e9; - constructor() { address stETH_Holesky = 0x3F1c547b21f65e10480dE3ad8E19fAAC46C95034; address stETH_Mainnet = 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84; @@ -137,22 +116,20 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { bool forkMainnet = _hash("forktest") == _hash(cheats.envOr(string("FOUNDRY_PROFILE"), string("default"))); if (forkMainnet) { - console.log("Setting up `%s` integration tests:", "MAINNET_FORK".green().bold()); - console.log("RPC:", cheats.rpcUrl("mainnet")); - console.log("Block:", mainnetForkBlock); - - cheats.createSelectFork(cheats.rpcUrl("mainnet"), mainnetForkBlock); forkType = MAINNET; + _setUpMainnet(); } else { - console.log("Setting up `%s` integration tests:", "LOCAL".yellow().bold()); - forkType = LOCAL; + _setUpLocal(); } - - _deployOrFetchContracts(); } + /// Deploy EigenLayer locally function _setUpLocal() public virtual { + console.log("Setting up `%s` integration tests:", "LOCAL".yellow().bold()); + // Bypass upgrade tests when running locally + isUpgraded = true; + // Deploy ProxyAdmin eigenLayerProxyAdmin = new ProxyAdmin(); executorMultisig = address(eigenLayerProxyAdmin.owner()); @@ -163,138 +140,25 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { eigenLayerPauserReg = new PauserRegistry(pausers, unpauser); // Deploy mocks - EmptyContract emptyContract = new EmptyContract(); - ethPOSDeposit = new ETHPOSDepositMock(); + emptyContract = new EmptyContract(); // Matching parameters to testnet DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS = 50; DEALLOCATION_DELAY = 50; ALLOCATION_CONFIGURATION_DELAY = 75; - /** - * First, deploy upgradeable proxy contracts that **will point** to the implementations. Since the implementation contracts are - * not yet deployed, we give these proxies an empty contract as the initial implementation, to act as if they have no code. - */ - delegationManager = DelegationManager( - address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) - ); - strategyManager = StrategyManager( - address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) - ); - eigenPodManager = EigenPodManager( - address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) - ); - avsDirectory = AVSDirectory( - address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) - ); - strategyFactory = StrategyFactory( - address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) - ); - allocationManager = AllocationManager( - address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) - ); - permissionController = PermissionController( - address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) - ); - - // Deploy EigenPod Contracts - eigenPodImplementation = new EigenPod(ethPOSDeposit, eigenPodManager, GENESIS_TIME_LOCAL); - - eigenPodBeacon = new UpgradeableBeacon(address(eigenPodImplementation)); - // Second, deploy the *implementation* contracts, using the *proxy contracts* as inputs - delegationManagerImplementation = new DelegationManager(strategyManager, eigenPodManager, allocationManager, eigenLayerPauserReg, permissionController, DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS); - strategyManagerImplementation = new StrategyManager(delegationManager, eigenLayerPauserReg); - eigenPodManagerImplementation = new EigenPodManager( - ethPOSDeposit, - eigenPodBeacon, - delegationManager, - eigenLayerPauserReg - ); - strategyManagerImplementation = new StrategyManager(delegationManager, eigenLayerPauserReg); - eigenPodManagerImplementation = new EigenPodManager(ethPOSDeposit, eigenPodBeacon, delegationManager, eigenLayerPauserReg); - avsDirectoryImplementation = new AVSDirectory(delegationManager, eigenLayerPauserReg); - strategyFactoryImplementation = new StrategyFactory(strategyManager, eigenLayerPauserReg); - allocationManagerImplementation = new AllocationManager(delegationManager, eigenLayerPauserReg, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY); - permissionControllerImplementation = new PermissionController(); - - // Third, upgrade the proxy contracts to point to the implementations - // DelegationManager - eigenLayerProxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(payable(address(delegationManager))), - address(delegationManagerImplementation), - abi.encodeWithSelector( - DelegationManager.initialize.selector, - eigenLayerReputedMultisig, // initialOwner - 0 /* initialPausedStatus */ - ) - ); - // StrategyManager - eigenLayerProxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(payable(address(strategyManager))), - address(strategyManagerImplementation), - abi.encodeWithSelector( - StrategyManager.initialize.selector, - eigenLayerReputedMultisig, //initialOwner - eigenLayerReputedMultisig, //initial whitelister - 0 // initialPausedStatus - ) - ); - // EigenPodManager - eigenLayerProxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(payable(address(eigenPodManager))), - address(eigenPodManagerImplementation), - abi.encodeWithSelector( - EigenPodManager.initialize.selector, - eigenLayerReputedMultisig, // initialOwner - 0 // initialPausedStatus - ) - ); - // AVSDirectory - eigenLayerProxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(payable(address(avsDirectory))), - address(avsDirectoryImplementation), - abi.encodeWithSelector( - AVSDirectory.initialize.selector, - eigenLayerReputedMultisig, // initialOwner - 0 // initialPausedStatus - ) - ); - // AllocationManager - eigenLayerProxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(payable(address(allocationManager))), - address(allocationManagerImplementation), - abi.encodeWithSelector( - AllocationManager.initialize.selector, - eigenLayerReputedMultisig, // initialOwner - 0 // initialPausedStatus - ) - ); - //PermissionController - eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(permissionController))), - address(permissionControllerImplementation) - ); - // Create base strategy implementation and deploy a few strategies - baseStrategyImplementation = new StrategyBase(strategyManager, eigenLayerPauserReg); - - // Create a proxy beacon for base strategy implementation - strategyBeacon = new UpgradeableBeacon(address(baseStrategyImplementation)); - - // Strategy Factory, upgrade and initalized - eigenLayerProxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(payable(address(strategyFactory))), - address(strategyFactoryImplementation), - abi.encodeWithSelector( - StrategyFactory.initialize.selector, - eigenLayerReputedMultisig, - 0, // initial paused status - IBeacon(strategyBeacon) - ) - ); + REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS = 86400; + REWARDS_COORDINATOR_MAX_REWARDS_DURATION = 6048000; + REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH = 7776000; + REWARDS_COORDINATOR_MAX_FUTURE_LENGTH = 2592000; + REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP = 1710979200; - cheats.prank(eigenLayerReputedMultisig); - strategyManager.setStrategyWhitelister(address(strategyFactory)); + _deployProxies(); + _deployImplementations(); + _upgradeProxies(); + _initializeProxies(); + // Deploy and configure strategies and tokens for (uint i = 1; i < NUM_LST_STRATS + 1; ++i) { string memory name = string.concat("LST-Strat", cheats.toString(i), " token"); string memory symbol = string.concat("lstStrat", cheats.toString(i)); @@ -307,24 +171,49 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { allTokens.push(NATIVE_ETH); // Create time machine and beacon chain. Set block time to beacon chain genesis time - // TODO: update if needed to sane timestamp - cheats.warp(GENESIS_TIME_LOCAL); + BEACON_GENESIS_TIME = GENESIS_TIME_LOCAL; + cheats.warp(BEACON_GENESIS_TIME); timeMachine = new TimeMachine(); - beaconChain = new BeaconChainMock(eigenPodManager, GENESIS_TIME_LOCAL); + beaconChain = new BeaconChainMock(eigenPodManager, BEACON_GENESIS_TIME); } - /** - * @notice deploy current implementation contracts and upgrade the existing proxy EigenLayer contracts - * on Mainnet. Setup for integration tests on mainnet fork. - * - * Note that beacon chain oracle and eth deposit contracts are mocked and pointed to different addresses for these tests. - */ + /// Parse existing contracts from mainnet + function _setUpMainnet() public virtual { + console.log("Setting up `%s` integration tests:", "MAINNET_FORK".green().bold()); + console.log("RPC:", cheats.rpcUrl("mainnet")); + console.log("Block:", mainnetForkBlock); + + cheats.createSelectFork(cheats.rpcUrl("mainnet"), mainnetForkBlock); + + string memory deploymentInfoPath = "script/configs/mainnet/mainnet-addresses.config.json"; + _parseDeployedContracts(deploymentInfoPath); + string memory existingDeploymentParams = "script/configs/mainnet.json"; + _parseParamsForIntegrationUpgrade(existingDeploymentParams); + + // Add deployed strategies to lstStrats and allStrats + for (uint i; i < deployedStrategyArray.length; i++) { + IStrategy strategy = IStrategy(deployedStrategyArray[i]); + + if (tokensNotTested[address(strategy.underlyingToken())]) { + continue; + } + + // Add to lstStrats and allStrats + lstStrats.push(strategy); + allStrats.push(strategy); + allTokens.push(strategy.underlyingToken()); + } + + // Create time machine and mock beacon chain + BEACON_GENESIS_TIME = GENESIS_TIME_MAINNET; + timeMachine = new TimeMachine(); + beaconChain = new BeaconChainMock(eigenPodManager, BEACON_GENESIS_TIME); + } + + /// Deploy current implementation contracts and upgrade existing proxies function _upgradeMainnetContracts() public virtual { cheats.startPrank(address(executorMultisig)); - ethPOSDeposit = new ETHPOSDepositMock(); - ETHPOSDepositAddress = address(ethPOSDeposit); // overwrite for upgrade checks later - // First, deploy the new contracts as empty contracts emptyContract = new EmptyContract(); allocationManager = AllocationManager( @@ -334,7 +223,58 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) ); - // Second, deploy the *implementation* contracts, using the *proxy contracts* as inputs + emit log_named_uint("EPM pause status", eigenPodManager.paused()); + + // Deploy new implementation contracts and upgrade all proxies to point to them + _deployImplementations(); + _upgradeProxies(); + + emit log_named_uint("EPM pause status", eigenPodManager.paused()); + + // Initialize the newly-deployed proxy + allocationManager.initialize({ + initialOwner: executorMultisig, + initialPausedStatus: 0 + }); + + cheats.stopPrank(); + + ethStrats.push(BEACONCHAIN_ETH_STRAT); + allStrats.push(BEACONCHAIN_ETH_STRAT); + allTokens.push(NATIVE_ETH); + } + + function _deployProxies() public { + delegationManager = DelegationManager( + address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) + ); + strategyManager = StrategyManager( + address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) + ); + eigenPodManager = EigenPodManager( + address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) + ); + rewardsCoordinator = RewardsCoordinator( + address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) + ); + avsDirectory = AVSDirectory( + address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) + ); + strategyFactory = StrategyFactory( + address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) + ); + allocationManager = AllocationManager( + address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) + ); + permissionController = PermissionController( + address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) + ); + eigenPodBeacon = new UpgradeableBeacon(address(emptyContract)); + strategyBeacon = new UpgradeableBeacon(address(emptyContract)); + } + + /// Deploy an implementation contract for each contract in the system + function _deployImplementations() public { allocationManagerImplementation = new AllocationManager(delegationManager, eigenLayerPauserReg, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY); permissionControllerImplementation = new PermissionController(); delegationManagerImplementation = new DelegationManager(strategyManager, eigenPodManager, allocationManager, eigenLayerPauserReg, permissionController, DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS); @@ -353,141 +293,75 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { ); avsDirectoryImplementation = new AVSDirectory(delegationManager, eigenLayerPauserReg); eigenPodManagerImplementation = new EigenPodManager( - ethPOSDeposit, + DEPOSIT_CONTRACT, eigenPodBeacon, delegationManager, eigenLayerPauserReg ); - eigenPodImplementation = new EigenPod(ethPOSDeposit, eigenPodManager, GENESIS_TIME_MAINNET); strategyFactoryImplementation = new StrategyFactory(strategyManager, eigenLayerPauserReg); + + // Beacon implementations + eigenPodImplementation = new EigenPod(DEPOSIT_CONTRACT, eigenPodManager, BEACON_GENESIS_TIME); baseStrategyImplementation = new StrategyBase(strategyManager, eigenLayerPauserReg); - // Third, upgrade the proxy contracts to point to the implementations - - // Initialize the newly deployed contracts - eigenLayerProxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(payable(address(allocationManager))), - address(allocationManagerImplementation), - abi.encodeWithSelector( - AllocationManager.initialize.selector, - executorMultisig, - 0 // initialPausedStatus - ) - ); - eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(permissionController))), - address(permissionControllerImplementation) - ); + // Pre-longtail StrategyBaseTVLLimits implementation + // TODO - need to update ExistingDeploymentParser + } + function _upgradeProxies() public { // DelegationManager eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(delegationManager))), address(delegationManagerImplementation) + ITransparentUpgradeableProxy(payable(address(delegationManager))), + address(delegationManagerImplementation) ); + // StrategyManager eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(strategyManager))), address(strategyManagerImplementation) - ); - // RewardsCoordinator - eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(rewardsCoordinator))), address(rewardsCoordinatorImplementation) - ); - // AVSDirectory - eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(avsDirectory))), address(avsDirectoryImplementation) + ITransparentUpgradeableProxy(payable(address(strategyManager))), + address(strategyManagerImplementation) ); + // EigenPodManager eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(eigenPodManager))), address(eigenPodManagerImplementation) - ); - // EigenPod - eigenPodBeacon.upgradeTo(address(eigenPodImplementation)); - // StrategyFactory - eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(strategyFactory))), address(strategyFactoryImplementation) + ITransparentUpgradeableProxy(payable(address(eigenPodManager))), + address(eigenPodManagerImplementation) ); - // Strategy Beacon - strategyBeacon.upgradeTo(address(baseStrategyImplementation)); - // Upgrade All deployed strategy contracts to new base strategy - for (uint i = 0; i < numStrategiesDeployed; i++) { - // Upgrade existing strategy - eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(deployedStrategyArray[i]))), - address(baseStrategyImplementation) - ); - } - - // Third, unpause core contracts - delegationManager.unpause(0); - eigenPodManager.unpause(0); - strategyManager.unpause(0); - - cheats.stopPrank(); - - ethStrats.push(BEACONCHAIN_ETH_STRAT); - allStrats.push(BEACONCHAIN_ETH_STRAT); - allTokens.push(NATIVE_ETH); - } - - /** - * @notice deploy current implementation contracts and upgrade the existing proxy EigenLayer contracts - * on Holesky. Setup for integration tests on Holesky fork. - * - * Note that beacon chain oracle and eth deposit contracts are mocked and pointed to different addresses for these tests. - */ - function _upgradeHoleskyContracts() public virtual { - cheats.startPrank(address(executorMultisig)); - - ethPOSDeposit = new ETHPOSDepositMock(); - ETHPOSDepositAddress = address(ethPOSDeposit); // overwrite for upgrade checks later - - // Deploy EigenPod Contracts - eigenPodImplementation = new EigenPod(ethPOSDeposit, eigenPodManager, 0); - eigenPodBeacon.upgradeTo(address(eigenPodImplementation)); - // Deploy AVSDirectory, contract has not been deployed on mainnet yet - avsDirectory = AVSDirectory( - address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")) + // RewardsCoordinator + eigenLayerProxyAdmin.upgrade( + ITransparentUpgradeableProxy(payable(address(rewardsCoordinator))), + address(rewardsCoordinatorImplementation) ); - // First, deploy the *implementation* contracts, using the *proxy contracts* as inputs - delegationManagerImplementation = new DelegationManager(strategyManager, eigenPodManager, allocationManager, eigenLayerPauserReg, permissionController, DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS); - strategyManagerImplementation = new StrategyManager(delegationManager, eigenLayerPauserReg); - eigenPodManagerImplementation = new EigenPodManager( - ethPOSDeposit, - eigenPodBeacon, - delegationManager, - eigenLayerPauserReg + // AVSDirectory + eigenLayerProxyAdmin.upgrade( + ITransparentUpgradeableProxy(payable(address(avsDirectory))), + address(avsDirectoryImplementation) ); - strategyManagerImplementation = new StrategyManager(delegationManager, eigenLayerPauserReg); - eigenPodManagerImplementation = new EigenPodManager(ethPOSDeposit, eigenPodBeacon, delegationManager, eigenLayerPauserReg); - avsDirectoryImplementation = new AVSDirectory(delegationManager, eigenLayerPauserReg); - // Second, upgrade the proxy contracts to point to the implementations - // DelegationManager + // AllocationManager eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(delegationManager))), address(delegationManagerImplementation) + ITransparentUpgradeableProxy(payable(address(allocationManager))), + address(allocationManagerImplementation) ); - // StrategyManager + + // PermissionController eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(strategyManager))), address(strategyManagerImplementation) + ITransparentUpgradeableProxy(payable(address(permissionController))), + address(permissionControllerImplementation) ); - // EigenPodManager + + // StrategyFactory eigenLayerProxyAdmin.upgrade( - ITransparentUpgradeableProxy(payable(address(eigenPodManager))), address(eigenPodManagerImplementation) - ); - // AVSDirectory, upgrade and initalized - eigenLayerProxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(payable(address(avsDirectory))), - address(avsDirectoryImplementation), - abi.encodeWithSelector( - AVSDirectory.initialize.selector, - executorMultisig, - 0 // initialPausedStatus - ) + ITransparentUpgradeableProxy(payable(address(strategyFactory))), + address(strategyFactoryImplementation) ); - // Create base strategy implementation and deploy a few strategies - baseStrategyImplementation = new StrategyBase(strategyManager, eigenLayerPauserReg); + // EigenPod beacon + eigenPodBeacon.upgradeTo(address(eigenPodImplementation)); + + // StrategyBase Beacon + strategyBeacon.upgradeTo(address(baseStrategyImplementation)); // Upgrade All deployed strategy contracts to new base strategy for (uint i = 0; i < numStrategiesDeployed; i++) { @@ -497,17 +371,40 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { address(baseStrategyImplementation) ); } + } - // Third, unpause core contracts - delegationManager.unpause(0); - eigenPodManager.unpause(0); - strategyManager.unpause(0); - - cheats.stopPrank(); - - ethStrats.push(BEACONCHAIN_ETH_STRAT); - allStrats.push(BEACONCHAIN_ETH_STRAT); - allTokens.push(NATIVE_ETH); + function _initializeProxies() public { + delegationManager.initialize({ + initialOwner: executorMultisig, + initialPausedStatus: 0 + }); + + strategyManager.initialize({ + initialOwner: executorMultisig, + initialStrategyWhitelister: address(strategyFactory), + initialPausedStatus: 0 + }); + + eigenPodManager.initialize({ + initialOwner: executorMultisig, + _initPausedStatus: 0 + }); + + avsDirectory.initialize({ + initialOwner: executorMultisig, + initialPausedStatus: 0 + }); + + allocationManager.initialize({ + initialOwner: executorMultisig, + initialPausedStatus: 0 + }); + + strategyFactory.initialize({ + _initialOwner: executorMultisig, + _initialPausedStatus: 0, + _strategyBeacon: strategyBeacon + }); } /// @dev Deploy a strategy and its underlying token, push to global lists of tokens/strategies, and whitelist @@ -541,15 +438,8 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { IStrategy[] memory strategies = new IStrategy[](1); strategies[0] = strategy; - if (forkType == MAINNET) { - cheats.prank(strategyManager.strategyWhitelister()); - IStrategyManager_DeprecatedM1(address(strategyManager)).addStrategiesToDepositWhitelist(strategies); - cheats.prank(eigenLayerPauserReg.unpauser()); - StrategyBaseTVLLimits(address(strategy)).setTVLLimits(type(uint).max, type(uint).max); - } else { - cheats.prank(strategyManager.strategyWhitelister()); - strategyManager.addStrategiesToDepositWhitelist(strategies); - } + cheats.prank(strategyManager.strategyWhitelister()); + strategyManager.addStrategiesToDepositWhitelist(strategies); // Add to lstStrats and allStrats lstStrats.push(strategy); @@ -570,89 +460,6 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { assertTrue(userTypes.length != 0, "_configRand: no user types selected"); } - /** - * Depending on the forkType, either deploy contracts locally or parse existing contracts - * from network. - * - * Note: for non-LOCAL forktypes, upgrade of contracts will be peformed after user initialization. - */ - function _deployOrFetchContracts() internal { - if (forkType == LOCAL) { - _setUpLocal(); - // Set Upgraded as local setup deploys most up to date contracts - isUpgraded = true; - } else if (forkType == MAINNET) { - // cheats.selectFork(mainnetForkId); - string memory deploymentInfoPath = "script/configs/mainnet/mainnet-addresses.config.json"; - _parseDeployedContracts(deploymentInfoPath); - string memory existingDeploymentParams = "script/configs/mainnet.json"; - _parseParamsForIntegrationUpgrade(existingDeploymentParams); - - // Unpause to enable deposits and withdrawals for initializing random user state - cheats.prank(eigenLayerPauserReg.unpauser()); - strategyManager.unpause(0); - - // Add deployed strategies to lstStrats and allStrats - for (uint i; i < deployedStrategyArray.length; i++) { - IStrategy strategy = IStrategy(deployedStrategyArray[i]); - - if (tokensNotTested[address(strategy.underlyingToken())]) { - continue; - } - - // Add to lstStrats and allStrats - lstStrats.push(strategy); - allStrats.push(strategy); - allTokens.push(strategy.underlyingToken()); - } - - // Create time machine and mock beacon chain - timeMachine = new TimeMachine(); - beaconChain = new BeaconChainMock(eigenPodManager, GENESIS_TIME_MAINNET); - } else if (forkType == HOLESKY) { - revert("_deployOrFetchContracts - holesky tests currently broken sorry"); - // // cheats.selectFork(holeskyForkId); - // string memory deploymentInfoPath = "script/configs/holesky/Holesky_current_deployment.config.json"; - // _parseDeployedContracts(deploymentInfoPath); - - // // Add deployed strategies to lstStrats and allStrats - // for (uint i; i < deployedStrategyArray.length; i++) { - // IStrategy strategy = IStrategy(deployedStrategyArray[i]); - - // if (tokensNotTested[address(strategy.underlyingToken())]) { - // continue; - // } - - // // Add to lstStrats and allStrats - // lstStrats.push(strategy); - // allStrats.push(strategy); - // allTokens.push(strategy.underlyingToken()); - // } - - // // Update deposit contract to be a mock - // ethPOSDeposit = new ETHPOSDepositMock(); - // eigenPodImplementation = new EigenPod( - // ethPOSDeposit, - // eigenPodImplementation.delayedWithdrawalRouter(), - // eigenPodImplementation.eigenPodManager(), - // eigenPodImplementation.MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR(), - // 0 - // ); - // // Create time machine and set block timestamp forward so we can create EigenPod proofs in the past - // timeMachine = new TimeMachine(); - // beaconChainOracle = new BeaconChainOracleMock(); - // // Create mock beacon chain / proof gen interface - // beaconChain = new BeaconChainMock(timeMachine, beaconChainOracle, eigenPodManager); - - // cheats.startPrank(executorMultisig); - // eigenPodBeacon.upgradeTo(address(eigenPodImplementation)); - // eigenPodManager.updateBeaconChainOracle(beaconChainOracle); - // cheats.stopPrank(); - } else { - revert("_deployOrFetchContracts: unimplemented forkType"); - } - } - /** * @dev Create a new User with a random config using the range defined in `_configRand` * @@ -731,20 +538,6 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { } else { revert("_randUser: unimplemented userType"); } - } else if (forkType == HOLESKY) { - // User deployment for Holesky is exact same as holesky. - // Current Holesky deployment is up to date and no deprecated interfaces have been added. - - user = new User(name); - - if (userType == DEFAULT) { - user = new User(name); - } else if (userType == ALT_METHODS) { - // User will use nonstandard methods like `depositIntoStrategyWithSignature` - user = User(new User_AltMethods(name)); - } else { - revert("_randUser: unimplemented userType"); - } } else { revert("_randUser: unimplemented forkType"); } @@ -757,8 +550,6 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { avs = new AVS(name); } else if (forkType == MAINNET) { avs = new AVS(name); - } else if (forkType == HOLESKY) { - avs = new AVS(name); } else { revert("_genRandAVS: unimplemented forkType"); } @@ -837,30 +628,6 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { return (strategies, tokenBalances); } - /// @dev By default will have a assetType of HOLDS_LST - function _dealRandAssets_M1( - User user - ) internal returns (IStrategy[] memory, uint[] memory) { - // Select a random number of assets - uint numAssets = _randUint({min: 1, max: lstStrats.length}); - - IStrategy[] memory strategies = new IStrategy[](numAssets); - uint[] memory tokenBalances = new uint[](numAssets); - - // For each asset, award the user a random balance of the underlying token - for (uint i = 0; i < numAssets; i++) { - IStrategy strat = lstStrats[i]; - IERC20 underlyingToken = strat.underlyingToken(); - uint balance = _randUint({min: MIN_BALANCE, max: MAX_BALANCE}); - - StdCheats.deal(address(underlyingToken), address(user), balance); - tokenBalances[i] = balance; - strategies[i] = strat; - } - - return (strategies, tokenBalances); - } - /// @dev Uses `random` to return a random uint, with a range given by `min` and `max` (inclusive) /// @return `min` <= result <= `max` function _randUint(uint min, uint max) internal returns (uint) { diff --git a/src/test/integration/mocks/BeaconChainMock.t.sol b/src/test/integration/mocks/BeaconChainMock.t.sol index 414d18b666..5f4fdfcc41 100644 --- a/src/test/integration/mocks/BeaconChainMock.t.sol +++ b/src/test/integration/mocks/BeaconChainMock.t.sol @@ -7,6 +7,7 @@ import "src/contracts/libraries/BeaconChainProofs.sol"; import "src/contracts/libraries/Merkle.sol"; import "src/contracts/pods/EigenPodManager.sol"; +import "src/test/mocks/ETHDepositMock.sol"; import "src/test/integration/mocks/EIP_4788_Oracle_Mock.t.sol"; import "src/test/utils/Logger.t.sol"; @@ -79,6 +80,7 @@ contract BeaconChainMock is Logger { uint64 public nextTimestamp; EigenPodManager eigenPodManager; + IETHPOSDeposit constant DEPOSIT_CONTRACT = IETHPOSDeposit(0x00000000219ab540356cBB839Cbe05303d7705Fa); EIP_4788_Oracle_Mock constant EIP_4788_ORACLE = EIP_4788_Oracle_Mock(0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02); /** @@ -126,6 +128,7 @@ contract BeaconChainMock is Logger { eigenPodManager = _eigenPodManager; // Create mock 4788 oracle + cheats.etch(address(DEPOSIT_CONTRACT), type(ETHPOSDepositMock).runtimeCode); cheats.etch(address(EIP_4788_ORACLE), type(EIP_4788_Oracle_Mock).runtimeCode); // Calculate nodes of empty merkle tree