EIP-7002 · Final · Core · 2023-05-09
EIP-7002: Execution layer triggerable withdrawals
Lets a validator's execution-layer withdrawal address, EOA or smart contract, trigger a full exit or partial withdrawal by calling a system contract, without needing the validator's signing key.
What problem does it solve?
A validator has two keys: a hot BLS signing key that performs duties, and withdrawal credentials, which for 0x01 credentials is an Ethereum address that receives the funds. The withdrawal address ultimately owns the stake, yet before this EIP only the signing key could start an exit.
That's a problem whenever the two are held by different parties. A staking pool's smart contract or a delegator could not force an exit, so the operator could effectively hold the ETH hostage, and workarounds like pre-signed exit messages are clumsy. If the signing key was lost, the owner could not get out at all.
EIP-7002 lets the withdrawal address trigger exits (and partial withdrawals) from the execution layer, by ordinary transaction or contract call.
How it works
- A system contract is predeployed at
0x00000961Ef480Eb55e80D19ad83579A64c007002. - Adding a request: call it with exactly 56 bytes of calldata: the 48-byte validator pubkey followed by a big-endian
uint64amount, and send at least the current fee asmsg.value.msg.senderis recorded as thesource_address; the consensus layer only acts if it matches the validator's withdrawal credentials. An amount of 0 means a full exit; a non-zero amount (in Gwei) requests a partial withdrawal. - Reading the fee: call with empty calldata; it returns the current fee in wei.
- Queue: requests are queued in contract storage. At the end of each block, a system call dequeues up to 16 and places them in the block as EIP-7685 requests (type
0x01). The consensus layer processes them like a voluntary exit, but an invalid request (e.g. validator already exiting) is just skipped rather than invalidating the block. - Fee: an EIP-1559-style exponential fee. It stays at 1 wei while usage averages at or below 2 requests per block, and grows exponentially with "excess" requests to stop griefing.
Using the pubkey rather than the validator index lets staking contracts that know the key in advance use it before the validator is assigned an index.
Sample code
Requesting a full exit from a contract, paying exactly the current fee (based on the spec's example):
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;
contract ExitTrigger {
address constant WITHDRAWAL_REQUESTS = 0x00000961Ef480Eb55e80D19ad83579A64c007002;
// Must be called from the validator's withdrawal-credential address.
function requestWithdrawal(bytes calldata pubkey, uint64 amountGwei, uint256 maxFee) external payable {
require(pubkey.length == 48, "bad pubkey");
(bool ok, bytes memory feeData) = WITHDRAWAL_REQUESTS.staticcall("");
require(ok, "fee read failed");
uint256 fee = uint256(bytes32(feeData));
require(fee <= maxFee, "fee too high");
// 48-byte pubkey ++ 8-byte big-endian amount (0 = full exit)
(bool sent, ) = WITHDRAWAL_REQUESTS.call{value: fee}(abi.encodePacked(pubkey, amountGwei));
require(sent, "request failed");
}
}
For this to work, the ExitTrigger contract itself must be the validator's 0x01 withdrawal address.
Things to know
- Status: Final. It went live on mainnet in the Pectra upgrade, alongside EIP-6110 (deposits) and EIP-7251 (larger validator balances).
- Overpaid fees are not refunded. Read the fee first and pay exactly that, with a cap, as above. Sending a fixed large value from an EOA wastes the difference.
- Under the Electra consensus rules, partial withdrawals apply only to validators with compounding (
0x02) credentials from EIP-7251; full exits work for0x01and0x02. - Requests are queued, so a request may not be included in the very block of your transaction, and the exit itself still waits in the beacon chain's exit queue.
- Custody setups that assumed the withdrawal address couldn't force an exit should re-check that assumption.