reth icon indicating copy to clipboard operation
reth copied to clipboard

Make DatabaseStorageProof stateful

Open Rjected opened this issue 8 months ago • 9 comments

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

Rjected avatar Apr 02 '25 22:04 Rjected

may i look into this?

Rimeeeeee avatar Apr 03 '25 06:04 Rimeeeeee

👋 are there anyone working on it? would love to take it

chungquantin avatar Apr 03 '25 12:04 chungquantin

👋 are there anyone working on it? would love to take it

currently working on something else.. u can take this :)

Rimeeeeee avatar Apr 03 '25 12:04 Rimeeeeee

Thanks man @Rimeeeeee

chungquantin avatar Apr 03 '25 13:04 chungquantin

@chungquantin assigned!

Rjected avatar Apr 03 '25 16:04 Rjected

@chungquantin are you still working on this?

jenpaff avatar Apr 15 '25 10:04 jenpaff

@chungquantin are you still working on this?

I'll push this done this week if it's ok. Apologies, was a bit packed with main work

chungquantin avatar Apr 16 '25 03:04 chungquantin

Can I take this one up if you are busy @chungquantin ?

18aaddy avatar Apr 19 '25 02:04 18aaddy

Can I take this one up if you are busy @chungquantin ?

assigned

jenpaff avatar Apr 19 '25 10:04 jenpaff