From 74438b7915c35ca5a0d312654716160c2499169d Mon Sep 17 00:00:00 2001 From: Michael Sun <35479365+8sunyuan@users.noreply.github.com> Date: Thu, 15 Aug 2024 15:36:05 -0400 Subject: [PATCH] build: update core submodule to new release (#298) * build: update core submodule to new release * fix: flakey tests from pepe upgrade --- lib/eigenlayer-contracts | 2 +- test/integration/IntegrationDeployer.t.sol | 32 ++----------------- test/integration/User.t.sol | 2 +- .../mocks/BeaconChainOracleMock.t.sol | 20 ------------ test/integration/utils/Sort.t.sol | 31 +++++++++--------- test/mocks/RewardsCoordinatorMock.sol | 8 +++-- test/utils/MockAVSDeployer.sol | 2 +- 7 files changed, 26 insertions(+), 71 deletions(-) delete mode 100644 test/integration/mocks/BeaconChainOracleMock.t.sol diff --git a/lib/eigenlayer-contracts b/lib/eigenlayer-contracts index 3b47ccf0..6c30b8ea 160000 --- a/lib/eigenlayer-contracts +++ b/lib/eigenlayer-contracts @@ -1 +1 @@ -Subproject commit 3b47ccf0ff98dc3f08befd24e3ae70d7ecce6342 +Subproject commit 6c30b8ea1b8338709c58008bc2dc8a248d303db7 diff --git a/test/integration/IntegrationDeployer.t.sol b/test/integration/IntegrationDeployer.t.sol index ec9075e9..dbe12a2c 100644 --- a/test/integration/IntegrationDeployer.t.sol +++ b/test/integration/IntegrationDeployer.t.sol @@ -20,11 +20,8 @@ import "eigenlayer-contracts/src/contracts/core/RewardsCoordinator.sol"; import "eigenlayer-contracts/src/contracts/strategies/StrategyBase.sol"; import "eigenlayer-contracts/src/contracts/pods/EigenPodManager.sol"; import "eigenlayer-contracts/src/contracts/pods/EigenPod.sol"; -import "eigenlayer-contracts/src/contracts/pods/DelayedWithdrawalRouter.sol"; import "eigenlayer-contracts/src/contracts/permissions/PauserRegistry.sol"; import "eigenlayer-contracts/src/test/mocks/ETHDepositMock.sol"; -// import "eigenlayer-contracts/src/test/integration/mocks/BeaconChainOracleMock.t.sol"; -import "test/integration/mocks/BeaconChainOracleMock.t.sol"; // Middleware contracts import "src/RegistryCoordinator.sol"; @@ -57,9 +54,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { Slasher slasher; IBeacon eigenPodBeacon; EigenPod pod; - DelayedWithdrawalRouter delayedWithdrawalRouter; ETHPOSDepositMock ethPOSDeposit; - BeaconChainOracleMock beaconChainOracle; // Base strategy implementation in case we want to create more strategies later StrategyBase baseStrategyImplementation; @@ -92,7 +87,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { address rewardsUpdater = address(uint160(uint256(keccak256("rewardsUpdater")))); // Constants/Defaults - uint64 constant MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR = 32e9; + uint64 constant GENESIS_TIME_LOCAL = 1 hours * 12; uint256 constant MIN_BALANCE = 1e6; uint256 constant MAX_BALANCE = 5e6; uint256 constant MAX_STRATEGY_COUNT = 32; // From StakeRegistry.MAX_WEIGHING_FUNCTION_LENGTH @@ -121,7 +116,6 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { // Deploy mocks EmptyContract emptyContract = new EmptyContract(); ethPOSDeposit = new ETHPOSDepositMock(); - beaconChainOracle = new BeaconChainOracleMock(); /** * First, deploy upgradeable proxy contracts that **will point** to the implementations. Since the implementation contracts are @@ -147,11 +141,6 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "") ) ); - delayedWithdrawalRouter = DelayedWithdrawalRouter( - address( - new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "") - ) - ); avsDirectory = AVSDirectory( address( new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "") @@ -164,10 +153,8 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { // Deploy EigenPod Contracts pod = new EigenPod( ethPOSDeposit, - delayedWithdrawalRouter, eigenPodManager, - MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR, - 0 + GENESIS_TIME_LOCAL ); eigenPodBeacon = new UpgradeableBeacon(address(pod)); @@ -181,8 +168,6 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { EigenPodManager eigenPodManagerImplementation = new EigenPodManager( ethPOSDeposit, eigenPodBeacon, strategyManager, slasher, delegationManager ); - DelayedWithdrawalRouter delayedWithdrawalRouterImplementation = - new DelayedWithdrawalRouter(eigenPodManager); AVSDirectory avsDirectoryImplemntation = new AVSDirectory(delegationManager); // RewardsCoordinator rewardsCoordinatorImplementation = new RewardsCoordinator( // delegationManager, @@ -240,24 +225,11 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { address(eigenPodManagerImplementation), abi.encodeWithSelector( EigenPodManager.initialize.selector, - address(beaconChainOracle), eigenLayerReputedMultisig, // initialOwner pauserRegistry, 0 // initialPausedStatus ) ); - // Delayed Withdrawal Router - proxyAdmin.upgradeAndCall( - TransparentUpgradeableProxy(payable(address(delayedWithdrawalRouter))), - address(delayedWithdrawalRouterImplementation), - abi.encodeWithSelector( - DelayedWithdrawalRouter.initialize.selector, - eigenLayerReputedMultisig, // initialOwner - pauserRegistry, - 0, // initialPausedStatus - minWithdrawalDelayBlocks - ) - ); // AVSDirectory proxyAdmin.upgradeAndCall( TransparentUpgradeableProxy(payable(address(avsDirectory))), diff --git a/test/integration/User.t.sol b/test/integration/User.t.sol index 2f89ab1a..9e5e5990 100644 --- a/test/integration/User.t.sol +++ b/test/integration/User.t.sol @@ -399,7 +399,7 @@ contract User_AltMethods is User { operatorsPerQuorum[i][j] = blsApkRegistry.getOperatorFromPubkeyHash(operatorIds[j]); } - Sort.sort(operatorsPerQuorum[i]); + operatorsPerQuorum[i] = Sort.sortAddresses(operatorsPerQuorum[i]); } registryCoordinator.updateOperatorsForQuorum(operatorsPerQuorum, allQuorums); diff --git a/test/integration/mocks/BeaconChainOracleMock.t.sol b/test/integration/mocks/BeaconChainOracleMock.t.sol deleted file mode 100644 index dabd6b6a..00000000 --- a/test/integration/mocks/BeaconChainOracleMock.t.sol +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.12; - -import "eigenlayer-contracts/src/contracts/interfaces/IBeaconChainOracle.sol"; - -// NOTE: There's a copy of this file in the core repo, but importing that was causing -// the compiler to complain for an unfathomable reason. Apparently reimplementing it -// here fixes the issue. -contract BeaconChainOracleMock is IBeaconChainOracle { - - mapping(uint64 => bytes32) blockRoots; - - function timestampToBlockRoot(uint timestamp) public view returns (bytes32) { - return blockRoots[uint64(timestamp)]; - } - - function setBlockRoot(uint64 timestamp, bytes32 blockRoot) public { - blockRoots[timestamp] = blockRoot; - } -} diff --git a/test/integration/utils/Sort.t.sol b/test/integration/utils/Sort.t.sol index 3853e544..46a2fc2b 100644 --- a/test/integration/utils/Sort.t.sol +++ b/test/integration/utils/Sort.t.sol @@ -2,23 +2,24 @@ pragma solidity ^0.8.12; library Sort { - - /// @dev In-place insertion sort of addrs, h/t ChatGPT - function sort(address[] memory addrs) internal pure { - for (uint i = 1; i < addrs.length; i++) { - address key = addrs[i]; - uint j = i - 1; - - // Move elements of addrs[0..i-1], that are greater than key, - // to one position ahead of their current position - while (j >= 0 && addrs[j] > key) { - addrs[j + 1] = addrs[j]; - if(j == 0) { - break; + /** + * @notice Sorts an array of addresses in ascending order. h/t ChatGPT take 2 + * @dev This function uses the Bubble Sort algorithm, which is simple but has O(n^2) complexity. + * @param addresses The array of addresses to be sorted. + * @return sortedAddresses The array of addresses sorted in ascending order. + */ + function sortAddresses(address[] memory addresses) internal pure returns (address[] memory) { + uint256 n = addresses.length; + for (uint256 i = 0; i < n; i++) { + for (uint256 j = 0; j < n - 1; j++) { + // Compare and swap if the current address is greater than the next one + if (addresses[j] > addresses[j + 1]) { + address temp = addresses[j]; + addresses[j] = addresses[j + 1]; + addresses[j + 1] = temp; } - j--; } - addrs[j + 1] = key; } + return addresses; } } diff --git a/test/mocks/RewardsCoordinatorMock.sol b/test/mocks/RewardsCoordinatorMock.sol index ff32a27a..425c447d 100644 --- a/test/mocks/RewardsCoordinatorMock.sol +++ b/test/mocks/RewardsCoordinatorMock.sol @@ -41,14 +41,16 @@ contract RewardsCoordinatorMock is IRewardsCoordinator { function getDistributionRootsLength() external view returns (uint256) {} - /// EXTERNAL FUNCTIONS /// - - function disableRoot(uint32 rootIndex) external {} + function getCurrentClaimableDistributionRoot() external view returns (DistributionRoot memory) {} function getDistributionRootAtIndex(uint256 index) external view returns (DistributionRoot memory) {} function getCurrentDistributionRoot() external view returns (DistributionRoot memory) {} + /// EXTERNAL FUNCTIONS /// + + function disableRoot(uint32 rootIndex) external {} + function createAVSRewardsSubmission(RewardsSubmission[] calldata rewardsSubmissions) external {} function createRewardsForAllSubmission(RewardsSubmission[] calldata rewardsSubmission) external {} diff --git a/test/utils/MockAVSDeployer.sol b/test/utils/MockAVSDeployer.sol index 23875760..eb7a9b70 100644 --- a/test/utils/MockAVSDeployer.sol +++ b/test/utils/MockAVSDeployer.sol @@ -147,7 +147,7 @@ contract MockAVSDeployer is Test { delegationMock = new DelegationMock(); avsDirectoryMock = new AVSDirectoryMock(); - eigenPodManagerMock = new EigenPodManagerMock(); + eigenPodManagerMock = new EigenPodManagerMock(pauserRegistry); strategyManagerMock = new StrategyManagerMock(); slasherImplementation = new Slasher(strategyManagerMock, delegationMock); slasher = Slasher(