cfx_executor/observer/
opcode_tracer.rs

1use cfx_types::{Address, Space, H256, U256};
2use cfx_vm_types::InterpreterInfo;
3
4use impl_tools::autoimpl;
5use impl_trait_for_tuples::impl_for_tuples;
6
7#[impl_for_tuples(3)]
8#[autoimpl(for<T: trait + ?Sized> &mut T)]
9pub trait OpcodeTracer {
10    fn do_trace_opcode(&self, _enabled: &mut bool) {}
11
12    /// Called before the interpreter is initialized.
13    #[inline]
14    fn initialize_interp(&mut self, gas_limit: U256) { let _ = gas_limit; }
15
16    /// Called on each step of the interpreter.
17    ///
18    /// Information about the current execution, including the memory, stack and
19    /// more is available on `interp` (see [Interpreter]).
20    fn step(&mut self, interp: &dyn InterpreterInfo) { let _ = interp; }
21
22    /// Called after `step` when the instruction has been executed.
23    fn step_end(&mut self, interp: &dyn InterpreterInfo) { let _ = interp; }
24
25    /// Called when a log is emitted.
26    #[inline]
27    fn log(&mut self, address: &Address, topics: &Vec<H256>, data: &[u8]) {
28        let _ = address;
29        let _ = topics;
30        let _ = data;
31    }
32
33    /// Called when a contract has been self-destructed with funds transferred
34    /// to target.
35    #[inline]
36    fn selfdestruct(
37        &mut self, space: Space, contract: &Address, target: &Address,
38        value: U256,
39    ) {
40        let _ = space;
41        let _ = contract;
42        let _ = target;
43        let _ = value;
44    }
45}