|
| 1 | +# cairo_program_runner |
| 2 | + |
| 3 | +Run a compiled Cairo program, optionally produce a Cairo PIE, and (in proof mode) generate AIR public/private inputs plus encoded trace/memory files. |
| 4 | +This runner uses a custom hint processor that supports internal programs used in SHARP, namely bootloaders and cairo verifier hints. |
| 5 | +It also uses the hints implemented in lambda-class's `cairo-vm` repo for hints from the cairo common library. |
| 6 | + |
| 7 | +Entry point: `crates/cairo-program-runner/src/bin/cairo_program_runner/main.rs` |
| 8 | + |
| 9 | +## Build & run |
| 10 | + |
| 11 | +cargo run -p cairo-program-runner --bin cairo_program_runner -- --help |
| 12 | + |
| 13 | +## Basic run (no proof mode) |
| 14 | + |
| 15 | +Runs the program. You may also dump: |
| 16 | + |
| 17 | +- program outputs (`--outputs_file`) |
| 18 | +- execution resources (`--execution_resources_file`) |
| 19 | +- Cairo PIE (`--cairo_pie_output`) |
| 20 | + |
| 21 | +Example: |
| 22 | +cargo run -p cairo-program-runner --bin cairo_program_runner -- \ |
| 23 | + --program path/to/compiled_program.json \ |
| 24 | + --program_input path/to/program_input.json \ |
| 25 | + --layout plain \ |
| 26 | + --outputs_file outputs.json \ |
| 27 | + --execution_resources_file execution_resources.json |
| 28 | + |
| 29 | +- The options for `--layout` are: `plain`, `small`, `dex`, `recursive`, `starknet`, `starknet_with_keccak`, `recursive_large_output`, `recursive_with_poseidon`, `all_solidity`, `all_cairo`, `dynamic`, `all_cairo_stwo`, `perpetual`, `dex_with_bitwise`. See the `LayoutName` enum definition in `cairo-vm`. |
| 30 | + |
| 31 | +### Cairo PIE output |
| 32 | + |
| 33 | +Write a Cairo PIE zip file: |
| 34 | +cargo run -p cairo-program-runner --bin cairo_program_runner -- \ |
| 35 | + --program path/to/compiled_program.json \ |
| 36 | + --program_input path/to/program_input.json \ |
| 37 | + --layout plain \ |
| 38 | + --cairo_pie_output run.pie.zip |
| 39 | + |
| 40 | +Optional: |
| 41 | + |
| 42 | +- `--merge_extra_segments`: merge extra memory segments before creating the PIE. |
| 43 | + |
| 44 | +Note: `--cairo_pie_output` cannot be used with `--proof_mode`. |
| 45 | + |
| 46 | +## Proof mode |
| 47 | + |
| 48 | +Proof mode enables generation of AIR inputs and encoded trace/memory. |
| 49 | + |
| 50 | +Required flags (must be provided together): |
| 51 | + |
| 52 | +- `--proof_mode` |
| 53 | +- `--air_public_input <PATH>` |
| 54 | +- `--air_private_input <PATH>` |
| 55 | + |
| 56 | +Optional outputs: |
| 57 | + |
| 58 | +- `--trace_file <PATH>` (if omitted, a temp file is created) |
| 59 | +- `--memory_file <PATH>` (if omitted, a temp file is created) |
| 60 | + |
| 61 | +Example: |
| 62 | +cargo run -p cairo-program-runner --bin cairo_program_runner -- \ |
| 63 | + --program path/to/compiled_program.json \ |
| 64 | + --program_input path/to/program_input.json \ |
| 65 | + --layout plain \ |
| 66 | + --proof_mode \ |
| 67 | + --air_public_input air_public_input.json \ |
| 68 | + --air_private_input air_private_input.json \ |
| 69 | + --trace_file trace.bin \ |
| 70 | + --memory_file memory.bin |
| 71 | + |
| 72 | +## Flag notes |
| 73 | + |
| 74 | +- `--disable_trace_padding`: disables padding the trace at end of run. Requires `--proof_mode`. |
| 75 | +- `--relocate_mem [true|false]` (default: `true`): only applies in proof mode; set `false` if relocation will be done later (e.g., by an adapter). |
| 76 | +- `--allow_missing_builtins[=true|false]`: boolean flag with optional value. Allows running programs that reference builtins not present in the layout (will fail if the run actually uses them). |
| 77 | + - default: `false` |
| 78 | + - `--allow_missing_builtins` (without value) sets it to `true` |
| 79 | + - accepts `true/false/1/0` |
| 80 | +- `--dynamic_params_file`: required only when `--layout dynamic`. This is the path to the dynamic layout parameters JSON file. |
| 81 | + |
| 82 | +## Outputs |
| 83 | + |
| 84 | +- `--outputs_file`: JSON array of output segment felts (parsed from VM output as decimal felts). |
| 85 | +- `--execution_resources_file`: JSON-serialized execution resources. |
| 86 | +- `--cairo_pie_output`: Cairo PIE zip file (non-proof mode only). |
| 87 | +- `--air_public_input`: AIR public input JSON (proof mode only). |
| 88 | +- `--air_private_input`: AIR private input JSON referencing trace/memory file paths (proof mode only). |
| 89 | +- `--trace_file` / `--memory_file`: encoded (binary) trace/memory. |
| 90 | + |
| 91 | +## Notes |
| 92 | + |
| 93 | +If `--trace_file` / `--memory_file` are not provided in proof mode, temporary files are created and kept on disk, and their paths are embedded into the AIR private input. |
0 commit comments