Skip to content

Commit

Permalink
chore: API cleanup (#2067)
Browse files Browse the repository at this point in the history
* chore: rm clone from PrecompileProvider

* clonable spec

* relax evm transact

* inspect relaxed trait for evm
  • Loading branch information
rakita authored Feb 11, 2025
1 parent 6fe9047 commit c12a95e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion crates/context/interface/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use specification::hardfork::SpecId;

#[auto_impl(&, &mut, Box, Arc)]
pub trait Cfg {
type Spec: Into<SpecId>;
type Spec: Into<SpecId> + Clone;

fn chain_id(&self) -> u64;

Expand Down
2 changes: 1 addition & 1 deletion crates/handler/src/precompile_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use specification::hardfork::SpecId;
use std::boxed::Box;

#[auto_impl(&mut, Box)]
pub trait PrecompileProvider: Clone {
pub trait PrecompileProvider {
type Context: ContextTrait;
type Output;

Expand Down
25 changes: 15 additions & 10 deletions crates/revm/src/mainnet_exec_inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@ use context_interface::{
};
use database_interface::DatabaseCommit;
use handler::inspector::JournalExt;
use handler::PrecompileProvider;
use handler::{handler::EvmTrait, inspector::EthInspectorHandler};
use handler::{
inspector::Inspector, instructions::EthInstructions, EthFrame, EthHandler, EthPrecompiles,
MainnetHandler,
inspector::Inspector, instructions::EthInstructions, EthFrame, EthHandler, MainnetHandler,
};
use interpreter::interpreter::EthInterpreter;

use interpreter::InterpreterResult;
use primitives::Log;
use state::EvmState;
use std::vec::Vec;

impl<CTX, INSP> ExecuteEvm
for Evm<CTX, INSP, EthInstructions<EthInterpreter, CTX>, EthPrecompiles<CTX>>
impl<CTX, INSP, PRECOMPILES> ExecuteEvm
for Evm<CTX, INSP, EthInstructions<EthInterpreter, CTX>, PRECOMPILES>
where
CTX: ContextSetters
+ ContextTrait<Journal: Journal<FinalOutput = (EvmState, Vec<Log>)> + JournalExt>,
INSP: Inspector<CTX, EthInterpreter>,
PRECOMPILES: PrecompileProvider<Context = CTX, Output = InterpreterResult>,
{
type Output = Result<
ResultAndState<HaltReason>,
Expand All @@ -37,15 +39,16 @@ where
}
}

impl<CTX, INSP> ExecuteCommitEvm
for Evm<CTX, INSP, EthInstructions<EthInterpreter, CTX>, EthPrecompiles<CTX>>
impl<CTX, INSP, PRECOMPILES> ExecuteCommitEvm
for Evm<CTX, INSP, EthInstructions<EthInterpreter, CTX>, PRECOMPILES>
where
CTX: ContextSetters
+ ContextTrait<
Journal: Journal<FinalOutput = (EvmState, Vec<Log>)> + JournalExt,
Db: DatabaseCommit,
>,
INSP: Inspector<CTX, EthInterpreter>,
PRECOMPILES: PrecompileProvider<Context = CTX, Output = InterpreterResult>,
{
type CommitOutput = Result<
ExecutionResult<HaltReason>,
Expand All @@ -60,12 +63,13 @@ where
}
}

impl<CTX, INSP> InspectEvm
for Evm<CTX, INSP, EthInstructions<EthInterpreter, CTX>, EthPrecompiles<CTX>>
impl<CTX, INSP, PRECOMPILES> InspectEvm
for Evm<CTX, INSP, EthInstructions<EthInterpreter, CTX>, PRECOMPILES>
where
CTX: ContextSetters
+ ContextTrait<Journal: Journal<FinalOutput = (EvmState, Vec<Log>)> + JournalExt>,
INSP: Inspector<CTX, EthInterpreter>,
PRECOMPILES: PrecompileProvider<Context = CTX, Output = InterpreterResult>,
{
type Inspector = INSP;

Expand All @@ -82,15 +86,16 @@ where
}
}

impl<CTX, INSP> InspectCommitEvm
for Evm<CTX, INSP, EthInstructions<EthInterpreter, CTX>, EthPrecompiles<CTX>>
impl<CTX, INSP, PRECOMPILES> InspectCommitEvm
for Evm<CTX, INSP, EthInstructions<EthInterpreter, CTX>, PRECOMPILES>
where
CTX: ContextSetters
+ ContextTrait<
Journal: Journal<FinalOutput = (EvmState, Vec<Log>)> + JournalExt,
Db: DatabaseCommit,
>,
INSP: Inspector<CTX, EthInterpreter>,
PRECOMPILES: PrecompileProvider<Context = CTX, Output = InterpreterResult>,
{
fn inspect_commit_previous(&mut self) -> Self::CommitOutput {
self.inspect_previous().map(|r| {
Expand Down

0 comments on commit c12a95e

Please sign in to comment.