Trait zksync_vm2_interface::Tracer

source ·
pub trait Tracer {
    // Provided methods
    fn before_instruction<OP: OpcodeType, S: StateInterface>(
        &mut self,
        _state: &mut S,
    ) { ... }
    fn after_instruction<OP: OpcodeType, S: StateInterface>(
        &mut self,
        _state: &mut S,
    ) { ... }
    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: StateInterface>(&mut self, state: &mut S) {
        match OP::VALUE {
            Opcode::FarCall(_) => self.0 += 1,
            _ => {}
        }
    }
}

Provided Methods§

source

fn before_instruction<OP: OpcodeType, S: StateInterface>( &mut self, _state: &mut S, )

Executes logic before an instruction handler.

The default implementation does nothing.

source

fn after_instruction<OP: OpcodeType, S: StateInterface>( &mut self, _state: &mut S, )

Executes logic after an instruction handler.

The default implementation does nothing.

source

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§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Tracer for ()

No-op tracer implementation.

source§

impl<A: Tracer, B: Tracer> Tracer for (A, B)

Implementors§