Skip to main content

Verkle trees

  • Discover what Verkle trees are
  • Read why Verkle trees were set aside in favor of a binary tree

Verkle trees (a portmanteau of "Vector commitment" and "Merkle Trees") are a data structure that can be used to upgrade Ethereum nodes so that they can stop storing large amounts of state data without losing the ability to validate blocks.

Verkle trees were proposed as Ethereum's next state tree in EIP-6800 (opens in a new tab), but that proposal is now stagnant and has been set aside in favor of a unified binary tree (EIP-7864 (opens in a new tab)). The binary tree pursues the same goal of small witnesses for stateless clients. This page explains how Verkle trees work and why research moved to a binary tree.

Statelessness

Verkle trees were designed as a step on the path to stateless Ethereum clients. Stateless clients are ones that do not have to store the entire state database in order to validate incoming blocks. Instead of using their own local copy of Ethereum's state to verify blocks, stateless clients use a "witness" to the state data that arrives with the block. A witness is a collection of individual pieces of the state data that are required to execute a particular set of transactions, and a cryptographic proof that the witness is really part of the full data. The witness is used instead of the state database. For this to work, the witnesses need to be very small, so that they can be safely broadcast across the network in time for validators to process them within a 12 second slot. The current state data structure is not suitable because witnesses are too large. Verkle trees solve this problem by enabling small witnesses, removing one of the main barriers to stateless clients.

Ethereum clients currently use a data structure known as a Patricia Merkle Trie to store its state data. Information about individual accounts is stored in leaves on the trie, and each branch node, which can have up to 16 children, is hashed together with its children's hashes, level by level, until only a single hash remains. This final hash is known as the "root". To verify blocks, Ethereum clients execute all the transactions in a block and update their local state trie. The block is considered valid if the root of the local tree is identical to the one provided by the block proposer, because any differences in the computation done by the block proposer and the validating node would cause the root hash to be completely different. The problem with this is that verifying the blockchain requires each client to store the whole state trie for the head block and several historical blocks (the default in Geth is to keep state data for 128 blocks behind the head). This requires clients to have access to a large amount of disk space, which is a barrier to running full nodes on cheap, low power hardware. A solution to this is to update the state trie to a more efficient structure (such as a Verkle tree or a binary tree) that can be summarized using a small "witness" to the data that can be shared instead of the full state data. Reformatting the state data into a new tree structure is a stepping stone for moving to stateless clients.

What is a witness and why do we need them?

Verifying a block means re-executing the transactions contained in the block, applying the changes to Ethereum's state trie, and calculating the new root hash. A verified block is one whose computed state root hash is the same as the one provided with the block (because this means the block proposer really did the computation they say they did). In today's Ethereum clients, updating the state requires access to the entire state trie, which is a large data structure that must be stored locally. A witness only contains the fragments of the state data that are required to execute the transactions in the block. A validator can then only use those fragments to verify that the block proposer has executed the block transactions and updated the state correctly. However, this means that the witness needs to be transferred between peers on the Ethereum network rapidly enough to be received and processed by each node safely within a 12 second slot. If the witness is too large, it might take some nodes too long to download it and keep up with the chain. This is a centralizing force because it means only nodes with fast internet connections can participate in validating blocks. With Verkle trees there is no need to have the state stored on your hard drive; everything you need to verify a block is contained within the block itself. Unfortunately, the witnesses that can be produced from Merkle tries are too large to support stateless clients.

Why do Verkle trees enable smaller witnesses?

The structure of a Merkle Trie makes witness sizes very large - too large to safely broadcast between peers within a 12 second slot. This is because the witness is a path connecting the data, which is held in leaves, to the root hash. To verify the data it is necessary to have not only all the intermediate hashes that connect each leaf to the root, but also all the "sibling" nodes. Each node in the proof has a sibling that it is hashed with to create the next hash up the trie. This is a lot of data. Verkle trees reduce the witness size by shortening the distance between the leaves of the tree and its root and also eliminating the need to provide sibling nodes for verifying the root hash. Even more space efficiency will be gained by using a powerful polynomial commitment scheme instead of the hash-style vector commitment. The polynomial commitment allows the witness to have a fixed size regardless of the number of leaves that it proves.

Under the polynomial commitment scheme, the witnesses have manageable sizes that can easily be transferred on the peer-to-peer network. This allows clients to verify state changes in each block with a minimal amount of data.

The witness size varies depending on the number of leaves it includes. Assuming the witness covers 1000 leaves, a witness for a Merkle trie would be about 3.5MB (assuming 7 levels to the trie). A witness for the same data in a Verkle tree (assuming 4 levels to the tree) would be about 150 kB - about 23x smaller. This reduction in witness size will allow stateless client witnesses to be acceptably small. Polynomial witnesses are 0.128 -1 kB depending on which specific polynomial commitment is used.

What is the structure of a Verkle tree?

Verkle trees are (key,value) pairs where the keys are 32-byte elements composed of a 31-byte stem and a single byte suffix. These keys are organized into extension nodes and inner nodes. Extension nodes represent a single stem for 256 children with different suffixes. Inner nodes also have 256 children, but they can be other extension nodes. The main difference between the Verkle tree and the Merkle tree structure is that the Verkle tree is much flatter, meaning there are fewer intermediate nodes linking a leaf to the root, and therefore less data required to generate a proof.

Fig. 1Looking up a key in a Verkle tree

Stem treeThe upper levels: the root and the inner nodes. Each node has up to 256 children, one per value of a stem byte, and is a Pedersen commitment to them. The dashed nodes are children off this key's path.ExtensionOne node per stem: a commitment to the marker 1, the 31-byte stem, and the two suffix commitments C1 and C2.Suffix treeC1 and C2: commitments to the stem's 256 suffix slots, two entries per slot. C1 covers suffixes 0 to 127, C2 covers 128 to 255.
  • Key's path
  • Proof
  • Structure
Choose a tree
5 steps

Choose a tree and look up the key to follow it from the root to its value, then see what a proof of that value carries.

Children per node
256
Levels on the path
–
Items in the proof
–
Witness per account
–

A key lookup, drawn top to bottom in four bands. Stem tree: a root node and a row of its children; only the middle child, an inner node, is on the key's path, and the dashed ones are other children. Extension: the stem's extension node, a commitment to (1, stem, C1, C2). Suffix tree: the commitments C1 and C2, each over half of the stem's 256 suffix slots, C1 over suffixes 0 to 127 and C2 over 128 to 255. Data: the value's two halves, value_lower and value_upper. With the Verkle tree chosen, step 1: the key's first 31 bytes, its stem, lead from the root down the stem tree, one byte per level, each node having up to 256 children. Step 2: the path reaches the stem's extension node. Step 3: the key's last byte, its suffix, here 1, picks a slot under C1. Step 4: the 32-byte value is read as two 16-byte halves, because one field element holds only 252 bits safely. Step 5: the proof carries one commitment per level below the root, 3 in all, plus one opening proof shared by the whole witness, and no sibling nodes. Choosing the Merkle trie instead draws today's hexary Patricia trie: 7 branch nodes, each a row of 16 child slots with one slot on the key's path, and the value at the end. Step 1: the path takes 7 levels, against 4 in the Verkle tree. Step 2: a leaf holds the value. Step 3: the proof must carry the other 15 children of every node on the path, 105 sibling hashes. EIP-6800 puts the average witness for one account at about 200 bytes with Verkle trees, against close to 3 kB today.

A Verkle tree routes a key's stem to an extension node and its suffix to the value. Its paths are shorter than a Merkle trie's, and its proofs carry no sibling hashes.

Read more about the structure of Verkle trees (opens in a new tab)

Current progress

EIP-6800 (opens in a new tab), the proposal to move Ethereum's state into a unified Verkle tree, is now stagnant. Research has moved to EIP-7864 (opens in a new tab), which proposes a unified binary tree instead. EIP-7864 is a draft, and no network upgrade has been scheduled for it.

EIP-7864 gives two main reasons for the change. Verkle trees rely on elliptic-curve cryptography that is not secure against quantum computers, so they would eventually need to be replaced, while a binary tree relies only on hash functions. Progress in proving systems also reduces the need for the small, fast-to-generate proofs that were the main advantage of Verkle trees. Because each node in a binary tree has only two children, its proofs are also much smaller than proofs from today's hexary trie.

Further reading