Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
* [How to run a cairo program with custom hints](./hint_processor/builtin_hint_processor)
* [References parsing](./references_parsing/)
* [Tracer](./tracer/)
* [Debugging](./debugging.md)
29 changes: 29 additions & 0 deletions docs/debugging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Debugging

## Comparing with Cairo-Lang

If you executed a Cairo0 proof program with both Rust and Python VM, you can use the following scripts to compare their output. They all require `delta` (modern diff) to be installed. If you don't have you can locally change it.

No output when running a differ script implies that there are no differences.

To compare the public inputs, run:
```bash
scripts/air_public_inputs_differ.bash <AIR-PUBLIC-INPUTS-1> <AIR-PUBLIC-INPUTS-2>
```

To compare the private inputs, run:
```bash
scripts/air_private_inputs_differ.bash <AIR-PRIVATE-INPUTS-1> <AIR-PRIVATE-INPUTS-2>
```

If you just want to visualize the memory, run:
```bash
scripts/memory_viewer.bash <MEMORY-FILE>
```
It will output the memory in two columns: address and value


To compare the memory, run:
```bash
scripts/memory_differ.bash <TRACE-1> <TRACE-2>
```
6 changes: 6 additions & 0 deletions scripts/air_private_inputs_differ.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

delta \
<(jq -S 'del(.memory_path,.trace_path)' "$1") \
<(jq -S 'del(.memory_path,.trace_path)' "$2") \
-s
6 changes: 6 additions & 0 deletions scripts/air_public_inputs_differ.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

delta \
<(jq -S . "$1") \
<(jq -S . "$2") \
-s
6 changes: 6 additions & 0 deletions scripts/memory_differ.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

delta \
<(hexdump -e '1/8 "%u " 4/8 "%x " "\n"' "$1" | sort -n) \
<(hexdump -e '1/8 "%u " 4/8 "%x " "\n"' "$2" | sort -n) \
-s
5 changes: 5 additions & 0 deletions scripts/memory_viewer.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
#
# outputs memory file in "ADDR VALUE" format, on cell per line

hexdump -e '1/8 "%10u " 4/8 "%x " "\n"' "$1" | sort -n
Loading