Skip to content

Commit

Permalink
feat: public block root getter (#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
wadealexc authored Jul 2, 2024
1 parent 0979b36 commit 1d117eb
Show file tree
Hide file tree
Showing 17 changed files with 230 additions and 33 deletions.
2 changes: 1 addition & 1 deletion pkg/bindings/AVSDirectory/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/DelegationManager/binding.go

Large diffs are not rendered by default.

35 changes: 33 additions & 2 deletions pkg/bindings/EigenPod/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/EigenPodManager/binding.go

Large diffs are not rendered by default.

33 changes: 32 additions & 1 deletion pkg/bindings/EigenPodStorage/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/EigenStrategy/binding.go

Large diffs are not rendered by default.

33 changes: 32 additions & 1 deletion pkg/bindings/IEigenPod/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/RewardsCoordinator/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/StrategyBase/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/StrategyBaseTVLLimits/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/StrategyManager/binding.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"eigenLayerPauserReg": "0x9Ab2FEAf0465f0eD51Fc2b663eF228B418c9Dad1",
"eigenLayerProxyAdmin": "0x1BEF05C7303d44e0E2FCD2A19d993eDEd4c51b5B",
"eigenPodBeacon": "0x92Cc4a800A1513E85C481dDDf3A06C6921211eaC",
"eigenPodImplementation": "0x537A9Ce71928C9377823ef72C7F898b8d092f520",
"eigenPodImplementation": "0xd4bbD235e25B44856927aD845611808040EfAb1c",
"eigenPodManager": "0xB8d8952f572e67B11e43bC21250967772fa883Ff",
"eigenPodManagerImplementation": "0x378C459ea6F026D8BF045404d2f3e3451682c6a2",
"emptyContract": "0x9690d52B1Ce155DB2ec5eCbF5a262ccCc7B3A6D2",
Expand Down
58 changes: 58 additions & 0 deletions script/deploy/holesky/v040-rc2-holesky-preprod-pepe.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import "../../utils/ExistingDeploymentParser.sol";

/**
* @notice Script used for upgrading EigenPod and EPM Implementation for Holesky preprod
* anvil --fork-url $RPC_HOLESKY
* forge script script/deploy/holesky/v040-rc2-holesky-preprod-pepe.s.sol --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv
* forge script script/deploy/holesky/v040-rc2-holesky-preprod-pepe.s.sol --rpc-url $RPC_HOLESKY --private-key $PRIVATE_KEY --verify --broadcast -vvvv
*/
contract EigenPod_Checkpoint_Deploy_Preprod is ExistingDeploymentParser {

address testAddress = 0xDA29BB71669f46F2a779b4b62f03644A84eE3479;
address initOwner = 0xDA29BB71669f46F2a779b4b62f03644A84eE3479;

function run() external virtual {
_parseInitialDeploymentParams(
"script/configs/holesky/eigenlayer_preprod.config.json"
);
_parseDeployedContracts(
"script/configs/holesky/eigenlayer_addresses_preprod.config.json"
);

emit log_named_address("Deployer Address", msg.sender);

// START RECORDING TRANSACTIONS FOR DEPLOYMENT
vm.startBroadcast();

_upgradeEigenPods();

// STOP RECORDING TRANSACTIONS FOR DEPLOYMENT
vm.stopBroadcast();

// Sanity Checks
_verifyContractPointers();
_verifyImplementations();
_verifyContractsInitialized();
_verifyInitializationParams();

logAndOutputContractAddresses("script/output/holesky/v040-rc2.output.json");
}

/**
* @notice Deploy EigenPod Implementation for Holesky preprod and upgrade the beacon
*/
function _upgradeEigenPods() internal {
// Deploy implementation
eigenPodImplementation = new EigenPod(
IETHPOSDeposit(ETHPOSDepositAddress),
eigenPodManager,
EIGENPOD_GENESIS_TIME
);

// upgrade UpgradeableBeacon
eigenPodBeacon.upgradeTo(address(eigenPodImplementation));
}
}
34 changes: 34 additions & 0 deletions script/output/holesky/v040-rc2.output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"addresses": {
"avsDirectory": "0x141d6995556135D4997b2ff72EB443Be300353bC",
"avsDirectoryImplementation": "0x357978adC03375BD6a3605DE055fABb84695d79A",
"baseStrategyImplementation": "0x62450517EfA1CE60d79801daf8f95973865e8D40",
"delegationManager": "0x75dfE5B44C2E530568001400D3f704bC8AE350CC",
"delegationManagerImplementation": "0x56E88cb4f0136fC27D95499dE4BE2acf47946Fa1",
"eigenLayerPauserReg": "0x9Ab2FEAf0465f0eD51Fc2b663eF228B418c9Dad1",
"eigenLayerProxyAdmin": "0x1BEF05C7303d44e0E2FCD2A19d993eDEd4c51b5B",
"eigenPodBeacon": "0x92Cc4a800A1513E85C481dDDf3A06C6921211eaC",
"eigenPodImplementation": "0xd4bbD235e25B44856927aD845611808040EfAb1c",
"eigenPodManager": "0xB8d8952f572e67B11e43bC21250967772fa883Ff",
"eigenPodManagerImplementation": "0x378C459ea6F026D8BF045404d2f3e3451682c6a2",
"emptyContract": "0x9690d52B1Ce155DB2ec5eCbF5a262ccCc7B3A6D2",
"rewardsCoordinator": "0xb22Ef643e1E067c994019A4C19e403253C05c2B0",
"rewardsCoordinatorImplementation": "0x7C80B0d3aFBeF9Bbd03Aab72cD2d90a12c11D394",
"slasher": "0x12699471dF8dca329C76D72823B1b79d55709384",
"slasherImplementation": "0x9460fCe11E1e0365419fa860599903B4E5097cf0",
"strategies": "",
"strategyManager": "0xF9fbF2e35D8803273E214c99BF15174139f4E67a",
"strategyManagerImplementation": "0x1a26B23a004C512350d7Dd89056655A80b850199"
},
"chainInfo": {
"chainId": 17000,
"deploymentBlock": 1851632
},
"parameters": {
"communityMultisig": "0xDA29BB71669f46F2a779b4b62f03644A84eE3479",
"executorMultisig": "0xDA29BB71669f46F2a779b4b62f03644A84eE3479",
"operationsMultisig": "0xDA29BB71669f46F2a779b4b62f03644A84eE3479",
"pauserMultisig": "0xDA29BB71669f46F2a779b4b62f03644A84eE3479",
"timelock": "0xcF19CE0561052a7A7Ff21156730285997B350A7D"
}
}
6 changes: 6 additions & 0 deletions src/contracts/interfaces/IEigenPod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,10 @@ interface IEigenPod {
/// i.e. if a validator was last checkpointed at 32.1 ETH before exiting, the next checkpoint will calculate their
/// "exited" amount to be 32.1 ETH rather than 32 ETH.
function checkpointBalanceExitedGwei(uint64) external view returns (uint64);

/// @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);
}
40 changes: 20 additions & 20 deletions src/contracts/pods/EigenPod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ contract EigenPod is

// Verify passed-in `beaconStateRoot` against the beacon block root
BeaconChainProofs.verifyStateRoot({
beaconBlockRoot: _getParentBlockRoot(beaconTimestamp),
beaconBlockRoot: getParentBlockRoot(beaconTimestamp),
proof: stateRootProof
});

Expand Down Expand Up @@ -353,7 +353,7 @@ contract EigenPod is

// Verify passed-in `beaconStateRoot` against the beacon block root
BeaconChainProofs.verifyStateRoot({
beaconBlockRoot: _getParentBlockRoot(beaconTimestamp),
beaconBlockRoot: getParentBlockRoot(beaconTimestamp),
proof: stateRootProof
});

Expand Down Expand Up @@ -598,7 +598,7 @@ contract EigenPod is
// `activeValidatorCount` as the number of checkpoint proofs needed to finalize
// the checkpoint.
Checkpoint memory checkpoint = Checkpoint({
beaconBlockRoot: _getParentBlockRoot(uint64(block.timestamp)),
beaconBlockRoot: getParentBlockRoot(uint64(block.timestamp)),
proofsRemaining: uint24(activeValidatorCount),
podBalanceGwei: podBalanceGwei,
balanceDeltasGwei: 0
Expand Down Expand Up @@ -642,23 +642,6 @@ contract EigenPod is
}
}

/// @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) internal view returns (bytes32) {
require(
block.timestamp - timestamp < BEACON_ROOTS_HISTORY_BUFFER_LENGTH * 12,
"EigenPod._getParentBlockRoot: timestamp out of range"
);

(bool success, bytes memory result) =
BEACON_ROOTS_ADDRESS.staticcall(abi.encode(timestamp));

require(success && result.length > 0, "EigenPod._getParentBlockRoot: invalid block root returned");
return abi.decode(result, (bytes32));
}

function _podWithdrawalCredentials() internal view returns (bytes memory) {
return abi.encodePacked(bytes1(uint8(1)), bytes11(0), address(this));
}
Expand Down Expand Up @@ -702,4 +685,21 @@ contract EigenPod is
function currentCheckpoint() public view returns (Checkpoint memory) {
return _currentCheckpoint;
}

/// @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) public view returns (bytes32) {
require(
block.timestamp - timestamp < BEACON_ROOTS_HISTORY_BUFFER_LENGTH * 12,
"EigenPod.getParentBlockRoot: timestamp out of range"
);

(bool success, bytes memory result) =
BEACON_ROOTS_ADDRESS.staticcall(abi.encode(timestamp));

require(success && result.length > 0, "EigenPod.getParentBlockRoot: invalid block root returned");
return abi.decode(result, (bytes32));
}
}
6 changes: 6 additions & 0 deletions src/test/mocks/EigenPodMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,10 @@ contract EigenPodMock is IEigenPod, Test {

function validatorStatus(bytes calldata pubkey) external view returns (VALIDATOR_STATUS){}
function validatorPubkeyToInfo(bytes calldata validatorPubkey) external view returns (ValidatorInfo memory){}

/// @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) {}
}

0 comments on commit 1d117eb

Please sign in to comment.