From 47d908a749331f837afcf583e9ef353535e05cc4 Mon Sep 17 00:00:00 2001 From: CPerezz Date: Fri, 18 Oct 2024 11:22:16 +0200 Subject: [PATCH] update: Remove `wasm` feature As @arnaucube correctly suggested to me, the `wasm` feature can be omitted as the `wasmer` loader does not require it. Therefore, feature set, CI and code has been updated accordingly. Also, the browser feature has been renamed to `circom-browser`. --- .github/scripts/wasm-target-test-build.sh | 2 +- .github/workflows/ci.yml | 12 ++++++------ folding-schemes/Cargo.toml | 3 +-- folding-schemes/src/folding/nova/circuits.rs | 2 +- folding-schemes/src/folding/nova/mod.rs | 6 +++--- folding-schemes/src/frontend/circom/mod.rs | 6 +++--- folding-schemes/src/frontend/mod.rs | 4 ++-- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.github/scripts/wasm-target-test-build.sh b/.github/scripts/wasm-target-test-build.sh index e86ef832..026fac82 100644 --- a/.github/scripts/wasm-target-test-build.sh +++ b/.github/scripts/wasm-target-test-build.sh @@ -15,7 +15,7 @@ cp "${GIT_ROOT}/rust-toolchain" . rustup target add wasm32-unknown-unknown wasm32-wasi # add dependencies -cargo add --path "${GIT_ROOT}/folding-schemes" --features wasm, parallel +cargo add --path "${GIT_ROOT}/folding-schemes" --features circom-browser cargo add getrandom --features js --target wasm32-unknown-unknown # test build for wasm32-* targets diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7ef464e..d731e6c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: feature_set: [basic] include: - feature_set: basic - features: --features default,light-test + features: --features default, light-test steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 @@ -99,7 +99,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: build - args: -p folding-schemes --no-default-features --target ${{ matrix.target }} --features "wasm, parallel" + args: -p folding-schemes --target ${{ matrix.target }} --features circom-frontend - name: Run wasm-compat script run: | chmod +x .github/scripts/wasm-target-test-build.sh @@ -156,13 +156,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - feature_set: [basic, wasm] + feature_set: [basic, circom-browser] include: - feature_set: basic features: --features default,light-test - # We only want to test `folding-schemes` package with `wasm` feature. - - feature_set: wasm - features: -p folding-schemes --features wasm,parallel --target wasm32-unknown-unknown + # We only want to test `folding-schemes` package with `circom-browser` feature. + - feature_set: circom-browser + features: -p folding-schemes --features circom-browser, parallel --target wasm32-unknown-unknown steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 diff --git a/folding-schemes/Cargo.toml b/folding-schemes/Cargo.toml index d0773bf8..470df177 100644 --- a/folding-schemes/Cargo.toml +++ b/folding-schemes/Cargo.toml @@ -81,8 +81,7 @@ getrandom = { version = "0.2", features = ["js"] } [features] default = ["ark-circom/default", "parallel"] parallel = [] -wasm = ["ark-circom/wasm"] -browser = ["wasm", "byteorder"] +circom-browser = ["ark-circom/wasm", "byteorder"] light-test = [] diff --git a/folding-schemes/src/folding/nova/circuits.rs b/folding-schemes/src/folding/nova/circuits.rs index 6778a4c5..2697d95f 100644 --- a/folding-schemes/src/folding/nova/circuits.rs +++ b/folding-schemes/src/folding/nova/circuits.rs @@ -411,7 +411,7 @@ where // get z_{i+1} from the F circuit let i_usize = self.i_usize.unwrap_or(0); - // If we are in the browser-frontend case. The witness is already loaded within + // If we are in the circom-browser-frontend case. The witness is already loaded within // self.F.witness. This was done at `self.prove_step()` fn. let z_i1 = self .F diff --git a/folding-schemes/src/folding/nova/mod.rs b/folding-schemes/src/folding/nova/mod.rs index dcb3e46d..62c9d913 100644 --- a/folding-schemes/src/folding/nova/mod.rs +++ b/folding-schemes/src/folding/nova/mod.rs @@ -642,12 +642,12 @@ where fn prove_step( &mut self, mut rng: impl RngCore, - // This contains the full witness when we're in the browser-frontend case + // This contains the full witness when we're in the circom-browser-frontend case external_inputs: Vec, // Nova does not support multi-instances folding _other_instances: Option, ) -> Result<(), Error> { - #[cfg(feature = "browser")] + #[cfg(feature = "circom-browser")] { // Slice and separate between external inputs and frontend witness. let (frontend_witness, external_inputs) = @@ -664,7 +664,7 @@ where (None, external_inputs) }; - // If we are in the browser-case (frontend_witness = Some(witness)) then we load the witness into the FCircuit. + // If we are in the circom-browser-case (frontend_witness = Some(witness)) then we load the witness into the FCircuit. if let Some(witness) = frontend_witness { self.F.load_witness(witness) }; diff --git a/folding-schemes/src/frontend/circom/mod.rs b/folding-schemes/src/frontend/circom/mod.rs index cb70eb43..8b9982a0 100644 --- a/folding-schemes/src/frontend/circom/mod.rs +++ b/folding-schemes/src/frontend/circom/mod.rs @@ -13,11 +13,11 @@ use num_bigint::BigInt; use std::rc::Rc; use std::{fmt, usize}; -#[cfg(feature = "browser")] +#[cfg(feature = "circom-browser")] pub mod browser; pub mod utils; -#[cfg(feature = "browser")] +#[cfg(feature = "circom-browser")] pub use browser::{load_witness_from_bin_reader, CircomFCircuitBrowser}; use utils::CircomWrapper; @@ -38,7 +38,7 @@ impl fmt::Debug for CustomStepNative { } } -/// This circuit is the one we will use in order to fold circom circuits +/// This circuit is the one we will use in order to fold Circom circuits /// from a non-browser environment. #[derive(Clone, Debug)] pub struct CircomFCircuit { diff --git a/folding-schemes/src/frontend/mod.rs b/folding-schemes/src/frontend/mod.rs index adffe409..e68c971f 100644 --- a/folding-schemes/src/frontend/mod.rs +++ b/folding-schemes/src/frontend/mod.rs @@ -50,10 +50,10 @@ pub trait FCircuit: Clone + Debug { ) -> Result>, SynthesisError>; /// Allows to load pre-generated witness into the FCircuit implementor. - /// This is only needed by the browser use cases where we have already computed our + /// This is only needed by the circom-browser use cases where we have already computed our /// witness there. And we need a way to load it into the FCircuit since it's already computed. /// - /// By default this method will simply do nothing. Only in the browser FCircuit implementors this will have usage. + /// By default this method will simply do nothing. Only in the circom-browser FCircuit implementors this will have usage. fn load_witness(&mut self, _witness: Vec) {} }