You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add feature gating for halo2 imports in SDK and CLI crates (#1731)
## Feature Gating for Halo2 Imports - INT-4112
This PR implements feature gating for all halo2 imports in the
openvm-sdk and openvm-cli crates, making EVM proving/verification
capabilities optional. This allows users who only need STARK
functionality to compile without pulling in halo2 dependencies,
improving compile times and reducing binary size.
### Changes Made
#### SDK Dependencies (crates/sdk/Cargo.toml)
- Made `snark-verifier` and `snark-verifier-sdk` optional dependencies
- Removed forced `static-verifier` feature from
`openvm-native-recursion`
- Updated `evm-prove` feature definition to properly include halo2
dependencies:
- `openvm-native-recursion/evm-prove`
- `openvm-native-recursion/static-verifier`
- `dep:snark-verifier`
- `dep:snark-verifier-sdk`
#### Feature Gating in SDK Source Files
- **lib.rs**: Added `#[cfg(any(feature = "evm-prove", feature =
"evm-verify"))]` to `agg_keygen` function
- **keygen/mod.rs**: Feature-gated `Halo2ProvingKey` struct and related
imports, added conditional compilation to `AggProvingKey.halo2_pk` field
- **keygen/static_verifier.rs**: Feature-gated entire module with
halo2-related functionality
- **types.rs**: Added feature gates to all EVM-related types
(`EvmHalo2Verifier`, `EvmProof`, etc.)
- **fs.rs**: Feature-gated halo2 file I/O functions and imports
#### CLI Updates (crates/cli/Cargo.toml)
- Removed `evm-verify` from default features
- Default features now: `["parallel", "jemalloc", "bench-metrics"]`
#### CLI Source Updates (crates/cli/src/util.rs)
- Feature-gated `read_agg_halo2_pk_from_file` import
- Feature-gated `read_default_agg_pk()` function
### Verification
All compilation scenarios have been tested and pass successfully:
**SDK Crate:**
- ✅ `cargo check --no-default-features` (STARK-only compilation)
- ✅ `cargo check --features evm-prove` (EVM proving enabled)
- ✅ `cargo check --features evm-verify` (EVM verification enabled)
**CLI Crate:**
- ✅ `cargo check --no-default-features` (STARK-only compilation)
- ✅ `cargo check --features evm-verify` (EVM verification enabled)
### Impact
- **STARK-only users**: Can now compile without halo2 dependencies,
resulting in faster compile times and smaller binaries
- **EVM users**: No breaking changes - existing functionality remains
available when EVM features are enabled
- **Backward compatibility**: Maintained through proper feature flag
design
### Link to Devin run
https://app.devin.ai/sessions/8bb6a0cf896e4b98972d872fffcb68bd
**Requested by:** Jonathan Wang
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Wang <[email protected]>
Co-authored-by: Jonathan Wang <[email protected]>
0 commit comments