Skip to content

Commit

Permalink
fix: make op evm impl blocks generic over precompiles (bluealloy#2142)
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr authored Mar 4, 2025
1 parent 4a42c45 commit c54e464
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions crates/optimism/src/api/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,32 @@ use revm::{
result::{EVMError, ExecutionResult, ResultAndState},
Block, Cfg, ContextTr, Database, Journal,
},
handler::{handler::EvmTr, instructions::EthInstructions, EthFrame, Handler},
interpreter::interpreter::EthInterpreter,
handler::{
handler::EvmTr, instructions::EthInstructions, EthFrame, Handler, PrecompileProvider,
},
interpreter::{interpreter::EthInterpreter, InterpreterResult},
state::EvmState,
Context, DatabaseCommit, ExecuteCommitEvm, ExecuteEvm,
};
use std::vec::Vec;

impl<BLOCK, TX, CFG, DB, JOURNAL, INSP> ExecuteEvm
impl<BLOCK, TX, CFG, DB, JOURNAL, INSP, PRECOMPILE> ExecuteEvm
for OpEvm<
Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
INSP,
EthInstructions<EthInterpreter, Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>>,
PRECOMPILE,
>
where
BLOCK: Block,
TX: OpTxTr,
CFG: Cfg<Spec = OpSpecId>,
DB: Database,
JOURNAL: Journal<Database = DB, FinalOutput = (EvmState, Vec<Log>)>,
PRECOMPILE: PrecompileProvider<
Context = Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
Output = InterpreterResult,
>,
{
type Output =
Result<ResultAndState<OpHaltReason>, EVMError<<DB as Database>::Error, OpTransactionError>>;
Expand All @@ -38,18 +45,23 @@ where
}
}

impl<BLOCK, TX, CFG, DB, JOURNAL, INSP> ExecuteCommitEvm
impl<BLOCK, TX, CFG, DB, JOURNAL, INSP, PRECOMPILE> ExecuteCommitEvm
for OpEvm<
Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
INSP,
EthInstructions<EthInterpreter, Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>>,
PRECOMPILE,
>
where
BLOCK: Block,
TX: OpTxTr,
CFG: Cfg<Spec = OpSpecId>,
DB: Database + DatabaseCommit,
JOURNAL: Journal<Database = DB, FinalOutput = (EvmState, Vec<Log>)> + JournalExt,
PRECOMPILE: PrecompileProvider<
Context = Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
Output = InterpreterResult,
>,
{
type CommitOutput = Result<
ExecutionResult<OpHaltReason>,
Expand All @@ -64,11 +76,12 @@ where
}
}

impl<BLOCK, TX, CFG, DB, JOURNAL, INSP> InspectEvm
impl<BLOCK, TX, CFG, DB, JOURNAL, INSP, PRECOMPILE> InspectEvm
for OpEvm<
Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
INSP,
EthInstructions<EthInterpreter, Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>>,
PRECOMPILE,
>
where
BLOCK: Block,
Expand All @@ -77,6 +90,10 @@ where
DB: Database,
JOURNAL: Journal<Database = DB, FinalOutput = (EvmState, Vec<Log>)> + JournalExt,
INSP: Inspector<Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>, EthInterpreter>,
PRECOMPILE: PrecompileProvider<
Context = Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
Output = InterpreterResult,
>,
{
type Inspector = INSP;

Expand All @@ -90,11 +107,12 @@ where
}
}

impl<BLOCK, TX, CFG, DB, JOURNAL, INSP> InspectCommitEvm
impl<BLOCK, TX, CFG, DB, JOURNAL, INSP, PRECOMPILE> InspectCommitEvm
for OpEvm<
Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
INSP,
EthInstructions<EthInterpreter, Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>>,
PRECOMPILE,
>
where
BLOCK: Block,
Expand All @@ -103,6 +121,10 @@ where
DB: Database + DatabaseCommit,
JOURNAL: Journal<Database = DB, FinalOutput = (EvmState, Vec<Log>)> + JournalExt,
INSP: Inspector<Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>, EthInterpreter>,
PRECOMPILE: PrecompileProvider<
Context = Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
Output = InterpreterResult,
>,
{
fn inspect_commit_previous(&mut self) -> Self::CommitOutput {
self.inspect_previous().map(|r| {
Expand Down

0 comments on commit c54e464

Please sign in to comment.