Skip to content

Commit

Permalink
Make server compile
Browse files Browse the repository at this point in the history
  • Loading branch information
gianbelinche committed Sep 2, 2024
1 parent 9773fe8 commit 593c7ea
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 12 deletions.
21 changes: 19 additions & 2 deletions core/lib/multivm/src/glue/tracers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//! - Add this trait as a trait bound for `T` in `MultiVMTracer` implementation.
//! - Implement the trait for `T` with a bound to `VmTracer` for a specific version.
use zksync_state::WriteStorage;
use zksync_state::{ImmutableStorageView, WriteStorage};

use crate::{tracers::old_tracers::OldTracers, HistoryMode};

Expand All @@ -44,6 +44,7 @@ pub trait MultiVMTracer<S: WriteStorage, H: HistoryMode>:
+ IntoVm1_4_1IntegrationTracer<S, H>
+ IntoVm1_4_2IntegrationTracer<S, H>
+ IntoOldVmTracer
+ IntoEraVmTracer<S, H>
{
fn into_tracer_pointer(self) -> MultiVmTracerPointer<S, H>
where
Expand All @@ -57,6 +58,10 @@ pub trait IntoLatestTracer<S: WriteStorage, H: HistoryMode> {
fn latest(&self) -> crate::vm_latest::TracerPointer<S, H::Vm1_5_0>;
}

pub trait IntoEraVmTracer<S: WriteStorage, H: HistoryMode> {
fn era_vm(&self) -> Box<dyn crate::era_vm::tracers::traits::VmTracer<S>>;
}

pub trait IntoVmVirtualBlocksTracer<S: WriteStorage, H: HistoryMode> {
fn vm_virtual_blocks(
&self,
Expand Down Expand Up @@ -106,6 +111,17 @@ where
}
}

impl<S, T, H> IntoEraVmTracer<S, H> for T
where
S: WriteStorage,
H: HistoryMode,
T: crate::era_vm::tracers::traits::VmTracer<S> + Clone + 'static,
{
fn era_vm(&self) -> Box<dyn crate::era_vm::tracers::traits::VmTracer<S>> {
Box::new(self.clone())
}
}

impl<S, T, H> IntoVmVirtualBlocksTracer<S, H> for T
where
S: WriteStorage,
Expand Down Expand Up @@ -180,6 +196,7 @@ where
+ IntoVmBoojumIntegrationTracer<S, H>
+ IntoVm1_4_1IntegrationTracer<S, H>
+ IntoVm1_4_2IntegrationTracer<S, H>
+ IntoOldVmTracer,
+ IntoOldVmTracer
+ IntoEraVmTracer<S, H>,
{
}
12 changes: 10 additions & 2 deletions core/lib/multivm/src/tracers/multivm_dispatcher.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use zksync_state::WriteStorage;
use zksync_state::{ImmutableStorageView, StorageView, WriteStorage};

use crate::{tracers::old_tracers, HistoryMode, MultiVmTracerPointer};
use crate::{tracers::old_tracers, HistoryMode, MultiVMTracer, MultiVmTracerPointer};

/// Tracer dispatcher is a tracer that can dispatch calls to multiple tracers.
pub struct TracerDispatcher<S, H> {
Expand Down Expand Up @@ -37,6 +37,14 @@ impl<S: WriteStorage, H: HistoryMode> From<TracerDispatcher<S, H>>
}
}

impl<S: WriteStorage, H: HistoryMode> From<TracerDispatcher<S, H>>
for crate::era_vm::tracers::dispatcher::TracerDispatcher<S>
{
fn from(value: TracerDispatcher<S, H>) -> Self {
Self::new(value.tracers.into_iter().map(|x| x.era_vm()).collect())
}
}

impl<S: WriteStorage, H: HistoryMode> From<TracerDispatcher<S, H>>
for crate::vm_boojum_integration::TracerDispatcher<S, H::VmBoojumIntegration>
{
Expand Down
22 changes: 22 additions & 0 deletions core/lib/multivm/src/tracers/storage_invocation/era_vm/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use era_vm::{
opcode::{RetOpcode, Variant},
value::FatPointer,
Execution, Opcode,
};
use zksync_state::ReadStorage;
use zksync_types::{
vm_trace::{Call, CallType},
zk_evm_types::FarCallOpcode,
CONTRACT_DEPLOYER_ADDRESS, U256,
};

use super::StorageInvocations;
use crate::{
era_vm::tracers::traits::{Tracer, VmTracer},
interface::VmRevertReason,
};

//TODO: Implement the Tracer trait for StorageInvocations
impl Tracer for StorageInvocations {}

impl<S: ReadStorage> VmTracer<S> for StorageInvocations {}
1 change: 1 addition & 0 deletions core/lib/multivm/src/tracers/storage_invocation/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{glue::tracers::IntoOldVmTracer, tracers::old_tracers::OldTracers};

pub mod era_vm;
pub mod vm_1_4_1;
pub mod vm_1_4_2;
pub mod vm_boojum_integration;
Expand Down
22 changes: 22 additions & 0 deletions core/lib/multivm/src/tracers/validator/era_vm/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use era_vm::{
opcode::{RetOpcode, Variant},
value::FatPointer,
Execution, Opcode,
};
use zksync_state::ReadStorage;
use zksync_types::{
vm_trace::{Call, CallType},
zk_evm_types::FarCallOpcode,
CONTRACT_DEPLOYER_ADDRESS, U256,
};

use super::ValidationTracer;
use crate::{
era_vm::tracers::traits::{Tracer, VmTracer},
interface::VmRevertReason,
};

//TODO: Implement the Tracer trait for ValidationTracer
impl<H> Tracer for ValidationTracer<H> {}

impl<S: ReadStorage, H> VmTracer<S> for ValidationTracer<H> {}
1 change: 1 addition & 0 deletions core/lib/multivm/src/tracers/validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::{
tracers::validator::types::{NewTrustedValidationItems, ValidationTracerMode},
};

mod era_vm;
mod types;
mod vm_1_4_1;
mod vm_1_4_2;
Expand Down
2 changes: 1 addition & 1 deletion core/lib/multivm/src/versions/era_vm/tracers/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl<S: ReadStorage> Tracer for VmTracerManager<S> {
}
}

impl<S: ReadStorage + 'static> VmTracer<S> for VmTracerManager<S> {
impl<S: ReadStorage> VmTracer<S> for VmTracerManager<S> {
fn before_bootloader_execution(&mut self, state: &mut Vm<S>) {
// Call the dispatcher to handle all the tracers added to it
self.dispatcher.before_bootloader_execution(state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl PubdataTracer {
fn get_storage_diff<S: ReadStorage>(&mut self, vm: &mut Vm<S>) -> Vec<StateDiffRecord> {
vm.inner
.state
.get_storage_changes()
.get_storage_changes(&mut vm.world)
.iter()
.filter_map(|(storage_key, initial_value, value)| {
let address = storage_key.address;
Expand Down Expand Up @@ -95,7 +95,7 @@ impl PubdataTracer {

impl Tracer for PubdataTracer {}

impl<S: ReadStorage + 'static> VmTracer<S> for PubdataTracer {
impl<S: ReadStorage> VmTracer<S> for PubdataTracer {
fn before_bootloader_execution(&mut self, vm: &mut super::traits::Vm<S>) {
self.pubdata_before_run = vm.inner.state.pubdata();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Into<Refunds> for RefundsTracer {

impl Tracer for RefundsTracer {}

impl<S: ReadStorage + 'static> VmTracer<S> for RefundsTracer {
impl<S: ReadStorage> VmTracer<S> for RefundsTracer {
fn before_bootloader_execution(&mut self, vm: &mut super::traits::Vm<S>) {
self.pubdata_before = vm.inner.state.pubdata() as u32;
}
Expand Down
4 changes: 2 additions & 2 deletions core/lib/multivm/src/versions/era_vm/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ impl<S: ReadStorage> Vm<S> {
}
}

impl<S: ReadStorage + 'static> Vm<S> {
impl<S: ReadStorage> Vm<S> {
pub fn inspect_inner(
&mut self,
tracer: TracerDispatcher<S>,
Expand Down Expand Up @@ -502,7 +502,7 @@ impl<S: ReadStorage + 'static> Vm<S> {
}
}

impl<S: ReadStorage + 'static> VmInterface for Vm<S> {
impl<S: ReadStorage> VmInterface for Vm<S> {
type TracerDispatcher = TracerDispatcher<S>;

fn push_transaction(&mut self, tx: Transaction) {
Expand Down
6 changes: 4 additions & 2 deletions core/lib/multivm/src/vm_instance.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::{cell::RefCell, rc::Rc};

use zksync_state::{ImmutableStorageView, ReadStorage, StoragePtr, StorageView};
use zksync_types::vm::{FastVmMode, VmVersion};
use zksync_utils::bytecode::CompressedBytecodeInfo;
Expand Down Expand Up @@ -263,8 +265,8 @@ impl<S: ReadStorage, H: HistoryMode> VmInstance<S, H> {
VmVersion::Vm1_5_0IncreasedBootloaderMemory => match mode {
FastVmMode::Old => Self::new(l1_batch_env, system_env, storage_view),
FastVmMode::New => {
// let storage = ImmutableStorageView::new(storage_view);
// Self::VmFast(crate::vm_fast::Vm::new(l1_batch_env, system_env, storage))
//let storage = ImmutableStorageView::new(storage_view);
//Self::VmFast(crate::vm_fast::Vm::new(l1_batch_env, system_env, storage))

Self::LambdaVm(crate::era_vm::vm::Vm::new(
l1_batch_env,
Expand Down

0 comments on commit 593c7ea

Please sign in to comment.