|
| 1 | +**Statelessness** is a concept that could be applied in many other fields, not only in Ethereum. |
| 2 | + |
| 3 | +## Idea of statelessness |
| 4 | + |
| 5 | +The idea of statelessness comes from an **unresolved problem** caused by the **continuous growth** of the Ethereum state. |
| 6 | +If we want Ethereum to stay **decentralized**, we must not allow the state to **keep growing**, because that would mean that only **large clients** could **run it**, while **smaller ones** would **run out of disk space**. |
| 7 | + |
| 8 | +> If statelessness enables EL clients to run without storing the state on disk, |
| 9 | +> then they can be run on: |
| 10 | +> - a laptop, |
| 11 | +> - a phone, |
| 12 | +> - a Raspberry Pi, |
| 13 | +> - or even in a browser (theoretically). |
| 14 | +> |
| 15 | +> and decentralization is not compromised. |
| 16 | +
|
| 17 | + |
| 18 | +## Current state |
| 19 | + |
| 20 | +Currently, the state is stored in a **Merkle tree**, and only a **small portion** of the state is **read/written** in **each block**. |
| 21 | +However, in the current protocol, every client (validator or proposer) is still required to store the entire state locally. |
| 22 | + |
| 23 | +In a stateless design, there is no longer a need to download the entire Ethereum state, because all the required information is packaged inside the block. |
| 24 | + |
| 25 | +This is achieved by using **Verkle trees** and adding state data to the block, which makes it possible to **reconstruct enough of the tree view** to execute that block. |
| 26 | + |
| 27 | +- Verkle trees are designed to work in both ZK environments and non-ZK environments. |
| 28 | +- For now, they work with [**polynomial commitments**](/docs/wiki/research/stateless/stateless.md#polynomial-commitments-simplified), but when **ZK** becomes more **trusted**, we can switch to ZK proofs **without making major upgrades** to the protocol. |
| 29 | + |
| 30 | +---- |
| 31 | + |
| 32 | +First, let’s define how we look at **processing a block in a blockchain**. |
| 33 | + |
| 34 | +We can think of it as a **state transition function**, where: |
| 35 | +1. We get some previous state |
| 36 | +2. Then we process a block |
| 37 | +3. Then we get some new state |
| 38 | + |
| 39 | + |
| 40 | +- Original state transition function: ```stf(state, block) -> new_state``` |
| 41 | +- Stateless state transition function: ```stf'(state_root, block, witness) -> new_state_root``` |
| 42 | + |
| 43 | + > - witness = the portions of the state that are read and modified, along with the proofs |
| 44 | + > - Instead of the client holding a state, the client holds the state root |
| 45 | +
|
| 46 | +=> If we can efficiently prove the Ethereum state, we unlock entirely new possibilities for **scaling** and **decentralization**. |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +### Current pain points in client development |
| 51 | +- **I/O** - writing data to disk (main problem) |
| 52 | +- **Sync** - joining the network can take a day in the best case |
| 53 | + - re-executing everything from genesis can take 2–3 weeks |
| 54 | +- **Block production** |
| 55 | + > - parallelism will be useful |
| 56 | + > - once the I/O problem is solved, this becomes the next major area for improvement |
| 57 | +
|
| 58 | + |
| 59 | +#### Benefits of a stateless design: |
| 60 | +- Reduced validator hardware requirements: IO, disk space, and computation |
| 61 | +- Faster sync times (near-zero sync time), since a node does not need more than an EL block to join the network |
| 62 | +- More people can become validators -> stronger decentralization |
| 63 | +- The gas limit can be increased |
| 64 | +- Easy [**state expiry**](/docs/wiki/research/stateless/stateless.md#state-expiry) |
| 65 | +- Clients can validate blocks out of order |
| 66 | + |
| 67 | +#### With stateless design: |
| 68 | +- It becomes easier to build and implement new EL clients |
| 69 | +- We got zk-friendly L1 where we remove heavy use of non-zk-friendly hashes (i.e: [keccak256](/docs/wiki/Cryptography/keccak256.md)) |
| 70 | + |
| 71 | +But before statelessness, other roadmap items need to be completed first, such as [Verkle Trees](https://ethereum.org/roadmap/verkle-trees/) and [Proposer-builder separation](https://ethereum.org/roadmap/pbs/). |
| 72 | + |
| 73 | +## State expiry |
| 74 | + |
| 75 | +While statelessness removes the need for clients to store the full state, it does not address unbounded state growth on its own. |
| 76 | + |
| 77 | +However, with a stateless design, it becomes feasible to safely expire or deactivate unused state without harming network participants. |
| 78 | + |
| 79 | +When to expire: |
| 80 | +1. **Expire by rent** |
| 81 | + - Direct rent |
| 82 | + - Rent via time-to-live (TTL) |
| 83 | +2. **Expire by time** |
| 84 | + - Refresh by touching |
| 85 | + - Everything expires at regular intervals ([ReGenesis proposal](https://hackmd.io/@vbuterin/state_size_management?stext=8196%3A18%3A0%3A1768226177%3AVh_fUA)) |
| 86 | + |
| 87 | +**Refresh by touching** is beneficial because: |
| 88 | +- it avoids requiring applications to add complex economic mechanisms to pass state rent costs on to their users; |
| 89 | +- it ensures a clear hard bound on the active state size at all times: (`block_gas_limit / cost_to_touch_state_object * time_to_live_period`). |
| 90 | + |
| 91 | +**ReGenesis:** Having large amounts of state expire at regular discrete intervals (ie. ReGenesis) also has these benefits, and it has interesting tradeoffs |
| 92 | +- **key benefit** - easier expiry - no need to walk through the tree and expire things one by one |
| 93 | +- **key downside** - more variability in how much witness data needs to be provided depending on how far into an epoch you are |
| 94 | + |
| 95 | +---- |
| 96 | + |
| 97 | +# Levels of statelessness |
| 98 | + |
| 99 | +Statelessness can be implemented at different levels. |
| 100 | + |
| 101 | +These models differ in their trade-offs between implementation complexity, resource requirements, and decentralization guarantees. |
| 102 | + |
| 103 | +In practice, this leads to two main approaches: **weak statelessness** and **strong statelessness**. |
| 104 | + |
| 105 | +## Weak statelessness |
| 106 | +Only block producers need access to the full state. |
| 107 | +Other nodes can verify blocks without storing a local state database. |
| 108 | + |
| 109 | +In this model: |
| 110 | +- proposing a block is expensive |
| 111 | +- verifying a block is cheap |
| 112 | + |
| 113 | +=> This implies that fewer operators may choose to run block-proposing nodes. |
| 114 | + |
| 115 | +But **decentralization** of **block proposers** is **not critical** as long as as many participants as possible can independently **verify** that the blocks they propose are valid. |
| 116 | +> For more details: [Why is it ok to have expensive proposers](https://notes.ethereum.org/WUUUXBKWQXORxpFMlLWy-w#So-why-is-it-ok-to-have-expensive-proposers) |
| 117 | +
|
| 118 | +#### MEV considerations |
| 119 | + |
| 120 | +At first look, this model may seem problematic, as it appears to increase the advantage and profitability of large, well-resourced operators and companies, especially in the context of MEV extraction. And we cannot ignore that this model will certainly encourage [MEV](https://ethresear.ch/t/flashbots-frontrunning-the-mev-crisis/8251) extraction. |
| 121 | + |
| 122 | +However, this can be handled by Encrypted mempools ([intro video](https://www.youtube.com/watch?v=mUoWwRoHrvk)) - which prevent builders and proposers from knowing the contents of transactions until after the block is broadcast. |
| 123 | + |
| 124 | +Additionally, once [Proposer-Builder Separation (PBS)](https://ethereum.org/roadmap/pbs/#pbs-and-mev) is implemented, the block builders might have done sophisticated MEV extraction, but the reward for it goes to the block proposer. |
| 125 | +Since the proposer is randomly selected from the entire validator set for each slot, even if a small pool of specialized builders dominates MEV extraction, the reward for it could go to **any validator** on the network, including individual home stakers. |
| 126 | + |
| 127 | +#### Summary |
| 128 | + |
| 129 | +In weak statelessness: |
| 130 | +- block proposers use full state data to construct witnesses, |
| 131 | +- a witness is the minimal set of state data and proofs required to validate the state changes in a block, |
| 132 | +- other validators do not store the full state — they only store the state root (a hash of the entire state). |
| 133 | + |
| 134 | +Validators receive a block together with its witness and use them to update their state root. |
| 135 | +This makes validating nodes extremely lightweight. |
| 136 | + |
| 137 | +Weak statelessness is expected to be **sufficient for Ethereum’s scaling needs**. |
| 138 | + |
| 139 | +--- |
| 140 | +## Strong statelessness |
| 141 | + |
| 142 | +In strong statelessness, no nodes have access to the full state data. |
| 143 | + |
| 144 | +This would enable extremely lightweight nodes, but comes with trade-offs, including making interactions with smart contracts more difficult. |
| 145 | + |
| 146 | +Strong statelessness is **not currently expected** to be part of Ethereum’s roadmap. |
| 147 | + |
| 148 | +--- |
| 149 | + |
| 150 | +# Polynomial commitments (simplified) |
| 151 | +Polynomial commitments are a special kind of "**hash**" of a polynomial (where that hash has extra properties). |
| 152 | + |
| 153 | +One of the main extra properties is that: |
| 154 | +- If the prover has polynomial `P`, and a coordinate `z` |
| 155 | + - he can produce an opening proof `Q` that allows a verifier to check that `P(z) = a`. |
| 156 | + |
| 157 | +This lets us represent data as a polynomial and prove values. |
| 158 | + |
| 159 | +### Two main families of polynomial commitments |
| 160 | +1. **Kate** commitments |
| 161 | + - To prove that `P(z) = a`, we check that `(X - z)` is a factor of `P(x) - a` |
| 162 | + > in other words we prove it by proving that `P(x) - a` has `0` at `z` |
| 163 | + - This is done by providing a commitment to `Q(x) = (P(x) - a) / (X - z)` |
| 164 | + - The verifier can then check the equation: `Q(x) * (X - z) + a = P(x)`. |
| 165 | + > This proves that `P(x)` has the value `a` at `z`. |
| 166 | + - We can verify this equation with [elliptic curve pairing](https://medium.com/@VitalikButerin/exploring-elliptic-curve-pairings-c73c1864e627). |
| 167 | + |
| 168 | +2. **FRI** commitments |
| 169 | + - Is hash-based polynomial commitment scheme (**post quantum secure** and **potentially faster to prove**) |
| 170 | + - This is a different process where the polynomial is recursively split into **even** and **odd** parts and **combined randomly** at each step until a constant polynomial is obtained (or low enough degree polynomial which is easy for direct check/verify). |
| 171 | + |
| 172 | +### **Multi openings** |
| 173 | + |
| 174 | +Polynomial commitments are especially useful for multi-openings, i.e., proving multiple values of a polynomial at once |
| 175 | + |
| 176 | +Instead of proving `P(z1) = a1, P(z2) = a2, ...`, separately, we can subtract a polynomial (e.g. [Lagrange polynomial](https://en.wikipedia.org/wiki/Lagrange_polynomial)) that interpolates all desired points. |
| 177 | + |
| 178 | +This produces one proof (witness) that can verify all points at once. |
| 179 | + |
| 180 | +This is very valuable for stateless clients, because it allows them to verify a large number of values efficiently with minimal data. |
| 181 | + |
| 182 | +---- |
| 183 | + |
| 184 | +# Current challenges |
| 185 | +- Block verification must be fast. |
| 186 | +- State availability in wallets is still a question — a solution like the Portal Network could be useful. |
| 187 | +- In the current MPT, every value can be accessed via its key, where the key is a hash of the account address or storage slot. |
| 188 | +- Since we are changing the hash function, we need to rehash the entire state, which cannot be done in one slot and could take months to complete. |
| 189 | + - the conversion process is described here: [The Verge - Converting the Ethereum state to Verkle trees](https://www.youtube.com/watch?v=F1Ne19Vew6w) |
| 190 | +- All required EIPs for statelessness must be implemented before the transition. |
| 191 | + |
| 192 | +## Documentation |
| 193 | + |
| 194 | +- [Ethereum stateless book](https://stateless.fyi/) |
| 195 | +- [Statelessness, state expiry and history expiry](https://ethereum.org/roadmap/statelessness/) |
| 196 | +- [video: Stateless client witnesses by Vitalik Buterin)](https://www.youtube.com/watch?v=kbcj1TKXaN4) |
| 197 | +- [Why is it ok to have expensive proposers](https://notes.ethereum.org/WUUUXBKWQXORxpFMlLWy-w#So-why-is-it-ok-to-have-expensive-proposers) |
| 198 | +- [video: Anatomy of a stateless client by Guillaume Ballet](https://www.youtube.com/watch?v=yFJxVSbQNcI) |
| 199 | +- [video: The Verge - Converting the Ethereum state to Verkle trees by Guillaume Ballet](https://www.youtube.com/watch?v=F1Ne19Vew6w) |
| 200 | +- [A Theory of Ethereum State Size Management by Vitalik Buterin](https://hackmd.io/@vbuterin/state_size_management) |
| 201 | +- [The Stateless Client Concept by Vitalik Buterin](https://ethresear.ch/t/the-stateless-client-concept/172) |
| 202 | +- [Why it's so important to go stateless by Dankrad Feist](https://dankradfeist.de/ethereum/2021/02/14/why-stateless.html#:~:text=,blocks%20requires%20the%20full%20state) |
| 203 | +- [Verkle trees by Vitalik Buterin](https://vitalik.eth.limo/general/2021/06/18/verkle.html) |
| 204 | +- [presentation by EF Stateless consensus team](https://docs.google.com/presentation/d/1ObHPXLOGqEzCCQvF_aBg2l_RYiX_5wxKIaLZ0zPNScw/edit?slide=id.g2c6554f624f_0_50#slide=id.g2c6554f624f_0_50) |
| 205 | +- [What are polynomial commitments?](https://ethresear.ch/t/using-polynomial-commitments-to-replace-state-roots/7095#p-20182-what-are-polynomial-commitments-2) |
0 commit comments