1use crate::{
2 inspect::{InspectCommitEvm, InspectEvm, InspectSystemCallEvm},
3 Inspector, InspectorEvmTr, InspectorHandler, JournalExt,
4};
5use context::{ContextSetters, ContextTr, Evm, JournalTr};
6use database_interface::DatabaseCommit;
7use handler::{
8 instructions::InstructionProvider, system_call::SystemCallTx, EthFrame, EvmTr, EvmTrError,
9 Handler, MainnetHandler, PrecompileProvider,
10};
11use interpreter::{interpreter::EthInterpreter, InterpreterResult};
12use primitives::{Address, Bytes};
13use state::EvmState;
14
15impl<EVM, ERROR> InspectorHandler for MainnetHandler<EVM, ERROR, EthFrame<EthInterpreter>>
17where
18 EVM: InspectorEvmTr<
19 Context: ContextTr<Journal: JournalTr<State = EvmState>>,
20 Frame = EthFrame<EthInterpreter>,
21 Inspector: Inspector<<<Self as Handler>::Evm as EvmTr>::Context, EthInterpreter>,
22 >,
23 ERROR: EvmTrError<EVM>,
24{
25 type IT = EthInterpreter;
26}
27
28impl<CTX, INSP, INST, PRECOMPILES> InspectEvm
30 for Evm<CTX, INSP, INST, PRECOMPILES, EthFrame<EthInterpreter>>
31where
32 CTX: ContextSetters + ContextTr<Journal: JournalTr<State = EvmState> + JournalExt>,
33 INSP: Inspector<CTX, EthInterpreter>,
34 INST: InstructionProvider<Context = CTX, InterpreterTypes = EthInterpreter>,
35 PRECOMPILES: PrecompileProvider<CTX, Output = InterpreterResult>,
36{
37 type Inspector = INSP;
38
39 fn set_inspector(&mut self, inspector: Self::Inspector) {
40 self.inspector = inspector;
41 }
42
43 fn inspect_one_tx(&mut self, tx: Self::Tx) -> Result<Self::ExecutionResult, Self::Error> {
44 self.set_tx(tx);
45 MainnetHandler::default().inspect_run(self)
46 }
47}
48
49impl<CTX, INSP, INST, PRECOMPILES> InspectCommitEvm
51 for Evm<CTX, INSP, INST, PRECOMPILES, EthFrame<EthInterpreter>>
52where
53 CTX: ContextSetters
54 + ContextTr<Journal: JournalTr<State = EvmState> + JournalExt, Db: DatabaseCommit>,
55 INSP: Inspector<CTX, EthInterpreter>,
56 INST: InstructionProvider<Context = CTX, InterpreterTypes = EthInterpreter>,
57 PRECOMPILES: PrecompileProvider<CTX, Output = InterpreterResult>,
58{
59}
60
61impl<CTX, INSP, INST, PRECOMPILES> InspectSystemCallEvm
63 for Evm<CTX, INSP, INST, PRECOMPILES, EthFrame<EthInterpreter>>
64where
65 CTX: ContextSetters
66 + ContextTr<Journal: JournalTr<State = EvmState> + JournalExt, Tx: SystemCallTx>,
67 INSP: Inspector<CTX, EthInterpreter>,
68 INST: InstructionProvider<Context = CTX, InterpreterTypes = EthInterpreter>,
69 PRECOMPILES: PrecompileProvider<CTX, Output = InterpreterResult>,
70{
71 fn inspect_one_system_call_with_caller(
72 &mut self,
73 caller: Address,
74 system_contract_address: Address,
75 data: Bytes,
76 ) -> Result<Self::ExecutionResult, Self::Error> {
77 self.set_tx(CTX::Tx::new_system_tx_with_caller(
79 caller,
80 system_contract_address,
81 data,
82 ));
83 MainnetHandler::default().inspect_run_system_call(self)
85 }
86}
87
88impl<CTX, INSP, I, P> InspectorEvmTr for Evm<CTX, INSP, I, P, EthFrame<EthInterpreter>>
90where
91 CTX: ContextTr<Journal: JournalExt> + ContextSetters,
92 I: InstructionProvider<Context = CTX, InterpreterTypes = EthInterpreter>,
93 P: PrecompileProvider<CTX, Output = InterpreterResult>,
94 INSP: Inspector<CTX, I::InterpreterTypes>,
95{
96 type Inspector = INSP;
97
98 fn inspector(&mut self) -> &mut Self::Inspector {
99 &mut self.inspector
100 }
101
102 fn ctx_inspector(&mut self) -> (&mut Self::Context, &mut Self::Inspector) {
103 (&mut self.ctx, &mut self.inspector)
104 }
105
106 fn ctx_inspector_frame(
107 &mut self,
108 ) -> (&mut Self::Context, &mut Self::Inspector, &mut Self::Frame) {
109 (&mut self.ctx, &mut self.inspector, self.frame_stack.get())
110 }
111
112 fn ctx_inspector_frame_instructions(
113 &mut self,
114 ) -> (
115 &mut Self::Context,
116 &mut Self::Inspector,
117 &mut Self::Frame,
118 &mut Self::Instructions,
119 ) {
120 (
121 &mut self.ctx,
122 &mut self.inspector,
123 self.frame_stack.get(),
124 &mut self.instruction,
125 )
126 }
127}