Skip to content

Make DatabaseStorageProof stateful #15477

@Rjected

Description

@Rjected

Describe the feature

Right now DatabaseStorageProof has an associated TX type and takes &'a Self::TX on every method:

/// Extends [`StorageProof`] with operations specific for working with a database transaction.
pub trait DatabaseStorageProof<'a, TX> {
/// Create a new [`StorageProof`] from database transaction and account address.
fn from_tx(tx: &'a TX, address: Address) -> Self;
/// Generates the storage proof for target slot based on [`TrieInput`].
fn overlay_storage_proof(
tx: &'a TX,
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(
tx: &'a TX,
address: Address,
slots: &[B256],
storage: HashedStorage,
) -> Result<StorageMultiProof, StateProofError>;
}

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

Metadata

Metadata

Assignees

Labels

A-dbRelated to the databaseA-trieRelated to Merkle Patricia Trie implementationC-enhancementNew feature or requestD-good-first-issueNice and easy! A great choice to get started

Type

No type

Projects

Status

Next Up

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions