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
8 changes: 4 additions & 4 deletions circuits/benchmarks/scripts/ensure_circuit_preset_built.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Ensure Noir circuit artifacts exist for a benchmark preset (insecure-512 | secure-8192).
#
# Usage (from repo root):
# ./circuits/benchmarks/scripts/ensure_circuit_preset_built.sh <preset> [--committee micro|small|medium] [--force-build] [--verbose]
# ./circuits/benchmarks/scripts/ensure_circuit_preset_built.sh <preset> [--committee micro|small|medium|large] [--force-build] [--verbose]
#
# Default: pnpm build:circuits --skip-if-built --no-clean --no-clean-targets (fast re-runs).
# --force-build: full rebuild (wipes dist/circuits and circuits/bin targets via build:circuits).
Expand All @@ -15,7 +15,7 @@ FORCE_BUILD=false
VERBOSE=false

usage() {
echo "Usage: $0 <insecure-512|secure-8192> [--committee micro|small|medium] [--force-build] [--verbose]"
echo "Usage: $0 <insecure-512|secure-8192> [--committee micro|small|medium|large] [--force-build] [--verbose]"
}

require_arg_value() {
Expand All @@ -34,9 +34,9 @@ while [[ $# -gt 0 ]]; do
require_arg_value "$1" "${2:-}"
COMMITTEE="$2"
case "$COMMITTEE" in
micro|small|medium) ;;
micro|small|medium|large) ;;
*)
echo "Error: --committee must be micro|small|medium (got: $COMMITTEE)"
echo "Error: --committee must be micro|small|medium|large (got: $COMMITTEE)"
usage
exit 1
;;
Expand Down
10 changes: 5 additions & 5 deletions circuits/benchmarks/scripts/extract_crisp_verify_gas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# extract_crisp_verify_gas.sh - Runs CRISP verifier test with gas reporter and emits JSON.
# Usage: ./extract_crisp_verify_gas.sh --output <json_file> [--mode insecure|secure]
# [--committee micro|small|medium] [--verbose] [--skip-build] [--force-build]
# [--committee micro|small|medium|large] [--verbose] [--skip-build] [--force-build]
#
# Integration test env (also set by run_benchmarks.sh):
# BENCHMARK_PROOF_AGGREGATION=true|false — recursive fold + folded Π_DKG/Π_dec (default: true)
Expand Down Expand Up @@ -31,9 +31,9 @@ while [[ $# -gt 0 ]]; do
--committee)
COMMITTEE="$2"
case "$COMMITTEE" in
micro|small|medium) ;;
micro|small|medium|large) ;;
*)
echo "Error: --committee must be micro|small|medium (got: $COMMITTEE)"
echo "Error: --committee must be micro|small|medium|large (got: $COMMITTEE)"
exit 1
;;
esac
Expand All @@ -53,14 +53,14 @@ while [[ $# -gt 0 ]]; do
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 --output <json_file> [--mode insecure|secure] [--committee micro|small|medium] [--verbose] [--skip-build] [--force-build]"
echo "Usage: $0 --output <json_file> [--mode insecure|secure] [--committee micro|small|medium|large] [--verbose] [--skip-build] [--force-build]"
exit 1
;;
esac
done

if [ -z "$OUTPUT_JSON" ]; then
echo "Usage: $0 --output <json_file> [--mode insecure|secure] [--committee micro|small|medium] [--verbose] [--skip-build] [--force-build]"
echo "Usage: $0 --output <json_file> [--mode insecure|secure] [--committee micro|small|medium|large] [--verbose] [--skip-build] [--force-build]"
exit 1
fi
if [ "$SKIP_BUILD" = true ] && [ "$FORCE_BUILD" = true ]; then
Expand Down
6 changes: 3 additions & 3 deletions circuits/benchmarks/scripts/regenerate_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ while [[ $# -gt 0 ]]; do
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--mode insecure|secure] [--committee micro|small|medium] [--proof-aggregation on|off] [--no-proof-aggregation]"
echo "Usage: $0 [--mode insecure|secure] [--committee micro|small|medium|large] [--proof-aggregation on|off] [--no-proof-aggregation]"
exit 1
;;
esac
Expand All @@ -57,9 +57,9 @@ fi

if [ -n "$COMMITTEE_OVERRIDE" ]; then
case "$COMMITTEE_OVERRIDE" in
micro|small|medium) ;;
micro|small|medium|large) ;;
*)
echo "Error: --committee must be one of micro|small|medium"
echo "Error: --committee must be one of micro|small|medium|large"
exit 1
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions circuits/benchmarks/scripts/replay_folded_verify_gas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ while [[ $# -gt 0 ]]; do
--committee)
COMMITTEE="$2"
case "$COMMITTEE" in
micro|small|medium) ;;
micro|small|medium|large) ;;
*)
echo "Error: --committee must be micro|small|medium (got: $COMMITTEE)"
echo "Error: --committee must be micro|small|medium|large (got: $COMMITTEE)"
exit 1
;;
esac
Expand Down
79 changes: 49 additions & 30 deletions crates/tests/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ fn select_benchmark_params() -> BenchmarkParams {
}
}

/// Registered ciphernodes (excluding the observer collector) for benchmark sortition.
///
/// Production registers enough nodes to fill `N + buffer`; the harness must register at least
/// `threshold_n` so party ids `0..N-1` all exist during encryption-key collection.
fn benchmark_participant_node_count(threshold_m: usize, threshold_n: usize) -> usize {
threshold_n + calculate_buffer_size(threshold_m, threshold_n)
}

/// Whether `test_trbfv_actor` runs the full recursive fold + aggregator path (default: on).
///
/// Set `BENCHMARK_PROOF_AGGREGATION=false` for a baseline run without node folds / folded Π_DKG.
Expand Down Expand Up @@ -1257,8 +1265,10 @@ async fn test_trbfv_actor() -> Result<()> {
let threshold_m = benchmark_committee.threshold;
let threshold_n = benchmark_committee.n;
let committee_h = benchmark_committee.h;
// Statistical security parameter λ used for smudging bound / error_size.
// Comes from the selected BFV preset metadata to avoid mixing parameter families.
let participant_count = benchmark_participant_node_count(threshold_m, threshold_n);
let nodes_spawned = participant_count + 1; // +1 non-registered observer collector
// Statistical security parameter λ used for smudging bound / error_size.
// Comes from the selected BFV preset metadata to avoid mixing parameter families.
let lambda = benchmark_params.lambda;

let seed = create_seed_from_u64(123);
Expand Down Expand Up @@ -1316,7 +1326,7 @@ async fn test_trbfv_actor() -> Result<()> {
let nodes = CiphernodeSystemBuilder::new()
// All nodes run the same binary under the aggregator-committee model.
// Node 0 stays an observer only because it is excluded from sortition registration.
// Adding 20 total nodes: 3 for committee + 3 buffer = 6 selected, 14 unselected
// Participant count scales with active committee (N + sortition buffer).
.add_group(1, || async {
let node_rng = next_benchmark_node_rng(BENCHMARK_NODE_RNG_BASE);
let addr = rand_eth_addr(&node_rng);
Expand All @@ -1339,28 +1349,31 @@ async fn test_trbfv_actor() -> Result<()> {
b.build().await
}
})
.add_group(19, || async {
let node_rng = next_benchmark_node_rng(BENCHMARK_NODE_RNG_BASE);
let addr = rand_eth_addr(&node_rng);
println!("Building normal {}", &addr);
{
let mut b = CiphernodeBuilder::new(node_rng, cipher.clone())
.with_history_collector()
.with_shared_taskpool(&task_pool)
.with_multithread_concurrent_jobs(concurrent_jobs)
.with_shared_multithread_report(&multithread_report)
.with_trbfv()
.with_zkproof(zk_backend.clone())
.with_signer(PrivateKeySigner::random())
.with_pubkey_aggregation()
.with_sortition_score()
.with_threshold_plaintext_aggregation()
.with_forked_bus(bus.event_bus())
.with_chains(&[bench_chain_config.clone()])
.with_logging();
b.build().await
}
})
.add_group(
u32::try_from(participant_count).expect("benchmark participant count fits in u32"),
|| async {
let node_rng = next_benchmark_node_rng(BENCHMARK_NODE_RNG_BASE);
let addr = rand_eth_addr(&node_rng);
println!("Building normal {}", &addr);
{
let mut b = CiphernodeBuilder::new(node_rng, cipher.clone())
.with_history_collector()
.with_shared_taskpool(&task_pool)
.with_multithread_concurrent_jobs(concurrent_jobs)
.with_shared_multithread_report(&multithread_report)
.with_trbfv()
.with_zkproof(zk_backend.clone())
.with_signer(PrivateKeySigner::random())
.with_pubkey_aggregation()
.with_sortition_score()
.with_threshold_plaintext_aggregation()
.with_forked_bus(bus.event_bus())
.with_chains(&[bench_chain_config.clone()])
.with_logging();
b.build().await
}
},
)
.simulate_libp2p()
.build()
.await?;
Expand All @@ -1370,7 +1383,7 @@ async fn test_trbfv_actor() -> Result<()> {
let committee_setup = Instant::now();
let chain_id = 1u64;

// Only register nodes 1-19 in sortition (exclude collector at index 0).
// Only register nodes 1..=participant_count in sortition (exclude collector at index 0).
// This ensures the collector is never selected, making the test deterministic.
// The collector node will observe events as a non-participant.
let collector_addr = nodes.get(0).unwrap().address();
Expand All @@ -1380,9 +1393,16 @@ async fn test_trbfv_actor() -> Result<()> {
.map(|n| n.address())
.collect();

anyhow::ensure!(
eth_addrs.len() >= threshold_n,
"benchmark harness: need at least {threshold_n} registered nodes for committee N, got {}",
eth_addrs.len()
);

println!(
"Test setup: {} registered nodes, {} threshold, collector (observer): {}",
"Test setup: {} registered nodes (pool target {}), committee N={}, collector (observer): {}",
eth_addrs.len(),
participant_count,
threshold_n,
collector_addr
);
Expand All @@ -1397,8 +1417,7 @@ async fn test_trbfv_actor() -> Result<()> {
///////////////////////////////////////////////////////////////////////////////////
// 2. Trigger E3Requested
//
// - m=1.
// - n=3
// - threshold_m / threshold_n / committee_h from active committee stamp
// - lambda -> calculate_error_size uses the selected BFV preset metadata
// - error_size -> calculate using calculate_error_size
// - esi_per_ciphertext = 1
Expand Down Expand Up @@ -2080,7 +2099,7 @@ async fn test_trbfv_actor() -> Result<()> {
committee_h,
threshold_n,
threshold_m,
20usize,
nodes_spawned,
);

let summary_json = format!(
Expand Down
Loading