Skip to content

Commit c54e464

Browse files
authored
fix: make op evm impl blocks generic over precompiles (#2142)
1 parent 4a42c45 commit c54e464

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

crates/optimism/src/api/exec.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,32 @@ use revm::{
99
result::{EVMError, ExecutionResult, ResultAndState},
1010
Block, Cfg, ContextTr, Database, Journal,
1111
},
12-
handler::{handler::EvmTr, instructions::EthInstructions, EthFrame, Handler},
13-
interpreter::interpreter::EthInterpreter,
12+
handler::{
13+
handler::EvmTr, instructions::EthInstructions, EthFrame, Handler, PrecompileProvider,
14+
},
15+
interpreter::{interpreter::EthInterpreter, InterpreterResult},
1416
state::EvmState,
1517
Context, DatabaseCommit, ExecuteCommitEvm, ExecuteEvm,
1618
};
1719
use std::vec::Vec;
1820

19-
impl<BLOCK, TX, CFG, DB, JOURNAL, INSP> ExecuteEvm
21+
impl<BLOCK, TX, CFG, DB, JOURNAL, INSP, PRECOMPILE> ExecuteEvm
2022
for OpEvm<
2123
Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
2224
INSP,
2325
EthInstructions<EthInterpreter, Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>>,
26+
PRECOMPILE,
2427
>
2528
where
2629
BLOCK: Block,
2730
TX: OpTxTr,
2831
CFG: Cfg<Spec = OpSpecId>,
2932
DB: Database,
3033
JOURNAL: Journal<Database = DB, FinalOutput = (EvmState, Vec<Log>)>,
34+
PRECOMPILE: PrecompileProvider<
35+
Context = Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
36+
Output = InterpreterResult,
37+
>,
3138
{
3239
type Output =
3340
Result<ResultAndState<OpHaltReason>, EVMError<<DB as Database>::Error, OpTransactionError>>;
@@ -38,18 +45,23 @@ where
3845
}
3946
}
4047

41-
impl<BLOCK, TX, CFG, DB, JOURNAL, INSP> ExecuteCommitEvm
48+
impl<BLOCK, TX, CFG, DB, JOURNAL, INSP, PRECOMPILE> ExecuteCommitEvm
4249
for OpEvm<
4350
Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
4451
INSP,
4552
EthInstructions<EthInterpreter, Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>>,
53+
PRECOMPILE,
4654
>
4755
where
4856
BLOCK: Block,
4957
TX: OpTxTr,
5058
CFG: Cfg<Spec = OpSpecId>,
5159
DB: Database + DatabaseCommit,
5260
JOURNAL: Journal<Database = DB, FinalOutput = (EvmState, Vec<Log>)> + JournalExt,
61+
PRECOMPILE: PrecompileProvider<
62+
Context = Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
63+
Output = InterpreterResult,
64+
>,
5365
{
5466
type CommitOutput = Result<
5567
ExecutionResult<OpHaltReason>,
@@ -64,11 +76,12 @@ where
6476
}
6577
}
6678

67-
impl<BLOCK, TX, CFG, DB, JOURNAL, INSP> InspectEvm
79+
impl<BLOCK, TX, CFG, DB, JOURNAL, INSP, PRECOMPILE> InspectEvm
6880
for OpEvm<
6981
Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
7082
INSP,
7183
EthInstructions<EthInterpreter, Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>>,
84+
PRECOMPILE,
7285
>
7386
where
7487
BLOCK: Block,
@@ -77,6 +90,10 @@ where
7790
DB: Database,
7891
JOURNAL: Journal<Database = DB, FinalOutput = (EvmState, Vec<Log>)> + JournalExt,
7992
INSP: Inspector<Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>, EthInterpreter>,
93+
PRECOMPILE: PrecompileProvider<
94+
Context = Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
95+
Output = InterpreterResult,
96+
>,
8097
{
8198
type Inspector = INSP;
8299

@@ -90,11 +107,12 @@ where
90107
}
91108
}
92109

93-
impl<BLOCK, TX, CFG, DB, JOURNAL, INSP> InspectCommitEvm
110+
impl<BLOCK, TX, CFG, DB, JOURNAL, INSP, PRECOMPILE> InspectCommitEvm
94111
for OpEvm<
95112
Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
96113
INSP,
97114
EthInstructions<EthInterpreter, Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>>,
115+
PRECOMPILE,
98116
>
99117
where
100118
BLOCK: Block,
@@ -103,6 +121,10 @@ where
103121
DB: Database + DatabaseCommit,
104122
JOURNAL: Journal<Database = DB, FinalOutput = (EvmState, Vec<Log>)> + JournalExt,
105123
INSP: Inspector<Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>, EthInterpreter>,
124+
PRECOMPILE: PrecompileProvider<
125+
Context = Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>,
126+
Output = InterpreterResult,
127+
>,
106128
{
107129
fn inspect_commit_previous(&mut self) -> Self::CommitOutput {
108130
self.inspect_previous().map(|r| {

0 commit comments

Comments
 (0)