EIPs Explained

EIP-7545 · Stagnant · Core · 2023-10-13

EIP-7545: Verkle proof verification precompile

Proposed a versioned precompile that verifies Ethereum state proofs (Merkle-Patricia or Verkle) against a state root, so bridges and dapps would not need to redeploy verifier code every time the proof format changes.

What problem does it solve?

Many contracts, especially bridges and light-client style apps, verify proofs that some account or storage slot has a given value under a given state root. Today they ship their own Merkle-Patricia proof verifier in Solidity.

The stateless Ethereum roadmap planned to change the state tree (to Verkle trees in EIP-6800), and the authors expected proof formats to keep evolving. Each change would force every such contract to deploy new, complex cryptographic code. EIP-7545 proposes moving that work into the protocol: one precompile that always knows how to verify the current proof formats.

How it works

  • A precompiled contract is added at address 0x21.
  • Input is tightly packed: version (1 byte) || state_root (32 bytes) || proof_data (rest).
    • version = 0: a Merkle-Patricia multiproof, in an SSZ format from the consensus-spec "verge" work.
    • version = 1: the polynomial-commitment multiproof used for Verkle trees in EIP-6800.
  • Output is 1 if the proof verifies and 0 otherwise, including for unknown versions.
  • Gas would scale with the number of commitments in the proof and the depth of each proven leaf. The constants POINT_COST and POLY_EVAL_COST were never set (listed as TBD).

Because the precompile is versioned, a new proof format would become a new version number, and existing contracts could use it without being upgraded.

Sample code

The spec's pseudocode, lightly condensed:

def proof_verification_precompile(input: bytes) -> int:
    version    = input[0]
    state_root = input[1:33]
    proof_data = input[33:]

    if version == 0:
        return verify_mpt_multiproof(deserialize_proof(state_root, proof_data))
    if version == 1:
        return verify_pcs_multiproof(deserialize_proof(state_root, proof_data))
    return 0

How a contract would have called it (illustrative only, since the precompile is not live on mainnet):

function verifyState(bytes32 root, bytes calldata proof) internal view returns (bool) {
    (bool ok, bytes memory out) = address(0x21).staticcall(
        abi.encodePacked(uint8(1), root, proof)   // version 1 = Verkle multiproof
    );
    return ok && out.length > 0 && uint8(out[out.length - 1]) == 1;
}

Things to know

  • Status is Stagnant. Gas costs, test cases and security analysis were never completed, and the proposal was not scheduled for any network upgrade.
  • It depends on the Verkle transition (EIP-6800, EIP-7612), which is also Stagnant. A binary-tree design (EIP-7864, Draft) has since been proposed for the state tree.
  • Do not assume address 0x21 is reserved for this. Precompile addresses are assigned per upgrade.
  • The spec notes an early prototype in an Optimism op-geth pull request; no mainnet client ships it.

#verkle #precompile #stateless #proofs #core

Details

Authors
Guillaume Ballet (@gballet), Diederik Loerakker (@protolambda)
Status
Stagnant
Type
Standards Track / Core
Created
2023-10-13
Required by

Machine-readable: Markdown · JSON