mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat(trie): HashedPostState::account_proof (#9319)
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
hashed_cursor::HashedPostStateCursorFactory,
|
hashed_cursor::HashedPostStateCursorFactory,
|
||||||
prefix_set::{PrefixSetMut, TriePrefixSetsMut},
|
prefix_set::{PrefixSetMut, TriePrefixSetsMut},
|
||||||
|
proof::Proof,
|
||||||
updates::TrieUpdates,
|
updates::TrieUpdates,
|
||||||
Nibbles, StateRoot,
|
Nibbles, StateRoot,
|
||||||
};
|
};
|
||||||
@ -13,6 +14,7 @@ use reth_db_api::{
|
|||||||
};
|
};
|
||||||
use reth_execution_errors::StateRootError;
|
use reth_execution_errors::StateRootError;
|
||||||
use reth_primitives::{keccak256, Account, Address, BlockNumber, B256, U256};
|
use reth_primitives::{keccak256, Account, Address, BlockNumber, B256, U256};
|
||||||
|
use reth_trie_common::AccountProof;
|
||||||
use revm::db::BundleAccount;
|
use revm::db::BundleAccount;
|
||||||
use std::{
|
use std::{
|
||||||
collections::{hash_map, HashMap, HashSet},
|
collections::{hash_map, HashMap, HashSet},
|
||||||
@ -252,6 +254,21 @@ impl HashedPostState {
|
|||||||
.with_prefix_sets(prefix_sets)
|
.with_prefix_sets(prefix_sets)
|
||||||
.root_with_updates()
|
.root_with_updates()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Generates the state proof for target account and slots on top of this [`HashedPostState`].
|
||||||
|
pub fn account_proof<TX: DbTx>(
|
||||||
|
&self,
|
||||||
|
tx: &TX,
|
||||||
|
address: Address,
|
||||||
|
slots: &[B256],
|
||||||
|
) -> Result<AccountProof, StateRootError> {
|
||||||
|
let sorted = self.clone().into_sorted();
|
||||||
|
let prefix_sets = self.construct_prefix_sets();
|
||||||
|
Proof::from_tx(tx)
|
||||||
|
.with_hashed_cursor_factory(HashedPostStateCursorFactory::new(tx, &sorted))
|
||||||
|
.with_prefix_sets_mut(prefix_sets)
|
||||||
|
.account_proof(address, slots)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Representation of in-memory hashed storage.
|
/// Representation of in-memory hashed storage.
|
||||||
|
|||||||
Reference in New Issue
Block a user