revm_optimism/api/
builder.rs

1use crate::{evm::OpEvm, transaction::OpTxTr, L1BlockInfo, OpSpecId, OpTransaction};
2use precompile::Log;
3use revm::{
4    context::{BlockEnv, Cfg, CfgEnv, TxEnv},
5    context_interface::{Block, Journal},
6    handler::instructions::EthInstructions,
7    interpreter::interpreter::EthInterpreter,
8    state::EvmState,
9    Context, Database, JournaledState,
10};
11use std::vec::Vec;
12
13pub trait OpBuilder: Sized {
14    type Context;
15
16    fn build_op(self) -> OpEvm<Self::Context, (), EthInstructions<EthInterpreter, Self::Context>>;
17
18    fn build_op_with_inspector<INSP>(
19        self,
20        inspector: INSP,
21    ) -> OpEvm<Self::Context, INSP, EthInstructions<EthInterpreter, Self::Context>>;
22}
23
24impl<BLOCK, TX, CFG, DB, JOURNAL> OpBuilder for Context<BLOCK, TX, CFG, DB, JOURNAL, L1BlockInfo>
25where
26    BLOCK: Block,
27    TX: OpTxTr,
28    CFG: Cfg<Spec = OpSpecId>,
29    DB: Database,
30    JOURNAL: Journal<Database = DB, FinalOutput = (EvmState, Vec<Log>)>,
31{
32    type Context = Self;
33
34    fn build_op(self) -> OpEvm<Self::Context, (), EthInstructions<EthInterpreter, Self::Context>> {
35        OpEvm::new(self, ())
36    }
37
38    fn build_op_with_inspector<INSP>(
39        self,
40        inspector: INSP,
41    ) -> OpEvm<Self::Context, INSP, EthInstructions<EthInterpreter, Self::Context>> {
42        OpEvm::new(self, inspector)
43    }
44}
45
46pub type OpContext<DB> =
47    Context<BlockEnv, OpTransaction<TxEnv>, CfgEnv<OpSpecId>, DB, JournaledState<DB>, L1BlockInfo>;