Skip to content

Commit

Permalink
change bechmarks to proof mode
Browse files Browse the repository at this point in the history
  • Loading branch information
StringNick committed Jun 27, 2024
1 parent e424685 commit 22b71de
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions scripts/benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ for file in $(ls ${BENCH_DIR} | grep .cairo | sed -E 's/\.cairo//'); do
cairo-compile --cairo_path="${CAIRO_DIR}:../${CAIRO_DIR}" ${BENCH_DIR}/${file}.cairo --output ${BENCH_DIR}/${file}.json --proof_mode
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 --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 --layout all_cairo"
-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"
done
4 changes: 2 additions & 2 deletions scripts/test_compare_output.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ for file in $(ls ${CAIRO_PROGRAMS_DIR} | grep .cairo | sed -E 's/\.cairo//'); do
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 --layout all_cairo
${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 --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

if sameContents $RUST_TRACE_OUTPUT $ZIG_TRACE_OUTPUT; then
echo "Rust & Zig output trace is same"
Expand Down
12 changes: 9 additions & 3 deletions src/vm/cairo_run.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const std = @import("std");
const json = std.json;
const Allocator = std.mem.Allocator;

const security = @import("security.zig");
const CairoRunner = @import("./runners/cairo_runner.zig").CairoRunner;
const CairoVM = @import("./core.zig").CairoVM;
const Config = @import("./config.zig").Config;
Expand Down Expand Up @@ -88,20 +89,25 @@ pub fn runConfig(allocator: Allocator, config: Config) !void {
// TODO: make flag for extensive_hints
var hint_processor: HintProcessor = .{};
try runner.runUntilPC(end, &hint_processor);

if (config.proof_mode) try runner.runForSteps(1, &hint_processor);

try runner.endRun(
allocator,
false,
false,
&hint_processor,
);

// TODO cairo_runner.vm.verify_auto_deductions()?;
try runner.vm.verifyAutoDeductions(allocator);

// cairo_runner.read_return_values(allow_missing_builtins)?;

if (config.proof_mode)
runner.finalizeSegments();
try runner.finalizeSegments();

if (secure_run) {}
if (secure_run)
try security.verifySecureRunner(allocator, &runner, true, null);

if (config.output_trace != null or config.output_memory != null) {
try runner.relocate();
Expand Down

0 comments on commit 22b71de

Please sign in to comment.