Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joonazan committed Oct 17, 2024
1 parent b67ae4b commit b15b78d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions crates/vm2-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
//! ```
//! # use zksync_vm2_interface as zksync_vm2_interface_v1;
//! use zksync_vm2_interface_v1::{
//! StateInterface as StateInterfaceV1, Tracer as TracerV1, opcodes::NearCall,
//! StateInterface as StateInterfaceV1, GlobalStateInterface as GlobalStateInterfaceV1, Tracer as TracerV1, opcodes::NearCall,
//! };
//!
//! trait StateInterface: StateInterfaceV1 {
//! fn get_some_new_field(&self) -> u32;
//! }
//!
//! trait GlobalStateInterface: StateInterface + GlobalStateInterfaceV1 {}
//!
//! pub struct NewOpcode;
//!
//! #[derive(PartialEq, Eq)]
Expand All @@ -57,27 +59,27 @@
//! }
//!
//! trait Tracer {
//! fn before_instruction<OP: OpcodeType, S: StateInterface>(&mut self, state: &mut S, storage: &mut S::StorageInterface) {}
//! fn after_instruction<OP: OpcodeType, S: StateInterface>(&mut self, state: &mut S, storage: &mut S::StorageInterface) {}
//! fn before_instruction<OP: OpcodeType, S: GlobalStateInterface>(&mut self, state: &mut S) {}
//! fn after_instruction<OP: OpcodeType, S: GlobalStateInterface>(&mut self, state: &mut S) {}
//! }
//!
//! impl<T: TracerV1> Tracer for T {
//! fn before_instruction<OP: OpcodeType, S: StateInterface>(&mut self, state: &mut S, storage: &mut S::StorageInterface) {
//! fn before_instruction<OP: OpcodeType, S: GlobalStateInterface>(&mut self, state: &mut S) {
//! match OP::VALUE {
//! Opcode::NewOpcode => {}
//! // Do this for every old opcode
//! Opcode::NearCall => {
//! <Self as TracerV1>::before_instruction::<NearCall, _>(self, state, storage)
//! <Self as TracerV1>::before_instruction::<NearCall, _>(self, state)
//! }
//! }
//! }
//! fn after_instruction<OP: OpcodeType, S: StateInterface>(&mut self, state: &mut S, storage: &mut S::StorageInterface) {}
//! fn after_instruction<OP: OpcodeType, S: GlobalStateInterface>(&mut self, state: &mut S) {}
//! }
//!
//! // Now you can use the new features by implementing TracerV2
//! struct MyTracer;
//! impl Tracer for MyTracer {
//! fn before_instruction<OP: OpcodeType, S: StateInterface>(&mut self, state: &mut S, _: &mut S::StorageInterface) {
//! fn before_instruction<OP: OpcodeType, S: GlobalStateInterface>(&mut self, state: &mut S) {
//! if OP::VALUE == Opcode::NewOpcode {
//! state.get_some_new_field();
//! }
Expand Down
2 changes: 1 addition & 1 deletion crates/vm2-interface/src/tracer_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl<T: opcodes::TypeLevelReturnType> OpcodeType for opcodes::Ret<T> {
/// struct FarCallCounter(usize);
///
/// impl Tracer for FarCallCounter {
/// fn before_instruction<OP: OpcodeType, S: GlobalStateInterface>(&mut self, state: &mut S, _: &mut S::StorageInterface) {
/// fn before_instruction<OP: OpcodeType, S: GlobalStateInterface>(&mut self, state: &mut S) {
/// match OP::VALUE {
/// Opcode::FarCall(_) => self.0 += 1,
/// _ => {}
Expand Down

0 comments on commit b15b78d

Please sign in to comment.