Commit 19ec16d
authored
refactor(prover-client): split orchestrator into sub-tree + top-tree pair (#22996)
Introduces a sub-tree + top-tree orchestrator pair that decomposes the
existing single-class proving orchestrator along the natural
state-coupling boundary — per-checkpoint block-level work vs.
epoch-level top-tree work — while leaving every existing API on the
legacy `EpochProver` / `ProvingOrchestrator` / `EpochProvingState` path
untouched. The prover-node and e2e tests build unchanged; this PR is
purely additive in surface area, with structural refactors on
`ProvingOrchestrator` to share scheduling and top-tree drivers with the
new `TopTreeOrchestrator`.
## What's new
- **`CheckpointSubTreeOrchestrator`**
(`checkpoint-sub-tree-orchestrator.ts`): extends `ProvingOrchestrator`,
single-checkpoint by construction. Drives chonk-verifier / base / merge
/ block-root / block-merge for one checkpoint and resolves a
`SubTreeResult` instead of escalating to the checkpoint root — the
parent's `checkAndEnqueueCheckpointRootRollup` is overridden to
short-circuit. The constructor calls `super.startNewEpoch(epoch, 1,
empty challenges)` to set up a single-checkpoint mini-epoch; the count
and challenges are never read because the override prevents the parent's
finalize / root path from running.
- **`TopTreeOrchestrator`** + **`TopTreeProvingState`**: self-contained
driver from checkpoint-root through epoch-root rollup. Takes
per-checkpoint block-proof promises and pipelines its hint chain against
them. Cancellation surfaces as `TopTreeCancelledError` so callers can
distinguish reorg-driven cancel from a genuine proving failure.
- **`EpochProvingContext`** (`epoch-proving-context.ts`): per-epoch
shared cache for chonk-verifier proofs. Survives sub-tree cancellation
so a tx that gets reorged out and re-appears in a replacement checkpoint
reuses the cached proof.
- **`ProvingScheduler`** (`proving-scheduler.ts`): abstract base owning
the `SerialQueue` deferred-job lifecycle, the `pendingProvingJobs`
controller list, and a unified `deferredProving<S, T>(state, request,
callback, isCancelled?)` submit envelope. The minimal `ProvingStateLike`
contract is just `verifyState()` + `reject(reason)`.
- **`TopTreeProvingScheduler`** (`top-tree-proving-scheduler.ts`):
extends `ProvingScheduler` and holds the checkpoint-merge, padding, and
root-rollup drivers (plus tree-walking helpers) shared by both
orchestrators. Wraps circuit calls via a `wrapCircuitCall` hook
(orchestrator overrides for spans; top-tree leaves identity) and
resolves via an `onRootRollupComplete` hook to bridge the two states'
differing `resolve` signatures. The per-checkpoint root driver stays
subclass-specific because input-building flows differ.
- **`EpochProverFactory` interface on `ProverClient`**: new factory
methods `createEpochProvingContext(epochNumber)`,
`createCheckpointSubTreeOrchestrator(...)`, and
`createTopTreeOrchestrator()`. A single shared
`BrokerCircuitProverFacade` is owned by `ProverClient` and shared across
every orchestrator.
## What changes in existing code
- `ProvingOrchestrator` extends `TopTreeProvingScheduler`; the inline
broker-job submit envelope, queue lifecycle, and the top-tree-section
drivers are inherited. `cancel()` delegates the queue-recreate +
abort-jobs logic to `resetSchedulerState(this.cancelJobsOnStop)`. Three
internal methods (`getOrEnqueueChonkVerifier`,
`checkAndEnqueueBaseRollup`, `checkAndEnqueueCheckpointRootRollup`)
become `protected` so the sub-tree can override them; `provingState` and
`provingPromise` likewise become `protected` so the sub-tree can hook
the parent's failure stream onto `subTreeResult`. No public API change
on `ProvingOrchestrator`.
- `CheckpointProvingState`: gains two read-only accessors used by the
sub-tree's checkpoint-root override — `getSubTreeOutputProofs()` and
`getLastArchiveSiblingPath()`. No state changes.
- `ProverClient` keeps `createEpochProver()` exactly as before (each
call spawns its own `BrokerCircuitProverFacade`); the new factory
methods share a `getFacade()` set up in `start()` and torn down in
`stop()`.
`EpochProver`, `EpochProverManager`, `ServerEpochProver`,
`EpochProvingState`, the integration tests in `orchestrator_*.test.ts`,
`bb_prover_full_rollup.test.ts`, and `stdlib/interfaces/*` are all
unchanged from `merge-train/spartan` — the prover-node and e2e tests
continue to build against the existing `EpochProver` API. Migrating the
prover-node onto the new factories (and the deferred-finalize flow that
goes with optimistic proving) is the follow-up PR.
## Test plan
- 261 prover-client tests pass (full `yarn workspace
@aztec/prover-client test`).
- `yarn build` clean against current merge-train/spartan (modulo the
pre-existing `@aztec/sqlite3mc-wasm` issue inherited from baseline).1 parent cef95ec commit 19ec16d
15 files changed
Lines changed: 1830 additions & 212 deletions
File tree
- yarn-project/prover-client/src
- mocks
- orchestrator
- prover-client
- proving_broker
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| 287 | + | |
287 | 288 | | |
288 | 289 | | |
289 | 290 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
349 | 362 | | |
Lines changed: 149 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
0 commit comments