feat(trie): create "updatable" trie representation #11167
Labels
A-trie
Related to Merkle Patricia Trie implementation
C-enhancement
New feature or request
M-prevent-stale
Prevents old inactive issues/PRs from being closed due to inactivity
Description
Subtrie, sparse trie, multiproof - these are the terms commonly used to describe parts of the trie that have been touched and/or updated following the state transition. Currently, the closest representation for desired feature is the
MultiProof
struct. However, we do not have a good way to reveal or update the paths inside this struct.Tasks
reth-trie-sparse
crate #11707SparseTrie::update_rlp_node_level
behavior #11805update_rlp_node_level
#11806SparseTrie::update_rlp_node_level
#12012Requirements
Requirements for the implementation:
TrieUpdates
equivalent toStateRoot
structConsiderations
Hash-Based Subtrie
The "updatable" trie can be represented similarly to the state field of the
ExecutionWitness
.The
update
function for the subtrie could be implemented using the following algorithm:self.nodes
by their hash (including the previous leaf at key if present) and retain the in-memory as a stack ([root, ..., parent, leaf?]
)self.nodes
one by onePath-Based Subtrie
This implementation can have inner representation similar to the
MultiProof
.Note
We avoid
BTreeMap
at all costs due to performance implications as the collection grows large.Then the
update
function could be implemented using the following algorithm:Relevant Links
struct MultiProof
reth/crates/trie/common/src/proofs.rs
Lines 15 to 24 in f2082e0
The text was updated successfully, but these errors were encountered: