Skip to content

Commit

Permalink
chore: get things compiling
Browse files Browse the repository at this point in the history
* i commented out/deleted a bajillion tests
  • Loading branch information
wadealexc committed Apr 17, 2024
1 parent 9359ccd commit f7f0de0
Show file tree
Hide file tree
Showing 26 changed files with 1,947 additions and 2,076 deletions.
10 changes: 0 additions & 10 deletions script/deploy/devnet/M2_Deploy_From_Scratch.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ contract Deployer_M2 is Script, Test {
ethPOSDeposit,
delayedWithdrawalRouter,
eigenPodManager,
MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR,
GOERLI_GENESIS_TIME
);

Expand Down Expand Up @@ -561,21 +560,12 @@ contract Deployer_M2 is Script, Test {
// require(delayedWithdrawalRouter.withdrawalDelayBlocks() == 7 days / 12 seconds,
// "delayedWithdrawalRouter: withdrawalDelayBlocks initialized incorrectly");
// uint256 MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR = 32 ether;
require(
eigenPodImplementation.MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR() == 32 gwei,
"eigenPod: MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR initialized incorrectly"
);

require(
strategyManager.strategyWhitelister() == operationsMultisig,
"strategyManager: strategyWhitelister address not set correctly"
);

require(
eigenPodManager.beaconChainOracle() == IBeaconChainOracle(address(0)),
"eigenPodManager: eigenPodBeacon contract address not set correctly"
);

require(
delayedWithdrawalRouter.eigenPodManager() == eigenPodManager,
"delayedWithdrawalRouter: eigenPodManager set incorrectly"
Expand Down
1 change: 0 additions & 1 deletion script/deploy/goerli/GoerliUpgrade1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ contract GoerliUpgrade1 is Script, Test {
IETHPOSDeposit(0xff50ed3d0ec03aC01D4C79aAd74928BFF48a7b2b),
delayedWithdrawalRouter,
eigenPodManager,
32e9,
1616508000
)
);
Expand Down
1 change: 0 additions & 1 deletion script/deploy/goerli/GoerliUpgrade2.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ contract GoerliUpgrade2 is Script, Test {
IETHPOSDeposit(0xff50ed3d0ec03aC01D4C79aAd74928BFF48a7b2b),
delayedWithdrawalRouter,
eigenPodManager,
32e9,
1616508000
)
);
Expand Down
2 changes: 0 additions & 2 deletions script/deploy/holesky/M2_Deploy_From_Scratch.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ contract M2_Deploy_Holesky_From_Scratch is ExistingDeploymentParser {
IETHPOSDeposit(ETHPOSDepositAddress),
delayedWithdrawalRouter,
eigenPodManager,
EIGENPOD_MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR,
EIGENPOD_GENESIS_TIME
);

Expand Down Expand Up @@ -151,7 +150,6 @@ contract M2_Deploy_Holesky_From_Scratch is ExistingDeploymentParser {
address(eigenPodManagerImplementation),
abi.encodeWithSelector(
EigenPodManager.initialize.selector,
beaconOracle,
msg.sender, // initialOwner is msg.sender for now to set forktimestamp later
eigenLayerPauserReg,
EIGENPOD_MANAGER_INIT_PAUSED_STATUS
Expand Down
8 changes: 0 additions & 8 deletions script/deploy/mainnet/M1_Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ contract Deployer_M1 is Script, Test {
ethPOSDeposit,
delayedWithdrawalRouter,
eigenPodManager,
uint64(MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR),
GOERLI_GENESIS_TIME
);

Expand Down Expand Up @@ -239,8 +238,6 @@ contract Deployer_M1 is Script, Test {
address(eigenPodManagerImplementation),
abi.encodeWithSelector(
EigenPodManager.initialize.selector,
EIGENPOD_MANAGER_MAX_PODS,
IBeaconChainOracle(address(0)),
executorMultisig,
eigenLayerPauserReg,
EIGENPOD_MANAGER_INIT_PAUSED_STATUS
Expand Down Expand Up @@ -542,11 +539,6 @@ contract Deployer_M1 is Script, Test {
"strategyManager: strategyWhitelister address not set correctly"
);

require(
eigenPodManager.beaconChainOracle() == IBeaconChainOracle(address(0)),
"eigenPodManager: eigenPodBeacon contract address not set correctly"
);

require(
delayedWithdrawalRouter.eigenPodManager() == eigenPodManager,
"delayedWithdrawalRouter: eigenPodManager set incorrectly"
Expand Down
6 changes: 0 additions & 6 deletions script/deploy/mainnet/M2Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ contract M2Deploy is Script, Test {
_ethPOS: ethPOS,
_delayedWithdrawalRouter: delayedWithdrawalRouter,
_eigenPodManager: eigenPodManager,
_MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR: 32 gwei,
_GENESIS_TIME: 1616508000
});

Expand Down Expand Up @@ -304,10 +303,6 @@ contract M2Deploy is Script, Test {
require(eigenPodManager.eigenPodBeacon() == eigenPodBeacon, "eigenPodManager.eigenPodBeacon incorrect");
require(eigenPodManager.strategyManager() == strategyManager, "eigenPodManager.strategyManager incorrect");
require(eigenPodManager.slasher() == slasher, "eigenPodManager.slasher incorrect");
require(
address(eigenPodManager.beaconChainOracle()) == beaconChainOracle,
"eigenPodManager.beaconChainOracle incorrect"
);
require(eigenPodManager.numPods() == numPods, "eigenPodManager.numPods incorrect");
require(EigenPodManagerStorage(address(eigenPodManager)).delegationManager() == delegation, "eigenPodManager.delegationManager incorrect");
}
Expand Down Expand Up @@ -336,7 +331,6 @@ contract M2Deploy is Script, Test {

cheats.expectRevert(bytes("Initializable: contract is already initialized"));
EigenPodManager(address(eigenPodManager)).initialize(
IBeaconChainOracle(address(this)),
address(this),
PauserRegistry(address(this)),
0
Expand Down
12 changes: 5 additions & 7 deletions script/deploy/mainnet/M2_Mainnet_Upgrade.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ contract M2_Mainnet_Upgrade is ExistingDeploymentParser {
IETHPOSDeposit(ETHPOSDepositAddress),
delayedWithdrawalRouter,
eigenPodManager,
EIGENPOD_MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR,
EIGENPOD_GENESIS_TIME
);
delegationManagerImplementation = new DelegationManager(strategyManager, slasher, eigenPodManager);
Expand Down Expand Up @@ -124,7 +123,6 @@ contract M2_Mainnet_Upgrade is ExistingDeploymentParser {
eigenPodManager.unpause(0);

eigenPodManager.setDenebForkTimestamp(EIGENPOD_MANAGER_DENEB_FORK_TIMESTAMP);
eigenPodManager.updateBeaconChainOracle(beaconOracle);
eigenPodBeacon.upgradeTo(address(eigenPodImplementation));

vm.stopPrank();
Expand Down Expand Up @@ -211,11 +209,11 @@ contract Queue_M2_Upgrade is M2_Mainnet_Upgrade, TimelockEncoding {
);

// set beacon chain oracle on EigenPodManager
txs[7] = Tx(
address(eigenPodManager),
0, // value
abi.encodeWithSelector(EigenPodManager.updateBeaconChainOracle.selector, beaconOracle)
);
// txs[7] = Tx(
// address(eigenPodManager),
// 0, // value
// abi.encodeWithSelector(EigenPodManager.updateBeaconChainOracle.selector, beaconOracle)
// );

// set Deneb fork timestamp on EigenPodManager
txs[8] = Tx(
Expand Down
11 changes: 0 additions & 11 deletions script/utils/ExistingDeploymentParser.sol
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ contract ExistingDeploymentParser is Script, Test {
// EigenPodManager
vm.expectRevert(bytes("Initializable: contract is already initialized"));
eigenPodManager.initialize(
beaconOracle,
address(0),
eigenLayerPauserReg,
EIGENPOD_MANAGER_INIT_PAUSED_STATUS
Expand Down Expand Up @@ -505,10 +504,6 @@ contract ExistingDeploymentParser is Script, Test {
eigenPodManager.denebForkTimestamp() == EIGENPOD_MANAGER_DENEB_FORK_TIMESTAMP,
"eigenPodManager: denebForkTimestamp not set correctly"
);
require(
eigenPodManager.beaconChainOracle() == beaconOracle,
"eigenPodManager: beaconChainOracle not set correctly"
);
require(
eigenPodManager.ethPOS() == IETHPOSDeposit(ETHPOSDepositAddress),
"eigenPodManager: ethPOS not set correctly"
Expand All @@ -520,12 +515,6 @@ contract ExistingDeploymentParser is Script, Test {
eigenPodImplementation.GENESIS_TIME() == EIGENPOD_GENESIS_TIME,
"eigenPodImplementation: GENESIS TIME not set correctly"
);
require(
eigenPodImplementation.MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR() ==
EIGENPOD_MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR
&& EIGENPOD_MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR % 1 gwei == 0,
"eigenPodImplementation: MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR not set correctly"
);
require(
eigenPodImplementation.ethPOS() == IETHPOSDeposit(ETHPOSDepositAddress),
"eigenPodImplementation: ethPOS not set correctly"
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/interfaces/IEigenPod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface IEigenPod {
bytes32 beaconStateRoot;

uint256 podBalanceGwei;
int256 balanceDeltas;
int256 balanceDeltasGwei;

uint256 proofsRemaining;
}
Expand Down
33 changes: 19 additions & 14 deletions src/contracts/interfaces/IEigenPodManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ interface IEigenPodManager is IPausable {
*/
function recordBeaconChainETHBalanceUpdate(address podOwner, int256 sharesDelta) external;

/**
* @notice Updates the oracle contract that provides the beacon chain state root
* @param newBeaconChainOracle is the new oracle contract being pointed to
* @dev Callable only by the owner of this contract (i.e. governance)
*/
function updateBeaconChainOracle(IBeaconChainOracle newBeaconChainOracle) external;

/// @notice Returns the address of the `podOwner`'s EigenPod if it has been deployed.
function ownerToPod(address podOwner) external view returns (IEigenPod);

Expand All @@ -85,13 +78,7 @@ interface IEigenPodManager is IPausable {

/// @notice Beacon proxy to which the EigenPods point
function eigenPodBeacon() external view returns (IBeacon);

/// @notice Oracle contract that provides updates to the beacon chain's state
function beaconChainOracle() external view returns (IBeaconChainOracle);

/// @notice Returns the beacon block root at `timestamp`. Reverts if the Beacon block root at `timestamp` has not yet been finalized.
function getBlockRootAtTimestamp(uint64 timestamp) external view returns (bytes32);


/// @notice EigenLayer's StrategyManager contract
function strategyManager() external view returns (IStrategyManager);

Expand Down Expand Up @@ -143,6 +130,24 @@ interface IEigenPodManager is IPausable {
*/
function withdrawSharesAsTokens(address podOwner, address destination, uint256 shares) external;

/// @notice Query the 4788 oracle to get the parent block root of the slot with the given `timestamp`
/// @param timestamp of the block for which the parent block root will be returned. MUST correspond
/// to an existing slot within the last 24 hours. If the slot at `timestamp` was skipped, this method
/// will revert.
function getParentBlockRoot(uint64 timestamp) external view returns (bytes32);

/**
* @dev Changes the `podOwner's` stale validator count by `countDelta`. The stale validator
* count can be used as an additional weighting mechanism to determine a staker or operator's shares.
* @param podOwner the pod owner whose stale validator count is being updated
* @param countDelta the change in `podOwner's` stale validator count as a signed integer
* @dev Callable only by the `podOwner's` EigenPod contract
*/
function updateStaleValidatorCount(
address podOwner,
int256 countDelta
) external;

/**
* @notice the deneb hard fork timestamp used to determine which proof path to use for proving a withdrawal
*/
Expand Down
30 changes: 25 additions & 5 deletions src/contracts/libraries/BeaconChainProofs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ library BeaconChainProofs {
uint256 internal constant WITHDRAWAL_FIELD_TREE_HEIGHT = 2;

uint256 internal constant VALIDATOR_TREE_HEIGHT = 40;
//refer to the eigenlayer-cli proof library. Despite being the same dimensions as the validator tree, the balance tree is merkleized differently
uint256 internal constant BALANCE_TREE_HEIGHT = 38;

// MAX_WITHDRAWALS_PER_PAYLOAD = 2**4, making tree height = 4
uint256 internal constant WITHDRAWALS_TREE_HEIGHT = 4;
Expand All @@ -49,14 +51,15 @@ library BeaconChainProofs {
uint256 internal constant BODY_ROOT_INDEX = 4;
// in beacon state https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#beaconstate
uint256 internal constant VALIDATOR_TREE_ROOT_INDEX = 11;
uint256 internal constant BALANCE_INDEX = 12;
uint256 internal constant HISTORICAL_SUMMARIES_INDEX = 27;

// in validator https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
uint256 internal constant VALIDATOR_PUBKEY_INDEX = 0;
uint256 internal constant VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX = 1;
uint256 internal constant VALIDATOR_BALANCE_INDEX = 2;
uint256 internal constant VALIDATOR_SLASHED_INDEX = 3;
uint256 internal constant VALIDATOR_WITHDRAWABLE_EPOCH_INDEX = 7;
uint256 internal constant VALIDATOR_EXIT_EPOCH_INDEX = 6;

// in execution payload header
uint256 internal constant TIMESTAMP_INDEX = 9;
Expand All @@ -81,6 +84,8 @@ library BeaconChainProofs {

bytes8 internal constant UINT64_MASK = 0xffffffffffffffff;

uint64 internal constant FAR_FUTURE_EPOCH = type(uint64).max;

/// @notice This struct contains the root and proof for verifying the state root against the oracle block root
struct StateRootProof {
bytes32 beaconStateRoot;
Expand Down Expand Up @@ -143,7 +148,7 @@ library BeaconChainProofs {
function verifyValidatorBalance(
bytes32 beaconStateRoot,
uint40 validatorIndex,
BalanceProof memory proof
BalanceProof calldata proof
) internal view returns (uint64 validatorBalanceGwei) {
require(
proof.proof.length == 32 * ((BALANCE_TREE_HEIGHT + 1) + BEACON_STATE_FIELD_TREE_HEIGHT),
Expand Down Expand Up @@ -211,6 +216,21 @@ library BeaconChainProofs {
return sha256(abi.encodePacked(validatorPubkey, bytes16(0)));
}

/**
* @notice Parses a balanceRoot to get the uint64 balance of a validator.
* @dev During merkleization of the beacon state balance tree, four uint64 values are treated as a single
* leaf in the merkle tree. We use validatorIndex % 4 to determine which of the four uint64 values to
* extract from the balanceRoot.
* @param balanceRoot is the combination of 4 validator balances being proven for
* @param validatorIndex is the index of the validator being proven for
* @return The validator's balance, in Gwei
*/
function getBalanceAtIndex(bytes32 balanceRoot, uint40 validatorIndex) internal pure returns (uint64) {
uint256 bitShiftAmount = (validatorIndex % 4) * 64;
return
Endian.fromLittleEndianUint64(bytes32((uint256(balanceRoot) << bitShiftAmount)));
}

/**
* Indices for validator fields (refer to consensus specs):
* 0: pubkey
Expand Down Expand Up @@ -252,11 +272,11 @@ library BeaconChainProofs {
}

/**
* @dev Retrieves a validator's withdrawable epoch
* @dev Retrieves a validator's exit epoch
*/
function getWithdrawableEpoch(bytes32[] memory validatorFields) internal pure returns (uint64) {
function getExitEpoch(bytes32[] memory validatorFields) internal pure returns (uint64) {
return
Endian.fromLittleEndianUint64(validatorFields[VALIDATOR_WITHDRAWABLE_EPOCH_INDEX]);
Endian.fromLittleEndianUint64(validatorFields[VALIDATOR_EXIT_EPOCH_INDEX]);
}

/**
Expand Down
Loading

0 comments on commit f7f0de0

Please sign in to comment.