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:
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:
- 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?
- 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?
- 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:
DATA_ROOT
|
/----------------------------------------\
/ \
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?