Invert provider access in SparseTrie #14646
Labels
A-db
Related to the database
A-trie
Related to Merkle Patricia Trie implementation
C-enhancement
New feature or request
Right now the
SparseTrie
takes ownership over a provider, this is used only in reveal / update methods:reth/crates/trie/sparse/src/trie.rs
Lines 177 to 178 in 2101ae8
This is what causes our issues when we try to operate over many storage tries in parallel, the provider under the hood is a tx which gets shared.
This is used in two places:
reth/crates/trie/sparse/src/trie.rs
Line 1122 in 2101ae8
reth/crates/trie/sparse/src/trie.rs
Line 1285 in 2101ae8
Owning the provider is partially for type safety, so that we can give a
BlindedProviderFactory
to theSparseStateTrie
, and have it make sure storage tries are operating over storage tables, but this means we do not have control over where / when database txs are created. If we really needed this type safety, we could probably solve it with some phantomdatas?We could instead invert provider access, requiring these methods to take in a provider as an argument.
The text was updated successfully, but these errors were encountered: