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:
- gets the headers for
fromBlock, its parent, andtoBlock; - uses
eth_getProofto read the matching accumulator at the parent and attoBlock; - 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
LOGopcodes, due to extraSLOAD/SSTOREand 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_getLogsas before. Strict response parsers may need to accept the newblockTimestampfield.