IEigenPod

IEigenPod

Author: Layr Labs, Inc.

Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service

The main functionalities are:

  • creating new ETH validators with their withdrawal credentials pointed to this contract

  • proving from beacon chain state roots that withdrawal credentials are pointed to this contract

  • proving from beacon chain state roots the balances of ETH validators with their withdrawal credentials pointed to this contract

  • updating aggregate balances in the EigenPodManager

  • withdrawing eth when withdrawals are initiated

Note that all beacon chain balances are stored as gwei within the beacon chain datastructures. We choose to account balances in terms of gwei in the EigenPod contract and convert to wei when making calls to other contracts

Functions

MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR

The max amount of eth, in gwei, that can be restaked per validator

function MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR() external view returns (uint64);

withdrawableRestakedExecutionLayerGwei

the amount of execution layer ETH in this contract that is staked in EigenLayer (i.e. withdrawn from beaconchain but not EigenLayer),

function withdrawableRestakedExecutionLayerGwei() external view returns (uint64);

nonBeaconChainETHBalanceWei

any ETH deposited into the EigenPod contract via the receive fallback function

function nonBeaconChainETHBalanceWei() external view returns (uint256);

initialize

Used to initialize the pointers to contracts crucial to the pod's functionality, in beacon proxy construction from EigenPodManager

function initialize(address owner) external;

stake

Called by EigenPodManager when the owner wants to create another ETH validator.

function stake(bytes calldata pubkey, bytes calldata signature, bytes32 depositDataRoot) external payable;

withdrawRestakedBeaconChainETH

Transfers amountWei in ether from this contract to the specified recipient address

Called by EigenPodManager to withdrawBeaconChainETH that has been added to the EigenPod's balance due to a withdrawal from the beacon chain.

The podOwner must have already proved sufficient withdrawals, so that this pod's withdrawableRestakedExecutionLayerGwei exceeds the amountWei input (when converted to GWEI).

Reverts if amountWei is not a whole Gwei amount

function withdrawRestakedBeaconChainETH(address recipient, uint256 amount) external;

eigenPodManager

The single EigenPodManager for EigenLayer

function eigenPodManager() external view returns (IEigenPodManager);

podOwner

The owner of this EigenPod

function podOwner() external view returns (address);

hasRestaked

an indicator of whether or not the podOwner has ever "fully restaked" by successfully calling verifyCorrectWithdrawalCredentials.

function hasRestaked() external view returns (bool);

mostRecentWithdrawalTimestamp

The latest timestamp at which the pod owner withdrew the balance of the pod, via calling withdrawBeforeRestaking.

This variable is only updated when the withdrawBeforeRestaking function is called, which can only occur before hasRestaked is set to true for this pod. Proofs for this pod are only valid against Beacon Chain state roots corresponding to timestamps after the stored mostRecentWithdrawalTimestamp.

function mostRecentWithdrawalTimestamp() external view returns (uint64);

validatorPubkeyHashToInfo

Returns the validatorInfo struct for the provided pubkeyHash

function validatorPubkeyHashToInfo(bytes32 validatorPubkeyHash) external view returns (ValidatorInfo memory);

provenWithdrawal

mapping that tracks proven withdrawals

function provenWithdrawal(bytes32 validatorPubkeyHash, uint64 slot) external view returns (bool);

validatorStatus

This returns the status of a given validator

function validatorStatus(bytes32 pubkeyHash) external view returns (VALIDATOR_STATUS);

verifyWithdrawalCredentials

This function verifies that the withdrawal credentials of validator(s) owned by the podOwner are pointed to this contract. It also verifies the effective balance of the validator. It verifies the provided proof of the ETH validator against the beacon chain state root, marks the validator as 'active' in EigenLayer, and credits the restaked ETH in Eigenlayer.

function verifyWithdrawalCredentials(
    uint64 oracleTimestamp,
    IBeaconChainProofs.StateRootProof calldata stateRootProof,
    uint40[] calldata validatorIndices,
    bytes[] calldata withdrawalCredentialProofs,
    bytes32[][] calldata validatorFields
) external;

Parameters

NameTypeDescription

oracleTimestamp

uint64

is the Beacon Chain timestamp whose state root the proof will be proven against.

stateRootProof

IBeaconChainProofs.StateRootProof

validatorIndices

uint40[]

is the list of indices of the validators being proven, refer to consensus specs

withdrawalCredentialProofs

bytes[]

is an array of proofs, where each proof proves each ETH validator's balance and withdrawal credentials against a beacon chain state root

validatorFields

bytes32[][]

are the fields of the "Validator Container", refer to consensus specs for details: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator

verifyBalanceUpdate

This function records an update (either increase or decrease) in the pod's balance in the StrategyManager. It also verifies a merkle proof of the validator's current beacon chain balance.

For more details on the Beacon Chain spec, see: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator

function verifyBalanceUpdate(
    uint64 oracleTimestamp,
    uint40 validatorIndex,
    IBeaconChainProofs.StateRootProof calldata stateRootProof,
    IBeaconChainProofs.BalanceUpdateProof calldata balanceUpdateProof,
    bytes32[] calldata validatorFields
) external;

Parameters

NameTypeDescription

oracleTimestamp

uint64

The oracleTimestamp whose state root the proof will be proven against. Must be within VERIFY_BALANCE_UPDATE_WINDOW_SECONDS of the current block.

validatorIndex

uint40

is the index of the validator being proven, refer to consensus specs

stateRootProof

IBeaconChainProofs.StateRootProof

balanceUpdateProof

IBeaconChainProofs.BalanceUpdateProof

is the proof of the validator's balance and validatorFields in the balance tree and the balanceRoot to prove for the StrategyManager in case it must be removed from the list of the podOwner's strategies

validatorFields

bytes32[]

are the fields of the "Validator Container", refer to consensus specs

verifyAndProcessWithdrawals

This function records full and partial withdrawals on behalf of one of the Ethereum validators for this EigenPod

function verifyAndProcessWithdrawals(
    uint64 oracleTimestamp,
    IBeaconChainProofs.StateRootProof calldata stateRootProof,
    IBeaconChainProofs.WithdrawalProof[] calldata withdrawalProofs,
    bytes[] calldata validatorFieldsProofs,
    bytes32[][] calldata validatorFields,
    bytes32[][] calldata withdrawalFields
) external;

Parameters

NameTypeDescription

oracleTimestamp

uint64

is the timestamp of the oracle slot that the withdrawal is being proven against

stateRootProof

IBeaconChainProofs.StateRootProof

withdrawalProofs

IBeaconChainProofs.WithdrawalProof[]

is the information needed to check the veracity of the block numbers and withdrawals being proven

validatorFieldsProofs

bytes[]

is the proof of the validator's fields' in the validator tree

validatorFields

bytes32[][]

are the fields of the validators being proven

withdrawalFields

bytes32[][]

are the fields of the withdrawals being proven

activateRestaking

Called by the pod owner to activate restaking by withdrawing all existing ETH from the pod and preventing further withdrawals via "withdrawBeforeRestaking()"

function activateRestaking() external;

withdrawBeforeRestaking

Called by the pod owner to withdraw the balance of the pod when hasRestaked is set to false

function withdrawBeforeRestaking() external;

withdrawNonBeaconChainETHBalanceWei

Called by the pod owner to withdraw the nonBeaconChainETHBalanceWei

function withdrawNonBeaconChainETHBalanceWei(address recipient, uint256 amountToWithdraw) external;

recoverTokens

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;

Events

EigenPodStaked

Emitted when an ETH validator stakes via this eigenPod

event EigenPodStaked(bytes pubkey);

ValidatorRestaked

Emitted when an ETH validator's withdrawal credentials are successfully verified to be pointed to this eigenPod

event ValidatorRestaked(uint40 validatorIndex);

ValidatorBalanceUpdated

Emitted when an ETH validator's balance is proven to be updated. Here newValidatorBalanceGwei is the validator's balance that is credited on EigenLayer.

event ValidatorBalanceUpdated(uint40 validatorIndex, uint64 balanceTimestamp, uint64 newValidatorBalanceGwei);

FullWithdrawalRedeemed

Emitted when an ETH validator is prove to have withdrawn from the beacon chain

event FullWithdrawalRedeemed(
    uint40 validatorIndex, uint64 withdrawalTimestamp, address indexed recipient, uint64 withdrawalAmountGwei
);

PartialWithdrawalRedeemed

Emitted when a partial withdrawal claim is successfully redeemed

event PartialWithdrawalRedeemed(
    uint40 validatorIndex, uint64 withdrawalTimestamp, address indexed recipient, uint64 partialWithdrawalAmountGwei
);

RestakedBeaconChainETHWithdrawn

Emitted when restaked beacon chain ETH is withdrawn from the eigenPod.

event RestakedBeaconChainETHWithdrawn(address indexed recipient, uint256 amount);

RestakingActivated

Emitted when podOwner enables restaking

event RestakingActivated(address indexed podOwner);

NonBeaconChainETHReceived

Emitted when ETH is received via the receive fallback

event NonBeaconChainETHReceived(uint256 amountReceived);

NonBeaconChainETHWithdrawn

Emitted when ETH that was previously received via the receive fallback is withdrawn

event NonBeaconChainETHWithdrawn(address indexed recipient, uint256 amountWithdrawn);

Structs

ValidatorInfo

struct ValidatorInfo {
    uint64 validatorIndex;
    uint64 restakedBalanceGwei;
    uint64 mostRecentBalanceUpdateTimestamp;
    VALIDATOR_STATUS status;
}

VerifiedWithdrawal

struct used to store amounts related to proven withdrawals in memory. Used to help manage stack depth and optimize the number of external calls, when batching withdrawal operations.

struct VerifiedWithdrawal {
    uint256 amountToSendGwei;
    int256 sharesDeltaGwei;
}

Enums

VALIDATOR_STATUS

enum VALIDATOR_STATUS {
    INACTIVE,
    ACTIVE,
    WITHDRAWN
}

PARTIAL_WITHDRAWAL_CLAIM_STATUS

enum PARTIAL_WITHDRAWAL_CLAIM_STATUS {
    REDEEMED,
    PENDING,
    FAILED
}

Last updated