Skip to content
Open
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 .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHANGELOG.md merge=union
1 change: 0 additions & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ jobs:
auto-push: true
alert-threshold: '130%'
comment-on-alert: true
alert-comment-cc-users: '@unbalancedparentheses'
- name: Clean benches
run: make clean
42 changes: 25 additions & 17 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ env:
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
cairo_programs/cairo-1-programs/bitwise.sierra
tests_cairo/**/*.json
TEST_COLLECT_COVERAGE: 1
PROPTEST_CASES: 100

Expand Down Expand Up @@ -48,6 +49,7 @@ jobs:
- cairo_test_programs
- cairo_1_test_contracts
- cairo_2_test_contracts
- tests_cairo_programs
name: Build Cairo programs
runs-on: ubuntu-24.04
steps:
Expand All @@ -66,7 +68,7 @@ jobs:
id: cache-programs
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}

# This is not pretty, but we need `make` to see the compiled programs are
# actually newer than the sources, otherwise it will try to rebuild them
Expand Down Expand Up @@ -120,37 +122,43 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true
- name: Fetch proof programs
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true
- name: Fetch bench programs
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_bench_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: cairo_bench_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true
- name: Fetch test contracts (Cairo 1)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_1_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: cairo_1_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true
- name: Fetch test contracts (Cairo 2)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_2_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: cairo_2_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true
- name: Fetch tests_cairo programs
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: tests_cairo_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true
- name: Merge caches
uses: actions/cache/save@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}

lint:
needs: merge-caches
Expand Down Expand Up @@ -179,7 +187,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

- name: Run clippy
Expand Down Expand Up @@ -229,7 +237,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

# NOTE: we do this separately because --workspace operates in weird ways
Expand Down Expand Up @@ -274,7 +282,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

- name: Check all features (workspace)
Expand Down Expand Up @@ -309,7 +317,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

- name: Install testing tools
Expand Down Expand Up @@ -390,7 +398,7 @@ jobs:
cairo_programs/**/*.air_public_input
cairo_programs/**/*.air_private_input
cairo_programs/**/*.pie.zip
key: ${{ matrix.program-target }}-reference-trace-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: ${{ matrix.program-target }}-reference-trace-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}

- name: Install uv
if: steps.trace-cache.outputs.cache-hit != 'true'
Expand All @@ -409,7 +417,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

# This is not pretty, but we need `make` to see the compiled programs are
Expand Down Expand Up @@ -456,7 +464,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

- name: Generate traces
Expand Down Expand Up @@ -615,7 +623,7 @@ jobs:
cairo_programs/**/*.air_public_input
cairo_programs/**/*.air_private_input
cairo_programs/**/*.pie.zip
key: ${{ matrix.program-target }}-reference-trace-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: ${{ matrix.program-target }}-reference-trace-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

- name: Fetch traces for cairo-vm
Expand Down Expand Up @@ -675,7 +683,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

- name: Run script
Expand Down Expand Up @@ -715,7 +723,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'tests_cairo/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

- name: Fetch pie
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,21 @@ Both branches support Stwo prover opcodes (Blake2s, QM31) since v2.0.0.

#### Upcoming Changes

* Add Stwo cairo runner API [#2351](https://github.com/lambdaclass/cairo-vm/pull/2351)

* Add union merge strategy for CHANGELOG.md [#2345](https://github.com/lambdaclass/cairo-vm/pull/2345)

* fix: Fix off-by-one comparisons in `split_int`, `assert_250_bit`, and `sqrt` hints [#2348](https://github.com/lambdaclass/cairo-vm/pull/2348)

* chore: Add `CairoFunctionRunner` for running Cairo entrypoints by name or PC, and broaden `CairoArg`/`MaybeRelocatable` conversions to support primitive signed/unsigned integers and big integers [#2352](https://github.com/lambdaclass/cairo-vm/pull/2352)

* chore: Add unit tests for `CairoFunctionRunner`, `CairoArg` conversions/macros, and `MaybeRelocatable` conversion macro coverage [#2354](https://github.com/lambdaclass/cairo-vm/pull/2354)

* test: Add `tests_cairo` utilities and a math Cairo test suite, including `assert_mr_eq!` and structured error helpers [#2353](https://github.com/lambdaclass/cairo-vm/pull/2353)

* chore: Add `math_cmp_test` for Cairo file `math_cmp` and add `sub_mod_prime` function to `math_test_utils` [#2355](https://github.com/lambdaclass/cairo-vm/pull/2355)


#### [3.2.0] - 2026-3-3

* fix: Change extended_resource_counter entry from u32 to usize [#2349](https://github.com/lambdaclass/cairo-vm/pull/2349)
Expand Down
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ UNAME := $(shell uname)
hyper-threading-benchmarks \
cairo_bench_programs cairo_proof_programs cairo_test_programs cairo_1_test_contracts cairo_2_test_contracts \
cairo_trace cairo-vm_trace cairo_proof_trace cairo-vm_proof_trace python-deps python-deps-macos \
build-cairo-lang hint-accountant \ create-proof-programs-symlinks \
build-cairo-lang hint-accountant \ create-proof-programs-symlinks tests_cairo_programs \
$(RELBIN) $(DBGBIN)

# Proof mode consumes too much memory with cairo-lang to execute
Expand Down Expand Up @@ -268,6 +268,21 @@ run:
check:
cargo check

# ======================
# Tests Cairo Programs
# ======================

TESTS_CAIRO_DIR=tests_cairo
TESTS_CAIRO_FILES:=$(shell find $(TESTS_CAIRO_DIR) -name "*.cairo")
COMPILED_TESTS_CAIRO:=$(patsubst %.cairo, %.json, $(TESTS_CAIRO_FILES))

$(TESTS_CAIRO_DIR)/%.json: $(TESTS_CAIRO_DIR)/%.cairo
. cairo-vm-env/bin/activate && cairo-compile \
--cairo_path="$(TESTS_CAIRO_DIR)" \
$< --output $@

tests_cairo_programs: $(COMPILED_TESTS_CAIRO)

cairo_test_programs: $(COMPILED_TESTS) $(COMPILED_BAD_TESTS) $(COMPILED_NORETROCOMPAT_TESTS) $(COMPILED_PRINT_TESTS) $(COMPILED_MOD_BUILTIN_TESTS) $(COMPILED_SECP_CAIRO0_HINTS) $(COMPILED_KZG_DA_CAIRO0_HINTS) $(COMPILED_SEGMENT_ARENA_CAIRO0_HINTS)
cairo_proof_programs: $(COMPILED_PROOF_TESTS) $(COMPILED_MOD_BUILTIN_PROOF_TESTS) $(COMPILED_STWO_EXCLUSIVE_TESTS)
cairo_bench_programs: $(COMPILED_BENCHES)
Expand All @@ -286,7 +301,7 @@ ifdef TEST_COLLECT_COVERAGE
TEST_COMMAND:=cargo llvm-cov nextest --no-report
endif

test: cairo_proof_programs cairo_test_programs cairo_1_test_contracts cairo_2_test_contracts cairo_1_program
test: cairo_proof_programs cairo_test_programs cairo_1_test_contracts cairo_2_test_contracts cairo_1_program tests_cairo_programs
$(TEST_COMMAND) --workspace --features "test_utils, cairo-1-hints"
test-extensive_hints: cairo_proof_programs cairo_test_programs cairo_1_test_contracts cairo_1_program cairo_2_test_contracts
$(TEST_COMMAND) --workspace --features "test_utils, cairo-1-hints, cairo-0-secp-hints, cairo-0-data-availability-hints, extensive_hints"
Expand Down
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,6 @@ When running a Cairo program directly using the Cairo-vm repository you would fi
cairo_runner.initialize_segments(None);
```

When using cairo-vm with the Starknet devnet there are additional parameters that are part of the OS context passed on to the `run_from_entrypoint` method that we do not have here when using it directly. These parameters are, for example, initial stacks of the builtins, which are the base of each of them and are needed as they are the implicit arguments of the function.

```rust
let _var = cairo_runner.run_from_entrypoint(
entrypoint,
vec![
&MaybeRelocatable::from(2).into(), //this is the entry point selector
&MaybeRelocatable::from((2,0)).into() //this would be the output_ptr for example if our cairo function uses it
],
false,
&mut hint_processor,
);
```
### Running cairo 1 programs

To run a cairo 1 program enter in the folder `cd cairo1-run` and follow the [`cairo1-run documentation`](cairo1-run/README.md)
Expand Down
Loading