Skip to content

chore(zk-host): orchestrate groth16 aggregation#3760

Draft
mw2000 wants to merge 1 commit into
mainfrom
mw2000/prover-service-groth16-orchestration
Draft

chore(zk-host): orchestrate groth16 aggregation#3760
mw2000 wants to merge 1 commit into
mainfrom
mw2000/prover-service-groth16-orchestration

Conversation

@mw2000

@mw2000 mw2000 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

ZK host now treats SnarkGroth16 jobs as a composed range-to-aggregation flow: it records the initial STARK range session, lets backends advance to a SNARK aggregation session, and resumes from the recorded SNARK session so prover-service continues handling a single generic proof request.

Comment thread crates/proof/zk/backend/src/succinct/cluster.rs
Comment thread crates/proof/zk/backend/src/succinct/network.rs Outdated
Comment thread crates/proof/zk/host/src/proof_generator.rs Outdated
@mw2000 mw2000 force-pushed the mw2000/prover-service-groth16-orchestration branch from 81402dd to 53f88f5 Compare June 24, 2026 21:56
Comment thread crates/proof/zk/backend/src/succinct/dry_run.rs Outdated
Comment thread crates/proof/zk/host/src/prover.rs
@mw2000 mw2000 force-pushed the mw2000/prover-service-groth16-orchestration branch 2 times, most recently from a616c18 to d6059e9 Compare June 24, 2026 22:23
@mw2000 mw2000 marked this pull request as ready for review June 24, 2026 22:26
Comment thread crates/proof/zk/backend/src/succinct/cluster.rs Outdated
Comment thread crates/proof/zk/host/src/proof_generator.rs
@mw2000 mw2000 force-pushed the mw2000/prover-service-groth16-orchestration branch from d6059e9 to ad17dd2 Compare June 24, 2026 22:34
Comment thread crates/proof/zk/backend/src/succinct/network.rs Outdated
@mw2000 mw2000 force-pushed the mw2000/prover-service-groth16-orchestration branch from ad17dd2 to dc54f02 Compare June 24, 2026 22:48
@mw2000 mw2000 marked this pull request as draft June 24, 2026 23:14
@mw2000 mw2000 marked this pull request as ready for review June 24, 2026 23:34
Comment thread crates/proof/zk/backend/src/succinct/provider.rs Outdated
Comment thread crates/proof/zk/backend/src/succinct/network.rs Outdated
Comment thread crates/proof/zk/backend/src/succinct/network.rs Outdated
Comment thread crates/proof/zk/host/src/prover.rs Outdated
@mw2000 mw2000 marked this pull request as draft June 25, 2026 09:03
@mw2000 mw2000 force-pushed the mw2000/prover-service-groth16-orchestration branch from dc54f02 to 414f4ed Compare June 25, 2026 09:32
Comment thread crates/proof/zk/backend/src/succinct/network.rs Outdated
@mw2000 mw2000 force-pushed the mw2000/prover-service-groth16-orchestration branch from 414f4ed to 9c0d54d Compare June 25, 2026 09:47
@mw2000 mw2000 force-pushed the mw2000/prover-service-groth16-orchestration branch from 9c0d54d to c169874 Compare June 25, 2026 16:19
@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

@mw2000 mw2000 force-pushed the mw2000/prover-service-groth16-orchestration branch 2 times, most recently from 7d3a72a to 5a20aae Compare June 26, 2026 00:18
ZK host now treats SnarkGroth16 jobs as a composed range-to-aggregation flow: it records the initial STARK range session, lets backends advance to a SNARK aggregation session, and resumes from the recorded SNARK session so prover-service continues handling a single generic proof request.

Co-authored-by: Codex <codex-noreply@coinbase.com>
@mw2000 mw2000 force-pushed the mw2000/prover-service-groth16-orchestration branch from 5a20aae to 42e1fa4 Compare June 26, 2026 00:30
Comment on lines +671 to 673
// Reuse the configured proof limits for both range and aggregation stages.
cycle_limit: self.config.range_cycle_limit,
gas_limit: self.config.range_gas_limit,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale comment: this says "Reuse the configured proof limits for both range and aggregation stages" but the aggregation request (line 856-857) now correctly uses aggregation_cycle_limit / aggregation_gas_limit. This comment should be removed or updated to just say these are the range-specific limits.

Suggested change
// Reuse the configured proof limits for both range and aggregation stages.
cycle_limit: self.config.range_cycle_limit,
gas_limit: self.config.range_gas_limit,
cycle_limit: self.config.range_cycle_limit,
gas_limit: self.config.range_gas_limit,

async fn download(&self, backend_session_id: &str) -> Result<ProofResult, ZkProverError> {
async fn download(
&self,
_session_type: SessionType,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

session_type is ignored here, and download() unconditionally returns ProofResult::Compressed. The cluster, mock, and dry-run backends all dispatch on session_type to return the correct ProofResult variant. While the network backend currently blocks Groth16 at submit(), this will silently return the wrong proof type if Groth16 support is added without updating download(). Consider either adding the same session_type check, or asserting session_type == Stark to fail loudly.

@github-actions

Copy link
Copy Markdown
Contributor

Review Summary

The PR introduces a well-structured two-stage Groth16 aggregation flow: STARK range proof → SNARK aggregation. The orchestration in proof_generator.rs is clean — the wait_for_backend_session loop records the STARK completion, calls submit_next for aggregation, records the SNARK session, and continues polling. The resume logic in resume_backend_session correctly handles crash recovery by checking the SNARK session first, then falling back to the STARK session (which, if already Completed, re-drives only the aggregation via submit_next).

Findings

Minor (2 inline comments posted):

  1. Stale comment in cluster.rs:671 — says "Reuse the configured proof limits for both range and aggregation stages" but the aggregation request now has its own dedicated aggregation_cycle_limit/aggregation_gas_limit. The comment is misleading and should be removed.

  2. Network backend download() ignores session_type (network.rs:400) — always returns ProofResult::Compressed regardless of session_type, unlike the cluster/mock/dry-run backends which dispatch on it. Safe today since network blocks Groth16 at submit(), but will silently produce wrong results when Groth16 support is added.

Note on prior review comments

Most of the 13 existing inline comments from the previous review run are stale and refer to code patterns that no longer exist in the current iteration (e.g., MOCK_SNARK_PREFIX dead code — already removed; SP1PublicValues::read() panic — replaced with proper bincode::serde::decode_from_slice error handling; network submit_next concerns — network doesn't implement submit_next; STARK session not recorded as Completed — now recorded at proof_generator.rs:354-361).

@github-actions

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.

2 participants