Introduce HashedPostStateProvider (#12607)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
frisitano
2024-12-04 00:56:17 +08:00
committed by GitHub
parent e4c7fac9db
commit 886471d693
42 changed files with 318 additions and 137 deletions

View File

@ -30,7 +30,6 @@ reth-rpc-eth-types.workspace = true
reth-rpc-server-types.workspace = true
reth-network-api.workspace = true
reth-node-api.workspace = true
reth-trie.workspace = true
reth-trie-common = { workspace = true, features = ["eip1186"] }
# ethereum

View File

@ -36,7 +36,6 @@ use reth_transaction_pool::{
error::InvalidPoolTransactionError, BestTransactionsAttributes, PoolTransaction,
TransactionPool,
};
use reth_trie::HashedPostState;
use revm::{db::states::bundle_state::BundleRetention, DatabaseCommit, State};
use std::time::{Duration, Instant};
use tokio::sync::Mutex;
@ -427,7 +426,7 @@ pub trait LoadPendingBlock:
block_number,
Vec::new(),
);
let hashed_state = HashedPostState::from_bundle_state(&execution_outcome.state().state);
let hashed_state = db.database.hashed_post_state(execution_outcome.state());
let receipts_root = self.receipts_root(&block_env, &execution_outcome, block_number);

View File

@ -8,7 +8,7 @@ use alloy_primitives::{
};
use reth_errors::ProviderResult;
use reth_revm::{database::StateProviderDatabase, db::CacheDB, DatabaseRef};
use reth_storage_api::StateProvider;
use reth_storage_api::{HashedPostStateProvider, StateProvider};
use reth_trie::HashedStorage;
use revm::Database;
@ -139,6 +139,15 @@ impl reth_storage_api::BlockHashReader for StateProviderTraitObjWrapper<'_> {
}
}
impl HashedPostStateProvider for StateProviderTraitObjWrapper<'_> {
fn hashed_post_state(
&self,
bundle_state: &revm::db::BundleState,
) -> reth_trie::HashedPostState {
self.0.hashed_post_state(bundle_state)
}
}
impl StateProvider for StateProviderTraitObjWrapper<'_> {
fn storage(
&self,

View File

@ -34,7 +34,6 @@ reth-evm.workspace = true
reth-rpc-eth-types.workspace = true
reth-rpc-server-types.workspace = true
reth-network-types.workspace = true
reth-trie.workspace = true
reth-consensus.workspace = true
reth-payload-validator.workspace = true

View File

@ -25,7 +25,6 @@ use reth_revm::{cached::CachedReads, database::StateProviderDatabase};
use reth_rpc_api::BlockSubmissionValidationApiServer;
use reth_rpc_server_types::result::internal_rpc_err;
use reth_tasks::TaskSpawner;
use reth_trie::HashedPostState;
use revm_primitives::{Address, B256, U256};
use serde::{Deserialize, Serialize};
use std::{collections::HashSet, sync::Arc};
@ -186,7 +185,7 @@ where
self.ensure_payment(&block, &output, &message)?;
let state_root =
state_provider.state_root(HashedPostState::from_bundle_state(&output.state.state))?;
state_provider.state_root(state_provider.hashed_post_state(&output.state))?;
if state_root != block.state_root {
return Err(ConsensusError::BodyStateRootDiff(