reth
reth copied to clipboard
Make DatabaseStorageProof stateful
trafficstars
Describe the feature
Right now DatabaseStorageProof has an associated TX type and takes &'a Self::TX on every method:
https://github.com/paradigmxyz/reth/blob/ca862ab9854080e6dfee98e8ef480fbd2a6d4887/crates/trie/db/src/proof.rs#L84-L104
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 [`StorageProof`] with operations specific for working with a database transaction.
pub trait DatabaseStorageProof {
/// Generates the storage proof for target slot based on [`TrieInput`].
fn overlay_storage_proof(
&self,
address: Address,
slot: B256,
storage: HashedStorage,
) -> Result<reth_trie::StorageProof, StateProofError>;
/// Generates the storage multiproof for target slots based on [`TrieInput`].
fn overlay_storage_multiproof(
&self,
address: Address,
slots: &[B256],
storage: HashedStorage,
) -> Result<StorageMultiProof, StateProofError>;
}
And the implementers can have a from_tx method on the struct itself
Additional context
No response