From 4fd710c98d51cf3901395a54a719aea3f23c1aa9 Mon Sep 17 00:00:00 2001 From: Joonatan Saarhelo Date: Wed, 16 Oct 2024 16:59:08 +0200 Subject: [PATCH 1/3] feat: vm2 tracers can access storage --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- core/lib/multivm/src/versions/vm_fast/circuits_tracer.rs | 6 +++++- core/tests/vm-benchmark/src/vm.rs | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 774471d3d6c3..79d00629a60e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11322,7 +11322,7 @@ dependencies = [ [[package]] name = "zksync_vm2" version = "0.2.1" -source = "git+https://github.com/matter-labs/vm2.git?rev=a233d44bbe61dc6a758a754c3b78fe4f83e56699#a233d44bbe61dc6a758a754c3b78fe4f83e56699" +source = "git+https://github.com/matter-labs/vm2.git?rev=f27d9ff086032ab9c382e0baa7244bd247d10e49#f27d9ff086032ab9c382e0baa7244bd247d10e49" dependencies = [ "enum_dispatch", "primitive-types", @@ -11334,7 +11334,7 @@ dependencies = [ [[package]] name = "zksync_vm2_interface" version = "0.2.1" -source = "git+https://github.com/matter-labs/vm2.git?rev=a233d44bbe61dc6a758a754c3b78fe4f83e56699#a233d44bbe61dc6a758a754c3b78fe4f83e56699" +source = "git+https://github.com/matter-labs/vm2.git?rev=f27d9ff086032ab9c382e0baa7244bd247d10e49#f27d9ff086032ab9c382e0baa7244bd247d10e49" dependencies = [ "primitive-types", ] diff --git a/Cargo.toml b/Cargo.toml index 60b5628f4191..b78a430c8fa6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -230,7 +230,7 @@ zk_evm_1_4_1 = { package = "zk_evm", version = "0.141" } zk_evm_1_5_0 = { package = "zk_evm", version = "=0.150.5" } # New VM; pinned to a specific commit because of instability -zksync_vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "a233d44bbe61dc6a758a754c3b78fe4f83e56699" } +zksync_vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "f27d9ff086032ab9c382e0baa7244bd247d10e49" } # Consensus dependencies. zksync_concurrency = "=0.5.0" diff --git a/core/lib/multivm/src/versions/vm_fast/circuits_tracer.rs b/core/lib/multivm/src/versions/vm_fast/circuits_tracer.rs index b48ec7eacb0b..c52fe39a17a6 100644 --- a/core/lib/multivm/src/versions/vm_fast/circuits_tracer.rs +++ b/core/lib/multivm/src/versions/vm_fast/circuits_tracer.rs @@ -24,7 +24,11 @@ pub struct CircuitsTracer { } impl Tracer for CircuitsTracer { - fn after_instruction(&mut self, _state: &mut S) { + fn after_instruction( + &mut self, + _: &mut S, + _: &mut S::StorageInterface, + ) { self.main_vm_cycles += 1; match OP::VALUE { diff --git a/core/tests/vm-benchmark/src/vm.rs b/core/tests/vm-benchmark/src/vm.rs index 30e2321298fe..b1243770d8f3 100644 --- a/core/tests/vm-benchmark/src/vm.rs +++ b/core/tests/vm-benchmark/src/vm.rs @@ -107,6 +107,7 @@ impl BenchmarkingVmFactory for Fast >( &mut self, _: &mut S, + _: &mut S::StorageInterface, ) { self.0 += 1; } From ad824686ffeda66fa579d02272b605f342dda5bc Mon Sep 17 00:00:00 2001 From: Joonatan Saarhelo Date: Thu, 17 Oct 2024 17:52:15 +0200 Subject: [PATCH 2/3] update --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- core/lib/multivm/src/versions/vm_fast/circuits_tracer.rs | 8 ++------ core/tests/vm-benchmark/src/vm.rs | 3 +-- prover/Cargo.lock | 4 ++-- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79d00629a60e..149b93125f3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11322,7 +11322,7 @@ dependencies = [ [[package]] name = "zksync_vm2" version = "0.2.1" -source = "git+https://github.com/matter-labs/vm2.git?rev=f27d9ff086032ab9c382e0baa7244bd247d10e49#f27d9ff086032ab9c382e0baa7244bd247d10e49" +source = "git+https://github.com/matter-labs/vm2.git?rev=b67ae4b751909bb665285ff651b8c70c970cd38e#b67ae4b751909bb665285ff651b8c70c970cd38e" dependencies = [ "enum_dispatch", "primitive-types", @@ -11334,7 +11334,7 @@ dependencies = [ [[package]] name = "zksync_vm2_interface" version = "0.2.1" -source = "git+https://github.com/matter-labs/vm2.git?rev=f27d9ff086032ab9c382e0baa7244bd247d10e49#f27d9ff086032ab9c382e0baa7244bd247d10e49" +source = "git+https://github.com/matter-labs/vm2.git?rev=b67ae4b751909bb665285ff651b8c70c970cd38e#b67ae4b751909bb665285ff651b8c70c970cd38e" dependencies = [ "primitive-types", ] diff --git a/Cargo.toml b/Cargo.toml index b78a430c8fa6..4101c99b3cf7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -230,7 +230,7 @@ zk_evm_1_4_1 = { package = "zk_evm", version = "0.141" } zk_evm_1_5_0 = { package = "zk_evm", version = "=0.150.5" } # New VM; pinned to a specific commit because of instability -zksync_vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "f27d9ff086032ab9c382e0baa7244bd247d10e49" } +zksync_vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "b67ae4b751909bb665285ff651b8c70c970cd38e" } # Consensus dependencies. zksync_concurrency = "=0.5.0" diff --git a/core/lib/multivm/src/versions/vm_fast/circuits_tracer.rs b/core/lib/multivm/src/versions/vm_fast/circuits_tracer.rs index c52fe39a17a6..f588f20ab25d 100644 --- a/core/lib/multivm/src/versions/vm_fast/circuits_tracer.rs +++ b/core/lib/multivm/src/versions/vm_fast/circuits_tracer.rs @@ -1,5 +1,5 @@ use circuit_sequencer_api_1_5_0::{geometry_config::get_geometry_config, toolset::GeometryConfig}; -use zksync_vm2::interface::{CycleStats, Opcode, OpcodeType, StateInterface, Tracer}; +use zksync_vm2::interface::{CycleStats, GlobalStateInterface, Opcode, OpcodeType, Tracer}; use zksync_vm_interface::CircuitStatistic; use crate::vm_latest::tracers::circuits_capacity::*; @@ -24,11 +24,7 @@ pub struct CircuitsTracer { } impl Tracer for CircuitsTracer { - fn after_instruction( - &mut self, - _: &mut S, - _: &mut S::StorageInterface, - ) { + fn after_instruction(&mut self, _: &mut S) { self.main_vm_cycles += 1; match OP::VALUE { diff --git a/core/tests/vm-benchmark/src/vm.rs b/core/tests/vm-benchmark/src/vm.rs index b1243770d8f3..dddef0de82fe 100644 --- a/core/tests/vm-benchmark/src/vm.rs +++ b/core/tests/vm-benchmark/src/vm.rs @@ -103,11 +103,10 @@ impl BenchmarkingVmFactory for Fast impl vm_fast::Tracer for InstructionCount { fn before_instruction< OP: zksync_vm2::interface::OpcodeType, - S: zksync_vm2::interface::StateInterface, + S: zksync_vm2::interface::GlobalStateInterface, >( &mut self, _: &mut S, - _: &mut S::StorageInterface, ) { self.0 += 1; } diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 1d584a473d96..336e0568fe3c 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -8639,7 +8639,7 @@ dependencies = [ [[package]] name = "zksync_vm2" version = "0.2.1" -source = "git+https://github.com/matter-labs/vm2.git?rev=a233d44bbe61dc6a758a754c3b78fe4f83e56699#a233d44bbe61dc6a758a754c3b78fe4f83e56699" +source = "git+https://github.com/matter-labs/vm2.git?rev=b67ae4b751909bb665285ff651b8c70c970cd38e#b67ae4b751909bb665285ff651b8c70c970cd38e" dependencies = [ "enum_dispatch", "primitive-types", @@ -8651,7 +8651,7 @@ dependencies = [ [[package]] name = "zksync_vm2_interface" version = "0.2.1" -source = "git+https://github.com/matter-labs/vm2.git?rev=a233d44bbe61dc6a758a754c3b78fe4f83e56699#a233d44bbe61dc6a758a754c3b78fe4f83e56699" +source = "git+https://github.com/matter-labs/vm2.git?rev=b67ae4b751909bb665285ff651b8c70c970cd38e#b67ae4b751909bb665285ff651b8c70c970cd38e" dependencies = [ "primitive-types", ] From a2b5c4391c79bed0c0aabef19bd50f285f55e45b Mon Sep 17 00:00:00 2001 From: Joonatan Saarhelo Date: Fri, 18 Oct 2024 12:31:26 +0200 Subject: [PATCH 3/3] depend on merged code --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- prover/Cargo.lock | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 149b93125f3d..665f7a08de98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11322,7 +11322,7 @@ dependencies = [ [[package]] name = "zksync_vm2" version = "0.2.1" -source = "git+https://github.com/matter-labs/vm2.git?rev=b67ae4b751909bb665285ff651b8c70c970cd38e#b67ae4b751909bb665285ff651b8c70c970cd38e" +source = "git+https://github.com/matter-labs/vm2.git?rev=df5bec3d04d64d434f9b0ccb285ba4681008f7b3#df5bec3d04d64d434f9b0ccb285ba4681008f7b3" dependencies = [ "enum_dispatch", "primitive-types", @@ -11334,7 +11334,7 @@ dependencies = [ [[package]] name = "zksync_vm2_interface" version = "0.2.1" -source = "git+https://github.com/matter-labs/vm2.git?rev=b67ae4b751909bb665285ff651b8c70c970cd38e#b67ae4b751909bb665285ff651b8c70c970cd38e" +source = "git+https://github.com/matter-labs/vm2.git?rev=df5bec3d04d64d434f9b0ccb285ba4681008f7b3#df5bec3d04d64d434f9b0ccb285ba4681008f7b3" dependencies = [ "primitive-types", ] diff --git a/Cargo.toml b/Cargo.toml index 4101c99b3cf7..796c6dcdf3c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -230,7 +230,7 @@ zk_evm_1_4_1 = { package = "zk_evm", version = "0.141" } zk_evm_1_5_0 = { package = "zk_evm", version = "=0.150.5" } # New VM; pinned to a specific commit because of instability -zksync_vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "b67ae4b751909bb665285ff651b8c70c970cd38e" } +zksync_vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "df5bec3d04d64d434f9b0ccb285ba4681008f7b3" } # Consensus dependencies. zksync_concurrency = "=0.5.0" diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 336e0568fe3c..5d88d89f2ee3 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -8639,7 +8639,7 @@ dependencies = [ [[package]] name = "zksync_vm2" version = "0.2.1" -source = "git+https://github.com/matter-labs/vm2.git?rev=b67ae4b751909bb665285ff651b8c70c970cd38e#b67ae4b751909bb665285ff651b8c70c970cd38e" +source = "git+https://github.com/matter-labs/vm2.git?rev=df5bec3d04d64d434f9b0ccb285ba4681008f7b3#df5bec3d04d64d434f9b0ccb285ba4681008f7b3" dependencies = [ "enum_dispatch", "primitive-types", @@ -8651,7 +8651,7 @@ dependencies = [ [[package]] name = "zksync_vm2_interface" version = "0.2.1" -source = "git+https://github.com/matter-labs/vm2.git?rev=b67ae4b751909bb665285ff651b8c70c970cd38e#b67ae4b751909bb665285ff651b8c70c970cd38e" +source = "git+https://github.com/matter-labs/vm2.git?rev=df5bec3d04d64d434f9b0ccb285ba4681008f7b3#df5bec3d04d64d434f9b0ccb285ba4681008f7b3" dependencies = [ "primitive-types", ]