Skip to content

Commit

Permalink
chore: fix formatting and borked config
Browse files Browse the repository at this point in the history
* fix: fix borked addresses in holesky config

* chore: fix formatting again
  • Loading branch information
wadealexc committed Aug 9, 2024
1 parent 2eb368a commit 6116bb3
Show file tree
Hide file tree
Showing 19 changed files with 165 additions and 172 deletions.
2 changes: 1 addition & 1 deletion pkg/bindings/BeaconChainProofs/binding.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 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.

2 changes: 1 addition & 1 deletion pkg/bindings/EigenStrategy/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/StrategyFactory/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.

4 changes: 2 additions & 2 deletions script/configs/holesky/eigenlayer_addresses.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"eigenLayerPauserReg": "0x85Ef7299F8311B25642679edBF02B62FA2212F06",
"eigenLayerProxyAdmin": "0xDB023566064246399b4AE851197a97729C93A6cf",
"eigenPodBeacon": "0x7261C2bd75a7ACE1762f6d7FAe8F63215581832D",
"eigenPodImplementation": "0xcd327c3f4C866dA3F3F83218ebA7c478567E7a9E",
"eigenPodImplementation": "0xe98f9298344527608A1BCC23907B8145F9Cb641c",
"eigenPodManager": "0x30770d7E3e71112d7A6b7259542D1f680a70e315",
"eigenPodManagerImplementation": "0x378C459ea6F026D8BF045404d2f3e3451682c6a2",
"eigenPodManagerImplementation": "0x5265C162f7d5F3fE3175a78828ab16bf5E324a7B",
"emptyContract": "0x9690d52B1Ce155DB2ec5eCbF5a262ccCc7B3A6D2",
"rewardsCoordinator": "0xAcc1fb458a1317E886dB376Fc8141540537E68fE",
"rewardsCoordinatorImplementation": "0x123C1A3543DBCA3f704E703dDda7FAAaA8e43D02",
Expand Down
75 changes: 40 additions & 35 deletions src/contracts/interfaces/IEigenPod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
* to account balances in terms of gwei in the EigenPod contract and convert to wei when making calls to other contracts
*/
interface IEigenPod {

/*******************************************************************************
STRUCTS / ENUMS
*******************************************************************************/

/**
*
* STRUCTS / ENUMS
*
*/
enum VALIDATOR_STATUS {
INACTIVE, // doesnt exist
ACTIVE, // staked on ethpos and withdrawal credentials are pointed to the EigenPod
Expand All @@ -43,9 +43,11 @@ interface IEigenPod {
int128 balanceDeltasGwei;
}

/*******************************************************************************
EVENTS
*******************************************************************************/
/**
*
* EVENTS
*
*/

/// @notice Emitted when an ETH validator stakes via this eigenPod
event EigenPodStaked(bytes pubkey);
Expand All @@ -67,7 +69,9 @@ interface IEigenPod {
event NonBeaconChainETHReceived(uint256 amountReceived);

/// @notice Emitted when a checkpoint is created
event CheckpointCreated(uint64 indexed checkpointTimestamp, bytes32 indexed beaconBlockRoot, uint256 validatorCount);
event CheckpointCreated(
uint64 indexed checkpointTimestamp, bytes32 indexed beaconBlockRoot, uint256 validatorCount
);

/// @notice Emitted when a checkpoint is finalized
event CheckpointFinalized(uint64 indexed checkpointTimestamp, int256 totalShareDeltaWei);
Expand All @@ -78,9 +82,11 @@ interface IEigenPod {
/// @notice Emitted when a validaor is proven to have 0 balance at a given checkpoint
event ValidatorWithdrawn(uint64 indexed checkpointTimestamp, uint40 indexed validatorIndex);

/*******************************************************************************
EXTERNAL STATE-CHANGING METHODS
*******************************************************************************/
/**
*
* EXTERNAL STATE-CHANGING METHODS
*
*/

/// @notice Used to initialize the pointers to contracts crucial to the pod's functionality, in beacon proxy construction from EigenPodManager
function initialize(address owner) external;
Expand All @@ -98,8 +104,8 @@ interface IEigenPod {
function withdrawRestakedBeaconChainETH(address recipient, uint256 amount) external;

/**
* @dev Create a checkpoint used to prove this pod's active validator set. Checkpoints are completed
* by submitting one checkpoint proof per ACTIVE validator. During the checkpoint process, the total
* @dev Create a checkpoint used to prove this pod's active validator set. Checkpoints are completed
* by submitting one checkpoint proof per ACTIVE validator. During the checkpoint process, the total
* change in ACTIVE validator balance is tracked, and any validators with 0 balance are marked `WITHDRAWN`.
* @dev Once finalized, the pod owner is awarded shares corresponding to:
* - the total change in their ACTIVE validator balances
Expand All @@ -124,9 +130,8 @@ interface IEigenPod {
function verifyCheckpointProofs(
BeaconChainProofs.BalanceContainerProof calldata balanceContainerProof,
BeaconChainProofs.BalanceProof[] calldata proofs
)
external;

) external;

/**
* @dev Verify one or more validators have their withdrawal credentials pointed at this EigenPod, and award
* shares based on their effective balance. Proven validators are marked `ACTIVE` within the EigenPod, and
Expand All @@ -147,27 +152,26 @@ interface IEigenPod {
uint40[] calldata validatorIndices,
bytes[] calldata validatorFieldsProofs,
bytes32[][] calldata validatorFields
)
external;

) external;

/**
* @dev Prove that one of this pod's active validators was slashed on the beacon chain. A successful
* staleness proof allows the caller to start a checkpoint.
*
*
* @dev Note that in order to start a checkpoint, any existing checkpoint must already be completed!
* (See `_startCheckpoint` for details)
*
*
* @dev Note that this method allows anyone to start a checkpoint as soon as a slashing occurs on the beacon
* chain. This is intended to make it easier to external watchers to keep a pod's balance up to date.
*
*
* @dev Note too that beacon chain slashings are not instant. There is a delay between the initial slashing event
* and the validator's final exit back to the execution layer. During this time, the validator's balance may or
* may not drop further due to a correlation penalty. This method allows proof of a slashed validator
* to initiate a checkpoint for as long as the validator remains on the beacon chain. Once the validator
* has exited and been checkpointed at 0 balance, they are no longer "checkpoint-able" and cannot be proven
* "stale" via this method.
* See https://eth2book.info/capella/part3/transition/epoch/#slashings for more info.
*
*
* @param beaconTimestamp the beacon chain timestamp sent to the 4788 oracle contract. Corresponds
* to the parent beacon block root against which the proof is verified.
* @param stateRootProof proves a beacon state root against a beacon block root
Expand All @@ -184,9 +188,8 @@ interface IEigenPod {
uint64 beaconTimestamp,
BeaconChainProofs.StateRootProof calldata stateRootProof,
BeaconChainProofs.ValidatorProof calldata proof
)
external;

) external;

/// @notice called by owner of a pod to remove any ERC20s deposited in the pod
function recoverTokens(IERC20[] memory tokenList, uint256[] memory amountsToWithdraw, address recipient) external;

Expand All @@ -199,9 +202,11 @@ interface IEigenPod {
/// pod owner will be able to call `startCheckpoint` and `verifyWithdrawalCredentials`
function setProofSubmitter(address newProofSubmitter) external;

/*******************************************************************************
VIEW METHODS
*******************************************************************************/
/**
*
* VIEW METHODS
*
*/

/// @notice An address with permissions to call `startCheckpoint` and `verifyWithdrawalCredentials`, set
/// by the podOwner. This role exists to allow a podOwner to designate a hot wallet that can call
Expand Down Expand Up @@ -247,11 +252,11 @@ interface IEigenPod {
/// NOTE that the values added to this mapping are NOT guaranteed to capture the entirety of a validator's
/// exit - rather, they capture the total change in a validator's balance when a checkpoint shows their
/// balance change from nonzero to zero. While a change from nonzero to zero DOES guarantee that a validator
/// has been fully exited, it is possible that the magnitude of this change does not capture what is
/// has been fully exited, it is possible that the magnitude of this change does not capture what is
/// typically thought of as a "full exit."
///
///
/// For example:
/// 1. Consider a validator was last checkpointed at 32 ETH before exiting. Once the exit has been processed,
/// 1. Consider a validator was last checkpointed at 32 ETH before exiting. Once the exit has been processed,
/// it is expected that the validator's exited balance is calculated to be `32 ETH`.
/// 2. However, before `startCheckpoint` is called, a deposit is made to the validator for 1 ETH. The beacon
/// chain will automatically withdraw this ETH, but not until the withdrawal sweep passes over the validator
Expand All @@ -260,11 +265,11 @@ interface IEigenPod {
/// `-31 ETH`, and because the validator has a nonzero balance, it is not marked WITHDRAWN.
/// 4. After the exit is processed by the beacon chain, a subsequent `startCheckpoint` and checkpoint proof
/// will calculate a balance delta of `-1 ETH` and attribute a 1 ETH exit to the validator.
///
///
/// If this edge case impacts your usecase, it should be possible to mitigate this by monitoring for deposits
/// to your exited validators, and waiting to call `startCheckpoint` until those deposits have been automatically
/// exited.
///
///
/// Additional edge cases this mapping does not cover:
/// - If a validator is slashed, their balance exited will reflect their original balance rather than the slashed amount
/// - The final partial withdrawal for an exited validator will be likely be included in this mapping.
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/interfaces/IEigenPodManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ interface IEigenPodManager is IPausable {

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

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

Expand Down
48 changes: 21 additions & 27 deletions src/contracts/libraries/BeaconChainProofs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import "../libraries/Endian.sol";
//BeaconBlockHeader Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader
//BeaconState Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconstate
library BeaconChainProofs {

/// @notice Heights of various merkle trees in the beacon chain
/// - beaconBlockRoot
/// | HEIGHT: BEACON_BLOCK_HEADER_TREE_HEIGHT
Expand All @@ -25,7 +24,7 @@ library BeaconChainProofs {
uint256 internal constant BEACON_STATE_TREE_HEIGHT = 5;
uint256 internal constant BALANCE_TREE_HEIGHT = 38;
uint256 internal constant VALIDATOR_TREE_HEIGHT = 40;

/// @notice Index of the beaconStateRoot in the `BeaconBlockHeader` container
///
/// BeaconBlockHeader = [..., state_root, ...]
Expand Down Expand Up @@ -90,17 +89,16 @@ library BeaconChainProofs {
bytes proof;
}

/*******************************************************************************
VALIDATOR FIELDS -> BEACON STATE ROOT -> BEACON BLOCK ROOT
*******************************************************************************/
/**
*
* VALIDATOR FIELDS -> BEACON STATE ROOT -> BEACON BLOCK ROOT
*
*/

/// @notice Verify a merkle proof of the beacon state root against a beacon block root
/// @param beaconBlockRoot merkle root of the beacon block
/// @param proof the beacon state root and merkle proof of its inclusion under `beaconBlockRoot`
function verifyStateRoot(
bytes32 beaconBlockRoot,
StateRootProof calldata proof
) internal view {
function verifyStateRoot(bytes32 beaconBlockRoot, StateRootProof calldata proof) internal view {
require(
proof.proof.length == 32 * (BEACON_BLOCK_HEADER_TREE_HEIGHT),
"BeaconChainProofs.verifyStateRoot: Proof has incorrect length"
Expand Down Expand Up @@ -171,9 +169,11 @@ library BeaconChainProofs {
);
}

/*******************************************************************************
VALIDATOR BALANCE -> BALANCE CONTAINER ROOT -> BEACON BLOCK ROOT
*******************************************************************************/
/**
*
* VALIDATOR BALANCE -> BALANCE CONTAINER ROOT -> BEACON BLOCK ROOT
*
*/

/// @notice Verify a merkle proof of the beacon state's balances container against the beacon block root
/// @dev This proof starts at the balance container root, proves through the beacon state root, and
Expand All @@ -184,10 +184,7 @@ library BeaconChainProofs {
/// against the same balance container root.
/// @param beaconBlockRoot merkle root of the beacon block
/// @param proof a beacon balance container root and merkle proof of its inclusion under `beaconBlockRoot`
function verifyBalanceContainer(
bytes32 beaconBlockRoot,
BalanceContainerProof calldata proof
) internal view {
function verifyBalanceContainer(bytes32 beaconBlockRoot, BalanceContainerProof calldata proof) internal view {
require(
proof.proof.length == 32 * (BEACON_BLOCK_HEADER_TREE_HEIGHT + BEACON_STATE_TREE_HEIGHT),
"BeaconChainProofs.verifyBalanceContainer: Proof has incorrect length"
Expand All @@ -200,7 +197,7 @@ library BeaconChainProofs {
/// | HEIGHT: BEACON_STATE_TREE_HEIGHT
/// ---- balancesContainerRoot
uint256 index = (STATE_ROOT_INDEX << (BEACON_STATE_TREE_HEIGHT)) | BALANCE_CONTAINER_INDEX;

require(
Merkle.verifyInclusionSha256({
proof: proof.proof,
Expand Down Expand Up @@ -235,7 +232,7 @@ library BeaconChainProofs {
/// | HEIGHT: BALANCE_TREE_HEIGHT
/// -- balanceRoot
uint256 balanceIndex = uint256(validatorIndex / 4);

require(
Merkle.verifyInclusionSha256({
proof: proof.proof,
Expand All @@ -251,18 +248,17 @@ library BeaconChainProofs {
}

/**
* @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
* @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)));
return Endian.fromLittleEndianUint64(bytes32((uint256(balanceRoot) << bitShiftAmount)));
}

/// @notice Indices for fields in the `Validator` container:
Expand Down Expand Up @@ -294,8 +290,7 @@ library BeaconChainProofs {

/// @dev Retrieves a validator's activation epoch
function getActivationEpoch(bytes32[] memory validatorFields) internal pure returns (uint64) {
return
Endian.fromLittleEndianUint64(validatorFields[VALIDATOR_ACTIVATION_EPOCH_INDEX]);
return Endian.fromLittleEndianUint64(validatorFields[VALIDATOR_ACTIVATION_EPOCH_INDEX]);
}

/// @dev Retrieves true IFF a validator is marked slashed
Expand All @@ -305,7 +300,6 @@ library BeaconChainProofs {

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

0 comments on commit 6116bb3

Please sign in to comment.