1use crate::{
2 handler::inspect_instructions,
3 inspect::{InspectCommitEvm, InspectEvm},
4 Inspector, InspectorEvmTr, InspectorFrame, InspectorHandler, JournalExt,
5};
6use context::{ContextSetters, ContextTr, Evm, JournalTr};
7use database_interface::DatabaseCommit;
8use handler::{
9 instructions::InstructionProvider, EthFrame, EvmTr, EvmTrError, Frame, FrameResult, Handler,
10 MainnetHandler, PrecompileProvider,
11};
12use interpreter::{
13 interpreter::EthInterpreter, FrameInput, Interpreter, InterpreterAction, InterpreterResult,
14 InterpreterTypes,
15};
16use state::EvmState;
17
18impl<EVM, ERROR, FRAME> InspectorHandler for MainnetHandler<EVM, ERROR, FRAME>
20where
21 EVM: InspectorEvmTr<
22 Context: ContextTr<Journal: JournalTr<State = EvmState>>,
23 Inspector: Inspector<<<Self as Handler>::Evm as EvmTr>::Context, EthInterpreter>,
24 >,
25 ERROR: EvmTrError<EVM>,
26 FRAME: Frame<Evm = EVM, Error = ERROR, FrameResult = FrameResult, FrameInit = FrameInput>
27 + InspectorFrame<IT = EthInterpreter>,
28{
29 type IT = EthInterpreter;
30}
31
32impl<CTX, INSP, INST, PRECOMPILES> InspectEvm for Evm<CTX, INSP, INST, PRECOMPILES>
34where
35 CTX: ContextSetters + ContextTr<Journal: JournalTr<State = EvmState> + JournalExt>,
36 INSP: Inspector<CTX, EthInterpreter>,
37 INST: InstructionProvider<Context = CTX, InterpreterTypes = EthInterpreter>,
38 PRECOMPILES: PrecompileProvider<CTX, Output = InterpreterResult>,
39{
40 type Inspector = INSP;
41
42 fn set_inspector(&mut self, inspector: Self::Inspector) {
43 self.inspector = inspector;
44 }
45
46 fn inspect_tx(&mut self, tx: Self::Tx) -> Result<Self::ExecutionResult, Self::Error> {
47 self.set_tx(tx);
48 let mut t = MainnetHandler::<_, _, EthFrame<_, _, _>> {
49 _phantom: core::marker::PhantomData,
50 };
51 t.inspect_run(self)
52 }
53}
54
55impl<CTX, INSP, INST, PRECOMPILES> InspectCommitEvm for Evm<CTX, INSP, INST, PRECOMPILES>
57where
58 CTX: ContextSetters
59 + ContextTr<Journal: JournalTr<State = EvmState> + JournalExt, Db: DatabaseCommit>,
60 INSP: Inspector<CTX, EthInterpreter>,
61 INST: InstructionProvider<Context = CTX, InterpreterTypes = EthInterpreter>,
62 PRECOMPILES: PrecompileProvider<CTX, Output = InterpreterResult>,
63{
64}
65
66impl<CTX, INSP, I, P> InspectorEvmTr for Evm<CTX, INSP, I, P>
68where
69 CTX: ContextTr<Journal: JournalExt> + ContextSetters,
70 I: InstructionProvider<
71 Context = CTX,
72 InterpreterTypes: InterpreterTypes<Output = InterpreterAction>,
73 >,
74 P: PrecompileProvider<CTX>,
75 INSP: Inspector<CTX, I::InterpreterTypes>,
76{
77 type Inspector = INSP;
78
79 fn inspector(&mut self) -> &mut Self::Inspector {
80 &mut self.inspector
81 }
82
83 fn ctx_inspector(&mut self) -> (&mut Self::Context, &mut Self::Inspector) {
84 (&mut self.ctx, &mut self.inspector)
85 }
86
87 fn run_inspect_interpreter(
88 &mut self,
89 interpreter: &mut Interpreter<
90 <Self::Instructions as InstructionProvider>::InterpreterTypes,
91 >,
92 ) -> <<Self::Instructions as InstructionProvider>::InterpreterTypes as InterpreterTypes>::Output
93 {
94 let context = &mut self.ctx;
95 let instructions = &mut self.instruction;
96 let inspector = &mut self.inspector;
97
98 inspect_instructions(
99 context,
100 interpreter,
101 inspector,
102 instructions.instruction_table(),
103 )
104 }
105}