Skip to content

refactor: replace magic numbers with named constants in M extension gadgets #1698

refactor: replace magic numbers with named constants in M extension gadgets

refactor: replace magic numbers with named constants in M extension gadgets #1698

Workflow file for this run

name: CI
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
push:
branches:
- main
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
toolchain: nightly-2025-04-06
- name: Run `cargo fmt`
run: |
cargo fmt --all --check
cd prover-benches && cargo fmt --check
check-and-clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
cache-on-failure: "true"
- name: Install & Use `mold`
uses: rui314/setup-mold@v1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
toolchain: nightly-2025-04-06
targets: riscv32im-unknown-none-elf
- name: Add clippy
run: rustup component add clippy
- name: Make Warnings Errors
run: echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV
- name: Run `cargo check` for native target
run: |
# only need to build guest binaries once
NEXUS_VM_BUILD_GUEST_TEST_BINARIES=true cargo check --all-features --all-targets --workspace --exclude example
cargo check --all-features --all-targets --examples --workspace --exclude example
cd prover-benches && cargo check --benches --workspace
- name: Run `cargo check` for riscv32im-unknown-none-elf target (examples)
run: cargo check --package example --target riscv32im-unknown-none-elf
- name: Run `cargo clippy`
run: cargo clippy --no-deps --all-targets --all-features
tests:
runs-on: ubuntu-latest
strategy:
matrix:
crate: [nexus-common, nexus-vm, nexus-vm-prover, nexus-vm-prover2, testing-framework, nexus-precompiles]
steps:
- uses: actions/checkout@v6
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
cache-on-failure: "true"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2025-04-06
targets: riscv32im-unknown-none-elf
- name: Install cargo-expand
run: cargo install cargo-expand --locked --version 1.0.95 # blocked on upgrading rust; might involve upgrading stwo-prover
- uses: taiki-e/install-action@nextest
- name: Install & Use `mold`
uses: rui314/setup-mold@v1
- name: Make Warnings Errors
run: echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV
- name: Build VM Guest Binaries
run: echo "NEXUS_VM_BUILD_GUEST_TEST_BINARIES=true" >> $GITHUB_ENV
- name: Run tests for ${{ matrix.crate }}
run: cargo nextest run --package ${{ matrix.crate }} --cargo-profile ci-test --all-features --test-threads num-cpus
- name: Run doc tests for ${{ matrix.crate }}
run: cargo test --package ${{ matrix.crate }} --doc
wasm-tests:
runs-on: ubuntu-latest
strategy:
matrix:
crate: [nexus-vm, nexus-vm-prover]
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2025-04-06 # same version as normal tests
# need riscv32im-unknown-none-elf for building guest binaries
targets: wasm32-wasip1, riscv32im-unknown-none-elf
- name: Install & Use `mold`
uses: rui314/setup-mold@v1
- name: Setup `wasmtime`
uses: bytecodealliance/actions/wasmtime/setup@v1
- name: Make Warnings Errors
run: echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV
- name: Build VM Guest Binaries
run: echo "NEXUS_VM_BUILD_GUEST_TEST_BINARIES=true" >> $GITHUB_ENV
- name: Configure `wasmtime`
run: |
echo "CARGO_TARGET_WASM32_WASIP1_RUNNER=wasmtime" >> $GITHUB_ENV
echo "WASMTIME_BACKTRACE_DETAILS=1" >> $GITHUB_ENV
- name: Run Tests in wasm32-wasip1 for ${{ matrix.crate }}
run: cargo test -p ${{ matrix.crate }} --target wasm32-wasip1 --profile ci-test
tests-sdk:
runs-on: ubuntu-latest-m
strategy:
matrix:
crate: [nexus-sdk]
steps:
- uses: actions/checkout@v6
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
cache-on-failure: "true"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2025-04-06
targets: riscv32im-unknown-none-elf
- uses: taiki-e/install-action@nextest
- name: Make Warnings Errors
run: echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV
- name: Build cargo-nexus
run: cargo build -r -p cargo-nexus
- name: Run cargo-nexus
run: target/release/cargo-nexus nexus host /tmp/nexus-host
- name: Change host SDK to current PR
run: |
sdk_path=$(pwd)/sdk
pushd /tmp/nexus-host
cargo add nexus-sdk --path $sdk_path
popd
- name: Change guest SDK to current PR
run: |
runtime_path=$(pwd)/runtime
pushd /tmp/nexus-host/src/guest
cargo add nexus-rt --path $runtime_path
popd
- name: Pre-build host application
run: |
cp sdk/examples/stwo_instrument.rs /tmp/nexus-host/src/main.rs
pushd /tmp/nexus-host
cargo build -r
popd
- name: Upload cargo-nexus binary
uses: actions/upload-artifact@v5
with:
name: cargo-nexus
path: target/release/cargo-nexus
retention-days: 90
- name: Upload pre-built host project
uses: actions/upload-artifact@v5
with:
name: nexus-host-project
path: /tmp/nexus-host
retention-days: 90
run-sdk-examples:
runs-on: ubuntu-latest-m
needs: tests-sdk
strategy:
matrix:
example: [
fact, fib, galeshapley, keccak, lambda_calculus, multiply, palindromes, simple_hash,
]
fail-fast: false
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2025-04-06
targets: riscv32im-unknown-none-elf
- name: Download pre-built host project
uses: actions/download-artifact@v6
with:
name: nexus-host-project
path: /tmp/nexus-host
- name: Make host binary executable
run: chmod +x /tmp/nexus-host/target/release/nexus-host
- name: Make Warnings Errors
run: echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV
- name: Run example ${{ matrix.example }}
continue-on-error: true
run: |
cp examples/src/bin/${{ matrix.example }}.rs /tmp/nexus-host/src/guest/src/main.rs
pushd /tmp/nexus-host/src/guest
cargo build -r --bin guest
popd
pushd /tmp/nexus-host
./target/release/nexus-host
popd