diff --git a/crates/trie/common/src/proofs.rs b/crates/trie/common/src/proofs.rs index 5a8be0fb19c12..8aca67f8d1ad3 100644 --- a/crates/trie/common/src/proofs.rs +++ b/crates/trie/common/src/proofs.rs @@ -214,6 +214,12 @@ impl StorageProof { Self { key, nibbles, ..Default::default() } } + /// Set proof nodes on storage proof. + pub fn with_proof(mut self, proof: Vec) -> Self { + self.proof = proof; + self + } + /// Verify the proof against the provided storage root. pub fn verify(&self, root: B256) -> Result<(), ProofVerificationError> { let expected = diff --git a/crates/trie/db/tests/proof.rs b/crates/trie/db/tests/proof.rs index 33a19de38037c..5ffa6729b49a8 100644 --- a/crates/trie/db/tests/proof.rs +++ b/crates/trie/db/tests/proof.rs @@ -1,6 +1,7 @@ #![allow(missing_docs)] use alloy_primitives::{keccak256, Address, Bytes, B256, U256}; +use alloy_rlp::EMPTY_STRING_CODE; use reth_chainspec::{Chain, ChainSpec, HOLESKY, MAINNET}; use reth_primitives::{constants::EMPTY_ROOT_HASH, Account}; use reth_provider::test_utils::{create_test_provider_factory, insert_genesis}; @@ -111,7 +112,10 @@ fn testspec_empty_storage_proof() { assert_eq!(slots.len(), account_proof.storage_proofs.len()); for (idx, slot) in slots.into_iter().enumerate() { let proof = account_proof.storage_proofs.get(idx).unwrap(); - assert_eq!(proof, &StorageProof::new(slot)); + assert_eq!( + proof, + &StorageProof::new(slot).with_proof(vec![Bytes::from([EMPTY_STRING_CODE])]) + ); assert_eq!(proof.verify(account_proof.storage_root), Ok(())); } assert_eq!(account_proof.verify(root), Ok(()));