[Ethereum] state-trie pruning and how does it work

blockchainstate-trie-pruning

Several sources mention the idea of state-trie pruning. What is that, and is it currently being implemented on the network? Is this a manual process or can it be done automatically? If Ethereum is currently processing 1 GB per month under the current volume, and could grow with greater adoption, can state-trie pruning prevent the size of the ethereum blockchain from becoming unwieldy? Some sources seem concerned.

Best Answer

It is a similar concept to garbage collection in programming languages and in tree-based version control system like git. When ethereum contracts run, they modify their state. And since the state tree is an immutable append-only structure, it means that every time the state is modified, it gets a new state root. Some elements that were reachable from the old roots may be not be reachable from the new root (due to operations that delete or modify entries). Theoretically, they can be pruned (garbage collected). However, since the Proof-Of-Work consensus as it is does not define when state transitions are final, there is always a theoretical possibility that state will be reverted to older roots and things that were pruned would be needed again. So, pruning is currently a trade-off. We say, that, for example, after 5000 block we assume that the state won't be reverted and prune all unreachable nodes. Someone might still want to disable this feature to keep the entire history of the blockchain for special purposes.

Here is a very detailed description: https://blog.ethereum.org/2015/06/26/state-tree-pruning/

Related Topic