Skip to content

Commit

Permalink
proof mode air input public and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
StringNick committed Jul 9, 2024
1 parent 22b71de commit 4feb465
Show file tree
Hide file tree
Showing 23 changed files with 889 additions and 114 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ Run all benchmarks and compare:
make build-compare-benchmarks
```

Run all programs and compare output memory/trace for Zig/Rust cairo-vm:
```bash
make build-compare-output
```


Run all unit tests with test summary:

Expand Down
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
.hash = "1220ab73fb7cc11b2308edc3364988e05efcddbcac31b707f55e6216d1b9c0da13f1",
},
.starknet = .{
.url = "https://github.com/StringNick/starknet-zig/archive/8cfb4286ffda4ad2781647c3d96b2aec8ccfeb32.zip",
.hash = "122026eaa24834fd2e2cc7e8b6c4eefb03dda08158a2844615f189758fa24d32fc44",
.url = "https://github.com/StringNick/starknet-zig/archive/d9e95579ce9f61a8acf42da03d9371af62925a9e.zip",
.hash = "12205f6b98ed2d3b99420d95f94a28d4e2f25f49001aca5db539d6a23e7b1840710e",
},
},
}
2 changes: 1 addition & 1 deletion scripts/benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ for file in $(ls ${BENCH_DIR} | grep .cairo | sed -E 's/\.cairo//'); do
echo "Running ${file} benchmark"
hyperfine --show-output --warmup 2 \
-n "cairo-vm (Rust)" "${CAIRO_VM_CLI} ${BENCH_DIR}/${file}.json --memory_file /dev/null --trace_file /dev/null --proof_mode --layout all_cairo" \
-n "cairo-vm (Zig)" "${ZIG_CLI} execute --filename ${BENCH_DIR}/${file}.json --enable-trace=true --output-memory=/dev/null --output-trace=/dev/null --proof-mode=true --layout all_cairo"
-n "cairo-vm (Zig)" "${ZIG_CLI} execute --filename ${BENCH_DIR}/${file}.json --memory-file=/dev/null --trace-file=/dev/null --proof-mode=true --layout all_cairo"
done
16 changes: 10 additions & 6 deletions scripts/test_compare_output.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ ZIG_MEMORY_OUTPUT="./tmp/zig_memory.tmp"
RUST_TRACE_OUTPUT="./tmp/rust_trace.tmp"
ZIG_TRACE_OUTPUT="./tmp/zig_trace.tmp"

Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
NC='\033[0m' # No Color

trap ctrl_c INT

ctrl_c() {
Expand All @@ -32,24 +36,24 @@ ctrl_c() {
mkdir tmp

for file in $(ls ${CAIRO_PROGRAMS_DIR} | grep .cairo | sed -E 's/\.cairo//'); do
echo "Compiling ${file} program..."
echo "${NC}Compiling ${file} program..."
cairo-compile --cairo_path="${CAIRO_DIR}:" ${CAIRO_PROGRAMS_DIR}/${file}.cairo --output ${CAIRO_PROGRAMS_DIR}/${file}.json --proof_mode
echo "Running ${file}"

${CAIRO_VM_CLI} ${CAIRO_PROGRAMS_DIR}/${file}.json --memory_file $RUST_MEMORY_OUTPUT --trace_file $RUST_TRACE_OUTPUT --proof_mode --layout all_cairo

${ZIG_CLI} execute --filename ${CAIRO_PROGRAMS_DIR}/${file}.json --enable-trace=true --output-memory=$ZIG_MEMORY_OUTPUT --output-trace=$ZIG_TRACE_OUTPUT --proof-mode=true --layout all_cairo
${ZIG_CLI} execute --filename ${CAIRO_PROGRAMS_DIR}/${file}.json --memory-file=$ZIG_MEMORY_OUTPUT --trace-file=$ZIG_TRACE_OUTPUT --proof-mode=true --layout=all_cairo

if sameContents $RUST_TRACE_OUTPUT $ZIG_TRACE_OUTPUT; then
echo "Rust & Zig output trace is same"
echo "${Green}Rust & Zig output trace is same"
else
echo "Zig have different output trace"
echo "${Red}Zig have different output trace"
fi

if sameContents $RUST_MEMORY_OUTPUT $ZIG_MEMORY_OUTPUT; then
echo "Rust & Zig memory output is same"
echo "${Green}Rust & Zig memory output is same"
else
echo "Zig have different output memory"
echo "${Red}Zig have different output memory"
fi
done

Expand Down
7 changes: 0 additions & 7 deletions src/build_options.zig

This file was deleted.

Loading

0 comments on commit 4feb465

Please sign in to comment.