33

This question was asked on Reddit a while ago:

Where is the state data actually stored though? On the hard drive of each node? Separate from or within the blockchain? Reddit: Basic Questions About the Ethereum EVM and State Storage

1
  • 1
    This article written by me provides a complete and clear answer to your question. As the explanation is detailed it's better to not to copy and paste so much content here. Commented Aug 5, 2018 at 6:38

3 Answers 3

34

Conceptually, there are 2 important components of an account-based blockchain:

  • transactions represent state transition functions
  • the result of these functions can be stored

A "full/archival" node might store all transactions and resulting state transitions for all block heights in a local data store. This would include all historical states, even those no longer valid. This allows clients to query the state of the blockchain at any time in the past without having to re-calculate everything from the beginning. This will likely require very large amounts of disk storage and because it is not strictly necessary, conceptually blockchain data can be separated:

  • chain data (the list of blocks forming the chain)
  • state data (the result of each transaction's state transition)

While all chain data will be needed to ensure the cryptographic chain-of-custody and that nothing has been tampered with, old state data can be discarded (known as "pruning"). This is because state data is implicit data. That is, its value is known only from calculation, not from the actual information communicated. By contrast, chain data is explicit and stored as the block chain itself.

So currently, while both chain and state data are stored locally on the node's disk, only the chain data is strictly necessary. State data is can be ephemeral.

4
  • Is it possible to query throught this state data? Commented Apr 13, 2016 at 15:01
  • 3
    Thanks for the answer. Can I ask you what exactly state means here? Does it include the result of the calculation (update) performed by a contract? For instance, when a contract keeps a balance and the balance may get updated by transactions, would the updated data be stored in the nodes local storage?
    – user153465
    Commented Aug 11, 2017 at 9:10
  • @HenriqueBarcelos medium.com/aigang-network/… does this suffice?
    – noooooooob
    Commented Dec 12, 2018 at 13:31
  • so where is contract storage?
    – f.khantsis
    Commented Sep 14, 2022 at 13:19
18

Technically the states are assembled into a state tree (patricia-tree) linked to the account (balance in case of EAOs and balance and storage in case of contract's account) and to the blocks (figures bellow). Physically the states are part of the blockchain so you could find them in the .ethereum folder (in a leveldb database) of each full node . For more detail,please visit this link .

enter image description here

enter image description here

3
6

Fusing nuggets of information from multiple sources (primarily, this and this):

  1. State data (together with account balances, contract code and account nonce) is stored by every Ethereum client (or Ethereum node)
  2. The Ethereum blockchain includes state roots (one per block) that store the root hash of the hash tree representing the system state at the time the block was generated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.