1use crate::{
2 inspect::{InspectCommitEvm, InspectEvm, InspectSystemCallEvm},
3 Inspector, InspectorEvmTr, InspectorHandler, JournalExt,
4};
5use context::{ContextSetters, ContextTr, Evm, FrameStack, 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 all_inspector(
99 &self,
100 ) -> (
101 &Self::Context,
102 &Self::Instructions,
103 &Self::Precompiles,
104 &FrameStack<Self::Frame>,
105 &Self::Inspector,
106 ) {
107 let ctx = &self.ctx;
108 let frame = &self.frame_stack;
109 let instructions = &self.instruction;
110 let precompiles = &self.precompiles;
111 let inspector = &self.inspector;
112 (ctx, instructions, precompiles, frame, inspector)
113 }
114 fn all_mut_inspector(
115 &mut self,
116 ) -> (
117 &mut Self::Context,
118 &mut Self::Instructions,
119 &mut Self::Precompiles,
120 &mut FrameStack<Self::Frame>,
121 &mut Self::Inspector,
122 ) {
123 let ctx = &mut self.ctx;
124 let frame = &mut self.frame_stack;
125 let instructions = &mut self.instruction;
126 let precompiles = &mut self.precompiles;
127 let inspector = &mut self.inspector;
128 (ctx, instructions, precompiles, frame, inspector)
129 }
130}