offset trie improvments - #2496
Conversation
There was a problem hiding this comment.
Pull request overview
This PR cleans up RLP encoding paths in the offset-format witness trie by making “hash-as-RLP” handling explicit and reusable, reducing ad-hoc memcpy/encode patterns and improving type-safety around fixed-size hash RLP payloads.
Changes:
- Define
HASH_RLP_LENin terms ofKECCAK256_SIZEand introducehash_rlp_viewfor fixed-size RLP-encoded hashes. - Add
DigestView::hash_rlp()and update account leaf code-hash accessors to return a dedicated hash RLP view. - Centralize hash RLP encoding/copying via
OffsetTrie::encode_rlp(...)overloads and use them at call sites.
Verdict: CORRECT
Generated with Claude Code
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| category/execution/ethereum/db/offset_trie.hpp | Introduces hash_rlp_view, adds digest/hash RLP view helpers, and centralizes hash RLP emission via encode_rlp overloads. |
| category/execution/ethereum/db/offset_trie.cpp | Switches account-leaf encoding to use the new encode_rlp(l.code_hash_rlp(), ...) helper instead of manual memcpy. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Clean, semantically-equivalent refactor: hash_rlp_view encodes the fixed 33-byte RLP-hash extent in the type, DigestView::hash_rlp() leans on the DIGEST == 0x80 + KECCAK256_SIZE invariant (guarded by the existing static_assert), and the two new OffsetTrie::encode_rlp overloads collapse three ad-hoc memcpy/shrink sites into one call. One P3 nit inline about an adjacent open-coded storage_root write in AccountLeafView encoding that the same helper could take over.
Verdict: CORRECT
🤖 Generated with Claude Code
c176f08 to
a7b72bc
Compare
a7b72bc to
2ea99fa
Compare
babfad7 to
e5b92a8
Compare
30b3103 to
a46eaa3
Compare
e5b92a8 to
073157e
Compare
a46eaa3 to
1a72784
Compare
073157e to
0d6d7ff
Compare
1a72784 to
9cdadf2
Compare
0d6d7ff to
57abbae
Compare
9cdadf2 to
d5cde85
Compare
57abbae to
f07ffab
Compare
d5cde85 to
af52b41
Compare
1593c6d to
ceb0ebc
Compare
- constructor validates the data forms a tree, i.e. each child has exactly one parent and no nodes are unreachable - Bound path length at MAX_PATH_NIBBLES as the decoder assumes the encoding is always a short string - Rework checked_end onto offsets, fixing an out-of-bounds read - hashes_ insert is now guarded on the RLP length, enforcing the invariant that only hash-referenced nodes get cached in the map Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ceb0ebc to
b7056a6
Compare
offset trie fixes/improvements:
exactly one parent and no nodes are unreachable
encoding is always a short string
invariant that only hash-referenced nodes get cached in the map