Skip to content

feat: batch verifier service for Chonk proofs#21460

Open
AztecBot wants to merge 1 commit intolw/batch-verifier-cppfrom
lw/batch-verifier-service-v3
Open

feat: batch verifier service for Chonk proofs#21460
AztecBot wants to merge 1 commit intolw/batch-verifier-cppfrom
lw/batch-verifier-service-v3

Conversation

@AztecBot
Copy link
Collaborator

@AztecBot AztecBot commented Mar 12, 2026

Summary

Asynchronous batch verification service for Chonk IVC proofs. Builds on Luke's primitives from #21083 (reduce_to_ipa_claim, batch_reduce_verify).

Architecture & Design Doc

3-phase pipeline: parallel reduce (work-stealing) → batch IPA check (single MSM) → emit OK or bisect failures. Results stream over a named pipe as size-delimited msgpack.

ChonkBatchVerifier (in chonk/batch_verifier/) — the async pipeline core. Supersedes Luke's simple synchronous ChonkBatchVerifier with parallel reduce, work-stealing, and bisection-based failure isolation.

ChonkBatchVerifierService (in bbapi/) — FIFO streaming wrapper + Start/Queue/Stop RPC commands.

Test plan

  • chonk_tests — 4 ChonkBatchVerifierTests pass (valid batch, flush-on-stop, bisection, invalid VK)
  • bbapi_tests — builds clean
  • CI with ci-barretenberg

@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
Copy link
Collaborator

ludamad commented Mar 17, 2026

/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
Copy link
Collaborator Author

AztecBot commented Mar 17, 2026

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

transcript_msm_x_inverse_trace = (row_msm_infinity || msm_accumulator_trace.is_point_at_infinity())
? 0
: (msm_accumulator_trace.x - offset_generator().x);
transcript_msm_x_inverse_trace =
Copy link
Contributor

Choose a reason for hiding this comment

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

Whats going on here?

@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 from 510ffbe to 1ee7350 Compare March 18, 2026 03:52
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
- QueuedIVCVerifier: concurrency limiter + OTel metrics (RPC path)
- TestCircuitVerifier: fake verifier for non-real-proofs mode
- BBCircuitVerifier used for RPC path (file-based, one proof at a time)
- P2P proof validation now optional (undefined = skip)
- Config: bbRpcVerifyConcurrency, bbPeerVerifyBatchSize
- Integration tests and queue robustness tests via bb.js bindings
@ludamad ludamad force-pushed the lw/batch-verifier-service-v3 branch from 1ee7350 to 9ed03ff Compare March 18, 2026 04:23
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 claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants