HomeEtherumUnveiling "The 1.x Files": The Current Status of Stateless Ethereum

Unveiling “The 1.x Files”: The Current Status of Stateless Ethereum

Published on

In the previous edition of The 1.x files, we provided a brief overview of the Eth 1.x research initiative, its importance, and potential solutions. We introduced the concept of stateless ethereum and saved a more detailed examination of the stateless client for this post. Stateless is the new direction of Eth 1.x research, and in this article, we will delve into the challenges and possibilities that lie ahead. For those looking for more in-depth information, we will provide links to additional resources whenever possible.

Understanding the Current State of Ethereum

To understand where we are headed, we must first comprehend the concept of “state”. In this context, state refers to the “state of affairs” within Ethereum. The complete state of Ethereum encompasses the current status of all accounts and balances, as well as the collective memory of all deployed and running smart contracts in the EVM. Each finalized block in the chain represents one and only one state that is agreed upon by all participants in the network. This state is modified and updated with the addition of each new block.

It is essential for Eth 1.x research to not only understand what state is but also how it is represented in both the protocol (as defined in the yellow paper) and most client implementations (e.g., geth, parity, trinity, besu, etc.). The data structure used in Ethereum is called a Merkle-Patricia Trie. Interestingly, “Trie” is derived from the word “retrieval,” but it is generally pronounced as “try” to differentiate it from “tree.” In this article, we will explore the key aspects of Merkle-Patricia Tries:

1. Value Nodes: These nodes contain specific data that represents the state, such as an account’s balance or a variable stored in a smart contract (e.g., the total supply of an ERC-20 token).

2. Branch Nodes: These nodes connect the value nodes together through hashing. A branch node is an array that holds hashes of its child nodes, and each branch node is hashed and placed in the array of its parent node. This process continues until a single state root node is reached on the other end of the trie.

The simplified diagram above illustrates each value and the path required to reach it. For instance, to reach V-2, we follow the path 1,3,3,4. Similarly, V-3 can be accessed by following the path 3,2,3,3. It is important to note that paths in this example are always 4 characters long, and often there is only one possible path to reach a value.

This structure possesses the crucial properties of being deterministic and cryptographically verifiable. Generating a state root is only possible by computing it from each individual piece of the state, and any attempt to modify the state with different values will result in a different state root hash. Two identical states can be easily proven by comparing the root hash and the hashes that led to it (a Merkle proof). It is impossible to create two different states with the same root hash. Ethereum optimizes the trie structure by introducing extension nodes and leaf nodes, which improve efficiency. These nodes encode parts of the path into the trie, making it more compact. However, this trie structure, while seemingly efficient, is not optimal, as we will explore in the next section.

To access a specific part of the state (e.g., an account’s balance of Ether), one must start at the state root and traverse the trie from node to node until the desired value is reached. At each node, characters in the path are used to determine the next node to visit. The real version used in Ethereum employs the hashes of addresses (64 characters/256 bits long) for paths and RLP-encoded data for values. Branch nodes are arrays with 17 elements (sixteen for hexadecimal characters and one for a value), while leaf and extension nodes have 2 elements (one partial path and either a value or the hash of the next child node). Those interested in learning more can read the Ethereum wiki or explore this article, which offers a DIY trie exercise in Python.

Storage in the Database

It is important to understand that the trie structure is an abstract concept used to pack the entirety of Ethereum state into a unified structure. This structure must then be implemented in client code and stored in a database, which typically only understands [key, value] pairs. In most Ethereum clients (except turbo-geth), the Merkle-Patricia Trie is implemented by creating a unique [key, value] pair for each node. The node itself becomes the value, while its hash serves as the key. The process of traversing the trie remains similar to the theoretical process described earlier. To retrieve an account balance, one would begin with the root hash and look up its value in the database to obtain the first branch node. Using the first character of the hashed address, we find the hash of the next node. This process continues until we reach our desired account and retrieve its balance from the database. Computing the hash of each new block follows a similar process in reverse. Starting with all the edge nodes (accounts), the trie is built through successive hashings until a new root hash is generated and compared to the last agreed-upon block in the chain.

This is where the apparent efficiency of the state trie becomes relevant. Rebuilding the entire trie exerts great demands on disk resources, and the modified Merkle-Patricia trie structure used by Ethereum is more protocol efficient but less implementation efficient. The introduction of additional node types, such as leaf and extension nodes, helps reduce the memory required to store the trie. However, they make the algorithms responsible for modifying the state within the regular database more complex. While a sufficiently powerful computer can perform this process quickly, sheer processing power has its limitations.

Keeping the Network in Sync

Thus far, our focus has been on the processes occurring within an individual computer running an Ethereum implementation like geth. However, Ethereum is a network, and the ultimate aim is to maintain a consistent state across thousands of computers worldwide and different protocol implementations. The dynamic nature of Ethereum, with rapidly changing states arising from activities such as #Defi transactions, cryptokitty auctions, and ETH transfers, poses challenges to Ethereum clients in staying synchronized. Synchronization becomes increasingly challenging as Ethereum grows in popularity and the state trie becomes more extensive.

One implementation, turbo-geth, directly addresses this challenge. It flattens the trie database and uses the path of a node, rather than its hash, as the [key, value] pair. This effectively

Latest articles

Analyst Suggests Ethereum Price Could Surge to $3,100 with Bullish Momentum

Ethereum (ETH), the second-largest cryptocurrency, has seen a significant price increase over the past...

Cboe Digital Announces Plan to Introduce Margin Futures Trading for Bitcoin and Ethereum by 2024

On Nov. 13, Cboe Digital announced that it will soon launch trading and clearing...

Top Trader Predicts Significant Price Increases for Sushi and Apecoin – Check Out His Projections

A crypto strategist says more rallies are up ahead for prominent decentralized exchange (DEX)...

What is the difference between NVMe and M.2?

`` Over the last decade, solid-state drives (SSDs) have become the top choice for many...

More like this

Analyst Suggests Ethereum Price Could Surge to $3,100 with Bullish Momentum

Ethereum (ETH), the second-largest cryptocurrency, has seen a significant price increase over the past...

Cboe Digital Announces Plan to Introduce Margin Futures Trading for Bitcoin and Ethereum by 2024

On Nov. 13, Cboe Digital announced that it will soon launch trading and clearing...

Top Trader Predicts Significant Price Increases for Sushi and Apecoin – Check Out His Projections

A crypto strategist says more rallies are up ahead for prominent decentralized exchange (DEX)...
bitcoin
Bitcoin (BTC) $ 51,060.68 0.01%
ethereum
Ethereum (ETH) $ 2,959.26 0.62%
tether
Tether (USDT) $ 0.999636 0.19%
bnb
BNB (BNB) $ 379.87 0.88%
solana
Solana (SOL) $ 102.13 0.12%
xrp
XRP (XRP) $ 0.541942 0.89%
staked-ether
Lido Staked Ether (STETH) $ 2,958.07 0.65%
usd-coin
USDC (USDC) $ 0.999892 0.21%
cardano
Cardano (ADA) $ 0.584959 0.13%
avalanche-2
Avalanche (AVAX) $ 36.30 0.46%