Skip to content

Commit

Permalink
build: update core submodule to new release (#298)
Browse files Browse the repository at this point in the history
* build: update core submodule to new release

* fix: flakey tests from pepe upgrade
  • Loading branch information
8sunyuan authored Aug 15, 2024
1 parent a9c1aa7 commit 74438b7
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 71 deletions.
2 changes: 1 addition & 1 deletion lib/eigenlayer-contracts
32 changes: 2 additions & 30 deletions test/integration/IntegrationDeployer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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), "")
Expand All @@ -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));
Expand All @@ -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,
Expand Down Expand Up @@ -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))),
Expand Down
2 changes: 1 addition & 1 deletion test/integration/User.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 0 additions & 20 deletions test/integration/mocks/BeaconChainOracleMock.t.sol

This file was deleted.

31 changes: 16 additions & 15 deletions test/integration/utils/Sort.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
8 changes: 5 additions & 3 deletions test/mocks/RewardsCoordinatorMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
2 changes: 1 addition & 1 deletion test/utils/MockAVSDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 74438b7

Please sign in to comment.