Skip to content

Commit

Permalink
update ContextFul usage with FinalizeExecution bound on State<DB>
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Edison <[email protected]>
  • Loading branch information
greged93 committed Nov 27, 2024
1 parent e85bb37 commit 19efb8d
Show file tree
Hide file tree
Showing 21 changed files with 180 additions and 125 deletions.
10 changes: 4 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/engine/invalid-block-hooks/src/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ where
db.merge_transitions(BundleRetention::Reverts);

// Take the bundle state
let mut bundle_state: reth_revm::db::BundleState = db.finalize();
let mut bundle_state = db.finalize();

// Initialize a map of preimages.
let mut state_preimages = HashMap::default();
Expand Down
16 changes: 10 additions & 6 deletions crates/ethereum/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use reth_evm::{
ConfigureEvm, TxEnvOverrides,
};
use reth_primitives::{BlockWithSenders, Receipt};
use reth_revm::db::State;
use reth_scroll_execution::ContextFul;
use reth_revm::db::{BundleState, State};
use reth_scroll_execution::FinalizeExecution;
use revm_primitives::{
db::{Database, DatabaseCommit},
BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState, U256,
Expand Down Expand Up @@ -61,12 +61,15 @@ where
EvmConfig:
Clone + Unpin + Sync + Send + 'static + ConfigureEvm<Header = alloy_consensus::Header>,
{
type Strategy<DB: Database<Error: Into<ProviderError> + Display> + ContextFul> =
EthExecutionStrategy<DB, EvmConfig>;
type Strategy<DB: Database<Error: Into<ProviderError> + Display>>
= EthExecutionStrategy<DB, EvmConfig>
where
State<DB>: FinalizeExecution<Output = BundleState>;

fn create_strategy<DB>(&self, db: DB) -> Self::Strategy<DB>
where
DB: Database<Error: Into<ProviderError> + Display> + ContextFul,
DB: Database<Error: Into<ProviderError> + Display>,
State<DB>: FinalizeExecution<Output = BundleState>,
{
let state =
State::builder().with_database(db).with_bundle_update().without_state_clear().build();
Expand Down Expand Up @@ -128,7 +131,8 @@ where

impl<DB, EvmConfig> BlockExecutionStrategy<DB> for EthExecutionStrategy<DB, EvmConfig>
where
DB: Database<Error: Into<ProviderError> + Display> + ContextFul,
DB: Database<Error: Into<ProviderError> + Display>,
State<DB>: FinalizeExecution<Output = BundleState>,
EvmConfig: ConfigureEvm<Header = alloy_consensus::Header>,
{
type Error = BlockExecutionError;
Expand Down
1 change: 0 additions & 1 deletion crates/evm/execution-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ reth-execution-errors.workspace = true
reth-trie.workspace = true
reth-primitives-traits.workspace = true

# scroll
revm.workspace = true

# alloy
Expand Down
22 changes: 14 additions & 8 deletions crates/evm/src/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,33 @@ use reth_execution_errors::BlockExecutionError;
use reth_execution_types::{BlockExecutionInput, BlockExecutionOutput, ExecutionOutcome};
use reth_primitives::{BlockWithSenders, Receipt};
use reth_prune_types::PruneModes;
use reth_scroll_execution::FinalizeExecution;
use reth_storage_errors::provider::ProviderError;
use revm::{db::BundleState, State};
use revm_primitives::db::Database;

// re-export Either
pub use futures_util::future::Either;
use reth_scroll_execution::ContextFul;
use revm::State;

impl<A, B> BlockExecutorProvider for Either<A, B>
where
A: BlockExecutorProvider,
B: BlockExecutorProvider,
{
type Executor<DB: Database<Error: Into<ProviderError> + Display> + ContextFul> =
Either<A::Executor<DB>, B::Executor<DB>>;
type Executor<DB: Database<Error: Into<ProviderError> + Display>>
= Either<A::Executor<DB>, B::Executor<DB>>
where
State<DB>: FinalizeExecution<Output = BundleState>;

type BatchExecutor<DB: Database<Error: Into<ProviderError> + Display> + ContextFul> =
Either<A::BatchExecutor<DB>, B::BatchExecutor<DB>>;
type BatchExecutor<DB: Database<Error: Into<ProviderError> + Display>>
= Either<A::BatchExecutor<DB>, B::BatchExecutor<DB>>
where
State<DB>: FinalizeExecution<Output = BundleState>;

fn executor<DB>(&self, db: DB) -> Self::Executor<DB>
where
DB: Database<Error: Into<ProviderError> + Display> + ContextFul,
DB: Database<Error: Into<ProviderError> + Display>,
State<DB>: FinalizeExecution<Output = BundleState>,
{
match self {
Self::Left(a) => Either::Left(a.executor(db)),
Expand All @@ -43,7 +48,8 @@ where

fn batch_executor<DB>(&self, db: DB) -> Self::BatchExecutor<DB>
where
DB: Database<Error: Into<ProviderError> + Display> + ContextFul,
DB: Database<Error: Into<ProviderError> + Display>,
State<DB>: FinalizeExecution<Output = BundleState>,
{
match self {
Self::Left(a) => Either::Left(a.batch_executor(db)),
Expand Down
Loading

0 comments on commit 19efb8d

Please sign in to comment.