Skip to content

Commit f7e268b

Browse files
committed
cairo-air: remove dependency on adapter, no_std wasm build
1 parent b5826f3 commit f7e268b

File tree

13 files changed

+53
-33
lines changed

13 files changed

+53
-33
lines changed

.github/workflows/cairo-ci.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
uses: Swatinem/rust-cache@v2
6262
with:
6363
workspaces: stwo_cairo_prover
64-
- run: cargo nextest run --cargo-profile witness-opt-1 --features=slow-tests,std -j 1 -P ci
64+
- run: cargo nextest run --cargo-profile witness-opt-1 --features=slow-tests -j 1 -P ci
6565
env:
6666
RUST_MIN_STACK: 4194304
6767
RUSTFLAGS: -C target-cpu=native
@@ -110,6 +110,21 @@ jobs:
110110
- name: Build stwo_cairo_prover for wasm64
111111
run: RUSTFLAGS='--cfg getrandom_backend="custom"' cargo check --target wasm64-unknown-unknown -Z build-std=std,panic_abort --package stwo_cairo_prover --release
112112

113+
cairo-air-wasm:
114+
runs-on: ubuntu-latest
115+
defaults:
116+
run:
117+
working-directory: ./stwo_cairo_prover
118+
steps:
119+
- uses: actions/checkout@v3
120+
- uses: dtolnay/rust-toolchain@master
121+
with:
122+
toolchain: nightly-2025-07-14
123+
targets: wasm32-unknown-unknown
124+
- uses: Swatinem/rust-cache@v2
125+
- name: Build cairo-air for wasm32
126+
run: cargo check --package cairo-air --no-default-features --target wasm32-unknown-unknown --release
127+
113128
format:
114129
runs-on: ubuntu-latest
115130
defaults:

stwo_cairo_prover/Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

stwo_cairo_prover/crates/adapter/src/builtins.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,16 @@ use cairo_vm::stdlib::collections::HashMap;
55
use cairo_vm::types::builtin_name::BuiltinName;
66
use cairo_vm::types::relocatable::MaybeRelocatable;
77
use serde::{Deserialize, Serialize};
8+
use stwo_cairo_common::builtins::{
9+
ADD_MOD_MEMORY_CELLS, BITWISE_MEMORY_CELLS, ECDSA_MEMORY_CELLS, EC_OP_MEMORY_CELLS,
10+
KECCAK_MEMORY_CELLS, MUL_MOD_MEMORY_CELLS, OUTPUT_MEMORY_CELLS, PEDERSEN_MEMORY_CELLS,
11+
POSEIDON_MEMORY_CELLS, RANGE_CHECK_MEMORY_CELLS,
12+
};
813
use stwo_cairo_common::prover_types::simd::N_LANES;
914
use tracing::{info, span, Level};
1015

1116
use super::memory::MemoryBuilder;
1217

13-
pub const ADD_MOD_MEMORY_CELLS: usize = 7;
14-
pub const BITWISE_MEMORY_CELLS: usize = 5;
15-
pub const EC_OP_MEMORY_CELLS: usize = 7;
16-
pub const ECDSA_MEMORY_CELLS: usize = 2;
17-
pub const KECCAK_MEMORY_CELLS: usize = 16;
18-
pub const MUL_MOD_MEMORY_CELLS: usize = 7;
19-
pub const PEDERSEN_MEMORY_CELLS: usize = 3;
20-
pub const POSEIDON_MEMORY_CELLS: usize = 6;
21-
pub const RANGE_CHECK_MEMORY_CELLS: usize = 1;
22-
pub const OUTPUT_MEMORY_CELLS: usize = 1;
23-
2418
// Minimal builtins instances per segment, chosen to fit SIMD requirements.
2519
pub const MIN_SEGMENT_SIZE: usize = N_LANES;
2620

stwo_cairo_prover/crates/adapter/src/memory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use std::ops::{Deref, DerefMut};
55
use bytemuck::{Pod, Zeroable};
66
use dashmap::DashMap;
77
use serde::{Deserialize, Serialize};
8-
use stwo_cairo_common::memory::{N_BITS_PER_FELT, N_M31_IN_SMALL_FELT252};
8+
use stwo_cairo_common::memory::{
9+
LARGE_MEMORY_VALUE_ID_BASE, N_BITS_PER_FELT, N_M31_IN_SMALL_FELT252,
10+
};
911
use tracing::{span, Level};
1012

1113
/// P is 2^251 + 17 * 2^192 - 1.
@@ -235,8 +237,6 @@ impl DerefMut for MemoryBuilder {
235237
}
236238
}
237239

238-
pub const LARGE_MEMORY_VALUE_ID_BASE: u32 = 0x4000_0000;
239-
240240
/// Used to mark an unused address.
241241
/// Cannot be assigned as a valid ID, as [`DEFAULT_ID`] > 2**[`LOG_MEMORY_ADDRESS_BOUND`].
242242
pub const DEFAULT_ID: u32 = LARGE_MEMORY_VALUE_ID_BASE - 1;

stwo_cairo_prover/crates/cairo-air/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ version.workspace = true
44
edition.workspace = true
55

66
[features]
7-
default = ["std"]
8-
std = ["stwo/std", "stwo-constraint-framework/std"]
97
slow-tests = []
108

119
[dependencies]
@@ -18,7 +16,6 @@ num-traits.workspace = true
1816
paste.workspace = true
1917
# TODO(Ohad): Add parallel config.
2018
stwo-cairo-common.workspace = true
21-
stwo-cairo-adapter.workspace = true
2219
rayon.workspace = true
2320
serde.workspace = true
2421
starknet-ff.workspace = true

stwo_cairo_prover/crates/cairo-air/src/air.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::collections::HashMap;
2+
13
use itertools::{chain, Itertools};
24
use num_traits::Zero;
35
use serde::{Deserialize, Serialize};
@@ -11,7 +13,6 @@ use stwo::core::proof::StarkProof;
1113
use stwo::core::vcs::MerkleHasher;
1214
use stwo::prover::backend::simd::SimdBackend;
1315
use stwo::prover::ComponentProver;
14-
use stwo_cairo_adapter::HashMap;
1516
use stwo_cairo_common::prover_types::cpu::CasmState;
1617
use stwo_cairo_common::prover_types::felt::split_f252;
1718
use stwo_cairo_serialize::{CairoDeserialize, CairoSerialize};
@@ -945,7 +946,7 @@ impl std::fmt::Display for CairoComponents {
945946

946947
#[cfg(test)]
947948
mod tests {
948-
use stwo_cairo_adapter::HashMap;
949+
use std::collections::HashMap;
949950

950951
use crate::air::accumulate_relation_uses;
951952
use crate::verifier::RelationUse;

stwo_cairo_prover/crates/cairo-air/src/components/memory_id_to_big.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ use stwo::core::channel::Channel;
55
use stwo::core::fields::m31::M31;
66
use stwo::core::fields::qm31::{SecureField, SECURE_EXTENSION_DEGREE};
77
use stwo::core::pcs::TreeVec;
8-
use stwo_cairo_adapter::memory::LARGE_MEMORY_VALUE_ID_BASE;
9-
use stwo_cairo_common::memory::{N_M31_IN_FELT252, N_M31_IN_SMALL_FELT252};
8+
use stwo_cairo_common::memory::{
9+
LARGE_MEMORY_VALUE_ID_BASE, N_M31_IN_FELT252, N_M31_IN_SMALL_FELT252,
10+
};
1011
use stwo_cairo_common::preprocessed_columns::preprocessed_trace::{PreProcessedColumn, Seq};
1112
use stwo_cairo_serialize::{CairoDeserialize, CairoSerialize};
1213
use stwo_constraint_framework::{

stwo_cairo_prover/crates/cairo-air/src/verifier.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::collections::HashMap;
2+
13
use num_traits::{One, Zero};
24
use paste::paste;
35
use serde_json::to_string_pretty;
@@ -6,13 +8,11 @@ use stwo::core::fields::m31::BaseField;
68
use stwo::core::fields::qm31::SecureField;
79
use stwo::core::pcs::CommitmentSchemeVerifier;
810
use stwo::core::verifier::{verify, VerificationError};
9-
use stwo_cairo_adapter::builtins::{
11+
use stwo_cairo_common::builtins::{
1012
ADD_MOD_MEMORY_CELLS, BITWISE_MEMORY_CELLS, MUL_MOD_MEMORY_CELLS, PEDERSEN_MEMORY_CELLS,
1113
POSEIDON_MEMORY_CELLS, RANGE_CHECK_MEMORY_CELLS,
1214
};
13-
use stwo_cairo_adapter::memory::LARGE_MEMORY_VALUE_ID_BASE;
14-
use stwo_cairo_adapter::HashMap;
15-
use stwo_cairo_common::memory::LOG_MEMORY_ADDRESS_BOUND;
15+
use stwo_cairo_common::memory::{LARGE_MEMORY_VALUE_ID_BASE, LOG_MEMORY_ADDRESS_BOUND};
1616
use stwo_cairo_common::prover_types::cpu::{CasmState, PRIME};
1717
use stwo_constraint_framework::PREPROCESSED_TRACE_IDX;
1818
use thiserror::Error;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pub const ADD_MOD_MEMORY_CELLS: usize = 7;
2+
pub const BITWISE_MEMORY_CELLS: usize = 5;
3+
pub const EC_OP_MEMORY_CELLS: usize = 7;
4+
pub const ECDSA_MEMORY_CELLS: usize = 2;
5+
pub const KECCAK_MEMORY_CELLS: usize = 16;
6+
pub const MUL_MOD_MEMORY_CELLS: usize = 7;
7+
pub const PEDERSEN_MEMORY_CELLS: usize = 3;
8+
pub const POSEIDON_MEMORY_CELLS: usize = 6;
9+
pub const RANGE_CHECK_MEMORY_CELLS: usize = 1;
10+
pub const OUTPUT_MEMORY_CELLS: usize = 1;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(portable_simd)]
2+
pub mod builtins;
23
pub mod memory;
34
pub mod preprocessed_columns;
45
pub mod prover_types;

0 commit comments

Comments
 (0)