Skip to content

feat: batch chonk verifier TS integration#21460

Closed
AztecBot wants to merge 1 commit into
nextfrom
lw/batch-verifier-service-v3
Closed

feat: batch chonk verifier TS integration#21460
AztecBot wants to merge 1 commit into
nextfrom
lw/batch-verifier-service-v3

Conversation

@AztecBot

@AztecBot AztecBot commented Mar 12, 2026

Copy link
Copy Markdown
Collaborator

Adds BatchChonkVerifier, the TS integration for the C++ batch chonk verifier service. Proofs arriving over P2P are batched so a single IPA SRS MSM covers the entire batch, with bisection to isolate bad proofs on failure.

The node now runs two separate verification paths:

  • Peer: BatchChonkVerifier — persistent bb subprocess, FIFO pipe, batched IPA
  • RPC: BBCircuitVerifier wrapped in QueuedIVCVerifier — file-based, concurrency-limited, with OTel metrics
  • Test mode: TestCircuitVerifier for both (always valid)
BB_CHONK_VERIFY_BATCH_SIZE=8        # peer: proofs per batch
BB_CHONK_VERIFY_BATCH_CONCURRENCY=0 # peer: worker threads (0=auto)
BB_NUM_IVC_VERIFIERS=8              # rpc: max concurrent verifications
BB_IVC_CONCURRENCY=1                # rpc: threads per verification

New files: BatchChonkVerifier, FifoFrameReader, integration tests, queue robustness tests, bench (wired into bootstrap.sh).

QueuedIVCVerifier constructor simplified from (config, verifier) to (verifier, concurrency).

@AztecBot AztecBot added the ci-barretenberg Run all barretenberg/cpp checks. label Mar 12, 2026
@ludamad ludamad requested a review from LeilaWang as a code owner March 13, 2026 18:53
@ludamad ludamad removed the ci-barretenberg Run all barretenberg/cpp checks. label Mar 13, 2026
@ludamad ludamad force-pushed the lw/batch-verifier-service-v3 branch from da347fb to 5533d02 Compare March 13, 2026 18:55
@ludamad ludamad added ci-full-no-test-cache ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure labels Mar 13, 2026
@ludamad ludamad force-pushed the lw/batch-verifier-service-v3 branch from 91a0228 to a164f96 Compare March 16, 2026 17:06
@ludamad ludamad force-pushed the lw/batch-verifier-service-v3 branch 2 times, most recently from 6bb0fc6 to 63882d9 Compare March 17, 2026 01:00
ludamad added a commit that referenced this pull request Mar 17, 2026
## Summary

Review fixes for #21460 (batch chonk verifier service), addressing
findings from a 4-agent code review:

- **S1 — Shell injection**: Replace `execSync(`mkfifo ...`)` with
`execFileSync('mkfifo', [...])` in production code
(`batch_chonk_verifier.ts`) and test code (`batch_verifier.test.ts`).
The bench and queue test files already used the safe form.
- **S2 — Silent truncation**: Add `BB_ASSERT(len <= UINT32_MAX)` in
`write_frame` before the `uint32_t` cast to catch >4GiB payloads instead
of silently truncating.
- **P1 — Bisection optimization**: When bisecting a failed batch, check
the left half first. If it passes, all failures must be in the right
half — skip the redundant `batch_check` call. This halves bisection cost
for the common single-bad-proof case (3 batch_checks instead of 6 for a
batch of 8).
- **P2 — O(1) queue front-erase**: Change `queue_` from `std::vector` to
`std::deque` so front-erasure in `coordinator_loop` is O(1) instead of
O(n).
- **P4 — Single syscall write**: Combine the 4-byte header and payload
into a single buffer in `write_frame` for one `write()` syscall instead
of two.
- **P5 — Default harmonization**: Change C++
`BatchVerifierConfig::batch_size` default from 4 to 8 to match the
TypeScript default.

## Test plan

- Existing batch verifier tests (`batch_verifier_queue.test.ts`,
`batch_verifier.test.ts`) cover all bisection patterns including random
patterns with multiple bad proofs — these validate the P1 bisection
optimization.
- The `execFileSync` change is a drop-in replacement with identical
behavior for valid paths.
- The `std::deque` change is API-compatible with `std::vector` for all
operations used.

---------

Co-authored-by: AztecBot <tech@aztecprotocol.com>
@ledwards2225 ledwards2225 self-requested a review March 17, 2026 22:59
@ludamad ludamad added the claudebox Owned by claudebox. it can push to this PR. label Mar 17, 2026
@ludamad

ludamad commented Mar 17, 2026

Copy link
Copy Markdown
Collaborator

/claudebox fix CI denoise/./bootstrap.sh build_gcc_syntax_check_only — failed (138s)
denoise/./bootstrap.sh build_native_objects
denoise/./bootstrap.sh build_native_objects — failed (146s)
denoise/./bootstrap.sh build_preset wasm-threads
denoise/./bootstrap.sh build_preset wasm-threads — use the read_log tool

@AztecBot

AztecBot commented Mar 17, 2026

Copy link
Copy Markdown
Collaborator Author

Run #1 — Session completed (5m)
Live status

Pushed fix to #21460 — two issues: GCC couldn't prove memcpy bound in write_frame (replaced BB_ASSERT with hard if-check), and WASM build referenced the old sync ChonkBatchVerifier API that was replaced by the async version (removed stale benchmark). Details: https://gist.github.com/AztecBot/672a17bcd9cd9c762ab07cefde494f7c

Comment thread barretenberg/cpp/src/barretenberg/eccvm/transcript_builder.hpp Outdated
@ludamad ludamad force-pushed the lw/batch-verifier-service-v3 branch 4 times, most recently from 28de31e to d163b17 Compare March 18, 2026 02:10
@ludamad ludamad changed the base branch from merge-train/barretenberg to lw/batch-verifier-cpp March 18, 2026 02:48
@ludamad ludamad added the ci-release-pr Creates a development tag and runs the release suite label Mar 18, 2026
@AztecBot AztecBot removed the ci-release-pr Creates a development tag and runs the release suite label Mar 18, 2026
@ludamad ludamad force-pushed the lw/batch-verifier-service-v3 branch from d163b17 to f581dfb Compare March 18, 2026 03:41
@ludamad ludamad force-pushed the lw/batch-verifier-cpp branch from 44798f2 to 9b0194c Compare March 18, 2026 03:41
@ludamad ludamad force-pushed the lw/batch-verifier-service-v3 branch from f581dfb to 510ffbe Compare March 18, 2026 03:42
@ludamad ludamad force-pushed the lw/batch-verifier-cpp branch from 9b0194c to 755aa9c Compare March 18, 2026 03:52
@ludamad ludamad force-pushed the lw/batch-verifier-service-v3 branch 2 times, most recently from 1ee7350 to 9ed03ff Compare March 18, 2026 04:23
Base automatically changed from lw/batch-verifier-cpp to next March 18, 2026 17:06
@ludamad ludamad force-pushed the lw/batch-verifier-service-v3 branch from 490e3dc to cc236e2 Compare March 19, 2026 03:26
@ludamad ludamad changed the title feat: batch verifier service for Chonk proofs feat: batch chonk verifier TS integration Mar 19, 2026
Comment thread yarn-project/prover-client/src/config.ts Outdated
Comment thread yarn-project/ivc-integration/src/batch_verifier_test_helpers.ts Outdated
Comment thread yarn-project/ivc-integration/src/batch_verifier.test.ts
Comment thread yarn-project/ivc-integration/src/batch_verifier.bench.test.ts
@ludamad ludamad force-pushed the lw/batch-verifier-service-v3 branch 6 times, most recently from 34d507b to c5fa5d2 Compare March 19, 2026 04:37
@ludamad ludamad removed the claudebox Owned by claudebox. it can push to this PR. label Mar 19, 2026
@ludamad ludamad force-pushed the lw/batch-verifier-service-v3 branch from c5fa5d2 to 0f4ab30 Compare March 19, 2026 21:21
Comment thread yarn-project/bb-prover/src/verifier/queued_chonk_verifier.ts
@ludamad ludamad force-pushed the lw/batch-verifier-service-v3 branch 3 times, most recently from dc59992 to 1b6da82 Compare March 19, 2026 21:43
Adds TypeScript integration for the batch chonk verifier C++ service:

- BatchChonkVerifier: TS orchestrator managing bb subprocess, FIFO pipe,
  and proof lifecycle (peer path with batching)
- FifoFrameReader: length-delimited frame reader for named pipes
- TestCircuitVerifier used for both peer and RPC in fake-proof mode
- BBCircuitVerifier + QueuedIVCVerifier for RPC path (real proofs)
- Server splits proofVerifier into peerProofVerifier + rpcProofVerifier

Config changes:
- numConcurrentIVCVerifiers -> bbRpcVerifyConcurrency + bbPeerVerifyBatchSize
- bbIVCConcurrency -> bbBatchVerifyThreads
- QueuedIVCVerifier takes (verifier, concurrency) instead of (config, verifier)

Integration tests and queue robustness tests via bb.js bindings.
@ludamad ludamad force-pushed the lw/batch-verifier-service-v3 branch from 1b6da82 to 7c72073 Compare March 19, 2026 22:05
@@ -199,6 +199,7 @@ describe('aztec node', () => {
epochCache,
getPackageVersion() ?? '',
new TestCircuitVerifier(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now have two verifier types

@ludamad ludamad closed this Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-full-no-test-cache ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants