Follow-ups from PR review, bundled together because they are all
non-functional documentation and helper polish:
- Move accountDeletedMarkerKey to key_encoding.go alongside the
other leaf-key constants, and drop the stale "Keep this in sync"
directive. After this PR both GetAccount and DeleteAccount
reference the constant by name, so there is nothing left to
manually keep in sync.
- Replace the hard-coded "trie.go:219" line references in the
DeleteAccount doc and body comments with function-name references
("GetAccount's deletion-detection branch"). Line references rot
on any edit above the target line.
- Clarify what protects header storage from DeleteAccount: it shares
the same stem as BasicData/CodeHash, so the safety comes from
non-colliding offsets plus the nil-means-"do not overwrite"
semantics of StemNode.InsertValuesAtStem, not from living at a
different stem. Mirror the clarification in the
TestDeleteAccountDoesNotAffectMainStorage comment and
cross-reference the header-storage test.
- Rename newTestTrie to newEmptyTestTrie so readers can pick between
"empty" (this helper) and "pre-populated with entries" (makeTrie
in iterator_test.go) without guessing.
Binary tree hashing is quite slow, owing to many factors. One of them is
the GC pressure that is the consequence of allocating many hashers, as a
binary tree has 4x the size of an MPT. This PR introduces an
optimization that already exists for the MPT: keep a pool of hashers, in
order to reduce the amount of allocations.
The computation of `MAIN_STORAGE_OFFSET` was incorrect, causing the last
byte of the stem to be dropped. This means that there would be a
collision in the hash computation (at the preimage level, not a hash
collision of course) if two keys were only differing at byte 31.
Based on [EIP-7864](https://eips.ethereum.org/EIPS/eip-7864), the tree
index should be 32 bytes instead of 31 bytes.
```
def get_tree_key(address: Address32, tree_index: int, sub_index: int):
# Assumes STEM_SUBTREE_WIDTH = 256
return tree_hash(address + tree_index.to_bytes(32, "little"))[:31] + bytes(
[sub_index]
)
```
In order to reduce the amount of code that is embedded into the keeper
binary, I am removing all the verkle code that uses go-verkle and
go-ipa. This will be followed by further PRs that are more like stubs to
replace code when the keeper build is detected.
I'm keeping the binary tree of course. This means that you will still
see `isVerkle` variables all over the codebase, but they will be renamed
when code is touched (i.e. this is not an invitation for 30+ AI slop
PRs).
---------
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
This is broken off of #31730 to only focus on testing networks that
start with verkle at genesis.
The PR has seen a lot of work since its creation, and it now targets
creating and re-executing tests for a binary tree testnet without the
transition (so it starts at genesis). The transition tree has been moved
to its own package. It also replaces verkle with the binary tree for
this specific application.
---------
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
Implement the binary tree as specified in [eip-7864](https://eips.ethereum.org/EIPS/eip-7864).
This will gradually replace verkle trees in the codebase. This is only
running the tests and will not be executed in production, but will help
me rebase some of my work, so that it doesn't bitrot as much.
---------
Signed-off-by: Guillaume Ballet
Co-authored-by: Parithosh Jayanthi <parithosh.jayanthi@ethereum.org>
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>