feat : add storage_root provider function for account (#9659)

Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
This commit is contained in:
nk_ysg
2024-08-02 15:19:12 +08:00
committed by GitHub
parent db2ece8d08
commit 44028076ff
15 changed files with 202 additions and 27 deletions

View File

@ -673,7 +673,7 @@ mod tests {
use reth_storage_api::{
AccountReader, BlockHashReader, StateProofProvider, StateProvider, StateRootProvider,
};
use reth_trie::AccountProof;
use reth_trie::{AccountProof, HashedStorage};
fn create_mock_state(
test_block_builder: &mut TestBlockBuilder,
@ -753,6 +753,14 @@ mod tests {
) -> ProviderResult<(B256, TrieUpdates)> {
Ok((B256::random(), TrieUpdates::default()))
}
fn hashed_storage_root(
&self,
_address: Address,
_hashed_storage: HashedStorage,
) -> ProviderResult<B256> {
Ok(B256::random())
}
}
impl StateProofProvider for MockStateProvider {

View File

@ -8,7 +8,7 @@ use reth_primitives::{
use reth_storage_api::{
AccountReader, BlockHashReader, StateProofProvider, StateProvider, StateRootProvider,
};
use reth_trie::{updates::TrieUpdates, AccountProof, HashedPostState};
use reth_trie::{updates::TrieUpdates, AccountProof, HashedPostState, HashedStorage};
/// A state provider that stores references to in-memory blocks along with their state as well as
/// the historical state provider for fallback lookups.
@ -101,6 +101,15 @@ impl StateRootProvider for MemoryOverlayStateProvider {
state.extend(hashed_state);
self.historical.hashed_state_root_with_updates(state)
}
// TODO: Currently this does not reuse available in-memory trie nodes.
fn hashed_storage_root(
&self,
address: Address,
storage: HashedStorage,
) -> ProviderResult<B256> {
self.historical.hashed_storage_root(address, storage)
}
}
impl StateProofProvider for MemoryOverlayStateProvider {