diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8af32e5197..07fbdd0542 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -194,6 +194,10 @@ jobs: smoke: needs: merge-caches name: Make sure all builds work + strategy: + fail-fast: false + matrix: + crate: ["vm", "cairo-vm-cli", "cairo1-run"] runs-on: ubuntu-22.04 steps: - name: Install Rust @@ -210,6 +214,7 @@ jobs: uses: taiki-e/install-action@v2 with: tool: cargo-all-features + - name: Checkout uses: actions/checkout@v3 @@ -226,19 +231,86 @@ jobs: fail-on-cache-miss: true # NOTE: we do this separately because --workspace operates in weird ways - - name: Check all features (vm) + - name: Check all features (${{ matrix.crate }}) run: | - cd vm + cd ${{ matrix.crate }} cargo check-all-features + cargo check-all-features --workspace --all-targets + + smoke-workspace: + needs: merge-caches + name: Make sure all builds work (workspace) + strategy: + fail-fast: false + matrix: + chunk: [1, 2, 3, 4, 5, 6] + runs-on: ubuntu-22.04 + steps: + - name: Install Rust + uses: dtolnay/rust-toolchain@1.74.1 + with: + targets: wasm32-unknown-unknown + + - name: Set up cargo cache + uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + + - name: Install cargo-all-features + uses: taiki-e/install-action@v2 + with: + tool: cargo-all-features + + - name: Checkout + uses: actions/checkout@v3 + + - name: Download proof programs symlinks + uses: actions/download-artifact@master + with: + name: proof_programs + path: cairo_programs/proof_programs/ + + - 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: Check all features (CLI) - run: | - cd cairo-vm-cli - cargo check-all-features - - name: Check all features (workspace) run: | - cargo check-all-features --workspace --all-targets + cargo check-all-features --n-chunks 6 --chunk ${{ matrix.chunk }} --workspace --all-targets + + smoke-no-std: + needs: merge-caches + name: Make sure all builds work (no_std) + runs-on: ubuntu-22.04 + steps: + - name: Install Rust + uses: dtolnay/rust-toolchain@1.74.1 + with: + targets: wasm32-unknown-unknown + + - name: Set up cargo cache + uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + + - name: Checkout + uses: actions/checkout@v3 + + - name: Download proof programs symlinks + uses: actions/download-artifact@master + with: + name: proof_programs + path: cairo_programs/proof_programs/ + + - 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: Check no-std run: | diff --git a/bench/criterion_benchmark.rs b/bench/criterion_benchmark.rs index 5f4c4c1193..48b095cc1f 100644 --- a/bench/criterion_benchmark.rs +++ b/bench/criterion_benchmark.rs @@ -4,10 +4,8 @@ use cairo_vm::{ }; use criterion::{black_box, criterion_group, criterion_main, BatchSize, Criterion}; -#[cfg(feature = "with_mimalloc")] use mimalloc::MiMalloc; -#[cfg(feature = "with_mimalloc")] #[global_allocator] static ALLOC: MiMalloc = MiMalloc; diff --git a/bench/iai_benchmark.rs b/bench/iai_benchmark.rs index 07fcf214b8..02666c93c4 100644 --- a/bench/iai_benchmark.rs +++ b/bench/iai_benchmark.rs @@ -6,10 +6,8 @@ use cairo_vm::{ vm::{runners::cairo_runner::CairoRunner, vm_core::VirtualMachine}, }; -#[cfg(feature = "with_mimalloc")] use mimalloc::MiMalloc; -#[cfg(feature = "with_mimalloc")] #[global_allocator] static ALLOC: MiMalloc = MiMalloc; diff --git a/cairo-vm-cli/Cargo.toml b/cairo-vm-cli/Cargo.toml index 783e896156..5acd241bf1 100644 --- a/cairo-vm-cli/Cargo.toml +++ b/cairo-vm-cli/Cargo.toml @@ -22,5 +22,7 @@ rstest = "0.17.0" [features] default = ["with_mimalloc"] -with_mimalloc = ["cairo-vm/with_mimalloc", "dep:mimalloc"] -with_tracer = ["cairo-vm/with_tracer", "cairo-vm-tracer"] + +with_mimalloc = ["dep:mimalloc"] +with_tracer = ["cairo-vm/tracer", "cairo-vm-tracer"] + diff --git a/cairo-vm-tracer/Cargo.toml b/cairo-vm-tracer/Cargo.toml index 0ce1ebdea2..e8f933f4b0 100644 --- a/cairo-vm-tracer/Cargo.toml +++ b/cairo-vm-tracer/Cargo.toml @@ -10,7 +10,6 @@ readme.workspace = true default = ["std"] std = [] alloc = [] -tracer = [] [dependencies] cairo-vm = { workspace = true, features = ["arbitrary", "std"] } diff --git a/cairo1-run/Cargo.toml b/cairo1-run/Cargo.toml index a831387a82..a4423fabf8 100644 --- a/cairo1-run/Cargo.toml +++ b/cairo1-run/Cargo.toml @@ -30,4 +30,4 @@ num-traits = { version = "0.2", default-features = false } [features] default = ["with_mimalloc"] -with_mimalloc = ["cairo-vm/with_mimalloc", "dep:mimalloc"] +with_mimalloc = ["dep:mimalloc"] diff --git a/vm/Cargo.toml b/vm/Cargo.toml index bb23ec2014..f31f6df1fb 100644 --- a/vm/Cargo.toml +++ b/vm/Cargo.toml @@ -9,9 +9,7 @@ readme.workspace = true keywords.workspace = true [features] -default = ["std", "with_mimalloc"] -with_mimalloc = ["dep:mimalloc"] -with_tracer = ["tracer"] +default = ["std"] std = [ "serde_json/std", "bincode/std", @@ -46,7 +44,6 @@ print = ["std"] [dependencies] zip = {version = "0.6.6", optional = true } -mimalloc = { workspace = true, optional = true } num-bigint = { workspace = true } rand = { workspace = true } num-traits = { workspace = true } @@ -94,6 +91,7 @@ wasm-bindgen-test = "0.3.34" iai-callgrind = "0.3.1" criterion = { version = "0.5.1", features = ["html_reports"] } proptest = "1.0.0" +mimalloc.workspace = true [[bench]] path = "../bench/iai_benchmark.rs" diff --git a/vm/src/lib.rs b/vm/src/lib.rs index bbd334ae81..c4cfbd1334 100644 --- a/vm/src/lib.rs +++ b/vm/src/lib.rs @@ -5,7 +5,6 @@ //! - `skip_next_instruction_hint`: Enable the `skip_next_instruction()` hint. Not enabled by default. //! - `hooks`: Enable [`Hooks`](crate::vm::hooks::Hooks) support for the [VirtualMachine](vm::vm_core::VirtualMachine). Not enabled by default. //! - `test_utils`: Enables test utils (`hooks` and `skip_next_instruction` features). Not enabled by default. -//! - `with_mimalloc`: Use [`MiMalloc`](https://crates.io/crates/mimalloc) as the program global allocator. //! - `cairo-1-hints`: Enable hints that were introduced in Cairo 1. Not enabled by default. //! - `arbitrary`: Enables implementations of [`arbitrary::Arbitrary`](https://docs.rs/arbitrary/latest/arbitrary/) for some structs. Not enabled by default. diff --git a/vm/src/vm/vm_core.rs b/vm/src/vm/vm_core.rs index a4098464e5..a1e74d87a4 100644 --- a/vm/src/vm/vm_core.rs +++ b/vm/src/vm/vm_core.rs @@ -955,7 +955,7 @@ impl VirtualMachine { Err(VirtualMachineError::NoOutputBuiltin) } - #[cfg(feature = "with_tracer")] + #[cfg(feature = "tracer")] pub fn relocate_segments(&self) -> Result, MemoryError> { self.segments.relocate_segments() }