You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By root here one means the Merkle root of the smart contract storage, organised into a tree. Non-contract accounts cannot have storage,
41
41
therefore root makes sense only for smart contract accounts. For non-contract accounts, the root field is assumed to be equal to the
42
42
Merkle root of an empty tree, which is hard-coded in the variable `EmptyRoot` in
43
-
[trie/trie.go](../../trie/trie.go). For contract accounts, the root is computed using member function `Hash` of
44
-
type `Trie`[trie/trie.go](../../trie/trie.go), once the storage of the contract has been organised into the tree by calling member functions
43
+
[turbo/trie/trie.go](../../turbo/trie/trie.go). For contract accounts, the root is computed using member function `Hash` of
44
+
type `Trie`[turbo/trie/trie.go](../../turbo/trie/trie.go), once the storage of the contract has been organised into the tree by calling member functions
45
45
`Update` and `Delete` on the same type.
46
46
47
47
#### Code hash
@@ -112,22 +112,22 @@ Merkle Patricia tree hashing rules first remove redundant parts of each key with
112
112
pairs so-called "leaf nodes". To produce the hash of a leaf node, one applies the hash function to the two-piece RLP (Recursive Length Prefix).
113
113
The first piece is the representation of the non-redundant part of the key. And the second piece is the
114
114
representation of the leaf value corresponding to the key, as shown in the member function `hashChildren` of the
115
-
type `hasher`[trie/hasher.go](../../trie/hasher.go), under the `*shortNode` case.
115
+
type `hasher`[turbo/trie/hasher.go](../../turbo/trie/hasher.go), under the `*shortNode` case.
116
116
117
117
Hashes of the elements within a prefix group are combined into so-called "branch nodes". They correspond to the
118
-
types `duoNode` (for prefix groups with exactly two elements) and `fullNode` in the file [trie/node.go](../../trie/node.go).
118
+
types `duoNode` (for prefix groups with exactly two elements) and `fullNode` in the file [turbo/trie/node.go](../../turbo/trie/node.go).
119
119
To produce the hash of a branch node, one represents it as an array of 17 elements (17-th element is for the attached leaf,
120
120
if exists).
121
121
The positions in the array that do not have corresponding elements in the prefix group are filled with empty strings. This is
122
-
shown in the member function `hashChildren` of the type `hasher`[trie/hasher.go](../../trie/hasher.go), under the `*duoNode` and
122
+
shown in the member function `hashChildren` of the type `hasher`[turbo/trie/hasher.go](../../turbo/trie/hasher.go), under the `*duoNode` and
123
123
`*fullNode` cases.
124
124
125
125
Sometimes, nested prefix groups have longer prefixes than 1-digit extension of their encompassing prefix group, as it is the case
126
126
in the group of items `12, 13` or in the group of items `29, 30, 31`. Such cases give rise to so-called "extension nodes".
127
127
However, the value in an extension node is always the representation of a prefix group, rather than a leaf. To produce the hash of an extension node,
128
128
one applies the hash function to the two-piece RLP. The first piece is the representation of the non-redundant part of the key.
129
129
The second part is the hash of the branch node representing the prefix group. This shown in the member function `hashChildren` of the
130
-
type `hasher`[trie/hasher.go](../../trie/hasher.go), under the `*shortNode` case.
130
+
type `hasher`[turbo/trie/hasher.go](../../turbo/trie/hasher.go), under the `*shortNode` case.
131
131
132
132
This is the illustration of resulting leaf nodes, branch nodes, and extension nodes for our example:
133
133
@@ -255,7 +255,7 @@ HASH 1
255
255
BRANCH 0123
256
256
```
257
257
258
-
These opcodes are implemented by the type `HashBuilder` (implements the interface `structInfoReceiver`) in [trie/hashbuilder.go](../../trie/hashbuilder.go)
258
+
These opcodes are implemented by the type `HashBuilder` (implements the interface `structInfoReceiver`) in [turbo/trie/hashbuilder.go](../../turbo/trie/hashbuilder.go)
259
259
260
260
### Multiproofs
261
261
@@ -385,7 +385,7 @@ In the deeper recursive step, max common prefix is empty. Since the common prefi
385
385
the common prefix with the succeeding key (they are both empty). The optional part of the step happens, opcode `BRANCH 0123`
386
386
is emitted, and `groups` is trimmed to become empty. No recursive invocation follows.
387
387
388
-
The step of this algorithm is implemented by the function `GenStructStep` in [trie/gen_struct_step.go](../../trie/gen_struct_step.go).
388
+
The step of this algorithm is implemented by the function `GenStructStep` in [turbo/trie/gen_struct_step.go](../../turbo/trie/gen_struct_step.go).
389
389
390
390
### Converting sequence of keys and value into a multiproof
391
391
@@ -407,7 +407,7 @@ However, in order to make these choices efficiently, the set of keys being resol
407
407
list. Then, at each point when the algorithm processes a key, it maintains references to two consecutive keys from
408
408
that sorted list - one "LTE" (Less Than or Equal to the currently processed key), and another "GT" (Greater Than the
409
409
currently processed key). If max common prefix is also prefix of either LTE or GT, then `BRANCH` opcode is emitted,
410
-
otherwise, `BRANCHHASH` opcode is emitted. This is implemented by the type `ResolveSet` in [trie/resolve_set.go](../../trie/resolve_set.go)
410
+
otherwise, `BRANCHHASH` opcode is emitted. This is implemented by the type `ResolveSet` in [turbo/trie/resolve_set.go](../../turbo/trie/resolve_set.go)
411
411
412
412
### Extension of the structure to support contracts with contract storage
413
413
When it is required to construct tries containing accounts as well as contract storage, and contract code, the
@@ -501,7 +501,7 @@ Then delete this account (SELFDESTRUCT).
501
501
will not process any incoming block that time. To protect against this attack:
502
502
PlainState, HashedState and IntermediateTrieHash buckets have "incarnations". Account entity has field "Incarnation" -
503
503
just a digit which increasing each SELFDESTRUCT or CREATE2 opcodes. Storage key formed by:
504
-
`{account_key}{incarnation}{storage_hash}`. And [trie/trie_root.go](../../trie/trie_root.go) has logic - every time
504
+
`{account_key}{incarnation}{storage_hash}`. And [turbo/trie/trie_root.go](../../turbo/trie/trie_root.go) has logic - every time
505
505
when Account visited - we save it to `accAddrHashWithInc` variable and skip any Storage or IntermediateTrieHashes with another incarnation.
0 commit comments