---
eip: 6873
label: EIP-6873
title: Preimage retention
status: Stagnant
type: Standards Track
category: Core
created: 2023-04-14
official: https://eips.ethereum.org/EIPS/eip-6873
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-6873.md
canonical: https://eips.huatuo.xyz/eip-6873/
lang: en
tldr: A stagnant proposal requiring every execution client to record the preimages of hashed addresses and storage slots in the fork before the Verkle transition, so each node can convert its own state to the new tree.
tags: [verkle, state, preimages, execution-client, core]
---

# EIP-6873: Preimage retention

> Execution clients must retain the preimages of addresses and slots accessed between the fork preceding the verge, and the verge itself.

**TL;DR:** A stagnant proposal requiring every execution client to record the preimages of hashed addresses and storage slots in the fork before the Verkle transition, so each node can convert its own state to the new tree.

## What problem does it solve?

Ethereum's current state trie stores accounts and storage slots under **hashed** keys (`keccak256(address)`, `keccak256(slot)`). Most execution clients keep only those hashes, not the original values, called preimages.

Moving to Verkle trees ("the Verge") changes how keys are derived, so every key must be recomputed from the original address and slot. A node that only has hashes cannot do that. The spec notes that on mainnet the preimages already took about 70 GB when it was written.

Two ways to get them were considered:

- re-sync from scratch with preimage recording on. That takes a machine offline for days, which cannot be forced on the whole network at once;
- download a preimage file. That is practical, but the file is immediately out of date, because new addresses and slots are touched every block, and a 70 GB download takes far longer than a slot.

EIP-6873 closes the gap: download the history up to a point, and have every node record new preimages itself during the period before the switch.

## How it works

Let `T_p` be the timestamp of the fork **before** the Verge and `T_v` the timestamp of the Verge fork.

- Execution clients **must** save the preimage of every address hash and storage-slot hash they produce while executing blocks between `T_p` and `T_v`.
- They **may** also store preimages outside that window.
- Given a hash produced in the window, a client **should** be able to show it has the preimage.
- Clients **should** be able to download preimages for hashes produced before `T_v` from a publicly available datastore.

Combined, a node has every preimage it needs on Verge day without a full resync. This matters if each node does its own state conversion, as in the overlay-tree approach of [EIP-7612](/eip-7612/).

## Sample code

What "retaining a preimage" means, as pseudocode inside block execution:

```python
def hashed_key(preimage_db, raw: bytes, block_ts: int) -> bytes:
    h = keccak256(raw)                        # address (20 bytes) or slot (32 bytes)
    if T_P <= block_ts < T_V:                 # mandatory window
        preimage_db.put(h, raw)
    return h

def account_key(db, address, ts):        return hashed_key(db, address, ts)
def storage_key(db, slot: bytes, ts):    return hashed_key(db, slot, ts)
```

Clients already offer this as an option. For example, in Geth:

```bash
geth --cache.preimages   # record keccak preimages of trie keys
```

## Things to know

- **Status: Stagnant.** The fork timestamps were never set, and the Verkle migration itself ([EIP-6800](/eip-6800/), [EIP-7612](/eip-7612/)) has not been scheduled. See [EIP-7748](/eip-7748/) for a later state-conversion proposal.
- The spec says all clients already implement preimage retention at least as an option, so the change is mainly about making it mandatory for a defined window.
- Expect extra disk usage on every node during the window.
- Security Considerations are marked "Needs discussion".


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-6873
