Skip to content

Commit

Permalink
feat: add Zig cairo vm submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
zmalatrax committed Jun 18, 2024
1 parent 05f3007 commit c0b8dea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
path = cairo-vm
url = [email protected]:lambdaclass/cairo-vm.git
shallow = true
[submodule "ziggy-starkdust"]
path = ziggy-starkdust
url = [email protected]:keep-starknet-strange/ziggy-starkdust.git
20 changes: 17 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
.PHONY: compile run-all diff-test bench build-cairo-vm-rs-cli clean-diff-test clean--bench clean-tmp
.PHONY: compile run-all diff-test bench build-cairo-vm-cli build-cairo-vm-rs-cli build-cairo-vm-zig-cli clean-diff-test clean--bench clean-tmp

# Clone & build the other VMs - Assume that related lang are installed
CAIRO_VM_RS_CLI:=cairo-vm/target/release/cairo-vm-cli
CAIRO_VM_ZIG_CLI:=ziggy-starkdust/zig-out/bin/ziggy-starkdust

$(CAIRO_VM_RS_CLI):
@git submodule init; \
git submodule update; \
cd cairo-vm; cargo build --release --bin cairo-vm-cli

$(CAIRO_VM_ZIG_CLI):
@git submodule init; \
git submodule update; \
cd ziggy-starkdust; zig build

build-cairo-vm-rs-cli: | $(CAIRO_VM_RS_CLI)

build-cairo-vm-zig-cli: | $(CAIRO_VM_ZIG_CLI)

build-cairo-vm-cli: build-cairo-vm-rs-cli build-cairo-vm-zig-cli

TMP_PREFIX="cairo-vm-ts"

CAIRO_0_PATH=cairo_programs/cairo_0
Expand Down Expand Up @@ -61,15 +71,18 @@ diff-test: $(VALID_COMPILED_CAIRO_0_FILES)
ts_memory=$$TMP_DIR/$$(basename $$file .json).ts.memory; \
py_memory=$$TMP_DIR/$$(basename $$file .json).py.memory; \
rs_memory=$$TMP_DIR/$$(basename $$file .json).rs.memory; \
zig_memory=$$TMP_DIR/$$(basename $$file .json).zig.memory; \
ts_trace=$$TMP_DIR/$$(basename $$file .json).ts.trace; \
py_trace=$$TMP_DIR/$$(basename $$file .json).py.trace; \
rs_trace=$$TMP_DIR/$$(basename $$file .json).rs.trace; \
zig_trace=$$TMP_DIR/$$(basename $$file .json).zig.trace; \
cairo run $$file --silent --offset 1 --export-memory $$ts_memory --export-trace $$ts_trace; \
poetry run cairo-run --program $$file --layout starknet_with_keccak --memory_file $$py_memory --trace_file $$py_trace; \
$(CAIRO_VM_RS_CLI) $$file --layout all_cairo --memory_file $$rs_memory --trace_file $$rs_trace; \
compare memory -s $$ts_memory $$rs_memory $$py_memory; \
$(CAIRO_VM_ZIG_CLI) execute --filename $$file --layout all_cairo --enable-trace --output-memory $$zig_memory --output-trace $$zig_trace; \
compare memory -s $$ts_memory $$rs_memory $$py_memory $$zig_memory; \
exit_code_mem=$$?; \
compare trace -s $$ts_trace $$rs_trace $$py_trace; \
compare trace -s $$ts_trace $$rs_trace $$py_trace $$zig_trace; \
exit_code_trace=$$?; \
if [ $$exit_code_mem -ne 0 ] || [ $$exit_code_trace -ne 0 ]; then \
failed_tests_ctr=$$((failed_tests_ctr + 1)); \
Expand All @@ -95,6 +108,7 @@ bench: $(COMPILED_CAIRO_0_BENCHMARK_FILES)
json_output=$$TMP_DIR/$$(basename $$file .json)_bench.json; \
hyperfine --warmup 2 \
"$(CAIRO_VM_RS_CLI) $$file --layout all_cairo" \
"$(CAIRO_VM_ZIG_CLI) execute --filename $$file --layout all_cairo" \
"cairo run $$file" \
"cairo-run --layout starknet_with_keccak --program $$file" \
--export-markdown $$md_output \
Expand Down
1 change: 1 addition & 0 deletions ziggy-starkdust
Submodule ziggy-starkdust added at 628765

0 comments on commit c0b8dea

Please sign in to comment.