diff --git a/docs/README.md b/docs/README.md index f25a1c762a..5d70a46fea 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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) diff --git a/docs/debugging.md b/docs/debugging.md new file mode 100644 index 0000000000..246f873c04 --- /dev/null +++ b/docs/debugging.md @@ -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 +``` + +To compare the private inputs, run: +```bash +scripts/air_private_inputs_differ.bash +``` + +If you just want to visualize the memory, run: +```bash +scripts/memory_viewer.bash +``` +It will output the memory in two columns: address and value + + +To compare the memory, run: +```bash +scripts/memory_differ.bash +``` diff --git a/scripts/air_private_inputs_differ.bash b/scripts/air_private_inputs_differ.bash new file mode 100755 index 0000000000..8ce3a0215c --- /dev/null +++ b/scripts/air_private_inputs_differ.bash @@ -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 diff --git a/scripts/air_public_inputs_differ.bash b/scripts/air_public_inputs_differ.bash new file mode 100755 index 0000000000..84637c350f --- /dev/null +++ b/scripts/air_public_inputs_differ.bash @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +delta \ + <(jq -S . "$1") \ + <(jq -S . "$2") \ + -s diff --git a/scripts/memory_differ.bash b/scripts/memory_differ.bash new file mode 100755 index 0000000000..b5c0f2649c --- /dev/null +++ b/scripts/memory_differ.bash @@ -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 diff --git a/scripts/memory_viewer.bash b/scripts/memory_viewer.bash new file mode 100755 index 0000000000..a6e74032f2 --- /dev/null +++ b/scripts/memory_viewer.bash @@ -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