Skip to content

Commit

Permalink
feat(vm): Do not panic on VM divergence (#2705)
Browse files Browse the repository at this point in the history
## What ❔

- Allows to continue batch execution on divergence via new
`ShadowLenient` VM mode.
- Dumps VM state to logs and optionally a file on divergence.

## Why ❔

Allows to detect divergencies in multiple batches w/o blockers. The
dumped VM state will hopefully allow investigating divergencies locally,
although this logic isn't implemented yet.

## Checklist

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [x] Tests for the changes have been added / updated.
- [x] Documentation comments have been added / updated.
- [x] Code has been formatted via `zk fmt` and `zk lint`.
  • Loading branch information
slowli authored Sep 20, 2024
1 parent e9d1d90 commit 7aa5721
Show file tree
Hide file tree
Showing 42 changed files with 1,398 additions and 513 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion core/lib/basic_types/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ pub enum FastVmMode {
/// Run only the old VM.
#[default]
Old,
/// Run only the new Vm.
/// Run only the new VM.
New,
/// Run both the new and old VM and compare their outputs for each transaction execution.
/// The VM will panic on divergence.
Shadow,
}
2 changes: 1 addition & 1 deletion core/lib/multivm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ anyhow.workspace = true
hex.workspace = true
itertools.workspace = true
once_cell.workspace = true
pretty_assertions.workspace = true
thiserror.workspace = true
tracing.workspace = true
vise.workspace = true

[dev-dependencies]
assert_matches.workspace = true
pretty_assertions.workspace = true
tokio = { workspace = true, features = ["time"] }
zksync_test_account.workspace = true
ethabi.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion core/lib/multivm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ pub use crate::{
mod glue;
pub mod tracers;
pub mod utils;
pub mod versions;
mod versions;
mod vm_instance;
5 changes: 4 additions & 1 deletion core/lib/multivm/src/versions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
pub mod shadow;
mod shared;
#[cfg(test)]
mod testonly;
#[cfg(test)]
mod tests;
pub mod vm_1_3_2;
pub mod vm_1_4_1;
pub mod vm_1_4_2;
Expand Down
305 changes: 0 additions & 305 deletions core/lib/multivm/src/versions/shadow.rs

This file was deleted.

Loading

0 comments on commit 7aa5721

Please sign in to comment.