Trait zksync_vm2_interface::Tracer
source · pub trait Tracer {
// Provided methods
fn before_instruction<OP: OpcodeType, S: GlobalStateInterface>(
&mut self,
state: &mut S,
) { ... }
fn after_instruction<OP: OpcodeType, S: GlobalStateInterface>(
&mut self,
state: &mut S,
) -> ShouldStop { ... }
fn on_extra_prover_cycles(&mut self, _stats: CycleStats) { ... }
}
Expand description
EraVM instruction tracer.
Self::before_instruction()
is called just before the actual instruction is executed.
If the instruction is skipped, before_instruction
will be called with Nop
.
Self::after_instruction()
is called once the instruction is executed and the program
counter has advanced.
§Examples
Here FarCallCounter
counts the number of far calls.
struct FarCallCounter(usize);
impl Tracer for FarCallCounter {
fn before_instruction<OP: OpcodeType, S: GlobalStateInterface>(&mut self, state: &mut S) {
match OP::VALUE {
Opcode::FarCall(_) => self.0 += 1,
_ => {}
}
}
}
Provided Methods§
sourcefn before_instruction<OP: OpcodeType, S: GlobalStateInterface>(
&mut self,
state: &mut S,
)
fn before_instruction<OP: OpcodeType, S: GlobalStateInterface>( &mut self, state: &mut S, )
This method is executed before an instruction handler.
The default implementation does nothing.
sourcefn after_instruction<OP: OpcodeType, S: GlobalStateInterface>(
&mut self,
state: &mut S,
) -> ShouldStop
fn after_instruction<OP: OpcodeType, S: GlobalStateInterface>( &mut self, state: &mut S, ) -> ShouldStop
This method is executed after an instruction handler.
The return value indicates whether the VM should continue or stop execution. The tracer’s return value takes precedence over the VM but only if it is at least as severe. For example, if the VM wants to stop and the tracer wants to suspend, the VM will still stop.
The default implementation does nothing.
sourcefn on_extra_prover_cycles(&mut self, _stats: CycleStats)
fn on_extra_prover_cycles(&mut self, _stats: CycleStats)
Provides cycle statistics for “complex” instructions from the prover perspective (mostly precompile calls).
The default implementation does nothing.
Object Safety§
Implementations on Foreign Types§
impl Tracer for ()
No-op tracer implementation.