@aztec/prover-client 5.0.0-private.20260319 → 5.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dest/config.d.ts +1 -1
  2. package/dest/config.d.ts.map +1 -1
  3. package/dest/config.js +16 -2
  4. package/dest/light/lightweight_checkpoint_builder.d.ts +1 -1
  5. package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
  6. package/dest/light/lightweight_checkpoint_builder.js +15 -5
  7. package/dest/mocks/test_context.d.ts +11 -11
  8. package/dest/mocks/test_context.d.ts.map +1 -1
  9. package/dest/mocks/test_context.js +25 -28
  10. package/dest/orchestrator/block-building-helpers.d.ts +1 -1
  11. package/dest/orchestrator/checkpoint-proving-state.d.ts +20 -36
  12. package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
  13. package/dest/orchestrator/checkpoint-proving-state.js +22 -120
  14. package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts +161 -0
  15. package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts.map +1 -0
  16. package/dest/orchestrator/{orchestrator.js → checkpoint-sub-tree-orchestrator.js} +267 -451
  17. package/dest/orchestrator/chonk-cache.d.ts +39 -0
  18. package/dest/orchestrator/chonk-cache.d.ts.map +1 -0
  19. package/dest/orchestrator/chonk-cache.js +80 -0
  20. package/dest/orchestrator/index.d.ts +4 -2
  21. package/dest/orchestrator/index.d.ts.map +1 -1
  22. package/dest/orchestrator/index.js +3 -1
  23. package/dest/orchestrator/proving-scheduler.d.ts +81 -0
  24. package/dest/orchestrator/proving-scheduler.d.ts.map +1 -0
  25. package/dest/orchestrator/proving-scheduler.js +120 -0
  26. package/dest/orchestrator/top-tree-orchestrator.d.ts +88 -0
  27. package/dest/orchestrator/top-tree-orchestrator.d.ts.map +1 -0
  28. package/dest/orchestrator/top-tree-orchestrator.js +232 -0
  29. package/dest/orchestrator/top-tree-proving-state.d.ts +61 -0
  30. package/dest/orchestrator/top-tree-proving-state.d.ts.map +1 -0
  31. package/dest/orchestrator/top-tree-proving-state.js +185 -0
  32. package/dest/prover-client/prover-client.d.ts +61 -4
  33. package/dest/prover-client/prover-client.d.ts.map +1 -1
  34. package/dest/prover-client/prover-client.js +54 -7
  35. package/dest/proving_broker/broker_prover_facade.d.ts +1 -1
  36. package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
  37. package/dest/proving_broker/broker_prover_facade.js +10 -16
  38. package/dest/proving_broker/config.d.ts +8 -72
  39. package/dest/proving_broker/config.d.ts.map +1 -1
  40. package/dest/proving_broker/config.js +2 -2
  41. package/dest/proving_broker/index.d.ts +2 -1
  42. package/dest/proving_broker/index.d.ts.map +1 -1
  43. package/dest/proving_broker/index.js +1 -0
  44. package/dest/proving_broker/proving_broker.d.ts +2 -2
  45. package/dest/proving_broker/proving_broker.d.ts.map +1 -1
  46. package/dest/proving_broker/proving_broker.js +32 -7
  47. package/dest/proving_broker/proving_broker_database/persisted.js +2 -2
  48. package/dest/proving_broker/rpc.d.ts +3 -1
  49. package/dest/proving_broker/rpc.d.ts.map +1 -1
  50. package/dest/proving_broker/rpc.js +80 -24
  51. package/dest/test/epoch_settlement.d.ts +36 -0
  52. package/dest/test/epoch_settlement.d.ts.map +1 -0
  53. package/dest/test/epoch_settlement.js +52 -0
  54. package/dest/test/index.d.ts +2 -0
  55. package/dest/test/index.d.ts.map +1 -0
  56. package/dest/test/index.js +1 -0
  57. package/dest/test/mock_prover.d.ts +3 -3
  58. package/package.json +19 -18
  59. package/src/config.ts +18 -2
  60. package/src/light/lightweight_checkpoint_builder.ts +16 -6
  61. package/src/mocks/test_context.ts +24 -41
  62. package/src/orchestrator/checkpoint-proving-state.ts +21 -162
  63. package/src/orchestrator/{orchestrator.ts → checkpoint-sub-tree-orchestrator.ts} +415 -661
  64. package/src/orchestrator/chonk-cache.ts +99 -0
  65. package/src/orchestrator/index.ts +8 -1
  66. package/src/orchestrator/proving-scheduler.ts +160 -0
  67. package/src/orchestrator/top-tree-orchestrator.ts +384 -0
  68. package/src/orchestrator/top-tree-proving-state.ts +219 -0
  69. package/src/prover-client/prover-client.ts +128 -18
  70. package/src/proving_broker/broker_prover_facade.ts +8 -16
  71. package/src/proving_broker/config.ts +2 -1
  72. package/src/proving_broker/index.ts +1 -0
  73. package/src/proving_broker/proving_broker.ts +27 -5
  74. package/src/proving_broker/proving_broker_database/persisted.ts +2 -2
  75. package/src/proving_broker/rpc.ts +36 -24
  76. package/src/test/epoch_settlement.ts +82 -0
  77. package/src/test/index.ts +1 -0
  78. package/dest/orchestrator/epoch-proving-state.d.ts +0 -75
  79. package/dest/orchestrator/epoch-proving-state.d.ts.map +0 -1
  80. package/dest/orchestrator/epoch-proving-state.js +0 -269
  81. package/dest/orchestrator/orchestrator.d.ts +0 -130
  82. package/dest/orchestrator/orchestrator.d.ts.map +0 -1
  83. package/dest/prover-client/server-epoch-prover.d.ts +0 -32
  84. package/dest/prover-client/server-epoch-prover.d.ts.map +0 -1
  85. package/dest/prover-client/server-epoch-prover.js +0 -40
  86. package/src/orchestrator/epoch-proving-state.ts +0 -380
  87. package/src/prover-client/server-epoch-prover.ts +0 -69
@@ -1,40 +0,0 @@
1
- /** Encapsulates the proving orchestrator and the broker facade */ export class ServerEpochProver {
2
- facade;
3
- orchestrator;
4
- constructor(facade, orchestrator){
5
- this.facade = facade;
6
- this.orchestrator = orchestrator;
7
- }
8
- startNewEpoch(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges) {
9
- this.orchestrator.startNewEpoch(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges);
10
- this.facade.start();
11
- }
12
- startNewCheckpoint(checkpointIndex, constants, l1ToL2Messages, totalNumBlocks, headerOfLastBlockInPreviousCheckpoint) {
13
- return this.orchestrator.startNewCheckpoint(checkpointIndex, constants, l1ToL2Messages, totalNumBlocks, headerOfLastBlockInPreviousCheckpoint);
14
- }
15
- startChonkVerifierCircuits(txs) {
16
- return this.orchestrator.startChonkVerifierCircuits(txs);
17
- }
18
- setBlockCompleted(blockNumber, expectedBlockHeader) {
19
- return this.orchestrator.setBlockCompleted(blockNumber, expectedBlockHeader);
20
- }
21
- finalizeEpoch() {
22
- return this.orchestrator.finalizeEpoch();
23
- }
24
- cancel() {
25
- this.orchestrator.cancel();
26
- }
27
- getProverId() {
28
- return this.orchestrator.getProverId();
29
- }
30
- async stop() {
31
- await this.facade.stop();
32
- await this.orchestrator.stop();
33
- }
34
- startNewBlock(blockNumber, timestamp, totalNumTxs) {
35
- return this.orchestrator.startNewBlock(blockNumber, timestamp, totalNumTxs);
36
- }
37
- addTxs(txs) {
38
- return this.orchestrator.addTxs(txs);
39
- }
40
- }
@@ -1,380 +0,0 @@
1
- import { BatchedBlob, BatchedBlobAccumulator, type FinalBlobBatchingChallenges } from '@aztec/blob-lib';
2
- import {
3
- type ARCHIVE_HEIGHT,
4
- type L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
5
- type NESTED_RECURSIVE_PROOF_LENGTH,
6
- type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
7
- OUT_HASH_TREE_HEIGHT,
8
- } from '@aztec/constants';
9
- import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
10
- import { Fr } from '@aztec/foundation/curves/bn254';
11
- import type { Tuple } from '@aztec/foundation/serialize';
12
- import {
13
- MerkleTreeCalculator,
14
- type TreeNodeLocation,
15
- UnbalancedTreeStore,
16
- shaMerkleHash,
17
- } from '@aztec/foundation/trees';
18
- import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
19
- import type { Proof } from '@aztec/stdlib/proofs';
20
- import {
21
- CheckpointConstantData,
22
- CheckpointMergeRollupPrivateInputs,
23
- CheckpointPaddingRollupPrivateInputs,
24
- CheckpointRollupPublicInputs,
25
- PublicChonkVerifierPublicInputs,
26
- RootRollupPrivateInputs,
27
- type RootRollupPublicInputs,
28
- } from '@aztec/stdlib/rollup';
29
- import { AppendOnlyTreeSnapshot, type MerkleTreeId } from '@aztec/stdlib/trees';
30
- import type { BlockHeader } from '@aztec/stdlib/tx';
31
-
32
- import { toProofData } from './block-building-helpers.js';
33
- import type { ProofState } from './block-proving-state.js';
34
- import { CheckpointProvingState } from './checkpoint-proving-state.js';
35
-
36
- export type TreeSnapshots = Map<MerkleTreeId, AppendOnlyTreeSnapshot>;
37
-
38
- enum PROVING_STATE_LIFECYCLE {
39
- PROVING_STATE_CREATED,
40
- PROVING_STATE_FULL,
41
- PROVING_STATE_RESOLVED,
42
- PROVING_STATE_REJECTED,
43
- }
44
-
45
- export type ProvingResult = { status: 'success' } | { status: 'failure'; reason: string };
46
-
47
- /**
48
- * The current state of the proving schedule for an epoch.
49
- * Contains the raw inputs and intermediate state to generate every constituent proof in the tree.
50
- * Carries an identifier so we can identify if the proving state is discarded and a new one started.
51
- * Captures resolve and reject callbacks to provide a promise base interface to the consumer of our proving.
52
- */
53
- export class EpochProvingState {
54
- private checkpointProofs: UnbalancedTreeStore<
55
- ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
56
- >;
57
- private checkpointPaddingProof:
58
- | ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
59
- | undefined;
60
- private rootRollupProof: ProofState<RootRollupPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH> | undefined;
61
- private checkpoints: (CheckpointProvingState | undefined)[] = [];
62
- private startBlobAccumulator: BatchedBlobAccumulator;
63
- private endBlobAccumulator: BatchedBlobAccumulator | undefined;
64
- private finalBatchedBlob: BatchedBlob | undefined;
65
- private provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_CREATED;
66
-
67
- // Map from tx hash to chonk verifier proof promise. Used when kickstarting chonk verifier proofs before tx processing.
68
- public readonly cachedChonkVerifierProofs = new Map<
69
- string,
70
- Promise<
71
- PublicInputsAndRecursiveProof<PublicChonkVerifierPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
72
- >
73
- >();
74
-
75
- constructor(
76
- public readonly epochNumber: EpochNumber,
77
- public readonly totalNumCheckpoints: number,
78
- private readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
79
- private onCheckpointBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => Promise<void>,
80
- private completionCallback: (result: ProvingResult) => void,
81
- private rejectionCallback: (reason: string) => void,
82
- ) {
83
- this.checkpointProofs = new UnbalancedTreeStore(totalNumCheckpoints);
84
- this.startBlobAccumulator = BatchedBlobAccumulator.newWithChallenges(finalBlobBatchingChallenges);
85
- }
86
-
87
- // Adds a block to the proving state, returns its index
88
- // Will update the proving life cycle if this is the last block
89
- public startNewCheckpoint(
90
- checkpointIndex: number,
91
- constants: CheckpointConstantData,
92
- totalNumBlocks: number,
93
- previousBlockHeader: BlockHeader,
94
- lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
95
- l1ToL2Messages: Fr[],
96
- lastL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot,
97
- lastL1ToL2MessageSubtreeRootSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH>,
98
- newL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot,
99
- newL1ToL2MessageSubtreeRootSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH>,
100
- ): CheckpointProvingState {
101
- if (checkpointIndex >= this.totalNumCheckpoints) {
102
- throw new Error(
103
- `Unable to start a new checkpoint at index ${checkpointIndex}. Expected at most ${this.totalNumCheckpoints} checkpoints.`,
104
- );
105
- }
106
-
107
- const checkpoint = new CheckpointProvingState(
108
- checkpointIndex,
109
- constants,
110
- totalNumBlocks,
111
- this.finalBlobBatchingChallenges,
112
- previousBlockHeader,
113
- lastArchiveSiblingPath,
114
- l1ToL2Messages,
115
- lastL1ToL2MessageTreeSnapshot,
116
- lastL1ToL2MessageSubtreeRootSiblingPath,
117
- newL1ToL2MessageTreeSnapshot,
118
- newL1ToL2MessageSubtreeRootSiblingPath,
119
- this,
120
- this.onCheckpointBlobAccumulatorSet,
121
- );
122
- this.checkpoints[checkpointIndex] = checkpoint;
123
-
124
- if (this.checkpoints.filter(c => !!c).length === this.totalNumCheckpoints) {
125
- this.provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_FULL;
126
- }
127
-
128
- return checkpoint;
129
- }
130
-
131
- public getCheckpointProvingState(index: number) {
132
- return this.checkpoints[index];
133
- }
134
-
135
- public getCheckpointProvingStateByBlockNumber(blockNumber: BlockNumber) {
136
- return this.checkpoints.find(
137
- c =>
138
- c &&
139
- Number(blockNumber) >= Number(c.firstBlockNumber) &&
140
- Number(blockNumber) < Number(c.firstBlockNumber) + c.totalNumBlocks,
141
- );
142
- }
143
-
144
- public getBlockProvingStateByBlockNumber(blockNumber: BlockNumber) {
145
- return this.getCheckpointProvingStateByBlockNumber(blockNumber)?.getBlockProvingStateByBlockNumber(blockNumber);
146
- }
147
-
148
- // Returns true if this proving state is still valid, false otherwise
149
- public verifyState() {
150
- return (
151
- this.provingStateLifecycle === PROVING_STATE_LIFECYCLE.PROVING_STATE_CREATED ||
152
- this.provingStateLifecycle === PROVING_STATE_LIFECYCLE.PROVING_STATE_FULL
153
- );
154
- }
155
-
156
- // Returns true if we are still able to accept checkpoints, false otherwise.
157
- public isAcceptingCheckpoints() {
158
- return this.checkpoints.filter(c => !!c).length < this.totalNumCheckpoints;
159
- }
160
-
161
- public setCheckpointRootRollupProof(
162
- checkpointIndex: number,
163
- provingOutput: PublicInputsAndRecursiveProof<
164
- CheckpointRollupPublicInputs,
165
- typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
166
- >,
167
- ): TreeNodeLocation {
168
- return this.checkpointProofs.setLeaf(checkpointIndex, { provingOutput });
169
- }
170
-
171
- public tryStartProvingCheckpointMerge(location: TreeNodeLocation) {
172
- if (this.checkpointProofs.getNode(location)?.isProving) {
173
- return false;
174
- } else {
175
- this.checkpointProofs.setNode(location, { isProving: true });
176
- return true;
177
- }
178
- }
179
-
180
- public setCheckpointMergeRollupProof(
181
- location: TreeNodeLocation,
182
- provingOutput: PublicInputsAndRecursiveProof<
183
- CheckpointRollupPublicInputs,
184
- typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
185
- >,
186
- ) {
187
- this.checkpointProofs.setNode(location, { provingOutput });
188
- }
189
-
190
- public tryStartProvingRootRollup() {
191
- if (this.rootRollupProof?.isProving) {
192
- return false;
193
- } else {
194
- this.rootRollupProof = { isProving: true };
195
- return true;
196
- }
197
- }
198
-
199
- public setRootRollupProof(provingOutput: PublicInputsAndRecursiveProof<RootRollupPublicInputs>) {
200
- this.rootRollupProof = { provingOutput };
201
- }
202
-
203
- public tryStartProvingPaddingCheckpoint() {
204
- if (this.checkpointPaddingProof?.isProving) {
205
- return false;
206
- } else {
207
- this.checkpointPaddingProof = { isProving: true };
208
- return true;
209
- }
210
- }
211
-
212
- public setCheckpointPaddingProof(
213
- provingOutput: PublicInputsAndRecursiveProof<
214
- CheckpointRollupPublicInputs,
215
- typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
216
- >,
217
- ) {
218
- this.checkpointPaddingProof = { provingOutput };
219
- }
220
-
221
- public async accumulateCheckpointOutHashes() {
222
- const treeCalculator = await MerkleTreeCalculator.create(OUT_HASH_TREE_HEIGHT, undefined, (left, right) =>
223
- Promise.resolve(shaMerkleHash(left, right)),
224
- );
225
-
226
- const computeOutHashHint = async (leaves: Fr[]) => {
227
- const tree = await treeCalculator.computeTree(leaves.map(l => l.toBuffer()));
228
- const nextAvailableLeafIndex = leaves.length;
229
- return {
230
- treeSnapshot: new AppendOnlyTreeSnapshot(Fr.fromBuffer(tree.root), nextAvailableLeafIndex),
231
- siblingPath: tree.getSiblingPath(nextAvailableLeafIndex).map(Fr.fromBuffer) as Tuple<
232
- Fr,
233
- typeof OUT_HASH_TREE_HEIGHT
234
- >,
235
- };
236
- };
237
-
238
- let hint = this.checkpoints[0]?.getOutHashHint();
239
- const outHashes = [];
240
- for (let i = 0; i < this.totalNumCheckpoints; i++) {
241
- const checkpoint = this.checkpoints[i];
242
- if (!checkpoint) {
243
- break;
244
- }
245
-
246
- // If hints are not set yet, it must be the first checkpoint. Compute the hints with an empty tree.
247
- hint ??= await computeOutHashHint([]);
248
- checkpoint.setOutHashHint(hint);
249
-
250
- // Get the out hash for this checkpoint.
251
- const outHash = checkpoint.accumulateBlockOutHashes();
252
- if (!outHash) {
253
- break;
254
- }
255
- outHashes.push(outHash);
256
-
257
- // If this is NOT the last checkpoint, get or create the hint for the next checkpoint.
258
- if (i !== this.totalNumCheckpoints - 1) {
259
- hint = checkpoint.getOutHashHintForNextCheckpoint() ?? (await computeOutHashHint(outHashes));
260
- checkpoint.setOutHashHintForNextCheckpoint(hint);
261
- }
262
- }
263
- }
264
-
265
- public async setBlobAccumulators() {
266
- let previousAccumulator = this.startBlobAccumulator;
267
- // Accumulate blobs as far as we can for this epoch.
268
- for (let i = 0; i < this.totalNumCheckpoints; i++) {
269
- const checkpoint = this.checkpoints[i];
270
- if (!checkpoint) {
271
- break;
272
- }
273
-
274
- const endAccumulator =
275
- checkpoint.getEndBlobAccumulator() || (await checkpoint.accumulateBlobs(previousAccumulator));
276
- if (!endAccumulator) {
277
- break;
278
- }
279
-
280
- previousAccumulator = endAccumulator;
281
-
282
- // If this is the last checkpoint, set the end blob accumulator.
283
- if (i === this.totalNumCheckpoints - 1) {
284
- this.endBlobAccumulator = endAccumulator;
285
- }
286
- }
287
- }
288
-
289
- public async finalizeBatchedBlob() {
290
- if (!this.endBlobAccumulator) {
291
- throw new Error('End blob accumulator not ready.');
292
- }
293
- this.finalBatchedBlob = await this.endBlobAccumulator.finalize(true /* verifyProof */);
294
- }
295
-
296
- public getParentLocation(location: TreeNodeLocation) {
297
- return this.checkpointProofs.getParentLocation(location);
298
- }
299
-
300
- public getCheckpointMergeRollupInputs(mergeLocation: TreeNodeLocation) {
301
- const [left, right] = this.checkpointProofs.getChildren(mergeLocation).map(c => c?.provingOutput);
302
- if (!left || !right) {
303
- throw new Error('At least one child is not ready for the checkpoint merge rollup.');
304
- }
305
-
306
- return new CheckpointMergeRollupPrivateInputs([toProofData(left), toProofData(right)]);
307
- }
308
-
309
- public getRootRollupInputs() {
310
- const [left, right] = this.#getChildProofsForRoot();
311
- if (!left || !right) {
312
- throw new Error('At least one child is not ready for the root rollup.');
313
- }
314
-
315
- return RootRollupPrivateInputs.from({
316
- previousRollups: [toProofData(left), toProofData(right)],
317
- });
318
- }
319
-
320
- public getPaddingCheckpointInputs() {
321
- return new CheckpointPaddingRollupPrivateInputs();
322
- }
323
-
324
- public getEpochProofResult(): { proof: Proof; publicInputs: RootRollupPublicInputs; batchedBlobInputs: BatchedBlob } {
325
- const provingOutput = this.rootRollupProof?.provingOutput;
326
-
327
- if (!provingOutput || !this.finalBatchedBlob) {
328
- throw new Error('Unable to get epoch proof result. Root rollup is not ready.');
329
- }
330
-
331
- return {
332
- proof: provingOutput.proof.binaryProof,
333
- publicInputs: provingOutput.inputs,
334
- batchedBlobInputs: this.finalBatchedBlob,
335
- };
336
- }
337
-
338
- public isReadyForCheckpointMerge(location: TreeNodeLocation) {
339
- return !!this.checkpointProofs.getSibling(location)?.provingOutput;
340
- }
341
-
342
- // Returns true if we have sufficient inputs to execute the block root rollup
343
- public isReadyForRootRollup() {
344
- const childProofs = this.#getChildProofsForRoot();
345
- return childProofs.every(p => !!p);
346
- }
347
-
348
- // Attempts to reject the proving state promise with a reason of 'cancelled'
349
- public cancel() {
350
- this.reject('Proving cancelled');
351
- }
352
-
353
- // Attempts to reject the proving state promise with the given reason
354
- // Does nothing if not in a valid state
355
- public reject(reason: string) {
356
- if (!this.verifyState()) {
357
- return;
358
- }
359
- this.provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_REJECTED;
360
- this.rejectionCallback(reason);
361
- }
362
-
363
- // Attempts to resolve the proving state promise with the given result
364
- // Does nothing if not in a valid state
365
- public resolve(result: ProvingResult) {
366
- if (!this.verifyState()) {
367
- return;
368
- }
369
- this.provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_RESOLVED;
370
- this.completionCallback(result);
371
- }
372
-
373
- #getChildProofsForRoot() {
374
- const rootLocation = { level: 0, index: 0 };
375
- // If there's only 1 block, its block root proof will be stored at the root.
376
- return this.totalNumCheckpoints === 1
377
- ? [this.checkpointProofs.getNode(rootLocation)?.provingOutput, this.checkpointPaddingProof?.provingOutput]
378
- : this.checkpointProofs.getChildren(rootLocation).map(c => c?.provingOutput);
379
- }
380
- }
@@ -1,69 +0,0 @@
1
- import type { BatchedBlob, FinalBlobBatchingChallenges } from '@aztec/blob-lib/types';
2
- import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
3
- import type { Fr } from '@aztec/foundation/curves/bn254';
4
- import type { EthAddress } from '@aztec/stdlib/block';
5
- import type { EpochProver } from '@aztec/stdlib/interfaces/server';
6
- import type { Proof } from '@aztec/stdlib/proofs';
7
- import type { CheckpointConstantData, RootRollupPublicInputs } from '@aztec/stdlib/rollup';
8
- import type { BlockHeader, ProcessedTx, Tx } from '@aztec/stdlib/tx';
9
- import type { UInt64 } from '@aztec/stdlib/types';
10
-
11
- import type { ProvingOrchestrator } from '../orchestrator/orchestrator.js';
12
- import type { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
13
-
14
- /** Encapsulates the proving orchestrator and the broker facade */
15
- export class ServerEpochProver implements EpochProver {
16
- constructor(
17
- private facade: BrokerCircuitProverFacade,
18
- private orchestrator: ProvingOrchestrator,
19
- ) {}
20
-
21
- startNewEpoch(
22
- epochNumber: EpochNumber,
23
- totalNumCheckpoints: number,
24
- finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
25
- ): void {
26
- this.orchestrator.startNewEpoch(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges);
27
- this.facade.start();
28
- }
29
- startNewCheckpoint(
30
- checkpointIndex: number,
31
- constants: CheckpointConstantData,
32
- l1ToL2Messages: Fr[],
33
- totalNumBlocks: number,
34
- headerOfLastBlockInPreviousCheckpoint: BlockHeader,
35
- ): Promise<void> {
36
- return this.orchestrator.startNewCheckpoint(
37
- checkpointIndex,
38
- constants,
39
- l1ToL2Messages,
40
- totalNumBlocks,
41
- headerOfLastBlockInPreviousCheckpoint,
42
- );
43
- }
44
- startChonkVerifierCircuits(txs: Tx[]): Promise<void> {
45
- return this.orchestrator.startChonkVerifierCircuits(txs);
46
- }
47
- setBlockCompleted(blockNumber: BlockNumber, expectedBlockHeader?: BlockHeader): Promise<BlockHeader> {
48
- return this.orchestrator.setBlockCompleted(blockNumber, expectedBlockHeader);
49
- }
50
- finalizeEpoch(): Promise<{ publicInputs: RootRollupPublicInputs; proof: Proof; batchedBlobInputs: BatchedBlob }> {
51
- return this.orchestrator.finalizeEpoch();
52
- }
53
- cancel(): void {
54
- this.orchestrator.cancel();
55
- }
56
- getProverId(): EthAddress {
57
- return this.orchestrator.getProverId();
58
- }
59
- async stop(): Promise<void> {
60
- await this.facade.stop();
61
- await this.orchestrator.stop();
62
- }
63
- startNewBlock(blockNumber: BlockNumber, timestamp: UInt64, totalNumTxs: number): Promise<void> {
64
- return this.orchestrator.startNewBlock(blockNumber, timestamp, totalNumTxs);
65
- }
66
- addTxs(txs: ProcessedTx[]): Promise<void> {
67
- return this.orchestrator.addTxs(txs);
68
- }
69
- }