Skip to content

Commit

Permalink
Merge branch 'main' into fuzz-cairo-compiled-programs
Browse files Browse the repository at this point in the history
  • Loading branch information
pefontana authored Jul 24, 2023
2 parents d33f6ef + b232d69 commit 8f75685
Show file tree
Hide file tree
Showing 11 changed files with 516 additions and 469 deletions.
213 changes: 93 additions & 120 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,24 @@ on:

env:
CARGO_TERM_COLOR: always
CAIRO_PROGRAMS_PATH: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
jobs:
build-programs:
strategy:
matrix:
# NOTE: we build cairo_proof_programs so clippy can check the benchmarks too
program-target: [ cairo_bench_programs, cairo_proof_programs, cairo_test_programs, cairo_1_test_contracts ]
program-target: [
cairo_bench_programs,
cairo_proof_programs,
cairo_test_programs,
cairo_1_test_contracts,
cairo_2_test_contracts,
]
name: Build Cairo programs
runs-on: ubuntu-22.04
steps:
Expand All @@ -28,11 +39,7 @@ jobs:
uses: actions/cache@v3
id: cache-programs
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
restore-keys: ${{ matrix.program-target }}-cache-

Expand All @@ -42,85 +49,110 @@ jobs:
uses: chetan/git-restore-mtime-action@v1

- name: Python3 Build
if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }}
if: steps.cache-programs.outputs.cache-hit != 'true' && matrix.program-target != 'cairo_1_test_contracts'
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'

- name: Install cairo-lang and deps
if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }}
if: |
steps.cache-programs.outputs.cache-hit != 'true'
&& matrix.program-target != 'cairo_1_test_contracts'
&& matrix.program-target != 'cairo_2_test_contracts'
run: pip install -r requirements.txt

- name: Install cairo 1 compiler
if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }}
if: steps.cache-programs.outputs.cache-hit != 'true' && matrix.program-target == 'cairo_1_test_contracts'
run: make build-cairo-1-compiler

- name: Install cairo 2 compiler
if: steps.cache-programs.outputs.cache-hit != 'true' && matrix.program-target == 'cairo_2_test_contracts'
run: make build-cairo-2-compiler

- name: Build programs
if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }}
if: steps.cache-programs.outputs.cache-hit != 'true'
run: make -j ${{ matrix.program-target }}


lint:
needs: build-programs
name: Run Lints
# NOTE: used to reduce the amount of cache steps we need in later jobs
# TODO: remove this cache once the workflow finishes
merge-caches:
name: Merge Cairo programs cache
runs-on: ubuntu-22.04
needs: build-programs
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@1.69.0
with:
components: rustfmt, clippy
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
- name: Checkout
uses: actions/checkout@v3

- name: Format
run: make check-fmt

- name: Fetch test programs
uses: actions/cache/restore@v3
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
fail-on-cache-miss: true
- name: Fetch proof programs
uses: actions/cache/restore@v3
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
fail-on-cache-miss: true
- name: Fetch bench programs
uses: actions/cache/restore@v3
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_bench_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
- name: Fetch test contracts
fail-on-cache-miss: true
- name: Fetch test contracts (Cairo 1)
uses: actions/cache/restore@v3
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_1_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
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', 'examples/wasm-demo/src/array_sum.cairo') }}
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', 'examples/wasm-demo/src/array_sum.cairo') }}

lint:
needs: build-programs
name: Run Lints
runs-on: ubuntu-22.04
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@1.69.0
with:
components: rustfmt, clippy
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
- name: Checkout
uses: actions/checkout@v3

- name: Format
run: make check-fmt

- name: Fetch programs
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
fail-on-cache-miss: true

- name: Run clippy
run: make clippy


# NOTE: the term "smoke test" comes from electronics design: the minimal
# expectations anyone has in their device is to not catch fire on boot.
smoke:
needs: build-programs
needs: merge-caches
name: Make sure all builds work
runs-on: ubuntu-22.04
steps:
Expand All @@ -141,42 +173,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Fetch test programs
uses: actions/cache/restore@v3
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
- name: Fetch proof programs
uses: actions/cache/restore@v3
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
- name: Fetch bench programs
uses: actions/cache/restore@v3
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
key: cairo_bench_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
- name: Fetch test contracts
- name: Fetch programs
uses: actions/cache/restore@v3
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
key: cairo_1_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
fail-on-cache-miss: true

# NOTE: we do this separately because --workspace operates in weird ways
- name: Check all features (felt)
Expand Down Expand Up @@ -206,7 +208,7 @@ jobs:
cargo check
tests:
needs: build-programs
needs: merge-caches
strategy:
fail-fast: false
matrix:
Expand All @@ -224,33 +226,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Fetch test programs
uses: actions/cache/restore@v3
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
- name: Fetch proof programs
uses: actions/cache/restore@v3
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
- name: Fetch test contracts
- name: Fetch programs
uses: actions/cache/restore@v3
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
key: cairo_1_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
fail-on-cache-miss: true

- name: Install testing tools
uses: taiki-e/install-action@v2
Expand Down Expand Up @@ -287,7 +268,6 @@ jobs:
path: lcov-${{ matrix.target }}-${{ matrix.special_features }}.info
key: codecov-cache-${{ matrix.target }}-${{ matrix.special_features }}-${{ github.sha }}


build-release:
name: Build release binary for comparisons
runs-on: ubuntu-22.04
Expand All @@ -307,7 +287,6 @@ jobs:
key: cli-bin-rel-${{ github.sha }}
path: target/release/cairo-vm-cli


run-cairo-reference:
strategy:
matrix:
Expand Down Expand Up @@ -343,29 +322,27 @@ jobs:
with:
python-version: '3.9'
cache: 'pip'

- name: Install cairo-lang and deps
if: steps.trace-cache.outputs.cache-hit != 'true'
run: pip install -r requirements.txt

- name: Fetch programs
if: ${{ steps.trace-cache.outputs.cache-hit != 'true' }}
if: steps.trace-cache.outputs.cache-hit != 'true'
uses: actions/cache/restore@v3
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
fail-on-cache-miss: true

# 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
- name: Restore timestamps
if: steps.trace-cache.outputs.cache-hit != 'true'
uses: chetan/git-restore-mtime-action@v1

- name: Generate traces
if: ${{ steps.trace-cache.outputs.cache-hit != 'true' }}
if: steps.trace-cache.outputs.cache-hit != 'true'
run: make -j ${{ matrix.nprocs }} ${{ matrix.trace-target }}


Expand Down Expand Up @@ -396,11 +373,7 @@ jobs:
- name: Fetch programs
uses: actions/cache/restore@v3
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
examples/wasm-demo/src/array_sum.json
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
fail-on-cache-miss: true

Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ bench/results
.python-version
cairo-vm-env/*
cairo-vm-pypy-env/*
cairo/
/cairo1/
/cairo2/
*.tar

ensure-no_std/Cargo.lock
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* fix: return error when a parsed hint's PC is invalid [#1340](https://github.com/lambdaclass/cairo-vm/pull/1340)

* chore(deps): bump _cairo-lang_ dependencies to v2.1.0-rc1 [#1339](https://github.com/lambdaclass/cairo-vm/pull/1339)

* chore(examples): remove _wee_alloc_ dependency from _wasm-demo_ example and _ensure-no_std_ dummy crate [#1337](https://github.com/lambdaclass/cairo-vm/pull/1337)

* docs: improved crate documentation [#1334](https://github.com/lambdaclass/cairo-vm/pull/1334)
Expand Down
Loading

0 comments on commit 8f75685

Please sign in to comment.