EIP-4788 · Final · Core · 2022-02-10
EIP-4788: Beacon block root in the EVM
Puts the parent beacon block root into every execution block and stores recent roots in a system contract, so smart contracts can verify consensus-layer facts like validator balances with Merkle proofs.
What problem does it solve?
Since the Merge, Ethereum has two layers: the execution layer (where contracts run) and the consensus layer (the beacon chain, holding validators, balances, withdrawals). Contracts could not see the consensus layer at all. Staking pools, restaking protocols and bridges that needed facts about validators had to rely on trusted oracles to relay them.
A beacon block root is a cryptographic commitment to the entire consensus state. If a contract can read a trusted root, anyone can submit a Merkle proof against it and the contract can verify that proof on-chain, with no oracle.
How it works
- Header field. Each execution block header gains
parent_beacon_block_root, the hash tree root of the parent beacon block. The consensus client supplies it; execution clients check it. - System contract. At
BEACON_ROOTS_ADDRESS(0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02) lives a tiny contract. At the start of every block, before any transaction, the client calls it fromSYSTEM_ADDRESS(0xfff…fffe) with the root. That call does not count against the block gas limit. - Ring buffers. The contract keeps
HISTORY_BUFFER_LENGTH = 8191entries in two ring buffers: one stores the block timestamp, the other the root, both at indextimestamp % 8191. The spec notes this covers about a day of blocks at current slot times. - Reading. Anyone else calls the contract with a 32-byte big-endian timestamp. It returns the root stored for that timestamp, or reverts if the input is not 32 bytes, is zero, or the stored timestamp does not match (so stale or missing entries are never returned).
The contract was deployed with a keyless "Nick's method" transaction, so its address is the same on any chain that deploys it the same way. It activated on mainnet with the Dencun upgrade in March 2024.
Sample code
Reading the beacon root for a given block timestamp from Solidity:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract BeaconRootReader {
address constant BEACON_ROOTS = 0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02;
/// Returns the parent beacon block root committed in the block with `ts`.
function rootAt(uint256 ts) public view returns (bytes32 root) {
(bool ok, bytes memory out) = BEACON_ROOTS.staticcall(abi.encode(ts));
require(ok, "no root for timestamp");
root = abi.decode(out, (bytes32));
}
function latestRoot() external view returns (bytes32) {
return rootAt(block.timestamp); // root of this block's parent beacon block
}
}
A proof verifier would then check an SSZ Merkle branch (for example to a validator's balance) against the returned root.
Things to know
- The returned root is that of the parent beacon block of the execution block with that timestamp, not of a beacon block at that time.
- Only roughly the last day of roots is available. Proofs must be submitted before their root is overwritten.
- Querying a timestamp with no execution block (a missed slot) reverts; callers should handle that.
- Merkle proofs are against SSZ hash tree roots, so you need consensus-layer tooling to build them.
- The companion EIP-2935 uses a similar system-contract pattern to serve historical execution block hashes.