I'm aware that ethereum has essentially 3 tree-like structures:

  • State data
  • Receipts data
  • Chain data

As I've just learned from this question, contract storage resides on state data tree.

Digging around, I've found the image bellow:

Blockchain state trie

If the image above is correct, only the changes in state are taken in account to create the state root of each block.

Here are the questions:

  1. If I only associate the changes with the block, in order to get the full state of ethereum, do I have to assemble it by following the state trie until there is no pointers to older nodes [in the tree]? Or the nodes [in the network] keep an updated database with only the current state?
  2. How exactly does one node under the state tree reference another? I'm sure there is a "pointer" within the node structure, but how is it possible to know which node it references?
  3. Thinking about smart contract storage, how is the data arranged?

About 3., I know that every variable within a contract has an unique ID, therefore, it's possible to create a node with a structure like <varID, value> and organize something like:

                   /                                          \
              H(H1 + H2)                                 H(H3 + H4)
                   |                                          |
          /-----------------\                        /-----------------\
         /                   \                      /                   \
H(<varID1, value1>)  H(<varID2, value2>)  H(<varID3, value3>)  H(<varID4, value4>)

Which leads to question 3.1:

3.1. Is this tree/trie full structure in the state tree under the node that identifies the contract account that owns this data?

  • There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs. – niksmac Apr 15 '16 at 2:24
  • In addition to what Nik said, it is preferred if you can post separate questions instead of combining your questions into one. That way, it helps the people answering your question and also others hunting for at least one of your questions. Thanks! – Afr Apr 15 '16 at 8:51
  • Agreed. Question 1 is here: ethereum.stackexchange.com/questions/3056/… – Henrique Barcelos Apr 15 '16 at 21:03