From 884c2f067db9bf147e00289953496a3db85a104c Mon Sep 17 00:00:00 2001 From: Andrew Milson Date: Mon, 4 Nov 2024 20:17:58 -0500 Subject: [PATCH] Add README for cairo verifier --- stwo_cairo_verifier/README.md | 58 +++++++++++++++++++++++++++++++ stwo_cairo_verifier/src/lib.cairo | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 stwo_cairo_verifier/README.md diff --git a/stwo_cairo_verifier/README.md b/stwo_cairo_verifier/README.md new file mode 100644 index 00000000..922e0b36 --- /dev/null +++ b/stwo_cairo_verifier/README.md @@ -0,0 +1,58 @@ +# Stwo Cairo Verifier + +A [Cairo](https://github.com/starkware-libs/cairo) program that verifies a [Stwo](https://github.com/starkware-libs/stwo) proof. + +## Install dependencies + +[Install asdf](https://asdf-vm.com/guide/getting-started.html#_3-install-asdf) and run: + +```bash +asdf plugin add scarb +asdf plugin add starknet-foundry +asdf install +``` + +## Run tests + +Make sure [dependencies are installed](#install-dependencies). Run: + +```bash +scarb test +``` + +## Profile tests + +Modify [`Scarb.toml`](./Scarb.toml) to use [Starknet Foundary](https://github.com/foundry-rs/starknet-foundry). + +```diff +[dev-dependencies] +- cairo_test = "2.8.0" ++ snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.32.0" } ++ assert_macros = "2.8.0" ++ ++ [scripts] ++ test = "snforge test --max-n-steps 100000000" +``` + +Generate trace for all tests. + + +> :warning: Command produces errors on Linux. + +```bash +scarb test -- --save-trace-data +``` + +Install [cairo-profiler](https://github.com/software-mansion/cairo-profiler) and run: + +```bash +# Replace `TEST_NAME` with the name of the test you want profiled. +cairo-profiler ./snfoundry_trace/TEST_NAME.json +``` + +Visualise profile in the browser. + +```bash +# Once opened navigate to `Sample -> steps`. +go tool pprof -http=":8000" profile.pb.gz +``` diff --git a/stwo_cairo_verifier/src/lib.cairo b/stwo_cairo_verifier/src/lib.cairo index 3dde905b..63cfb0bf 100644 --- a/stwo_cairo_verifier/src/lib.cairo +++ b/stwo_cairo_verifier/src/lib.cairo @@ -17,4 +17,4 @@ fn main() {} pub type ColumnArray = Array; /// An array in which each element relates (by index) to a commitment tree. -pub type TreeArray = Array; \ No newline at end of file +pub type TreeArray = Array;