@aztec/prover-client 0.0.1-commit.d431d1c → 0.0.1-commit.e310a4c8

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 (39) hide show
  1. package/dest/light/lightweight_checkpoint_builder.d.ts +9 -6
  2. package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
  3. package/dest/light/lightweight_checkpoint_builder.js +15 -9
  4. package/dest/mocks/fixtures.d.ts +1 -1
  5. package/dest/mocks/fixtures.d.ts.map +1 -1
  6. package/dest/mocks/fixtures.js +2 -1
  7. package/dest/orchestrator/block-building-helpers.js +1 -1
  8. package/dest/orchestrator/orchestrator.d.ts +8 -3
  9. package/dest/orchestrator/orchestrator.d.ts.map +1 -1
  10. package/dest/orchestrator/orchestrator.js +90 -74
  11. package/dest/prover-client/prover-client.d.ts +1 -1
  12. package/dest/prover-client/prover-client.d.ts.map +1 -1
  13. package/dest/prover-client/prover-client.js +7 -4
  14. package/dest/proving_broker/broker_prover_facade.d.ts +4 -3
  15. package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
  16. package/dest/proving_broker/broker_prover_facade.js +3 -3
  17. package/dest/proving_broker/config.d.ts +5 -1
  18. package/dest/proving_broker/config.d.ts.map +1 -1
  19. package/dest/proving_broker/config.js +7 -1
  20. package/dest/proving_broker/proving_agent.d.ts +4 -3
  21. package/dest/proving_broker/proving_agent.d.ts.map +1 -1
  22. package/dest/proving_broker/proving_agent.js +4 -4
  23. package/dest/proving_broker/proving_broker_instrumentation.d.ts +1 -1
  24. package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
  25. package/dest/proving_broker/proving_broker_instrumentation.js +11 -7
  26. package/dest/proving_broker/proving_job_controller.d.ts +4 -3
  27. package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
  28. package/dest/proving_broker/proving_job_controller.js +6 -3
  29. package/package.json +15 -15
  30. package/src/light/lightweight_checkpoint_builder.ts +22 -7
  31. package/src/mocks/fixtures.ts +2 -1
  32. package/src/orchestrator/block-building-helpers.ts +1 -1
  33. package/src/orchestrator/orchestrator.ts +89 -75
  34. package/src/prover-client/prover-client.ts +23 -6
  35. package/src/proving_broker/broker_prover_facade.ts +6 -3
  36. package/src/proving_broker/config.ts +9 -0
  37. package/src/proving_broker/proving_agent.ts +5 -2
  38. package/src/proving_broker/proving_broker_instrumentation.ts +10 -6
  39. package/src/proving_broker/proving_job_controller.ts +9 -3
@@ -10,7 +10,7 @@ import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
10
10
  import { padArrayEnd } from '@aztec/foundation/collection';
11
11
  import { Fr } from '@aztec/foundation/curves/bn254';
12
12
  import { AbortError } from '@aztec/foundation/error';
13
- import { createLogger } from '@aztec/foundation/log';
13
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
14
14
  import { promiseWithResolvers } from '@aztec/foundation/promise';
15
15
  import { assertLength } from '@aztec/foundation/serialize';
16
16
  import { pushTestData } from '@aztec/foundation/testing';
@@ -71,7 +71,10 @@ import { EpochProvingState, type ProvingResult, type TreeSnapshots } from './epo
71
71
  import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
72
72
  import { TxProvingState } from './tx-proving-state.js';
73
73
 
74
- const logger = createLogger('prover-client:orchestrator');
74
+ type WorldStateFork = {
75
+ fork: MerkleTreeWriteOperations;
76
+ cleanupPromise: Promise<void> | undefined;
77
+ };
75
78
 
76
79
  /**
77
80
  * Implements an event driven proving scheduler to build the recursive proof tree. The idea being:
@@ -94,14 +97,18 @@ export class ProvingOrchestrator implements EpochProver {
94
97
  private provingPromise: Promise<ProvingResult> | undefined = undefined;
95
98
  private metrics: ProvingOrchestratorMetrics;
96
99
  // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
97
- private dbs: Map<BlockNumber, MerkleTreeWriteOperations> = new Map();
100
+ private dbs: Map<BlockNumber, WorldStateFork> = new Map();
101
+ private logger: Logger;
98
102
 
99
103
  constructor(
100
104
  private dbProvider: ReadonlyWorldStateAccess & ForkMerkleTreeOperations,
101
105
  private prover: ServerCircuitProver,
102
106
  private readonly proverId: EthAddress,
107
+ private readonly cancelJobsOnStop: boolean = false,
103
108
  telemetryClient: TelemetryClient = getTelemetryClient(),
109
+ bindings?: LoggerBindings,
104
110
  ) {
111
+ this.logger = createLogger('prover-client:orchestrator', bindings);
105
112
  this.metrics = new ProvingOrchestratorMetrics(telemetryClient, 'ProvingOrchestrator');
106
113
  }
107
114
 
@@ -135,7 +142,7 @@ export class ProvingOrchestrator implements EpochProver {
135
142
 
136
143
  const { promise: _promise, resolve, reject } = promiseWithResolvers<ProvingResult>();
137
144
  const promise = _promise.catch((reason): ProvingResult => ({ status: 'failure', reason }));
138
- logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
145
+ this.logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
139
146
  this.provingState = new EpochProvingState(
140
147
  epochNumber,
141
148
  totalNumCheckpoints,
@@ -175,7 +182,7 @@ export class ProvingOrchestrator implements EpochProver {
175
182
  const db = await this.dbProvider.fork(lastBlockNumber);
176
183
 
177
184
  const firstBlockNumber = BlockNumber(lastBlockNumber + 1);
178
- this.dbs.set(firstBlockNumber, db);
185
+ this.dbs.set(firstBlockNumber, { fork: db, cleanupPromise: undefined });
179
186
 
180
187
  // Get archive sibling path before any block in this checkpoint lands.
181
188
  const lastArchiveSiblingPath = await getLastSiblingPath(MerkleTreeId.ARCHIVE, db);
@@ -227,15 +234,15 @@ export class ProvingOrchestrator implements EpochProver {
227
234
  }
228
235
 
229
236
  const constants = checkpointProvingState.constants;
230
- logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
237
+ this.logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
231
238
 
232
239
  // Fork the db only when it's not already set. The db for the first block is set in `startNewCheckpoint`.
233
240
  if (!this.dbs.has(blockNumber)) {
234
241
  // Fork world state at the end of the immediately previous block
235
242
  const db = await this.dbProvider.fork(BlockNumber(blockNumber - 1));
236
- this.dbs.set(blockNumber, db);
243
+ this.dbs.set(blockNumber, { fork: db, cleanupPromise: undefined });
237
244
  }
238
- const db = this.dbs.get(blockNumber)!;
245
+ const db = this.dbs.get(blockNumber)!.fork;
239
246
 
240
247
  // Get archive snapshot and sibling path before any txs in this block lands.
241
248
  const lastArchiveTreeSnapshot = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
@@ -288,7 +295,7 @@ export class ProvingOrchestrator implements EpochProver {
288
295
  if (!txs.length) {
289
296
  // To avoid an ugly throw below. If we require an empty block, we can just call setBlockCompleted
290
297
  // on a block with no txs. We cannot do that here because we cannot find the blockNumber without any txs.
291
- logger.warn(`Provided no txs to orchestrator addTxs.`);
298
+ this.logger.warn(`Provided no txs to orchestrator addTxs.`);
292
299
  return;
293
300
  }
294
301
 
@@ -308,9 +315,9 @@ export class ProvingOrchestrator implements EpochProver {
308
315
  throw new Error(`Block ${blockNumber} has been initialized with transactions.`);
309
316
  }
310
317
 
311
- logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
318
+ this.logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
312
319
 
313
- const db = this.dbs.get(blockNumber)!;
320
+ const db = this.dbs.get(blockNumber)!.fork;
314
321
  const lastArchive = provingState.lastArchiveTreeSnapshot;
315
322
  const newL1ToL2MessageTreeSnapshot = provingState.newL1ToL2MessageTreeSnapshot;
316
323
  const spongeBlobState = provingState.getStartSpongeBlob().clone();
@@ -323,7 +330,7 @@ export class ProvingOrchestrator implements EpochProver {
323
330
 
324
331
  validateTx(tx);
325
332
 
326
- logger.debug(`Received transaction: ${tx.hash}`);
333
+ this.logger.debug(`Received transaction: ${tx.hash}`);
327
334
 
328
335
  const startSpongeBlob = spongeBlobState.clone();
329
336
  const [hints, treeSnapshots] = await this.prepareBaseRollupInputs(
@@ -344,10 +351,10 @@ export class ProvingOrchestrator implements EpochProver {
344
351
  const txIndex = provingState.addNewTx(txProvingState);
345
352
  if (txProvingState.requireAvmProof) {
346
353
  this.getOrEnqueueChonkVerifier(provingState, txIndex);
347
- logger.debug(`Enqueueing public VM for tx ${txIndex}`);
354
+ this.logger.debug(`Enqueueing public VM for tx ${txIndex}`);
348
355
  this.enqueueVM(provingState, txIndex);
349
356
  } else {
350
- logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
357
+ this.logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
351
358
  this.enqueueBaseRollup(provingState, txIndex);
352
359
  }
353
360
  } catch (err: any) {
@@ -390,7 +397,7 @@ export class ProvingOrchestrator implements EpochProver {
390
397
  typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
391
398
  >
392
399
  >();
393
- logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
400
+ this.logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
394
401
  this.doEnqueueChonkVerifier(txHash, privateInputs, proof => {
395
402
  tubeProof.resolve(proof);
396
403
  });
@@ -430,19 +437,19 @@ export class ProvingOrchestrator implements EpochProver {
430
437
  }
431
438
 
432
439
  // Given we've applied every change from this block, now assemble the block header:
433
- logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
440
+ this.logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
434
441
  const header = await provingState.buildBlockHeader();
435
442
 
436
443
  if (expectedHeader && !header.equals(expectedHeader)) {
437
- logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
444
+ this.logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
438
445
  throw new Error('Block header mismatch');
439
446
  }
440
447
 
441
448
  // Get db for this block
442
- const db = this.dbs.get(provingState.blockNumber)!;
449
+ const db = this.dbs.get(provingState.blockNumber)!.fork;
443
450
 
444
451
  // Update the archive tree, so we're ready to start processing the next block:
445
- logger.verbose(
452
+ this.logger.verbose(
446
453
  `Updating archive tree with block ${provingState.blockNumber} header ${(await header.hash()).toString()}`,
447
454
  );
448
455
  await db.updateArchive(header);
@@ -456,31 +463,31 @@ export class ProvingOrchestrator implements EpochProver {
456
463
  protected async verifyBuiltBlockAgainstSyncedState(provingState: BlockProvingState) {
457
464
  const builtBlockHeader = provingState.getBuiltBlockHeader();
458
465
  if (!builtBlockHeader) {
459
- logger.debug('Block header not built yet, skipping header check.');
466
+ this.logger.debug('Block header not built yet, skipping header check.');
460
467
  return;
461
468
  }
462
469
 
463
470
  const output = provingState.getBlockRootRollupOutput();
464
471
  if (!output) {
465
- logger.debug('Block root rollup proof not built yet, skipping header check.');
472
+ this.logger.debug('Block root rollup proof not built yet, skipping header check.');
466
473
  return;
467
474
  }
468
475
  const header = await buildHeaderFromCircuitOutputs(output);
469
476
 
470
477
  if (!(await header.hash()).equals(await builtBlockHeader.hash())) {
471
- logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
478
+ this.logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
472
479
  provingState.reject(`Block header hash mismatch.`);
473
480
  return;
474
481
  }
475
482
 
476
483
  // Get db for this block
477
484
  const blockNumber = provingState.blockNumber;
478
- const db = this.dbs.get(blockNumber)!;
485
+ const db = this.dbs.get(blockNumber)!.fork;
479
486
 
480
487
  const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
481
488
  const syncedArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.dbProvider.getSnapshot(blockNumber));
482
489
  if (!syncedArchive.equals(newArchive)) {
483
- logger.error(
490
+ this.logger.error(
484
491
  `Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(
485
492
  syncedArchive,
486
493
  )} but built ${inspect(newArchive)}`,
@@ -491,7 +498,7 @@ export class ProvingOrchestrator implements EpochProver {
491
498
 
492
499
  const circuitArchive = output.newArchive;
493
500
  if (!newArchive.equals(circuitArchive)) {
494
- logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
501
+ this.logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
495
502
  provingState.reject(`New archive mismatch.`);
496
503
  return;
497
504
  }
@@ -504,11 +511,15 @@ export class ProvingOrchestrator implements EpochProver {
504
511
  }
505
512
 
506
513
  /**
507
- * Cancel any further proving
514
+ * Cancel any further proving.
515
+ * If cancelJobsOnStop is true, aborts all pending jobs with the broker (which marks them as 'Aborted').
516
+ * If cancelJobsOnStop is false (default), jobs remain in the broker queue and can be reused on restart/reorg.
508
517
  */
509
518
  public cancel() {
510
- for (const controller of this.pendingProvingJobs) {
511
- controller.abort();
519
+ if (this.cancelJobsOnStop) {
520
+ for (const controller of this.pendingProvingJobs) {
521
+ controller.abort();
522
+ }
512
523
  }
513
524
 
514
525
  this.provingState?.cancel();
@@ -544,17 +555,20 @@ export class ProvingOrchestrator implements EpochProver {
544
555
  }
545
556
 
546
557
  private async cleanupDBFork(blockNumber: BlockNumber): Promise<void> {
547
- logger.debug(`Cleaning up world state fork for ${blockNumber}`);
558
+ this.logger.debug(`Cleaning up world state fork for ${blockNumber}`);
548
559
  const fork = this.dbs.get(blockNumber);
549
560
  if (!fork) {
550
561
  return;
551
562
  }
552
563
 
553
564
  try {
554
- await fork.close();
565
+ if (!fork.cleanupPromise) {
566
+ fork.cleanupPromise = fork.fork.close();
567
+ }
568
+ await fork.cleanupPromise;
555
569
  this.dbs.delete(blockNumber);
556
570
  } catch (err) {
557
- logger.error(`Error closing db for block ${blockNumber}`, err);
571
+ this.logger.error(`Error closing db for block ${blockNumber}`, err);
558
572
  }
559
573
  }
560
574
 
@@ -570,7 +584,7 @@ export class ProvingOrchestrator implements EpochProver {
570
584
  callback: (result: T) => void | Promise<void>,
571
585
  ) {
572
586
  if (!provingState.verifyState()) {
573
- logger.debug(`Not enqueuing job, state no longer valid`);
587
+ this.logger.debug(`Not enqueuing job, state no longer valid`);
574
588
  return;
575
589
  }
576
590
 
@@ -588,7 +602,7 @@ export class ProvingOrchestrator implements EpochProver {
588
602
 
589
603
  const result = await request(controller.signal);
590
604
  if (!provingState.verifyState()) {
591
- logger.debug(`State no longer valid, discarding result`);
605
+ this.logger.debug(`State no longer valid, discarding result`);
592
606
  return;
593
607
  }
594
608
 
@@ -606,7 +620,7 @@ export class ProvingOrchestrator implements EpochProver {
606
620
  return;
607
621
  }
608
622
 
609
- logger.error(`Error thrown when proving job`, err);
623
+ this.logger.error(`Error thrown when proving job`, err);
610
624
  provingState!.reject(`${err}`);
611
625
  } finally {
612
626
  const index = this.pendingProvingJobs.indexOf(controller);
@@ -691,12 +705,12 @@ export class ProvingOrchestrator implements EpochProver {
691
705
  // Executes the next level of merge if all inputs are available
692
706
  private enqueueBaseRollup(provingState: BlockProvingState, txIndex: number) {
693
707
  if (!provingState.verifyState()) {
694
- logger.debug('Not running base rollup, state invalid');
708
+ this.logger.debug('Not running base rollup, state invalid');
695
709
  return;
696
710
  }
697
711
 
698
712
  if (!provingState.tryStartProvingBase(txIndex)) {
699
- logger.debug(`Base rollup for tx ${txIndex} already started.`);
713
+ this.logger.debug(`Base rollup for tx ${txIndex} already started.`);
700
714
  return;
701
715
  }
702
716
 
@@ -704,7 +718,7 @@ export class ProvingOrchestrator implements EpochProver {
704
718
  const { processedTx } = txProvingState;
705
719
  const { rollupType, inputs } = txProvingState.getBaseRollupTypeAndInputs();
706
720
 
707
- logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
721
+ this.logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
708
722
 
709
723
  this.deferredProving(
710
724
  provingState,
@@ -728,7 +742,7 @@ export class ProvingOrchestrator implements EpochProver {
728
742
  },
729
743
  ),
730
744
  result => {
731
- logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
745
+ this.logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
732
746
  validatePartialState(result.inputs.endTreeSnapshots, txProvingState.treeSnapshots);
733
747
  const leafLocation = provingState.setBaseRollupProof(txIndex, result);
734
748
  if (provingState.totalNumTxs === 1) {
@@ -744,7 +758,7 @@ export class ProvingOrchestrator implements EpochProver {
744
758
  // Once completed, will enqueue the the public tx base rollup.
745
759
  private getOrEnqueueChonkVerifier(provingState: BlockProvingState, txIndex: number) {
746
760
  if (!provingState.verifyState()) {
747
- logger.debug('Not running chonk verifier circuit, state invalid');
761
+ this.logger.debug('Not running chonk verifier circuit, state invalid');
748
762
  return;
749
763
  }
750
764
 
@@ -757,19 +771,19 @@ export class ProvingOrchestrator implements EpochProver {
757
771
  typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
758
772
  >,
759
773
  ) => {
760
- logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, { txHash });
774
+ this.logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, { txHash });
761
775
  txProvingState.setPublicChonkVerifierProof(result);
762
776
  this.provingState?.cachedChonkVerifierProofs.delete(txHash);
763
777
  this.checkAndEnqueueBaseRollup(provingState, txIndex);
764
778
  };
765
779
 
766
780
  if (this.provingState?.cachedChonkVerifierProofs.has(txHash)) {
767
- logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, { txHash });
781
+ this.logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, { txHash });
768
782
  void this.provingState!.cachedChonkVerifierProofs.get(txHash)!.then(handleResult);
769
783
  return;
770
784
  }
771
785
 
772
- logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
786
+ this.logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
773
787
  this.doEnqueueChonkVerifier(txHash, txProvingState.getPublicChonkVerifierPrivateInputs(), handleResult);
774
788
  }
775
789
 
@@ -785,7 +799,7 @@ export class ProvingOrchestrator implements EpochProver {
785
799
  provingState: EpochProvingState | BlockProvingState = this.provingState!,
786
800
  ) {
787
801
  if (!provingState.verifyState()) {
788
- logger.debug('Not running chonk verifier circuit, state invalid');
802
+ this.logger.debug('Not running chonk verifier circuit, state invalid');
789
803
  return;
790
804
  }
791
805
 
@@ -808,12 +822,12 @@ export class ProvingOrchestrator implements EpochProver {
808
822
  // Enqueues the next level of merge if all inputs are available
809
823
  private enqueueMergeRollup(provingState: BlockProvingState, location: TreeNodeLocation) {
810
824
  if (!provingState.verifyState()) {
811
- logger.debug('Not running merge rollup. State no longer valid.');
825
+ this.logger.debug('Not running merge rollup. State no longer valid.');
812
826
  return;
813
827
  }
814
828
 
815
829
  if (!provingState.tryStartProvingMerge(location)) {
816
- logger.debug('Merge rollup already started.');
830
+ this.logger.debug('Merge rollup already started.');
817
831
  return;
818
832
  }
819
833
 
@@ -839,18 +853,18 @@ export class ProvingOrchestrator implements EpochProver {
839
853
  // Executes the block root rollup circuit
840
854
  private enqueueBlockRootRollup(provingState: BlockProvingState) {
841
855
  if (!provingState.verifyState()) {
842
- logger.debug('Not running block root rollup, state no longer valid');
856
+ this.logger.debug('Not running block root rollup, state no longer valid');
843
857
  return;
844
858
  }
845
859
 
846
860
  if (!provingState.tryStartProvingBlockRoot()) {
847
- logger.debug('Block root rollup already started.');
861
+ this.logger.debug('Block root rollup already started.');
848
862
  return;
849
863
  }
850
864
 
851
865
  const { rollupType, inputs } = provingState.getBlockRootRollupTypeAndInputs();
852
866
 
853
- logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
867
+ this.logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
854
868
 
855
869
  this.deferredProving(
856
870
  provingState,
@@ -875,7 +889,7 @@ export class ProvingOrchestrator implements EpochProver {
875
889
  },
876
890
  ),
877
891
  async result => {
878
- logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
892
+ this.logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
879
893
 
880
894
  const leafLocation = provingState.setBlockRootRollupProof(result);
881
895
  const checkpointProvingState = provingState.parentCheckpoint;
@@ -903,12 +917,12 @@ export class ProvingOrchestrator implements EpochProver {
903
917
  baseParityIndex: number,
904
918
  ) {
905
919
  if (!provingState.verifyState()) {
906
- logger.debug('Not running base parity. State no longer valid.');
920
+ this.logger.debug('Not running base parity. State no longer valid.');
907
921
  return;
908
922
  }
909
923
 
910
924
  if (!provingState.tryStartProvingBaseParity(baseParityIndex)) {
911
- logger.warn(`Base parity ${baseParityIndex} already started.`);
925
+ this.logger.warn(`Base parity ${baseParityIndex} already started.`);
912
926
  return;
913
927
  }
914
928
 
@@ -943,12 +957,12 @@ export class ProvingOrchestrator implements EpochProver {
943
957
  // Enqueues the root rollup proof if all inputs are available
944
958
  private enqueueRootParityCircuit(provingState: BlockProvingState) {
945
959
  if (!provingState.verifyState()) {
946
- logger.debug('Not running root parity. State no longer valid.');
960
+ this.logger.debug('Not running root parity. State no longer valid.');
947
961
  return;
948
962
  }
949
963
 
950
964
  if (!provingState.tryStartProvingRootParity()) {
951
- logger.debug('Root parity already started.');
965
+ this.logger.debug('Root parity already started.');
952
966
  return;
953
967
  }
954
968
 
@@ -975,12 +989,12 @@ export class ProvingOrchestrator implements EpochProver {
975
989
  // Enqueues the next level of merge if all inputs are available
976
990
  private enqueueBlockMergeRollup(provingState: CheckpointProvingState, location: TreeNodeLocation) {
977
991
  if (!provingState.verifyState()) {
978
- logger.debug('Not running block merge rollup. State no longer valid.');
992
+ this.logger.debug('Not running block merge rollup. State no longer valid.');
979
993
  return;
980
994
  }
981
995
 
982
996
  if (!provingState.tryStartProvingBlockMerge(location)) {
983
- logger.debug('Block merge rollup already started.');
997
+ this.logger.debug('Block merge rollup already started.');
984
998
  return;
985
999
  }
986
1000
 
@@ -1004,18 +1018,18 @@ export class ProvingOrchestrator implements EpochProver {
1004
1018
 
1005
1019
  private enqueueCheckpointRootRollup(provingState: CheckpointProvingState) {
1006
1020
  if (!provingState.verifyState()) {
1007
- logger.debug('Not running checkpoint root rollup. State no longer valid.');
1021
+ this.logger.debug('Not running checkpoint root rollup. State no longer valid.');
1008
1022
  return;
1009
1023
  }
1010
1024
 
1011
1025
  if (!provingState.tryStartProvingCheckpointRoot()) {
1012
- logger.debug('Checkpoint root rollup already started.');
1026
+ this.logger.debug('Checkpoint root rollup already started.');
1013
1027
  return;
1014
1028
  }
1015
1029
 
1016
1030
  const rollupType = provingState.getCheckpointRootRollupType();
1017
1031
 
1018
- logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
1032
+ this.logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
1019
1033
 
1020
1034
  const inputs = provingState.getCheckpointRootRollupInputs();
1021
1035
 
@@ -1039,7 +1053,7 @@ export class ProvingOrchestrator implements EpochProver {
1039
1053
  const computedEndBlobAccumulatorState = provingState.getEndBlobAccumulator()!.toBlobAccumulator();
1040
1054
  const circuitEndBlobAccumulatorState = result.inputs.endBlobAccumulator;
1041
1055
  if (!circuitEndBlobAccumulatorState.equals(computedEndBlobAccumulatorState)) {
1042
- logger.error(
1056
+ this.logger.error(
1043
1057
  `Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(
1044
1058
  computedEndBlobAccumulatorState,
1045
1059
  )}`,
@@ -1048,7 +1062,7 @@ export class ProvingOrchestrator implements EpochProver {
1048
1062
  return;
1049
1063
  }
1050
1064
 
1051
- logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
1065
+ this.logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
1052
1066
 
1053
1067
  const leafLocation = provingState.setCheckpointRootRollupProof(result);
1054
1068
  const epochProvingState = provingState.parentEpoch;
@@ -1064,12 +1078,12 @@ export class ProvingOrchestrator implements EpochProver {
1064
1078
 
1065
1079
  private enqueueCheckpointMergeRollup(provingState: EpochProvingState, location: TreeNodeLocation) {
1066
1080
  if (!provingState.verifyState()) {
1067
- logger.debug('Not running checkpoint merge rollup. State no longer valid.');
1081
+ this.logger.debug('Not running checkpoint merge rollup. State no longer valid.');
1068
1082
  return;
1069
1083
  }
1070
1084
 
1071
1085
  if (!provingState.tryStartProvingCheckpointMerge(location)) {
1072
- logger.debug('Checkpoint merge rollup already started.');
1086
+ this.logger.debug('Checkpoint merge rollup already started.');
1073
1087
  return;
1074
1088
  }
1075
1089
 
@@ -1086,7 +1100,7 @@ export class ProvingOrchestrator implements EpochProver {
1086
1100
  signal => this.prover.getCheckpointMergeRollupProof(inputs, signal, provingState.epochNumber),
1087
1101
  ),
1088
1102
  result => {
1089
- logger.debug('Completed proof for checkpoint merge rollup.');
1103
+ this.logger.debug('Completed proof for checkpoint merge rollup.');
1090
1104
  provingState.setCheckpointMergeRollupProof(location, result);
1091
1105
  this.checkAndEnqueueNextCheckpointMergeRollup(provingState, location);
1092
1106
  },
@@ -1095,16 +1109,16 @@ export class ProvingOrchestrator implements EpochProver {
1095
1109
 
1096
1110
  private enqueueEpochPadding(provingState: EpochProvingState) {
1097
1111
  if (!provingState.verifyState()) {
1098
- logger.debug('Not running epoch padding. State no longer valid.');
1112
+ this.logger.debug('Not running epoch padding. State no longer valid.');
1099
1113
  return;
1100
1114
  }
1101
1115
 
1102
1116
  if (!provingState.tryStartProvingPaddingCheckpoint()) {
1103
- logger.debug('Padding checkpoint already started.');
1117
+ this.logger.debug('Padding checkpoint already started.');
1104
1118
  return;
1105
1119
  }
1106
1120
 
1107
- logger.debug('Padding epoch proof with a padding block root proof.');
1121
+ this.logger.debug('Padding epoch proof with a padding block root proof.');
1108
1122
 
1109
1123
  const inputs = provingState.getPaddingCheckpointInputs();
1110
1124
 
@@ -1119,7 +1133,7 @@ export class ProvingOrchestrator implements EpochProver {
1119
1133
  signal => this.prover.getCheckpointPaddingRollupProof(inputs, signal, provingState.epochNumber),
1120
1134
  ),
1121
1135
  result => {
1122
- logger.debug('Completed proof for padding checkpoint.');
1136
+ this.logger.debug('Completed proof for padding checkpoint.');
1123
1137
  provingState.setCheckpointPaddingProof(result);
1124
1138
  this.checkAndEnqueueRootRollup(provingState);
1125
1139
  },
@@ -1129,11 +1143,11 @@ export class ProvingOrchestrator implements EpochProver {
1129
1143
  // Executes the root rollup circuit
1130
1144
  private enqueueRootRollup(provingState: EpochProvingState) {
1131
1145
  if (!provingState.verifyState()) {
1132
- logger.debug('Not running root rollup, state no longer valid');
1146
+ this.logger.debug('Not running root rollup, state no longer valid');
1133
1147
  return;
1134
1148
  }
1135
1149
 
1136
- logger.debug(`Preparing root rollup`);
1150
+ this.logger.debug(`Preparing root rollup`);
1137
1151
 
1138
1152
  const inputs = provingState.getRootRollupInputs();
1139
1153
 
@@ -1148,7 +1162,7 @@ export class ProvingOrchestrator implements EpochProver {
1148
1162
  signal => this.prover.getRootRollupProof(inputs, signal, provingState.epochNumber),
1149
1163
  ),
1150
1164
  result => {
1151
- logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
1165
+ this.logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
1152
1166
  provingState.setRootRollupProof(result);
1153
1167
  provingState.resolve({ status: 'success' });
1154
1168
  },
@@ -1170,7 +1184,7 @@ export class ProvingOrchestrator implements EpochProver {
1170
1184
 
1171
1185
  private checkAndEnqueueBlockRootRollup(provingState: BlockProvingState) {
1172
1186
  if (!provingState.isReadyForBlockRootRollup()) {
1173
- logger.debug('Not ready for block root rollup');
1187
+ this.logger.debug('Not ready for block root rollup');
1174
1188
  return;
1175
1189
  }
1176
1190
 
@@ -1213,7 +1227,7 @@ export class ProvingOrchestrator implements EpochProver {
1213
1227
 
1214
1228
  private checkAndEnqueueRootRollup(provingState: EpochProvingState) {
1215
1229
  if (!provingState.isReadyForRootRollup()) {
1216
- logger.debug('Not ready for root rollup');
1230
+ this.logger.debug('Not ready for root rollup');
1217
1231
  return;
1218
1232
  }
1219
1233
 
@@ -1228,7 +1242,7 @@ export class ProvingOrchestrator implements EpochProver {
1228
1242
  */
1229
1243
  private enqueueVM(provingState: BlockProvingState, txIndex: number) {
1230
1244
  if (!provingState.verifyState()) {
1231
- logger.debug(`Not running VM circuit as state is no longer valid`);
1245
+ this.logger.debug(`Not running VM circuit as state is no longer valid`);
1232
1246
  return;
1233
1247
  }
1234
1248
 
@@ -1247,7 +1261,7 @@ export class ProvingOrchestrator implements EpochProver {
1247
1261
  );
1248
1262
 
1249
1263
  this.deferredProving(provingState, doAvmProving, proof => {
1250
- logger.debug(`Proven VM for tx index: ${txIndex}`);
1264
+ this.logger.debug(`Proven VM for tx index: ${txIndex}`);
1251
1265
  txProvingState.setAvmProof(proof);
1252
1266
  this.checkAndEnqueueBaseRollup(provingState, txIndex);
1253
1267
  });
@@ -1260,7 +1274,7 @@ export class ProvingOrchestrator implements EpochProver {
1260
1274
  }
1261
1275
 
1262
1276
  // We must have completed all proving (chonk verifier proof and (if required) vm proof are generated), we now move to the base rollup.
1263
- logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
1277
+ this.logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
1264
1278
 
1265
1279
  this.enqueueBaseRollup(provingState, txIndex);
1266
1280
  }
@@ -1,7 +1,7 @@
1
1
  import { type ACVMConfig, type BBConfig, BBNativeRollupProver, TestCircuitProver } from '@aztec/bb-prover';
2
2
  import { times } from '@aztec/foundation/collection';
3
3
  import type { EthAddress } from '@aztec/foundation/eth-address';
4
- import { createLogger } from '@aztec/foundation/log';
4
+ import { type Logger, createLogger } from '@aztec/foundation/log';
5
5
  import { NativeACVMSimulator } from '@aztec/simulator/server';
6
6
  import {
7
7
  type ActualProverConfig,
@@ -38,15 +38,29 @@ export class ProverClient implements EpochProverManager {
38
38
  private orchestratorClient: ProvingJobProducer,
39
39
  private agentClient?: ProvingJobConsumer,
40
40
  private telemetry: TelemetryClient = getTelemetryClient(),
41
- private log = createLogger('prover-client:tx-prover'),
41
+ private log: Logger = createLogger('prover-client:tx-prover'),
42
42
  ) {
43
43
  this.proofStore = new InlineProofStore();
44
44
  this.failedProofStore = this.config.failedProofStore ? createProofStore(this.config.failedProofStore) : undefined;
45
45
  }
46
46
 
47
47
  public createEpochProver(): EpochProver {
48
- const facade = new BrokerCircuitProverFacade(this.orchestratorClient, this.proofStore, this.failedProofStore);
49
- const orchestrator = new ProvingOrchestrator(this.worldState, facade, this.config.proverId, this.telemetry);
48
+ const bindings = this.log.getBindings();
49
+ const facade = new BrokerCircuitProverFacade(
50
+ this.orchestratorClient,
51
+ this.proofStore,
52
+ this.failedProofStore,
53
+ undefined,
54
+ bindings,
55
+ );
56
+ const orchestrator = new ProvingOrchestrator(
57
+ this.worldState,
58
+ facade,
59
+ this.config.proverId,
60
+ this.config.cancelJobsOnStop,
61
+ this.telemetry,
62
+ bindings,
63
+ );
50
64
  return new ServerEpochProver(facade, orchestrator);
51
65
  }
52
66
 
@@ -128,9 +142,11 @@ export class ProverClient implements EpochProverManager {
128
142
 
129
143
  const proofStore = new InlineProofStore();
130
144
  const prover = await buildServerCircuitProver(this.config, this.telemetry);
145
+ const bindings = this.log.getBindings();
131
146
  this.agents = times(
132
147
  this.config.proverAgentCount,
133
- () => new ProvingAgent(this.agentClient!, proofStore, prover, [], this.config.proverAgentPollIntervalMs),
148
+ () =>
149
+ new ProvingAgent(this.agentClient!, proofStore, prover, [], this.config.proverAgentPollIntervalMs, bindings),
134
150
  );
135
151
 
136
152
  await Promise.all(this.agents.map(agent => agent.start()));
@@ -149,8 +165,9 @@ export function buildServerCircuitProver(
149
165
  return BBNativeRollupProver.new(config, telemetry);
150
166
  }
151
167
 
168
+ const logger = createLogger('prover-client:acvm-native');
152
169
  const simulator = config.acvmBinaryPath
153
- ? new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath)
170
+ ? new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath, undefined, logger)
154
171
  : undefined;
155
172
 
156
173
  return Promise.resolve(new TestCircuitProver(simulator, config, telemetry));
@@ -6,7 +6,7 @@ import type {
6
6
  } from '@aztec/constants';
7
7
  import { EpochNumber } from '@aztec/foundation/branded-types';
8
8
  import { sha256 } from '@aztec/foundation/crypto/sha256';
9
- import { createLogger } from '@aztec/foundation/log';
9
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
10
10
  import { type PromiseWithResolvers, RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
11
11
  import { truncate } from '@aztec/foundation/string';
12
12
  import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
@@ -68,14 +68,17 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
68
68
  private runningPromise?: RunningPromise;
69
69
  private timeOfLastSnapshotSync = Date.now();
70
70
  private jobsToRetrieve: Set<ProvingJobId> = new Set();
71
+ private log: Logger;
71
72
 
72
73
  constructor(
73
74
  private broker: ProvingJobProducer,
74
75
  private proofStore: ProofStore = new InlineProofStore(),
75
76
  private failedProofStore?: ProofStore,
76
77
  private pollIntervalMs = 1000,
77
- private log = createLogger('prover-client:broker-circuit-prover-facade'),
78
- ) {}
78
+ bindings?: LoggerBindings,
79
+ ) {
80
+ this.log = createLogger('prover-client:broker-circuit-prover-facade', bindings);
81
+ }
79
82
 
80
83
  /**
81
84
  * This is a critical section. This function can not be async since it writes