reth
reth copied to clipboard
Make DatabaseTrieWitness stateful
trafficstars
Describe the feature
Right now DatabaseTrieWitness has an associated TX type and takes &'a Self::TX on every method:
https://github.com/paradigmxyz/reth/blob/ca862ab9854080e6dfee98e8ef480fbd2a6d4887/crates/trie/db/src/witness.rs#L10-L21
This is not necessary, instead we can make this into a regular trait that is stateful and takes &self. For example it would look like:
/// Extends [`TrieWitness`] with operations specific for working with a database transaction.
pub trait DatabaseTrieWitness {
/// Generates trie witness for target state based on [`TrieInput`].
fn overlay_witness(
&self,
input: TrieInput,
target: HashedPostState,
) -> Result<B256Map<Bytes>, TrieWitnessError>;
}
And the implementers can have a from_tx method on the struct itself
Additional context
No response