Skip to content

feat(zk-backend): two-stage groth16 dry-run#3869

Open
mw2000 wants to merge 4 commits into
mw2000/zk-host-groth16-orchestration-hostfrom
mw2000/zk-groth16-dryrun
Open

feat(zk-backend): two-stage groth16 dry-run#3869
mw2000 wants to merge 4 commits into
mw2000/zk-host-groth16-orchestration-hostfrom
mw2000/zk-groth16-dryrun

Conversation

@mw2000

@mw2000 mw2000 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extend the dry-run backend to advance SnarkGroth16 jobs from the STARK range stage to a SNARK aggregation stage via submit_next, storing a per-stage result keyed by backend session id.
  • Lets the host orchestrator (introduced in the base PR) exercise the full composed range-to-aggregation flow locally without a real proving backend.

Stacked on #3863 (host orchestration). Cluster and network aggregation backends follow in separate PRs.

Made with Cursor

Comment thread crates/proof/zk/backend/src/succinct/dry_run.rs Outdated
Comment thread crates/proof/zk/backend/src/succinct/dry_run.rs Outdated
@mw2000 mw2000 force-pushed the mw2000/zk-groth16-dryrun branch from c57445f to e990def Compare July 7, 2026 22:02
Comment thread crates/proof/zk/backend/src/succinct/dry_run.rs Outdated
@mw2000 mw2000 force-pushed the mw2000/zk-groth16-dryrun branch from e990def to f2adb7f Compare July 7, 2026 22:11
@mw2000 mw2000 force-pushed the mw2000/zk-host-groth16-orchestration-host branch 5 times, most recently from 40549d5 to e806c5d Compare July 7, 2026 23:06
@mw2000 mw2000 force-pushed the mw2000/zk-groth16-dryrun branch from f2adb7f to 983d611 Compare July 7, 2026 23:19
Comment thread crates/proof/zk/backend/src/succinct/dry_run.rs Outdated
@mw2000 mw2000 force-pushed the mw2000/zk-host-groth16-orchestration-host branch from e806c5d to 53ee3d8 Compare July 8, 2026 17:50
@mw2000 mw2000 force-pushed the mw2000/zk-groth16-dryrun branch from e9be5b5 to e4402c9 Compare July 8, 2026 17:50
mw2000 added a commit that referenced this pull request Jul 8, 2026
Snark dry-run completion lands in the stacked #3869 backend work, so keep the helper able to submit snark_groth16 requests.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mw2000 mw2000 force-pushed the mw2000/zk-host-groth16-orchestration-host branch from 53ee3d8 to e1c3714 Compare July 8, 2026 18:02
@mw2000 mw2000 force-pushed the mw2000/zk-groth16-dryrun branch from e4402c9 to 3c54cad Compare July 8, 2026 18:02
@mw2000 mw2000 force-pushed the mw2000/zk-host-groth16-orchestration-host branch from e1c3714 to 910ebeb Compare July 8, 2026 20:04
mw2000 and others added 4 commits July 8, 2026 13:04
Advance dry-run SnarkGroth16 jobs from the STARK range stage to a SNARK
aggregation stage via submit_next, storing a per-stage result so the host
orchestrator can drive the composed flow locally without a real backend.

Co-authored-by: Cursor <cursoragent@cursor.com>
Return the existing snark session id when the aggregation result is already
stored, so a crash-resume re-invocation with the same pair does not fail with
BackendSessionNotFound. Use the imported SnarkGroth16ProofRequest short name.

Co-authored-by: Cursor <cursoragent@cursor.com>
Acquire the completed-results lock once and hold it across the idempotency
check, range-result removal, and snark-result insertion so the swap is atomic
and no concurrent caller can observe a state where neither key is present.

Co-authored-by: Cursor <cursoragent@cursor.com>
Extract the range->snark result swap in submit_next into
DryRunZkProver::advance_range_to_snark so its stateful, mutex-guarded
map logic can be unit tested without a witness provider. Add tests for
the happy-path swap, idempotent crash-resume, and the missing-range
error case.

Also name the SNARK session-id prefix (DRY_RUN_SNARK_PREFIX) and rename
DRY_RUN_PREFIX to DRY_RUN_STARK_PREFIX so both stages use symmetric
constants instead of a bare literal.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mw2000 mw2000 force-pushed the mw2000/zk-groth16-dryrun branch from 3c54cad to 02c9eb5 Compare July 8, 2026 20:05
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Summary

PR: feat(zk-backend): two-stage groth16 dry-run

No blocking issues found. The implementation is clean and correct.

What was reviewed

  • advance_range_to_snark — atomic check-remove-insert under a single lock guard, with correct idempotency handling for crash-resume scenarios
  • submit — properly extended to accept SnarkGroth16 requests by extracting the inner ZkProofRequest for the initial STARK range stage
  • submit_next — delegates to advance_range_to_snark with deterministic session id derivation, satisfying the trait's idempotency contract
  • DRY_RUN_PREFIXDRY_RUN_STARK_PREFIX / DRY_RUN_SNARK_PREFIX rename — symmetric naming, re-exports updated in mod.rs and lib.rs
  • Unit tests cover the swap, idempotent resume, and missing-result error cases

Notes

  • The advance_range_to_snark method takes &Mutex<HashMap<...>> directly (rather than &self) which is a pragmatic choice enabling the unit tests to exercise the core logic without constructing a full DryRunZkProver with its witness provider dependencies. Acceptable trade-off for testability.
  • Previous inline comments from an earlier review run appear to reference code that has since been addressed in the current revision (single-lock atomicity, constant extraction, import cleanup).

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

✅ base-std fork tests: all 616 passed

base/base is fully in sync with the base-std spec.

Dependency Ref Commit
base-std main 4658f1b7
base-anvil 0092692587d8d064dd2c6923ce26a682c58f3694 00926925

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant