EIPs Explained

EIP-4895 · Final · Core · 2022-03-10

EIP-4895: Beacon chain push withdrawals as operations

Lets validator withdrawals flow from the beacon chain into the execution layer as a new system-level "withdrawal" operation that credits ETH to an address without a transaction or gas; activated in the Shanghai/Capella upgrade.

What problem does it solve?

After the Merge (EIP-3675) stakers' ETH lived on the beacon chain with no way back into the EVM. Rewards accumulated and exits were possible, but the ETH could not be spent.

EIP-4895 defines how withdrawn ETH crosses from the consensus layer into execution-layer balances. It uses a push model: when the consensus layer dequeues a withdrawal, the execution layer must apply it in that block. Nobody has to send a transaction to claim it.

How it works

  • A new payload object, the withdrawal, separate from user transactions: [index, validator_index, address, amount]. index is a global counter, amount is in Gwei and non-zero.
  • The execution payload gains a withdrawals list, and the block header gains withdrawals_root, a Merkle-Patricia trie root built the same way as the transactions root.
  • Withdrawals are processed after all transactions in the block. Each one simply increases the balance of address by amount × 10^9 wei.
  • This balance increase is unconditional, must not fail, costs no gas and runs no EVM code.

Activation is by timestamp: FORK_TIMESTAMP = 1681338455 (April 2023, the Shanghai execution / Capella consensus upgrade).

Why not a new transaction type? Withdrawals are initiated by the system, not by users. Keeping them as a separate object avoids interaction with normal transaction processing and simplifies testing and security review. The consensus layer bounds how many withdrawals appear per block, so skipping gas accounting is safe.

Sample code

Reading withdrawals from a block via JSON-RPC (ethers v6):

import { JsonRpcProvider, formatEther } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const block = await provider.send("eth_getBlockByNumber", ["latest", false]);

console.log("withdrawalsRoot:", block.withdrawalsRoot);
for (const w of block.withdrawals ?? []) {
  const wei = BigInt(w.amount) * 10n ** 9n; // amount is in Gwei
  console.log(`#${BigInt(w.index)} validator ${BigInt(w.validatorIndex)} -> ${w.address}: ${formatEther(wei)} ETH`);
}

Things to know

  • Withdrawals do not call the recipient. A contract receiving them will not run receive() or fallback(), and they emit no logs. Track them via the block's withdrawals list, not via events.
  • Because a withdrawal is not a transaction, it does not appear in transaction lists or receipts.
  • Which validators withdraw and how much is decided entirely on the consensus layer; this EIP only applies the result.
  • Later upgrades extended staking flows: EIP-7002 lets the withdrawal credentials trigger exits from the execution layer, EIP-6110 moves deposits on-chain and EIP-7251 raises the maximum effective balance.

#staking #withdrawals #consensus #core #shanghai

Details

Authors
Alex Stokes (@ralexstokes), Danny Ryan (@djrtwo)
Status
Final
Type
Standards Track / Core
Created
2022-03-10
Required by

Machine-readable: Markdown · JSON