Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNM] Trace dump & Emu support #62

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions Cargo.lock

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

17 changes: 11 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@ members = ["rpc-state-reader", "replay"]
resolver = "2"

[workspace.dependencies]
thiserror = "1.0.32"
starknet-types-core = "0.1.6"
tracing = "0.1"
serde_json = "1.0.116"
serde_with = "3.11.0"
serde_with = "3.9.0"
serde = "1.0.197"
cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "ae234bac7eb4b7f70715b3832363a843348c6927" }
cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "355c250f37cf0977ef2776b1aae2cb2e87c9da3d" }
# Sequencer Dependencies
starknet_api = { git = "https://github.com/lambdaclass/sequencer", branch = "native2.8.x" }
blockifier = { git = "https://github.com/lambdaclass/sequencer", branch = "native2.8.x" }
starknet_gateway = { git = "https://github.com/lambdaclass/sequencer", branch = "native2.8.x" }
starknet_api = { git = "https://github.com/lambdaclass/sequencer", rev = "f567fcb25680310dbc5528eebd087fe95802975c"}
blockifier = { git = "https://github.com/lambdaclass/sequencer", rev = "f567fcb25680310dbc5528eebd087fe95802975c"}
starknet_gateway = { git = "https://github.com/lambdaclass/sequencer", rev = "f567fcb25680310dbc5528eebd087fe95802975c"}
sierra-emu = { git = "https://github.com/lambdaclass/sierra-emu.git" }

[patch.'https://github.com/lambdaclass/cairo_native']
cairo-native = { git = "https://github.com/lambdaclass//cairo_native.git", rev = "ae234bac7eb4b7f70715b3832363a843348c6927" }
cairo-native = { path = "../cairo_native" }

[patch.'https://github.com/lambdaclass/sierra-emu']
sierra-emu = { path = "../sierra-emu" }
5 changes: 5 additions & 0 deletions replay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ only_cairo_vm = ["rpc-state-reader/only_casm"]
structured_logging = []
state_dump = ["dep:serde", "dep:serde_json", "dep:serde_with", "dep:starknet-types-core"]

# Executes transactions with Sierra Emu instead of Native
use-sierra-emu = ["blockifier/use-sierra-emu"]
# Records execution trace with Native or Sierra Emu
with-trace-dump = ["blockifier/with-trace-dump"]

[dependencies]
# starknet specific crates
blockifier = { workspace = true }
Expand Down
11 changes: 7 additions & 4 deletions replay/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,13 @@ fn show_execution_data(
{
use std::path::Path;

#[cfg(feature = "only_cairo_vm")]
let root = Path::new("state_dumps/vm");
#[cfg(not(feature = "only_cairo_vm"))]
let root = Path::new("state_dumps/native");
let root = if cfg!(feature = "only_cairo_vm") {
Path::new("state_dumps/vm")
} else if cfg!(feature = "use-sierra-emu") {
Path::new("state_dumps/emu")
} else {
Path::new("state_dumps/native")
};
let root = root.join(format!("block{}", block_number));

std::fs::create_dir_all(&root).ok();
Expand Down
26 changes: 26 additions & 0 deletions scripts/cmp_trace_dumps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

index=0
while : ; do
emu_trace="./traces/emu/trace_$index.json"
native_trace="./traces/native/trace_$index.json"

if ! [ -f $emu_trace ] && ! [ -f $native_trace ]; then
exit
fi

if ! [ -f $emu_trace ]; then
echo "missing file: $emu_trace"
exit
fi
if ! [ -f $native_trace ]; then
echo "missing file: $native_trace"
exit
fi

if ! cmp --silent $emu_trace $native_trace; then
echo "difference: $emu_trace $native_trace"
fi

index=$((index+1))
done
7 changes: 7 additions & 0 deletions scripts/delta_trace_dump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

index=$1
emu_trace="./traces/emu/trace_$index.json"
native_trace="./traces/native/trace_$index.json"

delta "$emu_trace" "$native_trace" --side-by-side
Loading