Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/chain-state/src/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ mod tests {
}

impl StateProofProvider for MockStateProvider {
fn hashed_proof(
fn proof(
&self,
_hashed_state: HashedPostState,
_address: Address,
Expand Down
4 changes: 2 additions & 2 deletions crates/chain-state/src/memory_overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ 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,
slots: &[B256],
) -> 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.
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl StateRootProvider for StateProviderTest {
}

impl StateProofProvider for StateProviderTest {
fn hashed_proof(
fn proof(
&self,
_hashed_state: HashedPostState,
_address: Address,
Expand Down
3 changes: 1 addition & 2 deletions crates/rpc/rpc-eth-api/src/helpers/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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))
})
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/rpc-eth-types/src/cache/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/provider/src/providers/state/latest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions crates/storage/provider/src/providers/state/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>;
}
);
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/provider/src/test_utils/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ impl StateRootProvider for MockEthProvider {
}

impl StateProofProvider for MockEthProvider {
fn hashed_proof(
fn proof(
&self,
_hashed_state: HashedPostState,
address: Address,
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/provider/src/test_utils/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ impl StateRootProvider for NoopProvider {
}

impl StateProofProvider for NoopProvider {
fn hashed_proof(
fn proof(
&self,
_hashed_state: HashedPostState,
address: Address,
Expand Down
14 changes: 1 addition & 13 deletions crates/storage/storage-api/src/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading