Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 80 additions & 65 deletions Cargo.lock

Large diffs are not rendered by default.

25 changes: 12 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ rand = "0.9"

# Quantus crypto dependencies (aligned with chain)
qp-dilithium-crypto = { version = "0.3.1", features = ["serde"] }
qp-poseidon = { version = "1.4.0" }
qp-rusty-crystals-dilithium = { version = "2.4.0" }
qp-rusty-crystals-hdwallet = { version = "2.3.1" }
qp-rusty-crystals-hdwallet = { version = "2.4.0" }

# HTTP client for Subsquid queries
blake3 = "1.8"
Expand Down Expand Up @@ -80,23 +79,23 @@ subxt-metadata = "0.44"
# ZK proof generation (aligned with chain)
anyhow = "1.0"

qp-plonky2 = { version = "1.4.1", default-features = false, features = ["rand", "std"] }
qp-wormhole-aggregator = { version = "2.0.1", default-features = false, features = ["rayon", "std"] }
qp-wormhole-circuit = { version = "2.0.1", default-features = false, features = ["std"] }
qp-wormhole-circuit-builder = { version = "2.0.1" }
qp-wormhole-inputs = { version = "2.0.1", default-features = false, features = ["std"] }
qp-wormhole-prover = { version = "2.0.1", default-features = false, features = ["std"] }
qp-wormhole-verifier = { version = "2.0.1", default-features = false, features = ["std"] }
qp-zk-circuits-common = { version = "2.0.1", default-features = false, features = ["std"] }
qp-plonky2 = { version = "1.5.1", default-features = false, features = ["rand", "std"] }
qp-wormhole-aggregator = { version = "3.0.0", default-features = false, features = ["rayon", "std"] }
qp-wormhole-circuit = { version = "3.0.0", default-features = false, features = ["std"] }
qp-wormhole-circuit-builder = { version = "3.0.0" }
qp-wormhole-inputs = { version = "3.0.0", default-features = false, features = ["std"] }
qp-wormhole-prover = { version = "3.0.0", default-features = false, features = ["std"] }
qp-wormhole-verifier = { version = "3.0.0", default-features = false, features = ["std"] }
qp-zk-circuits-common = { version = "3.0.0", default-features = false, features = ["std"] }


[build-dependencies]
hex = "0.4"
qp-poseidon-core = "1.4.0"
qp-wormhole-circuit-builder = { version = "2.0.1" }
qp-poseidon-core = "2.1.0"
qp-wormhole-circuit-builder = { version = "3.0.0" }

[dev-dependencies]
qp-poseidon-core = "1.4.0"
qp-poseidon-core = "2.1.0"
serial_test = "3.1"
tempfile = "3.8.1"

Expand Down
12 changes: 10 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,16 @@ fn main() {
.map(|v| v.parse().expect("QP_NUM_LEAF_PROOFS must be a valid usize"))
.unwrap_or(DEFAULT_NUM_LEAF_PROOFS);

// Don't emit any rerun-if-changed directives - this forces the build script
// to run on every build. Circuit generation is fast enough in release mode.
// Re-run when QP_NUM_LEAF_PROOFS env var changes. Note: emitting any `rerun-if-*`
// directive opts out of Cargo's default "re-run when any package file changes"
// behavior. However, the important cases still work:
// - Editing DEFAULT_NUM_LEAF_PROOFS in bins_consts.rs triggers a rebuild because
// `include!("src/bins_consts.rs")` above creates a dependency on that file.
// - Circuit crate version bumps (qp-wormhole-circuit-builder) recompile the build script, which
// re-runs it.
// For installed binaries, runtime detection in bins.rs `is_ready()` handles leaf
// count mismatches by regenerating on first use.
println!("cargo:rerun-if-env-changed=QP_NUM_LEAF_PROOFS");

println!(
"cargo:warning=[quantus-cli] Generating ZK circuit binaries (num_leaf_proofs={})...",
Expand Down
5 changes: 5 additions & 0 deletions clippy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Run the same clippy command as CI (see .github/workflows/ci.yml)
set -euo pipefail

cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
2 changes: 1 addition & 1 deletion examples/multisig_library_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async fn main() -> Result<()> {
for (i, signer) in info.signers.iter().enumerate() {
println!(" {}. {}", i + 1, signer);
}
println!(" Active Proposals: {}", info.active_proposals);
println!(" Proposal Nonce: {}", info.proposal_nonce);
println!();
}

Expand Down
22 changes: 21 additions & 1 deletion src/bins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,28 @@ fn is_ready(dir: &Path) -> bool {
if !REQUIRED_FILES.iter().all(|f| dir.join(f).exists()) {
return false;
}
match std::fs::read_to_string(dir.join(VERSION_MARKER)) {
// Check CLI version matches
let version_ok = match std::fs::read_to_string(dir.join(VERSION_MARKER)) {
Ok(v) => v.trim() == env!("CARGO_PKG_VERSION"),
Err(_) => return false,
};
if !version_ok {
return false;
}
// Check num_leaf_proofs in config.json matches current setting
let config_path = dir.join("config.json");
match std::fs::read_to_string(&config_path) {
Ok(content) => {
// Parse just the num_leaf_proofs field to avoid pulling in full config dependency
#[derive(serde::Deserialize)]
struct ConfigCheck {
num_leaf_proofs: usize,
}
match serde_json::from_str::<ConfigCheck>(&content) {
Ok(config) => config.num_leaf_proofs == env_num_leaf_proofs(),
Err(_) => false,
}
},
Err(_) => false,
}
}
Expand Down
13 changes: 10 additions & 3 deletions src/bins_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
/// Shared by `build.rs` and `crate::bins` via `include!`.
const VERSION_MARKER: &str = ".quantus-cli-version";

/// Number of leaf proofs aggregated into a single batch (default for both
/// build-time generation and runtime lazy generation).
const DEFAULT_NUM_LEAF_PROOFS: usize = 16;
/// Number of leaf proofs aggregated into a single batch.
///
/// 7 is optimal for mobile devices: fits in degree_bits=15 (~1.5 GB peak memory).
/// 8+ leaves require degree_bits=16 (~2.5 GB peak), limiting to 6GB+ devices.
///
/// Used by:
/// - build.rs: build-time circuit generation
/// - bins.rs: runtime lazy circuit generation
/// - collect_rewards_lib.rs: batching proofs for aggregation
pub const DEFAULT_NUM_LEAF_PROOFS: usize = 7;
Comment thread
cursor[bot] marked this conversation as resolved.
Loading
Loading