chore(trie): remove plain state proof variant (#10593)

This commit is contained in:
Roman Krasiuk
2024-08-28 05:00:46 -07:00
committed by GitHub
parent 0013399234
commit cf7416e2f2
12 changed files with 15 additions and 29 deletions

View File

@@ -924,7 +924,7 @@ mod tests {
}
impl StateProofProvider for MockStateProvider {
fn hashed_proof(
fn proof(
&self,
_hashed_state: HashedPostState,
_address: Address,

View File

@@ -167,7 +167,7 @@ impl StateRootProvider for MemoryOverlayStateProvider {
impl StateProofProvider for MemoryOverlayStateProvider {
// TODO: Currently this does not reuse available in-memory trie nodes.
fn hashed_proof(
fn proof(
&self,
state: HashedPostState,
address: Address,
@@ -175,7 +175,7 @@ impl StateProofProvider for MemoryOverlayStateProvider {
) -> ProviderResult<AccountProof> {
let mut hashed_state = self.trie_state().hashed_state.clone();
hashed_state.extend(state);
self.historical.hashed_proof(hashed_state, address, slots)
self.historical.proof(hashed_state, address, slots)
}
// TODO: Currently this does not reuse available in-memory trie nodes.

View File

@@ -110,7 +110,7 @@ impl StateRootProvider for StateProviderTest {
}
impl StateProofProvider for StateProviderTest {
fn hashed_proof(
fn proof(
&self,
_hashed_state: HashedPostState,
_address: Address,

View File

@@ -14,7 +14,6 @@ use reth_rpc_eth_types::{EthApiError, EthStateCache, PendingBlockEnv, RpcInvalid
use reth_rpc_types::{serde_helpers::JsonStorageKey, Account, EIP1186AccountProofResponse};
use reth_rpc_types_compat::proof::from_primitive_account_proof;
use reth_transaction_pool::{PoolTransaction, TransactionPool};
use revm::db::BundleState;
use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, SpecId};
use crate::{EthApiTypes, FromEthApiError};
@@ -122,7 +121,7 @@ pub trait EthState: LoadState + SpawnBlocking {
let state = this.state_at_block_id(block_id)?;
let storage_keys = keys.iter().map(|key| key.0).collect::<Vec<_>>();
let proof = state
.proof(&BundleState::default(), address, &storage_keys)
.proof(Default::default(), address, &storage_keys)
.map_err(Self::Error::from_eth_err)?;
Ok(from_primitive_account_proof(proof))
})

View File

@@ -60,13 +60,13 @@ impl<'a> reth_storage_api::StateRootProvider for StateProviderTraitObjWrapper<'a
}
impl<'a> reth_storage_api::StateProofProvider for StateProviderTraitObjWrapper<'a> {
fn hashed_proof(
fn proof(
&self,
hashed_state: reth_trie::HashedPostState,
address: revm_primitives::Address,
slots: &[B256],
) -> reth_errors::ProviderResult<reth_trie::AccountProof> {
self.0.hashed_proof(hashed_state, address, slots)
self.0.proof(hashed_state, address, slots)
}
fn witness(

View File

@@ -151,7 +151,7 @@ impl<SP: StateProvider, EDP: ExecutionDataProvider> StateRootProvider
impl<SP: StateProvider, EDP: ExecutionDataProvider> StateProofProvider
for BundleStateProvider<SP, EDP>
{
fn hashed_proof(
fn proof(
&self,
hashed_state: HashedPostState,
address: Address,
@@ -160,7 +160,7 @@ impl<SP: StateProvider, EDP: ExecutionDataProvider> StateProofProvider
let bundle_state = self.block_execution_data_provider.execution_outcome().state();
let mut state = HashedPostState::from_bundle_state(&bundle_state.state);
state.extend(hashed_state);
self.state_provider.hashed_proof(state, address, slots)
self.state_provider.proof(state, address, slots)
}
fn witness(

View File

@@ -349,7 +349,7 @@ impl<'b, TX: DbTx> StateRootProvider for HistoricalStateProviderRef<'b, TX> {
impl<'b, TX: DbTx> StateProofProvider for HistoricalStateProviderRef<'b, TX> {
/// Get account and storage proofs.
fn hashed_proof(
fn proof(
&self,
hashed_state: HashedPostState,
address: Address,

View File

@@ -125,7 +125,7 @@ impl<'b, TX: DbTx> StateRootProvider for LatestStateProviderRef<'b, TX> {
}
impl<'b, TX: DbTx> StateProofProvider for LatestStateProviderRef<'b, TX> {
fn hashed_proof(
fn proof(
&self,
hashed_state: HashedPostState,
address: Address,

View File

@@ -51,8 +51,7 @@ macro_rules! delegate_provider_impls {
fn hashed_storage_root(&self, address: reth_primitives::Address, storage: reth_trie::HashedStorage) -> reth_storage_errors::provider::ProviderResult<reth_primitives::B256>;
}
StateProofProvider $(where [$($generics)*])? {
fn proof(&self, state: &revm::db::BundleState, address: reth_primitives::Address, slots: &[reth_primitives::B256]) -> reth_storage_errors::provider::ProviderResult<reth_trie::AccountProof>;
fn hashed_proof(&self, state: reth_trie::HashedPostState, address: reth_primitives::Address, slots: &[reth_primitives::B256]) -> reth_storage_errors::provider::ProviderResult<reth_trie::AccountProof>;
fn proof(&self, state: reth_trie::HashedPostState, address: reth_primitives::Address, slots: &[reth_primitives::B256]) -> reth_storage_errors::provider::ProviderResult<reth_trie::AccountProof>;
fn witness(&self, state: reth_trie::HashedPostState, target: reth_trie::HashedPostState) -> reth_storage_errors::provider::ProviderResult<std::collections::HashMap<reth_primitives::B256, reth_primitives::Bytes>>;
}
);

View File

@@ -609,7 +609,7 @@ impl StateRootProvider for MockEthProvider {
}
impl StateProofProvider for MockEthProvider {
fn hashed_proof(
fn proof(
&self,
_hashed_state: HashedPostState,
address: Address,

View File

@@ -360,7 +360,7 @@ impl StateRootProvider for NoopProvider {
}
impl StateProofProvider for NoopProvider {
fn hashed_proof(
fn proof(
&self,
_hashed_state: HashedPostState,
address: Address,

View File

@@ -71,21 +71,9 @@ pub trait StateRootProvider: Send + Sync {
/// A type that can generate state proof on top of a given post state.
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait StateProofProvider: Send + Sync {
/// Get account and storage proofs of target keys in the `BundleState`
/// on top of the current state.
fn proof(
&self,
state: &BundleState,
address: Address,
slots: &[B256],
) -> ProviderResult<AccountProof> {
let hashed_state = HashedPostState::from_bundle_state(&state.state);
self.hashed_proof(hashed_state, address, slots)
}
/// Get account and storage proofs of target keys in the `HashedPostState`
/// on top of the current state.
fn hashed_proof(
fn proof(
&self,
hashed_state: HashedPostState,
address: Address,