[v5] Statediff builder unit test for internalized leaf nodes #338
Closed
opened 2023-03-15 22:53:50 +00:00 by i-norden
·
8 comments
No Branch/Tag Specified
v1.11.6-statediff-v5
v1.10.26-statediff-4.2.2-alpha
jenkins_reborn
v1.10.25-statediff-v4
v1.10.25-statediff-v4-wip
cerc_refactor
release-v1.10.23-statediff-4.2.0-alpha
v1.10.23-statediff-v4
v1.10.23-statediff-v4-wip
v1.10.22-statediff-v4-wip
v1.10.22-statediff-v4
v1.10.21-statediff-v4
linter_updates_wip
release-v1.10-21-statediff-4.1.2-alpha
release-v1.10.21-statediff-4.1.2-alpha
v1.10.20-statediff-v4
v1.10.19-statediff-v4
statediff
v1.13.14
v1.11.6-statediff-v5.0.8
v1.10.23-statediff-4.2.0-alpha-cerc-unstable
v1.10.23-statediff-4.2.0-alpha-unstable
v1.10.25
v1.10.24
v1.10.23-statediff-4.2.0-alpha
v1.10.23-statediff-v4-unstable
v1.10.23
v1.10.22
v1.10.21-statediff-4.1.2-alpha
v1.10.21
v1.10.19-statediff-4.1.1-alpha
v1.10.20-statediff-4.1.0-alpha
v1.10.19-statediff-4.1.0-alpha
v1.10.20
v1.10.19-statediff-4.0.4-alpha
v1.10.19-statediff-4.0.3-alpha
v1.10.19-statediff-4.0.2-alpha
v1.10.19
v1.10.18-statediff-4.0.2-alpha
v1.10.18-statediff-3.2.2
v1.10.18-statediff-4.0.1-alpha
v1.10.18-statediff-3.2.1
v1.10.18
v1.10.17-statediff-4.0.1-alpha
v1.10.17-statediff-4.0.0-alpha
v1.10.17-statediff-3.2.1
v1.10.17-statediff-3.2.0
v1.10.17
v1.10.16-statediff-3.0.2
v3.0.2
v1.10.15-statediff-3.0.2
v1.10.16
v1.10.15-statediff-3.1.0
v1.10.15-statediff-3.0.1
v1.10.15-statediff-3.0.0
v1.10.11-statediff-3.0.0
v1.10.15-statediff-2.0.0
v1.10.15-statediff-0.0.29
v1.10.15
v1.10.11-statediff-0.1.0
v1.10.14-statediff-0.0.29
v1.10.14-statediff-0.0.28
v1.10.14
v1.10.13-statediff-0.0.29
v1.10.11-statediff-0.0.28a
v1.10.13-statediff-0.0.28
v1.10.12-statediff-0.0.28
v1.10.12-statediff-0.0.27
v1.10.11-statediff-0.0.27i
v1.10.11-statediff-0.0.27h
v1.10.11-statediff-0.0.27g
v1.10.11-statediff-0.0.27f
v1.10.11-statediff-0.0.27e
v1.10.13
v1.10.11-statediff-0.0.27d
v1.10.11-statediff-0.0.27c
v1.10.11-statediff-0.0.27b
v1.10.11-statediff-0.0.27a
v1.10.12
v1.10.11-statediff-0.0.27
v1.10.11
v1.10.10-statediff-0.0.27
v1.10.10
v1.10.9-statediff-0.0.27
v1.10.9
v1.10.8-statediff-0.0.27
v1.10.8-statediff-0.0.26
v1.10.8-statediff-0.0.25
v1.10.8
v1.10.7-statediff-0.0.25
v1.10.7
v1.10.6-statediff-0.0.25
v1.10.6
v1.10.5-statediff-0.0.25
v1.10.5
v1.10.4-statediff-0.0.25
v1.10.4-statediff-0.0.24
v1.10.3-statediff-0.0.24
v1.10.4-ir-0.0.1
v1.10.3-statediff-0.0.23
v1.10.4
v1.10.3-statediff-0.0.22
v1.10.3-statediff-0.0.21
v1.10.3
v1.10.2-statediff-0.0.21
v1.10.2-statediff-0.0.20
v1.10.2-statediff-0.0.19
v1.10.2-statediff-0.0.18
v1.10.2-statediff-0.0.17
v1.10.1-statediff-0.0.17
v1.10.2
v1.10.1-statediff-0.0.16
v1.10.1-statediff-0.0.15
v1.10.1
v1.10.0
v1.9.25-statediff-0.0.15
v1.9.25-statediff-0.0.14
v1.9.25-statediff-0.0.13
v1.9.25
v1.9.24-statediff-0.0.13
v1.9.24-statediff-0.0.12
v1.9.24-statediff-0.0.11
v1.9.23-statediff-0.0.11
v1.9.24
v1.9.23-statediff-0.0.10
v1.9.23-statediff-0.0.9
v1.9.11-statediff-0.0.9
v1.9.11-statediff-0.0.8
v1.9.23
v1.9.15-1559-0.0.1
v1.9.11-statediff-0.0.7
v1.9.10-optimism-0.0.2
v1.9.22
v1.9.21
v1.9.10-optimism-0.0.1
v1.9.11-statediff-0.0.6
v1.9.20
v1.9.11-statediff-0.0.5
v1.9.11-statediff-0.0.4
v1.9.11-statediff-0.0.3
v1.9.19
v1.9.18
v1.9.17
v1.9.16
v1.9.15
v1.9.11-statediff-0.0.2
v1.9.14
v1.9.13
v1.9.12
v1.10-alpha.2
v1.9.11
v1.9.10
v1.10-alpha.1
v1.9.9
v1.9.8
v1.9.7
v1.9.6
v1.9.5
v1.9.4
v1.9.3
v1.9.2
v1.10-alpha.0
v1.9.1
v1.9.0
v1.8.27
v1.8.26
v1.8.25
v1.8.24
v1.8.23
v1.8.22
v1.8.21
v1.8.20
v1.8.19
v1.8.18
v1.8.17
v1.8.16
v1.8.15
v1.8.14
v1.8.13
v1.8.12
v1.8.11
v1.8.10
v1.8.9
v1.8.8
v1.8.7
v1.8.6
v1.8.5
v1.8.4
v1.8.3
v1.8.2
v1.8.1
v1.8.0
v1.7.3
v1.7.2
v1.7.1
v1.7.0
v1.6.7
v1.6.6
v1.6.5
v1.6.4
v1.6.3
v1.6.2
v1.6.1
v1.6.0
v1.5.9
v1.5.8
v1.5.7
v1.5.6
v1.5.5
v1.5.4
v1.5.3
v1.5.2
v1.5.1
v1.5.0
v1.4.19
v1.4.18
v1.4.17
v1.4.16
v1.4.15
v1.4.14
v1.4.13
v1.4.12
v1.4.11
v1.4.10
v1.4.9
v1.4.8
v1.4.7
v1.4.6
v1.4.5
v1.4.4
v1.4.3
v1.4.2
v1.4.1
v1.4.0
v1.3.6
v1.3.5
v1.3.4
v1.3.3
v1.3.2
v1.3.1
v1.2.3
v1.2.2
1.2.1
v1.1.3
v1.0.5
v1.0.4
v1.1.2
v1.1.1
v1.0.3
v1.1.0
v1.0.2
v1.0.1.2
v1.0.1.1
v1.0.1
v1.0.0
v0.9.39
v0.9.38
v0.9.36
v0.9.34-1
v0.9.34
v0.9.32
v0.9.30
v0.9.28
v0.9.26
v0.9.25
v0.9.24
0.9.23
v0.9.23
v0.9.22
v0.9.21.1
v0.9.21
v0.9.20
v0.9.18
v0.9.17
0.9.16
v0.8.5-2
v0.8.5
v0.8.4
v0.8.4-1
v0.7.11
v0.7.10
vv0.7.10
v0.7.10-broken
PoC6
v0.6.8
v0.6.7
v0.6.6
v0.6.5-2
v0.6.5-1
v0.6.5
v0.6.4
v0.6.3
v0.6.0
0.5.19
0.5.18
0.5.17
0.5.16
0.5.15
0.5.14
0.5.13
poc5-rc12
poc5-rc11
2
poc5-rc10
poc5-rc9
poc5-rc8
poc5-rc7
poc5-rc6
poc5-rc4
poc5-rc3
poc5-rc2
poc5-rc1
0.3.1
0.3.0
0.2.2
poc1
Labels
Clear labels
bug
critical
duplicate
enhancement
epic
help wanted
in progress
invalid
low priority
question
rebase
v1
v5
wontfix
Copied from Github
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
An issue or PR manually copied from GitHub.
Breaking change that won't be backward compatible
Something is not working
Documentation changes
Improve existing functionality
New functionality
This is security issue
Issue or pull request related to testing
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
No labels
v5
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cerc-io/go-ethereum#338
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
A leaf node is internalized only if its length is <= 32 bytes. This is possible in the storage tries but not the state trie (state account object is always >32 bytes). A leaf node consists of two members: the partial path and the value stored by the leaf node. This means that just because a stored value is less than 32 bytes does not mean that the leaf node will be less than 32 bytes. This makes it more difficult to devise a simple
ChainMakertest chain to setup this scenario, because for shallow tries the partial path is long (the node's position in the trie is very close to the root, so the remaining partial path corresponding to the rest of the leaf key is long).We must store at least one byte in the leaf node, or else it is removed (or never inserted). So in practice what this means is we need to create a
ChainMakertest chain that has a branch node at least 4 hex steps down the trie (less than 4 hex steps means the partial path is still 61+ nibbles, meaning the remaining partial path is 31+ bytes; add 1 byte for the terminator flag and 1 byte for the value and we are greater than 32 bytes). This isn't that deep in the trie, but it is difficult to devise a set of transactions that will lead to a branch node that includes an internalized leaf node at the 4th level down in the trie with a minimal number of total nodes in the trie. It's important to try to keep that number minimal, because we have to write out the expected node objects manually to test against since there is no other code to produce these objects to validate against.I'm 99% sure we are supporting internalized leaf nodes correctly now but I can't verify that yet without this or another test.
Correction: we need a branch at the 6th level or lower, because there is an additional byte overhead when encoding a list as RLP bytes.
slot1: 0x000000000000000000000000000000000000000000000000000000000000142f
slot2: 0x0000000000000000000000000000000000000000000000000000000000003095
key1: 010a08010b0d0c0d050803050b090b070a0a0d0f03070e070d020e040e0f080c0409010d030a040403040b0707070f0c0e0b0d0900020304050b080f0a070b0d
key2: 010a08010b0d00020703030b050a040c0c040b0b060302070505010508050b060602050c06030c0008020d09000704030c0b0a05040e04020200070a0e070600
key1str: 0x1a81bdcd5835b9b7aadf37e7d2e4ef8c491d3a4434b777fcebd902345b8fa7bd
key2str: 0x1a81bd02733b5a4cc4bb6327551585b6625c63c082d90743cba54e42207ae760
This corresponds to slots 5167 and 12437
Wrong again, it needs to be less-than 32 bytes, not less-than-or-equal-to (Why? I don't know. If it is 32 bytes it is the same size as a hash so why wouldn't it minimize num of nodes in the trie/on disc by storing it directly?). I don't think this is accurately documented anywhere. This means we need a branch at the 8th level or below.
slot1: 0x0000000000000000000000000000000000000000000000000000000000009dac
slot2: 0x0000000000000000000000000000000000000000000000000000000000019c5e
key1: 0f0209010603010c0d0007070b0b0c0905010a00040502090d0e0f0c01050d0a080c00060e0402070c0d0e000d070a010409090c05000907050b0b0e080a0a0b
key2: 0f0209010603010c000c06020508060c01080b0f010e0c0f0d0a0106010c0e0d0307040b070a0809040603000e020d0b0402060801040c02040e050d04020a0f
key1str: 0xf291631cd077bbc951a04529defc15da8c06e427cde0d7a1499c50975bbe8aab
key2str: 0xf291631c0c62586c18bf1ecfda161ced374b7a894630e2db426814c24e5d42af
Intersect to 0f0209010603010c
Corresponding to slots 40364 and 105566
Now lets see if we can even deploy a contract with an array[105566]... might be higher than normal block gas limits, requiring it to be built up by pushing to a dynamic array over multiple blocks... which would make the unit test impossible to write (would have to manually write out a trie with 105566 leafs in it lol), defeating the purpose of this endeavor.
We can deploy it 🙏