šŸ˜

Verkle Trees for Statelessness

šŸ’”
Verkle Trees = Vector Commitments + Merkle Trees

Contents

site maintained by @rudolf6, @ignaciohagopian, and @gballet (ping with any questions/requests)

1Ā Ā Introduction

Updated: Apr 08, 2024

āœØ
Tl;dr: Verkle Trees and statelessness bring many benefits to Ethereum
  • Smaller proof sizes allow proofs to be passed over the network, which will unlock many new types of functionality in addition to stateless clients
  • Lower hardware requirements to run a node, which improves decentralization
  • New nodes can join the network right away with faster sync
  • Potential scaling benefits in that it could allow for higher gas limits
  • More compatible with a zk-EVM future

ā€£
What are Verkle Trees?

Verkle Tries are a type of data structure similar to Merkle Patricia Trees (MPT), which is the data structure used in Ethereum today. While Verkle Tries utilize a tree-like structure similar to MPT, a key difference is each node uses a special type of hash (called a vector commitment) to commit to children nodes. These vector commitments provide several important, long-term benefits, and help pave the way for statelessness in Ethereum.

Note: Both Verkle Tries and Merkle Trees serve a key purpose in blockchain networks ā€” providing data in a format that allows for network participants to easily verify network state (needing only a short proof, aka ā€œwitnessā€, and the root of the tree).

ā€£
Why?

Because it can help Ethereum achieve statelessness! The key benefit of the vector commitments used in Verkle is that they allow for much smaller proof sizes (called witnesses). Instead of needing to provide hashes of all "sibling nodes" at each level, as in Merkle Trees, the prover needs only to provide all parent nodes (plus an extra proof, called an optional) along the paths from each leaf node to the root. Since we no longer need to provide all sibling nodes, we can structure Verkle Tries to be much wider than Merkle Trees. All of this allows for much smaller witness sizes.

Whatā€™s so great about small witness sizes? Large witnesses are the key problem standing in the way of statelessness. When witnesses (proofs) are small enough, they can be contained within each block. This allows for the verification of any block using only whatā€™s contained within the block itself.

The general principle of ā€œstatelessnessā€ is that nodes verifying blocks no longer need to store state. See this writeup from Dankrad Feist on why statelessness is a worthy goal.

ā€£
How?

How do we actually get from the current Merkle world to Verkle?

See this writeup on potential migration paths, which currently include four options:

  1. Overlay Method:
    • This is currently the leading candidate. In this method, you start with an empty, new overlay tree (the Verkle tree), and a base tree (the existing Merkle tree). Each block, a fixed number of values are copied from the base tree to the overlay tree. When reading the state, you first search the overlay tree for a key, and if itā€™s not found then search the base tree. When writing to the state, you always write to the overlay tree.
  2. Conversion Node:
    • A small group of very powerful machines do the translation at a fixed block height, and then share the result with the rest of the network. Less powerful clients download the conversion and replay blocks in Verkle mode until the head has been reached.
  3. Local Bulk:
    • Similar to the ā€œConversion Nodeā€ method, except there is no special class of nodes and all machines do the conversion themselves. This approach was previously not feasible, but has started to look possible based on recent performance optimizations.
  4. State Expiry:
    • The Merkle tree is frozen in place, and we start from a fresh tree. Reading and writing work the same as with the overlay method, but no conversion/merging of the trees ever happens.

ā€£
Want to help?
šŸ¤
Join the conversation in the Ethereum R&D discord (#verkle-trie channel)
šŸ“ž

Specific things you can do right away:

  1. Implement it in your clients, & try to join the testnets.
  2. Deploy your dapp on one of the testnets and report issues in Discord.
  3. Write some tooling!
  4. Ask a question in Discord :)

ā€£
Whatā€™s up with the elephant?

Elephants have been known to uproot trees :)

image

This is the latest and most up-to-date talk about Verkle Trees:

EthCC 2023

You can also see the Verkle Trees 101 presentation given for the Ethereum Protocol Fellowship Study Group:

2Ā Ā FAQ

Updated: Apr 08, 2024

ā€£
Why does Verkle require gas cost changes?

The motivation can be summarized as follows:

There is a strong desire to allowĀ stateless verificationĀ of blocks. A client should be able to verify the correctness of any individual block without any extra information except for a small file that any state-holding node can generate, called aĀ witness, that contains the portion of the state accessed by the block along with proofs of correctness. Stateless verification has important benefits including reducing disk-space requirements, allowing semi-light ā€œtrust but verify if alertedā€ clients, and supporting sharding setups where clients frequently jump between shards. Stateless verification is not viable at present, but the introduction of Verkle trees will make it viable. However, for this to work we need to adjust gas costs so that the gas cost of an operation corresponds to the witness size required for that operation. Operations that require witness sizes include: - Account reads (mostly calls but alsoĀ EXTCODEHASHĀ and similar operations): - SLOADĀ andĀ SSTORE - Contract code execution This EIP introduces a cleaner and simpler gas cost schedule that directly charges for accessing a subtree and accessing an element within the subtree. For (1) and (2), this EIP does not greatly change costs and is largely a simplification, asĀ EIP 2929Ā already raised gas costs for those operations to a sufficiently high level. For (3), however, it does add substantial gas cost increases, as contract code access is not properly charged for without this EIP.

ā€£
Could these gas cost changes break some fundamental assumptions for dapps/L2s/etc?

That might be the case, yes. See list of ā€œOpen Questionsā€ in the Dashboard below. Help is appreciated!

ā€£
What are stateless clients?

Today, to validate the chain, you need to have a fully synced node containing all the state. This is needed since, currently, blocks donā€™t have all the required state to execute that block due to the cost of generating a witness using the current Merkle Patricia Trie.

With Verkle Trees EIP, blocks can be self-contained execution units that allow them to be verified without requiring any extra information, in particular, the full state of the chain.

ā€£
When will Verkle Trees be available on mainnet?

Thereā€™s currently no defined date, but targeting sometime in 2024

ā€£
Regarding the Overlay Tree migration, how many key-values are migrated per block?

This number is still undecided since itā€™s mostly a balance between overall migration duration speed (good!) and rising the bar of hardware requirements for following validators (bad!). See the ā€œOpen Questionsā€ section of the Dashboard below.

3 Dashboard

Updated: Apr 08, 2024

All progress is shared in the Verkle Implementers Calls, which anyone can join.

ā€£

Current main tasks

Verkle Snap sync testing on Kaustinen
Refine EIP-4762 spec
Polish EIP-2935 proposal to be included in Pectra
ā€£

Upcoming tasks

Include the Overlay Tree migration logic in the spec
Analyze the impact of gas accounting in main contracts in mainnet

ā€£

Future milestones

More CL and EL clients joining testnet
CL & EL passing spec tests
Resume the pre-images distribution previous discussion to decide on a strategy
Shadow forks:
Testnet shadow forks
Mainnet shadow forks
Corresponding analysis (e.g: migration times, witness size, etc)
ā€£

Open questions

ā€£
Preimage generation and distribution strategy?

The overlay tree migration strategy requires the nodes to have the preimages for all the states in the MPT since we need to re-key them to the VKT.

If you want to understand more about the problem, see this document.

ā€£
What are witness and block size estimates post Verkle EIP?

As we create shadow forks, we can have more up-to-date information. But weā€™ll have a reasonable estimate when activating witness/proofs in our benchmarks, so we can indirectly have a sense of this sooner than shadow forks.

ā€£
Backward compatibility impact on the ecosystem?
  1. How does this affect L2s?
  2. How does this affect dev tools?
  3. How does this affect most used contracts/dapps?

From Vitalikā€™s writeup here

The three main backward-compatibility-breaking changes are:

  1. SELFDESTRUCT neutering (see here for a document stating the case for doing this despite the backward compatibility loss)
  2. Gas costs for code chunk access make some applications less economically viable.
  3. Tree structure change makes in-EVM proofs of historical state no longer work

(2) can be mitigated by increasing the gas limit at the same time as implementing this EIP, reducing the risk that applications will no longer work due to transaction gas usage rising above the block gas limit. (3) cannot be mitigated this time, but this proposal could be implemented to make this no longer a concern for any tree structure changes in the future.

ā€£
Testing

Apart from EL+CL joining devnets and shadow forks, it will be helpful to have some set of spec tests that all clients can run to have quick feedback about correctness. This EIP has many changes in data structures and gas model, which might have many border cases hard to test in test networks.

Tests for:

Consensus (e.g block format changes)
Execution
Data structure (Verkle Tree)?
Proofs?
New gas accounting?
Tests for migration phase?

This is just a braindump and requires more thinking on how to organize.

ā€£
How do reorgs impact clients?

Chain reorgs open some set of questions that we should explore and maybe document further:

  • How does a deep reorg impact low-setup nodes when catching up to the tip again?
  • Despite it might have a simple answer, should we document any consideration of reorgs during the migration phase?

ā€£
Impact on APIs

How does Verkle Trees impact on existing APIs (i.e: JSON-RPC), for example:

  • APIs related to proof generation.
  • Any consideration for the migration phase?
ā€£
Minimal hardware setup support + final migrated # key-values per block?

The Verkle Trees EIP has two main overheads:

  • It uses more complex cryptography, which will use more CPU on EL clients. This is independent of the migration phase or strategy.
  • The overlay migration period has the extra load (IO + CPU) of migrating state from MPT to VKT apart from usual block execution duties.
  • Producing and validation blocks have different CPU overheads, mainly regarding proof generation vs validation.

A natural question is whether this overhead will make some existing viable hardware setups enviable. We should separate this into more precise phases:

  1. During the migration phase:
    1. Creating blocks.
    2. Validating blocks.
  2. After the migration phase:
    1. Creating blocks.
    2. Validating blocks.

For now, validating blocks during and after the migration phase shouldnā€™t be a big problem for lower hardware setups (e.g: Rock5B). Generating blocks during the migration phase needs more research, especially during the migration phase, where the worst-case scenario might be. We should remember that the migration phase will have a limited timespan.

Finally, most of our benchmarks today arenā€™t accounting for 4844 overhead, which isnā€™t negligible. We have no historical chain to use in benchmarks, nor have we tried any draft version of clients supporting 4844 with some generated ā€œhigh loadā€ chain to understand things. It will be somewhat hard to be 100% sure about the reality of performance or low-power setups until 4844 is close or fully deployed to mainnet.

Verkle Implementers Call

Completed tasks

4Ā Ā Testnets

Updated: Apr 08, 2024

Kaustinen

icon
https://kaustinen-testnet.ethpandaops.io/
  • Updated EIP-4762 implementations
  • Updated EIP-2935 with a ring buffer of size 8192

See the following tutorial to know how to join the testnet.

5Ā Ā Resources

Updated: Apr 04, 2024

šŸ’¬Ā Join the Eth R&D discord server (#verkle-trie-migration)

šŸ§  Bringing Verkle into Ethereum involves many changes in the protocol:

  • A new data structure to save the state of the network
  • A new gas accounting model
  • A strategy to migrate the existing state from the MPT to the VKT
  • A new set of cryptography primitives
  • New fields at the block level

6Ā  Client Implementations

Updated: Apr 04, 2024

Updates shared in Verkle Implementers Callsā€¦

Latest summary here

Cryptography and other

EL Status

Client
Implementation
Testnet
Besu
WIP
šŸ”§ In progress
Erigon
WIP
EthJS
WIP
āœ… Kaustinen
Geth
WIP
āœ… Kaustinen
Nethermind
WIP
āœ… Kaustinen
Reth
ā€”

CL Status

Client
Implementation
Testnet
Lighthouse
WIP
āœ… Kaustinen
Lodestar
WIP
āœ… Kaustinen
Nimbus
WIP
šŸ”§ In progress
Prysm
ā€”
Teku
ā€”

šŸ’»
Client Updates (old)