Skip to content

Commit 63b4a55

Browse files
Add Debug scripts (#1839)
* Add debug scripts * Add debugging document * Add changelog * Revert changelog * Improve script usage code blocks * Remove extra space
1 parent 5f8a011 commit 63b4a55

File tree

6 files changed

+53
-0
lines changed

6 files changed

+53
-0
lines changed

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
* [How to run a cairo program with custom hints](./hint_processor/builtin_hint_processor)
66
* [References parsing](./references_parsing/)
77
* [Tracer](./tracer/)
8+
* [Debugging](./debugging.md)

docs/debugging.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Debugging
2+
3+
## Comparing with Cairo-Lang
4+
5+
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.
6+
7+
No output when running a differ script implies that there are no differences.
8+
9+
To compare the public inputs, run:
10+
```bash
11+
scripts/air_public_inputs_differ.bash <AIR-PUBLIC-INPUTS-1> <AIR-PUBLIC-INPUTS-2>
12+
```
13+
14+
To compare the private inputs, run:
15+
```bash
16+
scripts/air_private_inputs_differ.bash <AIR-PRIVATE-INPUTS-1> <AIR-PRIVATE-INPUTS-2>
17+
```
18+
19+
If you just want to visualize the memory, run:
20+
```bash
21+
scripts/memory_viewer.bash <MEMORY-FILE>
22+
```
23+
It will output the memory in two columns: address and value
24+
25+
26+
To compare the memory, run:
27+
```bash
28+
scripts/memory_differ.bash <TRACE-1> <TRACE-2>
29+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
delta \
4+
<(jq -S 'del(.memory_path,.trace_path)' "$1") \
5+
<(jq -S 'del(.memory_path,.trace_path)' "$2") \
6+
-s
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
delta \
4+
<(jq -S . "$1") \
5+
<(jq -S . "$2") \
6+
-s

scripts/memory_differ.bash

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
delta \
4+
<(hexdump -e '1/8 "%u " 4/8 "%x " "\n"' "$1" | sort -n) \
5+
<(hexdump -e '1/8 "%u " 4/8 "%x " "\n"' "$2" | sort -n) \
6+
-s

scripts/memory_viewer.bash

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
#
3+
# outputs memory file in "ADDR VALUE" format, on cell per line
4+
5+
hexdump -e '1/8 "%10u " 4/8 "%x " "\n"' "$1" | sort -n

0 commit comments

Comments
 (0)