1

For the block parameter of eth_getStorageAt call, we are given 4 options:

HEX String - an integer block number String "earliest" for the earliest/genesis block String "latest" - for the latest mined block String "pending" - for the pending state/transactions (https://github.com/ethereum/wiki/wiki/JSON-RPC#the-default-block-parameter)

How does Ethereum handle the case when the param is not 'latest'? In other words, how does it manage to retrieve the history storage?

3

The state of Ethereum is represented as a Patricia-Trie. It is called "Ethereum World State". The most recent root node is stored in each block header.

To answer a query at a given block the client needs to consult the "Ethereum World State" at that moment. For that it will read the root node from the block header and then it will use the Patricia-Trie that correspond to the root node.

Archive nodes will store all the Patricia-Tries and can answer any query.

  • So Ethereum world state can answer all questions like <stateRootAtBlockX, WorldStateAtBlockX> without needing to take additional snapshots.. – noooooooob Dec 13 '18 at 8:51
  • @noooooooob The Ethereum world state only contains information about all the balances and contracts at a single block. – Ismael Dec 13 '18 at 13:53
1

Ethereum full nodes, which provide the JSON RPC used to expose the Web3 APIs, download and store every block of the blockchain. Thus, it can also retrieve the state of the blockchain at any particular block.

  • Hi @Shawn Tabriz, thanks for your input. What I am trying to ask is how a Ethereum full nodes recover a previous storage snapshot. – noooooooob Dec 12 '18 at 7:32
  • I think those details are dependent on the implementation of the node software. Let's make up that it has a database, where there is a row which represents the full state of the blockchain for each block. Would that answer your question, or is there something more specific you are looking for? – Shawn Tabrizi Dec 12 '18 at 8:14
  • I was expecting something from the Ethereum spec or documentation about how we could recover a old world state given only a stateRoot. – noooooooob Dec 12 '18 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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