---
eip: 2584
label: EIP-2584
title: Trie format transition with overlay trees
status: Stagnant
type: Standards Track
category: Core
created: 2020-04-03
official: https://eips.ethereum.org/EIPS/eip-2584
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2584.md
canonical: https://eips.huatuo.xyz/eip-2584/
lang: en
tldr: "A stagnant plan to switch Ethereum's state from a hexary to a binary trie without halting the chain, by writing new state to an overlay trie while the old one is converted in the background."
tags: [state, trie, binary, migration, core, stagnant]
---

# EIP-2584: Trie format transition with overlay trees

> This EIP proposes a method to convert the state trie format from hexary to binary: new values are directly stored in a binary trie “laid over” the hexary trie. Meanwhile, the hexary trie is converted to a binary trie in the background. When the process is finished, both layers are merged.

**TL;DR:** A stagnant plan to switch Ethereum's state from a hexary to a binary trie without halting the chain, by writing new state to an overlay trie while the old one is converted in the background.

## What problem does it solve?

Ethereum stores its state in a hexary Merkle Patricia Trie: each branch node has 16 children. A binary trie (2 children per branch) gives much smaller Merkle proofs, which matters for stateless clients and light clients.

The hard part is the migration. The full state is far too large to convert within one block time, so you cannot just flip a switch at a fork block. Earlier ideas were "stop the world" (halt the chain during conversion) or "copy on write" (convert branches only when touched, which may never finish). EIP-2584 proposes a method that keeps the chain running and still completes in predictable time.

## How it works

Three phases (the abstract calls it four, but the text describes three):

1. **Phase 1 — overlay.** From block `h₁`, all state *writes* go to a new, initially empty binary **overlay trie**, whose root is a new block-header field. The old hexary **base trie** is frozen; reads check the overlay first, then fall back to the base. Deleted accounts are marked in the overlay with the empty hash. Meanwhile every node converts the frozen hexary trie to binary in the background.
2. **Phase 2 — merge.** At block `h₂`, the state root switches to the converted binary base root. The overlay becomes read/delete only; writes go to the base trie. Before each block, the first `N` accounts (in key order) are moved out of the overlay into the base trie.
3. **Phase 3 — done.** Once the overlay is empty, its root field is removed from the header.

`h₂` must be far enough after `h₁` for miners to finish converting; the author reports a prototype converting in roughly 30 minutes on a fast machine.

## Sample code

Pseudocode for state access during phase 1:

```python
EMPTY = keccak(b"")

def read_account(addr):
    v = overlay.get(addr)
    if v == EMPTY:            # deleted during the transition
        return None
    if v is not None:
        return v
    return base_hex.get(addr) # frozen hexary trie

def write_account(addr, value):
    overlay.put(addr, value)  # base trie is never touched in phase 1

def delete_account(addr):
    overlay.put(addr, EMPTY)
```

And the per-block merge step in phase 2:

```python
for addr, v in overlay.first_n_sorted(N):
    if v == EMPTY:
        base_bin.delete(addr)
    else:
        base_bin.put(addr, v)
    overlay.delete(addr)
```

## Things to know

- Status is **Stagnant**. It is a hard fork that changes block format and hashes, and was never scheduled.
- Security notes in the spec: an attacker could bloat the overlay to prolong phase 2 (possibly mitigated by pricier `SSTORE` in phase 1), and if `h₂` comes too soon, miners might not compute the converted root in time.
- The overlay idea lived on in later state-migration work: [EIP-7612](/eip-7612/) (overlay transition to Verkle) and [EIP-7748](/eip-7748/) (state conversion). The target tree has since shifted from Verkle ([EIP-6800](/eip-6800/)) to a unified binary tree ([EIP-7864](/eip-7864/)), both still drafts or stagnant.


---

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