Skip to content

Commit

Permalink
chore: bump mainnet to mainnet rewards v0.4.3 (#330)
Browse files Browse the repository at this point in the history
* chore: bump mainnet to mainnet rewards v0.4.3

* fix: test rejections from assume limit
  • Loading branch information
stevennevins authored Dec 16, 2024
1 parent 7d49b51 commit 512ce73
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 55 deletions.
2 changes: 1 addition & 1 deletion lib/eigenlayer-contracts
2 changes: 1 addition & 1 deletion test/integration/CoreRegistration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ contract Test_CoreRegistration is MockAVSDeployer {
cheats.prank(operator);
delegationManager.registerAsOperator(
IDelegationManager.OperatorDetails({
earningsReceiver: operator,
__deprecated_earningsReceiver: operator,
delegationApprover: address(0),
stakerOptOutWindowBlocks: 0
}),
Expand Down
26 changes: 3 additions & 23 deletions test/integration/IntegrationDeployer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import "eigenlayer-contracts/src/contracts/core/AVSDirectory.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";
Expand Down Expand Up @@ -56,7 +55,6 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
Slasher slasher;
IBeacon eigenPodBeacon;
EigenPod pod;
DelayedWithdrawalRouter delayedWithdrawalRouter;
ETHPOSDepositMock ethPOSDeposit;
BeaconChainOracleMock beaconChainOracle;

Expand Down Expand Up @@ -125,20 +123,15 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
eigenPodManager = EigenPodManager(
address(new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), ""))
);
delayedWithdrawalRouter = DelayedWithdrawalRouter(
address(new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), ""))
);
avsDirectory = AVSDirectory(
address(new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), ""))
);

// Deploy EigenPod Contracts
pod = new EigenPod(
ethPOSDeposit,
delayedWithdrawalRouter,
eigenPodManager,
MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR,
0
MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR
);

eigenPodBeacon = new UpgradeableBeacon(address(pod));
Expand All @@ -154,7 +147,6 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
slasher,
delegationManager
);
DelayedWithdrawalRouter delayedWithdrawalRouterImplementation = new DelayedWithdrawalRouter(eigenPodManager);
AVSDirectory avsDirectoryImplemntation = new AVSDirectory(delegationManager);

// Third, upgrade the proxy contracts to point to the implementations
Expand Down Expand Up @@ -210,18 +202,6 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
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 Expand Up @@ -305,7 +285,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
TransparentUpgradeableProxy(payable(address(stakeRegistry))),
address(stakeRegistryImplementation)
);

proxyAdmin.upgrade(
TransparentUpgradeableProxy(payable(address(blsApkRegistry))),
address(blsApkRegistryImplementation)
Expand Down Expand Up @@ -346,7 +326,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
/// @dev Deploy a strategy and its underlying token, push to global lists of tokens/strategies, and whitelist
/// strategy in strategyManager
function _newStrategyAndToken(string memory tokenName, string memory tokenSymbol, uint initialSupply, address owner) internal {
IERC20 underlyingToken = new ERC20PresetFixedSupply(tokenName, tokenSymbol, initialSupply, owner);
IERC20 underlyingToken = new ERC20PresetFixedSupply(tokenName, tokenSymbol, initialSupply, owner);
StrategyBase strategy = StrategyBase(
address(
new TransparentUpgradeableProxy(
Expand Down
20 changes: 10 additions & 10 deletions test/integration/User.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ contract User is Test {
BLSApkRegistry blsApkRegistry;
StakeRegistry stakeRegistry;
IndexRegistry indexRegistry;

TimeMachine timeMachine;

uint churnApproverPrivateKey;
Expand Down Expand Up @@ -145,12 +145,12 @@ contract User is Test {
assertEq(churnQuorums.length, churnTargets.length, "User.registerOperatorWithChurn: input length mismatch");
assertTrue(churnBitmap.noBitsInCommon(standardBitmap), "User.registerOperatorWithChurn: input quorums have common bits");

bytes memory allQuorums =
bytes memory allQuorums =
churnBitmap
.plus(standardBitmap)
.bitmapToBytesArray();

IRegistryCoordinator.OperatorKickParam[] memory kickParams
IRegistryCoordinator.OperatorKickParam[] memory kickParams
= new IRegistryCoordinator.OperatorKickParam[](allQuorums.length);

// this constructs OperatorKickParam[] in ascending quorum order
Expand Down Expand Up @@ -242,7 +242,7 @@ contract User is Test {
_log("registerAsOperator (core)");

IDelegationManager.OperatorDetails memory details = IDelegationManager.OperatorDetails({
earningsReceiver: address(this),
__deprecated_earningsReceiver: address(this),
delegationApprover: address(0),
stakerOptOutWindowBlocks: 0
});
Expand Down Expand Up @@ -327,14 +327,14 @@ contract User is Test {
emit log_named_string(string.concat(NAME, ".", s), quorums.toString());
}

// Operator0.registerOperatorWithChurn
// Operator0.registerOperatorWithChurn
// - standardQuorums: 0x00010203...
// - churnQuorums: 0x0405...
// - churnTargets: Operator1, Operator2, ...
function _logChurn(
string memory s,
bytes memory churnQuorums,
User[] memory churnTargets,
string memory s,
bytes memory churnQuorums,
User[] memory churnTargets,
bytes memory standardQuorums
) internal virtual {
emit log(string.concat(NAME, ".", s));
Expand Down Expand Up @@ -366,7 +366,7 @@ contract User_AltMethods is User {
_;
}

constructor(string memory name, uint _privKey, IBLSApkRegistry.PubkeyRegistrationParams memory _pubkeyParams)
constructor(string memory name, uint _privKey, IBLSApkRegistry.PubkeyRegistrationParams memory _pubkeyParams)
User(name, _privKey, _pubkeyParams) {}

/// @dev Rather than calling deregisterOperator, this pranks the ejector and calls
Expand Down Expand Up @@ -400,6 +400,6 @@ contract User_AltMethods is User {
Sort.sort(operatorsPerQuorum[i]);
}

registryCoordinator.updateOperatorsForQuorum(operatorsPerQuorum, allQuorums);
registryCoordinator.updateOperatorsForQuorum(operatorsPerQuorum, allQuorums);
}
}
61 changes: 52 additions & 9 deletions test/integration/mocks/BeaconChainOracleMock.t.sol
Original file line number Diff line number Diff line change
@@ -1,20 +1,63 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import "eigenlayer-contracts/src/contracts/interfaces/IBeaconChainOracle.sol";
import "eigenlayer-contracts/src/test/integration/deprecatedInterfaces/mainnet/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 {
contract BeaconChainOracleMock is IBeaconChainOracle_DeprecatedM1 {
mapping(uint64 => bytes32) blockRoots;

mapping(uint64 => bytes32) blockRoots;
function timestampToBlockRoot(uint timestamp) public view returns (bytes32) {
return blockRoots[uint64(timestamp)];
}

function timestampToBlockRoot(uint timestamp) public view returns (bytes32) {
return blockRoots[uint64(timestamp)];
}
function setBlockRoot(uint64 timestamp, bytes32 blockRoot) public {
blockRoots[timestamp] = blockRoot;
}

function setBlockRoot(uint64 timestamp, bytes32 blockRoot) public {
blockRoots[timestamp] = blockRoot;
}
function latestConfirmedOracleBlockNumber()
external
view
override
returns (uint64)
{}

function beaconStateRootAtBlockNumber(
uint64 blockNumber
) external view override returns (bytes32) {}

function isOracleSigner(
address _oracleSigner
) external view override returns (bool) {}

function hasVoted(
uint64 blockNumber,
address oracleSigner
) external view override returns (bool) {}

function stateRootVotes(
uint64 blockNumber,
bytes32 stateRoot
) external view override returns (uint256) {}

function totalOracleSigners() external view override returns (uint256) {}

function threshold() external view override returns (uint256) {}

function setThreshold(uint256 _threshold) external override {}

function addOracleSigners(
address[] memory _oracleSigners
) external override {}

function removeOracleSigners(
address[] memory _oracleSigners
) external override {}

function voteForBeaconChainStateRoot(
uint64 blockNumber,
bytes32 stateRoot
) external override {}
}
6 changes: 5 additions & 1 deletion test/mocks/AVSDirectoryMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ contract AVSDirectoryMock is IAVSDirectory {

/// @notice The EIP-712 typehash for the Registration struct used by the contract
function OPERATOR_AVS_REGISTRATION_TYPEHASH() external view returns (bytes32) {}
}

function cancelSalt(bytes32 salt) external {}

function domainSeparator() external view returns (bytes32) {}
}
24 changes: 20 additions & 4 deletions test/mocks/DelegationMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract DelegationMock is IDelegationManager {
mapping (address => address) public delegatedTo;

function registerAsOperator(OperatorDetails calldata /*registeringOperatorDetails*/, string calldata /*metadataURI*/) external pure {}

function updateOperatorMetadataURI(string calldata /*metadataURI*/) external pure {}

function updateAVSMetadataURI(string calldata /*metadataURI*/) external pure {}
Expand Down Expand Up @@ -58,7 +58,7 @@ contract DelegationMock is IDelegationManager {

function operatorDetails(address operator) external pure returns (OperatorDetails memory) {
OperatorDetails memory returnValue = OperatorDetails({
earningsReceiver: operator,
__deprecated_earningsReceiver: operator,
delegationApprover: operator,
stakerOptOutWindowBlocks: 0
});
Expand Down Expand Up @@ -169,8 +169,8 @@ contract DelegationMock is IDelegationManager {
bool[] calldata receiveAsTokens
) external {}

function migrateQueuedWithdrawals(IStrategyManager.DeprecatedStruct_QueuedWithdrawal[] memory withdrawalsToQueue) external {}
// function migrateQueuedWithdrawals(IStrategyManager.DeprecatedStruct_QueuedWithdrawal[] memory withdrawalsToQueue) external {}

// onlyDelegationManager functions in StrategyManager
function addShares(
IStrategyManager strategyManager,
Expand Down Expand Up @@ -200,4 +200,20 @@ contract DelegationMock is IDelegationManager {
) external {
strategyManager.withdrawSharesAsTokens(recipient, strategy, shares, token);
}

function getDelegatableShares(address staker) external view returns (IStrategy[] memory, uint256[] memory) {
IStrategy[] memory strategies;
uint256[] memory shares;
return (strategies, shares);
}

function beaconChainETHStrategy() external view returns (IStrategy) {
return IStrategy(address(0));
}

function setMinWithdrawalDelayBlocks(uint256 newMinWithdrawalDelayBlocks) external {
}

function setStrategyWithdrawalDelayBlocks(IStrategy[] calldata strategies, uint256[] calldata withdrawalDelayBlocks) external {
}
}
10 changes: 5 additions & 5 deletions test/unit/BLSApkRegistryUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ contract BLSApkRegistryUnitTests_registerBLSPublicKey is BLSApkRegistryUnitTests
pubkeyRegistrationParams.pubkeyRegistrationSignature = _signMessage(operator);

cheats.startPrank(address(registryCoordinator));
blsApkRegistry.registerBLSPublicKey(operator, pubkeyRegistrationParams, messageHash);
blsApkRegistry.registerBLSPublicKey(operator, pubkeyRegistrationParams, messageHash);

cheats.expectRevert("BLSApkRegistry.registerBLSPublicKey: public key already registered");
blsApkRegistry.registerBLSPublicKey(operator2, pubkeyRegistrationParams, messageHash);
Expand Down Expand Up @@ -800,8 +800,8 @@ contract BLSApkRegistryUnitTests_quorumApkUpdates is BLSApkRegistryUnitTests {
uint256 blockGap,
uint256 randSeed
) external {
cheats.assume(numRegistrants > 0 && numRegistrants < 100);
cheats.assume(blockGap < 100);
numRegistrants = bound(numRegistrants, 1, 99);
blockGap = bound(blockGap, 0, 99);

bytes memory quorumNumbers = new bytes(1);
quorumNumbers[0] = bytes1(defaultQuorumNumber);
Expand Down Expand Up @@ -850,12 +850,12 @@ contract BLSApkRegistryUnitTests_quorumApkUpdates is BLSApkRegistryUnitTests {
* and checking the correct revert messages are emitted for wrong blocknumber inputs
*/
function testFuzz_quorumApkUpdates_IncorrectBlockNumber(
uint256 numRegistrants,
uint32 numRegistrants,
uint32 indexToCheck,
uint32 wrongBlockNumber,
uint256 randSeed
) external {
cheats.assume(numRegistrants > 0 && numRegistrants < 100);
numRegistrants = uint32(bound(numRegistrants, 1, 99));
cheats.assume(indexToCheck < numRegistrants - 1);
bytes memory quorumNumbers = new bytes(1);
quorumNumbers[0] = bytes1(defaultQuorumNumber);
Expand Down
2 changes: 1 addition & 1 deletion test/utils/MockAVSDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,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 512ce73

Please sign in to comment.