EIPs Explained

EIP-7792 · Stagnant · Core · 2024-10-21

EIP-7792: Verifiable logs

Makes eth_getLogs results provable: every block accumulates log hashes into a system contract's storage, so a wallet can check with eth_getProof that a provider returned all matching logs and only real ones.

What problem does it solve?

Wallets build your transaction history from eth_getLogs. Today you simply have to trust the RPC provider: it could omit a transfer or invent one, and you cannot easily tell. The only built-in check is each block header's logs bloom, which has many false positives and would require downloading every header in the range. So wallets depend on trusted providers, which also see every address you query.

EIP-7792 adds a compact on-chain commitment to logs so a response can be checked for correctness and completeness with a handful of proofs.

How it works

After all transactions in a block run, the client adds every emitted log to running hash chains stored in a special address, LOG_CONTRACT_ADDRESS (0xfff…fffe). The account has no code, and its nonce is set to 1 so it is never removed under EIP-158.

For each log, the client builds a LogEntry that wraps the EIP-6466 SSZ Log with metadata (block number, block timestamp, transaction index) and takes its hash_tree_root. That root is folded into up to three accumulators:

  • one keyed by the emitting address,
  • one per topic,
  • one per address + topic pair.

Each accumulator is updated as new = sha256(entry_root ‖ old).

To verify eth_getLogs(address, topics, fromBlock, toBlock), a wallet:

  1. gets the headers for fromBlock, its parent, and toBlock;
  2. uses eth_getProof to read the matching accumulator at the parent and at toBlock;
  3. replays the returned logs onto the starting accumulator. If it arrives at the ending value, the response is exactly right: nothing missing, nothing extra.

eth_getLogs responses gain a blockTimestamp field so the wallet can rebuild each LogEntry.

Sample code

Client-side verification, following the spec (pseudocode, Python syntax):

from hashlib import sha256

def address_key(addr):          # LOG_ADDRESS_STORAGE_SLOT = 0
    return keccak256(abi_encode(addr, 0))

def verify_get_logs(addr, logs, from_block, to_block):
    parent = header(from_block.parent_hash)
    start = proven_storage(LOG_CONTRACT_ADDRESS, address_key(addr), parent)    # eth_getProof
    end   = proven_storage(LOG_CONTRACT_ADDRESS, address_key(addr), to_block)  # eth_getProof

    acc = start
    for log in logs:                          # in chain order
        entry = LogEntry(
            meta=LogMeta(block=BlockMeta(timestamp=log.blockTimestamp, number=log.blockNumber),
                         transaction_index=log.transactionIndex),
            log=Log(address=log.address, topics=log.topics, data=log.data),
        )
        acc = sha256(entry.hash_tree_root() + acc).digest()
    return acc == end

Things to know

  • Status is Stagnant. It depends on SSZ receipts (EIP-6466), which is still a Draft.
  • The spec is open that this is much more expensive than today's LOG opcodes, due to extra SLOAD/SSTORE and SHA-256 work. It suggests moving the accumulators out of state or into a ZK system if that proves too costly. EIP-7745 is a related proposal for a trustless log index.
  • Metadata uses block number and transaction index rather than hashes, because the block hash depends on the state root that contains the accumulators.
  • Unverifying clients can keep using eth_getLogs as before. Strict response parsers may need to accept the new blockTimestamp field.

#logs #json-rpc #light-client #privacy #core

Details

Authors
Etan Kissling (@etan-status), Gajinder Singh (@g11tech), Vitalik Buterin (@vbuterin)
Status
Stagnant
Type
Standards Track / Core
Created
2024-10-21
Requires

Machine-readable: Markdown · JSON