Skip to content

Make DatabaseProof trait stateful #15476

@Rjected

Description

@Rjected

Describe the feature

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

/// Extends [`Proof`] with operations specific for working with a database transaction.
pub trait DatabaseProof<'a, TX> {
/// Create a new [Proof] from database transaction.
fn from_tx(tx: &'a TX) -> Self;
/// Generates the state proof for target account based on [`TrieInput`].
fn overlay_account_proof(
tx: &'a TX,
input: TrieInput,
address: Address,
slots: &[B256],
) -> Result<AccountProof, StateProofError>;
/// Generates the state [`MultiProof`] for target hashed account and storage keys.
fn overlay_multiproof(
tx: &'a TX,
input: TrieInput,
targets: MultiProofTargets,
) -> Result<MultiProof, 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 [`Proof`] with operations specific for working with a database transaction. 
 pub trait DatabaseProof { 
     /// Generates the state proof for target account based on [`TrieInput`]. 
     fn overlay_account_proof( 
         &self, 
         input: TrieInput, 
         address: Address, 
         slots: &[B256], 
     ) -> Result<AccountProof, StateProofError>; 
  
     /// Generates the state [`MultiProof`] for target hashed account and storage keys. 
     fn overlay_multiproof( 
         &self, 
         input: TrieInput, 
         targets: MultiProofTargets, 
     ) -> Result<MultiProof, StateProofError>; 
 } 

And the implementers (like Proof etc) 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

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions