@aztec/prover-client 0.0.1-commit.6d3c34e → 0.0.1-commit.7035c9bd6

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 (92) hide show
  1. package/dest/light/lightweight_checkpoint_builder.d.ts +16 -7
  2. package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
  3. package/dest/light/lightweight_checkpoint_builder.js +64 -24
  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/mocks/test_context.d.ts +3 -2
  8. package/dest/mocks/test_context.d.ts.map +1 -1
  9. package/dest/mocks/test_context.js +11 -3
  10. package/dest/orchestrator/block-building-helpers.d.ts +5 -5
  11. package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
  12. package/dest/orchestrator/block-building-helpers.js +3 -3
  13. package/dest/orchestrator/block-proving-state.d.ts +4 -1
  14. package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
  15. package/dest/orchestrator/block-proving-state.js +7 -0
  16. package/dest/orchestrator/checkpoint-proving-state.d.ts +17 -4
  17. package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
  18. package/dest/orchestrator/checkpoint-proving-state.js +37 -4
  19. package/dest/orchestrator/epoch-proving-state.d.ts +7 -6
  20. package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
  21. package/dest/orchestrator/epoch-proving-state.js +37 -1
  22. package/dest/orchestrator/orchestrator.d.ts +20 -3
  23. package/dest/orchestrator/orchestrator.d.ts.map +1 -1
  24. package/dest/orchestrator/orchestrator.js +148 -99
  25. package/dest/prover-client/prover-client.d.ts +4 -4
  26. package/dest/prover-client/prover-client.d.ts.map +1 -1
  27. package/dest/prover-client/prover-client.js +15 -10
  28. package/dest/proving_broker/broker_prover_facade.d.ts +4 -3
  29. package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
  30. package/dest/proving_broker/broker_prover_facade.js +6 -6
  31. package/dest/proving_broker/config.d.ts +14 -2
  32. package/dest/proving_broker/config.d.ts.map +1 -1
  33. package/dest/proving_broker/config.js +20 -3
  34. package/dest/proving_broker/proof_store/factory.d.ts +2 -5
  35. package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
  36. package/dest/proving_broker/proof_store/factory.js +7 -30
  37. package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
  38. package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
  39. package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
  40. package/dest/proving_broker/proof_store/index.d.ts +2 -2
  41. package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
  42. package/dest/proving_broker/proof_store/index.js +1 -1
  43. package/dest/proving_broker/proving_agent.d.ts +4 -3
  44. package/dest/proving_broker/proving_agent.d.ts.map +1 -1
  45. package/dest/proving_broker/proving_agent.js +4 -4
  46. package/dest/proving_broker/proving_broker.d.ts +7 -4
  47. package/dest/proving_broker/proving_broker.d.ts.map +1 -1
  48. package/dest/proving_broker/proving_broker.js +36 -4
  49. package/dest/proving_broker/proving_broker_instrumentation.d.ts +3 -1
  50. package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
  51. package/dest/proving_broker/proving_broker_instrumentation.js +18 -7
  52. package/dest/proving_broker/proving_job_controller.d.ts +4 -3
  53. package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
  54. package/dest/proving_broker/proving_job_controller.js +6 -3
  55. package/dest/proving_broker/rpc.d.ts +4 -2
  56. package/dest/proving_broker/rpc.d.ts.map +1 -1
  57. package/dest/proving_broker/rpc.js +8 -0
  58. package/dest/test/mock_proof_store.d.ts +3 -3
  59. package/dest/test/mock_proof_store.d.ts.map +1 -1
  60. package/dest/test/mock_prover.d.ts +4 -4
  61. package/package.json +18 -20
  62. package/src/light/lightweight_checkpoint_builder.ts +93 -30
  63. package/src/mocks/fixtures.ts +2 -1
  64. package/src/mocks/test_context.ts +8 -3
  65. package/src/orchestrator/block-building-helpers.ts +3 -3
  66. package/src/orchestrator/block-proving-state.ts +9 -0
  67. package/src/orchestrator/checkpoint-proving-state.ts +51 -5
  68. package/src/orchestrator/epoch-proving-state.ts +59 -9
  69. package/src/orchestrator/orchestrator.ts +158 -108
  70. package/src/prover-client/prover-client.ts +31 -15
  71. package/src/proving_broker/broker_prover_facade.ts +15 -7
  72. package/src/proving_broker/config.ts +23 -1
  73. package/src/proving_broker/proof_store/factory.ts +10 -32
  74. package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
  75. package/src/proving_broker/proof_store/index.ts +1 -1
  76. package/src/proving_broker/proving_agent.ts +5 -2
  77. package/src/proving_broker/proving_broker.ts +37 -3
  78. package/src/proving_broker/proving_broker_instrumentation.ts +19 -6
  79. package/src/proving_broker/proving_job_controller.ts +9 -3
  80. package/src/proving_broker/rpc.ts +14 -0
  81. package/dest/block-factory/index.d.ts +0 -2
  82. package/dest/block-factory/index.d.ts.map +0 -1
  83. package/dest/block-factory/index.js +0 -1
  84. package/dest/block-factory/light.d.ts +0 -38
  85. package/dest/block-factory/light.d.ts.map +0 -1
  86. package/dest/block-factory/light.js +0 -106
  87. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +0 -14
  88. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +0 -1
  89. package/dest/proving_broker/proof_store/gcs_proof_store.js +0 -52
  90. package/src/block-factory/index.ts +0 -1
  91. package/src/block-factory/light.ts +0 -136
  92. package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
@@ -378,7 +378,9 @@ import { Fr } from '@aztec/foundation/curves/bn254';
378
378
  import { AbortError } from '@aztec/foundation/error';
379
379
  import { createLogger } from '@aztec/foundation/log';
380
380
  import { promiseWithResolvers } from '@aztec/foundation/promise';
381
+ import { SerialQueue } from '@aztec/foundation/queue';
381
382
  import { assertLength } from '@aztec/foundation/serialize';
383
+ import { sleep } from '@aztec/foundation/sleep';
382
384
  import { pushTestData } from '@aztec/foundation/testing';
383
385
  import { elapsed } from '@aztec/foundation/timer';
384
386
  import { BlockRootEmptyTxFirstRollupPrivateInputs, BlockRootFirstRollupPrivateInputs, BlockRootSingleTxFirstRollupPrivateInputs, BlockRootSingleTxRollupPrivateInputs, CheckpointRootSingleBlockRollupPrivateInputs, PrivateTxBaseRollupPrivateInputs } from '@aztec/stdlib/rollup';
@@ -389,7 +391,6 @@ import { buildHeaderFromCircuitOutputs, getLastSiblingPath, getPublicChonkVerifi
389
391
  import { EpochProvingState } from './epoch-proving-state.js';
390
392
  import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
391
393
  import { TxProvingState } from './tx-proving-state.js';
392
- const logger = createLogger('prover-client:orchestrator');
393
394
  _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
394
395
  [Attributes.BLOCK_NUMBER]: blockNumber
395
396
  })), _dec1 = trackSpan('ProvingOrchestrator.addTxs', (txs)=>({
@@ -414,6 +415,8 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
414
415
  dbProvider;
415
416
  prover;
416
417
  proverId;
418
+ cancelJobsOnStop;
419
+ enqueueConcurrency;
417
420
  static{
418
421
  ({ e: [_initProto] } = _apply_decs_2203_r(this, [
419
422
  [
@@ -449,15 +452,22 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
449
452
  metrics;
450
453
  // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
451
454
  dbs;
452
- constructor(dbProvider, prover, proverId, telemetryClient = getTelemetryClient()){
455
+ logger;
456
+ deferredJobQueue;
457
+ constructor(dbProvider, prover, proverId, cancelJobsOnStop = false, enqueueConcurrency, telemetryClient = getTelemetryClient(), bindings){
453
458
  this.dbProvider = dbProvider;
454
459
  this.prover = prover;
455
460
  this.proverId = proverId;
461
+ this.cancelJobsOnStop = cancelJobsOnStop;
462
+ this.enqueueConcurrency = enqueueConcurrency;
456
463
  this.provingState = (_initProto(this), undefined);
457
464
  this.pendingProvingJobs = [];
458
465
  this.provingPromise = undefined;
459
466
  this.dbs = new Map();
467
+ this.deferredJobQueue = new SerialQueue();
468
+ this.logger = createLogger('prover-client:orchestrator', bindings);
460
469
  this.metrics = new ProvingOrchestratorMetrics(telemetryClient, 'ProvingOrchestrator');
470
+ this.deferredJobQueue.start(this.enqueueConcurrency);
461
471
  }
462
472
  get tracer() {
463
473
  return this.metrics.tracer;
@@ -465,9 +475,14 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
465
475
  getProverId() {
466
476
  return this.proverId;
467
477
  }
468
- stop() {
478
+ getNumActiveForks() {
479
+ return this.dbs.size;
480
+ }
481
+ async stop() {
482
+ // Grab the old queue before cancel() replaces it, so we can await its draining.
483
+ const oldQueue = this.deferredJobQueue;
469
484
  this.cancel();
470
- return Promise.resolve();
485
+ await oldQueue.cancel();
471
486
  }
472
487
  startNewEpoch(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges) {
473
488
  if (this.provingState?.verifyState()) {
@@ -478,11 +493,18 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
478
493
  status: 'failure',
479
494
  reason
480
495
  }));
481
- logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
496
+ this.logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
482
497
  this.provingState = new EpochProvingState(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges, (provingState)=>this.checkAndEnqueueCheckpointRootRollup(provingState), resolve, reject);
483
498
  this.provingPromise = promise;
484
499
  }
485
- async startNewCheckpoint(checkpointIndex, constants, l1ToL2Messages, totalNumBlocks, headerOfLastBlockInPreviousCheckpoint) {
500
+ /**
501
+ * Starts a new checkpoint.
502
+ * @param checkpointIndex - The index of the checkpoint in the epoch.
503
+ * @param constants - The constants for this checkpoint.
504
+ * @param l1ToL2Messages - The set of L1 to L2 messages to be inserted at the beginning of this checkpoint.
505
+ * @param totalNumBlocks - The total number of blocks expected in the checkpoint (must be at least one).
506
+ * @param headerOfLastBlockInPreviousCheckpoint - The header of the last block in the previous checkpoint.
507
+ */ async startNewCheckpoint(checkpointIndex, constants, l1ToL2Messages, totalNumBlocks, headerOfLastBlockInPreviousCheckpoint) {
486
508
  if (!this.provingState) {
487
509
  throw new Error('Empty epoch proving state. Call startNewEpoch before starting a checkpoint.');
488
510
  }
@@ -518,14 +540,14 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
518
540
  throw new Error(`Checkpoint not accepting further blocks.`);
519
541
  }
520
542
  const constants = checkpointProvingState.constants;
521
- logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
543
+ this.logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
522
544
  // Fork the db only when it's not already set. The db for the first block is set in `startNewCheckpoint`.
523
545
  if (!this.dbs.has(blockNumber)) {
524
546
  // Fork world state at the end of the immediately previous block
525
547
  const db = await this.dbProvider.fork(BlockNumber(blockNumber - 1));
526
548
  this.dbs.set(blockNumber, db);
527
549
  }
528
- const db = this.dbs.get(blockNumber);
550
+ const db = this.getDbForBlock(blockNumber);
529
551
  // Get archive snapshot and sibling path before any txs in this block lands.
530
552
  const lastArchiveTreeSnapshot = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
531
553
  const lastArchiveSiblingPath = await getRootTreeSiblingPath(MerkleTreeId.ARCHIVE, db);
@@ -545,7 +567,8 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
545
567
  const blockEndBlobFields = blockProvingState.getBlockEndBlobFields();
546
568
  await endSpongeBlob.absorb(blockEndBlobFields);
547
569
  blockProvingState.setEndSpongeBlob(endSpongeBlob);
548
- // And also try to accumulate the blobs as far as we can:
570
+ // Try to accumulate the out hashes and blobs as far as we can:
571
+ await this.provingState.accumulateCheckpointOutHashes();
549
572
  await this.provingState.setBlobAccumulators();
550
573
  }
551
574
  }
@@ -559,7 +582,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
559
582
  if (!txs.length) {
560
583
  // To avoid an ugly throw below. If we require an empty block, we can just call setBlockCompleted
561
584
  // on a block with no txs. We cannot do that here because we cannot find the blockNumber without any txs.
562
- logger.warn(`Provided no txs to orchestrator addTxs.`);
585
+ this.logger.warn(`Provided no txs to orchestrator addTxs.`);
563
586
  return;
564
587
  }
565
588
  const blockNumber = BlockNumber(txs[0].globalVariables.blockNumber);
@@ -573,8 +596,8 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
573
596
  if (!provingState.isAcceptingTxs()) {
574
597
  throw new Error(`Block ${blockNumber} has been initialized with transactions.`);
575
598
  }
576
- logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
577
- const db = this.dbs.get(blockNumber);
599
+ this.logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
600
+ const db = this.getDbForBlock(blockNumber);
578
601
  const lastArchive = provingState.lastArchiveTreeSnapshot;
579
602
  const newL1ToL2MessageTreeSnapshot = provingState.newL1ToL2MessageTreeSnapshot;
580
603
  const spongeBlobState = provingState.getStartSpongeBlob().clone();
@@ -584,7 +607,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
584
607
  throw new Error(`Invalid proving state when adding a tx`);
585
608
  }
586
609
  validateTx(tx);
587
- logger.debug(`Received transaction: ${tx.hash}`);
610
+ this.logger.debug(`Received transaction: ${tx.hash}`);
588
611
  const startSpongeBlob = spongeBlobState.clone();
589
612
  const [hints, treeSnapshots] = await this.prepareBaseRollupInputs(tx, lastArchive, newL1ToL2MessageTreeSnapshot, startSpongeBlob, db);
590
613
  if (!provingState.verifyState()) {
@@ -595,10 +618,10 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
595
618
  const txIndex = provingState.addNewTx(txProvingState);
596
619
  if (txProvingState.requireAvmProof) {
597
620
  this.getOrEnqueueChonkVerifier(provingState, txIndex);
598
- logger.debug(`Enqueueing public VM for tx ${txIndex}`);
621
+ this.logger.debug(`Enqueueing public VM for tx ${txIndex}`);
599
622
  this.enqueueVM(provingState, txIndex);
600
623
  } else {
601
- logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
624
+ this.logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
602
625
  this.enqueueBaseRollup(provingState, txIndex);
603
626
  }
604
627
  } catch (err) {
@@ -612,7 +635,8 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
612
635
  const blockEndBlobFields = provingState.getBlockEndBlobFields();
613
636
  await spongeBlobState.absorb(blockEndBlobFields);
614
637
  provingState.setEndSpongeBlob(spongeBlobState);
615
- // Txs have been added to the block. Now try to accumulate the blobs as far as we can:
638
+ // Txs have been added to the block. Now try to accumulate the out hashes and blobs as far as we can:
639
+ await this.provingState.accumulateCheckpointOutHashes();
616
640
  await this.provingState.setBlobAccumulators();
617
641
  }
618
642
  /**
@@ -627,7 +651,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
627
651
  const txHash = tx.getTxHash().toString();
628
652
  const privateInputs = getPublicChonkVerifierPrivateInputsFromTx(tx, this.proverId.toField());
629
653
  const tubeProof = promiseWithResolvers();
630
- logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
654
+ this.logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
631
655
  this.doEnqueueChonkVerifier(txHash, privateInputs, (proof)=>{
632
656
  tubeProof.resolve(proof);
633
657
  });
@@ -656,17 +680,23 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
656
680
  throw new Error(`Block ${blockNumber} is still accepting txs. Call setBlockCompleted after all txs have been added.`);
657
681
  }
658
682
  // Given we've applied every change from this block, now assemble the block header:
659
- logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
683
+ this.logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
660
684
  const header = await provingState.buildBlockHeader();
661
685
  if (expectedHeader && !header.equals(expectedHeader)) {
662
- logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
686
+ this.logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
663
687
  throw new Error('Block header mismatch');
664
688
  }
665
- // Get db for this block
666
- const db = this.dbs.get(provingState.blockNumber);
667
- // Update the archive tree, so we're ready to start processing the next block:
668
- logger.verbose(`Updating archive tree with block ${provingState.blockNumber} header ${(await header.hash()).toString()}`);
669
- await db.updateArchive(header);
689
+ // Get db for this block and remove from map — no other code should use it after this point.
690
+ const db = this.getDbForBlock(provingState.blockNumber);
691
+ this.dbs.delete(provingState.blockNumber);
692
+ // Update the archive tree, capture the snapshot, and close the fork deterministically.
693
+ try {
694
+ this.logger.verbose(`Updating archive tree with block ${provingState.blockNumber} header ${(await header.hash()).toString()}`);
695
+ await db.updateArchive(header);
696
+ provingState.setBuiltArchive(await getTreeSnapshot(MerkleTreeId.ARCHIVE, db));
697
+ } finally{
698
+ await db.close();
699
+ }
670
700
  await this.verifyBuiltBlockAgainstSyncedState(provingState);
671
701
  return header;
672
702
  }
@@ -674,50 +704,65 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
674
704
  async verifyBuiltBlockAgainstSyncedState(provingState) {
675
705
  const builtBlockHeader = provingState.getBuiltBlockHeader();
676
706
  if (!builtBlockHeader) {
677
- logger.debug('Block header not built yet, skipping header check.');
707
+ this.logger.debug('Block header not built yet, skipping header check.');
678
708
  return;
679
709
  }
680
710
  const output = provingState.getBlockRootRollupOutput();
681
711
  if (!output) {
682
- logger.debug('Block root rollup proof not built yet, skipping header check.');
712
+ this.logger.debug('Block root rollup proof not built yet, skipping header check.');
713
+ return;
714
+ }
715
+ const newArchive = provingState.getBuiltArchive();
716
+ if (!newArchive) {
717
+ this.logger.debug('Archive snapshot not yet captured, skipping header check.');
683
718
  return;
684
719
  }
685
720
  const header = await buildHeaderFromCircuitOutputs(output);
686
721
  if (!(await header.hash()).equals(await builtBlockHeader.hash())) {
687
- logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
722
+ this.logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
688
723
  provingState.reject(`Block header hash mismatch.`);
689
724
  return;
690
725
  }
691
- // Get db for this block
692
726
  const blockNumber = provingState.blockNumber;
693
- const db = this.dbs.get(blockNumber);
694
- const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
695
727
  const syncedArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.dbProvider.getSnapshot(blockNumber));
696
728
  if (!syncedArchive.equals(newArchive)) {
697
- logger.error(`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(syncedArchive)} but built ${inspect(newArchive)}`);
729
+ this.logger.error(`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(syncedArchive)} but built ${inspect(newArchive)}`);
698
730
  provingState.reject(`Archive tree mismatch.`);
699
731
  return;
700
732
  }
701
733
  const circuitArchive = output.newArchive;
702
734
  if (!newArchive.equals(circuitArchive)) {
703
- logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
735
+ this.logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
704
736
  provingState.reject(`New archive mismatch.`);
705
737
  return;
706
738
  }
707
- // TODO(palla/prover): This closes the fork only on the happy path. If this epoch orchestrator
708
- // is aborted and never reaches this point, it will leak the fork. We need to add a global cleanup,
709
- // but have to make sure it only runs once all operations are completed, otherwise some function here
710
- // will attempt to access the fork after it was closed.
711
- logger.debug(`Cleaning up world state fork for ${blockNumber}`);
712
- void this.dbs.get(blockNumber)?.close().then(()=>this.dbs.delete(blockNumber)).catch((err)=>logger.error(`Error closing db for block ${blockNumber}`, err));
713
739
  }
714
740
  /**
715
- * Cancel any further proving
741
+ * Cancel any further proving.
742
+ * If cancelJobsOnStop is true, aborts all pending jobs with the broker (which marks them as 'Aborted').
743
+ * If cancelJobsOnStop is false (default), jobs remain in the broker queue and can be reused on restart/reorg.
716
744
  */ cancel() {
717
- for (const controller of this.pendingProvingJobs){
718
- controller.abort();
745
+ void this.deferredJobQueue.cancel();
746
+ // Recreate the queue so it can accept jobs for subsequent epochs.
747
+ this.deferredJobQueue = new SerialQueue();
748
+ this.deferredJobQueue.start(this.enqueueConcurrency);
749
+ if (this.cancelJobsOnStop) {
750
+ for (const controller of this.pendingProvingJobs){
751
+ controller.abort();
752
+ }
719
753
  }
720
754
  this.provingState?.cancel();
755
+ for (const [blockNumber, db] of this.dbs.entries()){
756
+ void db.close().catch((err)=>this.logger.error(`Error closing db for block ${blockNumber}`, err));
757
+ }
758
+ this.dbs.clear();
759
+ }
760
+ getDbForBlock(blockNumber) {
761
+ const db = this.dbs.get(blockNumber);
762
+ if (!db) {
763
+ throw new Error(`World state fork for block ${blockNumber} not found.`);
764
+ }
765
+ return db;
721
766
  }
722
767
  /**
723
768
  * Returns the proof for the current epoch.
@@ -744,7 +789,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
744
789
  * @param job - The actual job, returns a promise notifying of the job's completion
745
790
  */ deferredProving(provingState, request, callback) {
746
791
  if (!provingState.verifyState()) {
747
- logger.debug(`Not enqueuing job, state no longer valid`);
792
+ this.logger.debug(`Not enqueuing job, state no longer valid`);
748
793
  return;
749
794
  }
750
795
  const controller = new AbortController();
@@ -759,7 +804,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
759
804
  }
760
805
  const result = await request(controller.signal);
761
806
  if (!provingState.verifyState()) {
762
- logger.debug(`State no longer valid, discarding result`);
807
+ this.logger.debug(`State no longer valid, discarding result`);
763
808
  return;
764
809
  }
765
810
  // we could have been cancelled whilst waiting for the result
@@ -774,7 +819,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
774
819
  // drop this result
775
820
  return;
776
821
  }
777
- logger.error(`Error thrown when proving job`, err);
822
+ this.logger.error(`Error thrown when proving job`, err);
778
823
  provingState.reject(`${err}`);
779
824
  } finally{
780
825
  const index = this.pendingProvingJobs.indexOf(controller);
@@ -783,8 +828,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
783
828
  }
784
829
  }
785
830
  };
786
- // let the callstack unwind before adding the job to the queue
787
- setImmediate(()=>void safeJob());
831
+ void this.deferredJobQueue.put(async ()=>{
832
+ void safeJob();
833
+ // we yield here to the macro task queue such to give Nodejs a chance to run other operatoins in between enqueues
834
+ await sleep(0);
835
+ });
788
836
  }
789
837
  async updateL1ToL2MessageTree(l1ToL2Messages, db) {
790
838
  const l1ToL2MessagesPadded = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 'Too many L1 to L2 messages');
@@ -830,17 +878,17 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
830
878
  // Executes the next level of merge if all inputs are available
831
879
  enqueueBaseRollup(provingState, txIndex) {
832
880
  if (!provingState.verifyState()) {
833
- logger.debug('Not running base rollup, state invalid');
881
+ this.logger.debug('Not running base rollup, state invalid');
834
882
  return;
835
883
  }
836
884
  if (!provingState.tryStartProvingBase(txIndex)) {
837
- logger.debug(`Base rollup for tx ${txIndex} already started.`);
885
+ this.logger.debug(`Base rollup for tx ${txIndex} already started.`);
838
886
  return;
839
887
  }
840
888
  const txProvingState = provingState.getTxProvingState(txIndex);
841
889
  const { processedTx } = txProvingState;
842
890
  const { rollupType, inputs } = txProvingState.getBaseRollupTypeAndInputs();
843
- logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
891
+ this.logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
844
892
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, `ProvingOrchestrator.prover.${inputs instanceof PrivateTxBaseRollupPrivateInputs ? 'getPrivateTxBaseRollupProof' : 'getPublicTxBaseRollupProof'}`, {
845
893
  [Attributes.TX_HASH]: processedTx.hash.toString(),
846
894
  [Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
@@ -851,7 +899,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
851
899
  return this.prover.getPublicTxBaseRollupProof(inputs, signal, provingState.epochNumber);
852
900
  }
853
901
  }), (result)=>{
854
- logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
902
+ this.logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
855
903
  validatePartialState(result.inputs.endTreeSnapshots, txProvingState.treeSnapshots);
856
904
  const leafLocation = provingState.setBaseRollupProof(txIndex, result);
857
905
  if (provingState.totalNumTxs === 1) {
@@ -865,14 +913,14 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
865
913
  // Once completed, will enqueue the the public tx base rollup.
866
914
  getOrEnqueueChonkVerifier(provingState, txIndex) {
867
915
  if (!provingState.verifyState()) {
868
- logger.debug('Not running chonk verifier circuit, state invalid');
916
+ this.logger.debug('Not running chonk verifier circuit, state invalid');
869
917
  return;
870
918
  }
871
919
  const txProvingState = provingState.getTxProvingState(txIndex);
872
920
  const txHash = txProvingState.processedTx.hash.toString();
873
921
  NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH;
874
922
  const handleResult = (result)=>{
875
- logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
923
+ this.logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
876
924
  txHash
877
925
  });
878
926
  txProvingState.setPublicChonkVerifierProof(result);
@@ -880,18 +928,18 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
880
928
  this.checkAndEnqueueBaseRollup(provingState, txIndex);
881
929
  };
882
930
  if (this.provingState?.cachedChonkVerifierProofs.has(txHash)) {
883
- logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, {
931
+ this.logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, {
884
932
  txHash
885
933
  });
886
934
  void this.provingState.cachedChonkVerifierProofs.get(txHash).then(handleResult);
887
935
  return;
888
936
  }
889
- logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
937
+ this.logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
890
938
  this.doEnqueueChonkVerifier(txHash, txProvingState.getPublicChonkVerifierPrivateInputs(), handleResult);
891
939
  }
892
940
  doEnqueueChonkVerifier(txHash, inputs, handler, provingState = this.provingState) {
893
941
  if (!provingState.verifyState()) {
894
- logger.debug('Not running chonk verifier circuit, state invalid');
942
+ this.logger.debug('Not running chonk verifier circuit, state invalid');
895
943
  return;
896
944
  }
897
945
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getPublicChonkVerifierProof', {
@@ -903,11 +951,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
903
951
  // Enqueues the next level of merge if all inputs are available
904
952
  enqueueMergeRollup(provingState, location) {
905
953
  if (!provingState.verifyState()) {
906
- logger.debug('Not running merge rollup. State no longer valid.');
954
+ this.logger.debug('Not running merge rollup. State no longer valid.');
907
955
  return;
908
956
  }
909
957
  if (!provingState.tryStartProvingMerge(location)) {
910
- logger.debug('Merge rollup already started.');
958
+ this.logger.debug('Merge rollup already started.');
911
959
  return;
912
960
  }
913
961
  const inputs = provingState.getMergeRollupInputs(location);
@@ -921,15 +969,15 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
921
969
  // Executes the block root rollup circuit
922
970
  enqueueBlockRootRollup(provingState) {
923
971
  if (!provingState.verifyState()) {
924
- logger.debug('Not running block root rollup, state no longer valid');
972
+ this.logger.debug('Not running block root rollup, state no longer valid');
925
973
  return;
926
974
  }
927
975
  if (!provingState.tryStartProvingBlockRoot()) {
928
- logger.debug('Block root rollup already started.');
976
+ this.logger.debug('Block root rollup already started.');
929
977
  return;
930
978
  }
931
979
  const { rollupType, inputs } = provingState.getBlockRootRollupTypeAndInputs();
932
- logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
980
+ this.logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
933
981
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockRootRollupProof', {
934
982
  [Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
935
983
  }, (signal)=>{
@@ -945,15 +993,16 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
945
993
  return this.prover.getBlockRootRollupProof(inputs, signal, provingState.epochNumber);
946
994
  }
947
995
  }), async (result)=>{
948
- // If the proofs were slower than the block header building, then we need to try validating the block header hashes here.
949
- await this.verifyBuiltBlockAgainstSyncedState(provingState);
950
- logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
996
+ this.logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
951
997
  const leafLocation = provingState.setBlockRootRollupProof(result);
952
998
  const checkpointProvingState = provingState.parentCheckpoint;
999
+ // Verification is called from both here and setBlockCompleted. Whichever runs last
1000
+ // will be the first to see all three pieces (header, proof output, archive) and run the checks.
1001
+ await this.verifyBuiltBlockAgainstSyncedState(provingState);
953
1002
  if (checkpointProvingState.totalNumBlocks === 1) {
954
- this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
1003
+ await this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
955
1004
  } else {
956
- this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
1005
+ await this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
957
1006
  }
958
1007
  });
959
1008
  }
@@ -961,11 +1010,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
961
1010
  // Enqueues the root parity circuit if all inputs are available
962
1011
  enqueueBaseParityCircuit(checkpointProvingState, provingState, baseParityIndex) {
963
1012
  if (!provingState.verifyState()) {
964
- logger.debug('Not running base parity. State no longer valid.');
1013
+ this.logger.debug('Not running base parity. State no longer valid.');
965
1014
  return;
966
1015
  }
967
1016
  if (!provingState.tryStartProvingBaseParity(baseParityIndex)) {
968
- logger.warn(`Base parity ${baseParityIndex} already started.`);
1017
+ this.logger.warn(`Base parity ${baseParityIndex} already started.`);
969
1018
  return;
970
1019
  }
971
1020
  const inputs = checkpointProvingState.getBaseParityInputs(baseParityIndex);
@@ -986,11 +1035,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
986
1035
  // Enqueues the root rollup proof if all inputs are available
987
1036
  enqueueRootParityCircuit(provingState) {
988
1037
  if (!provingState.verifyState()) {
989
- logger.debug('Not running root parity. State no longer valid.');
1038
+ this.logger.debug('Not running root parity. State no longer valid.');
990
1039
  return;
991
1040
  }
992
1041
  if (!provingState.tryStartProvingRootParity()) {
993
- logger.debug('Root parity already started.');
1042
+ this.logger.debug('Root parity already started.');
994
1043
  return;
995
1044
  }
996
1045
  const inputs = provingState.getParityRootInputs();
@@ -1005,33 +1054,33 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
1005
1054
  // Enqueues the next level of merge if all inputs are available
1006
1055
  enqueueBlockMergeRollup(provingState, location) {
1007
1056
  if (!provingState.verifyState()) {
1008
- logger.debug('Not running block merge rollup. State no longer valid.');
1057
+ this.logger.debug('Not running block merge rollup. State no longer valid.');
1009
1058
  return;
1010
1059
  }
1011
1060
  if (!provingState.tryStartProvingBlockMerge(location)) {
1012
- logger.debug('Block merge rollup already started.');
1061
+ this.logger.debug('Block merge rollup already started.');
1013
1062
  return;
1014
1063
  }
1015
1064
  const inputs = provingState.getBlockMergeRollupInputs(location);
1016
1065
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockMergeRollupProof', {
1017
1066
  [Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-block-merge'
1018
- }, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
1067
+ }, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), async (result)=>{
1019
1068
  provingState.setBlockMergeRollupProof(location, result);
1020
- this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
1069
+ await this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
1021
1070
  });
1022
1071
  }
1023
- enqueueCheckpointRootRollup(provingState) {
1072
+ async enqueueCheckpointRootRollup(provingState) {
1024
1073
  if (!provingState.verifyState()) {
1025
- logger.debug('Not running checkpoint root rollup. State no longer valid.');
1074
+ this.logger.debug('Not running checkpoint root rollup. State no longer valid.');
1026
1075
  return;
1027
1076
  }
1028
1077
  if (!provingState.tryStartProvingCheckpointRoot()) {
1029
- logger.debug('Checkpoint root rollup already started.');
1078
+ this.logger.debug('Checkpoint root rollup already started.');
1030
1079
  return;
1031
1080
  }
1032
1081
  const rollupType = provingState.getCheckpointRootRollupType();
1033
- logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
1034
- const inputs = provingState.getCheckpointRootRollupInputs();
1082
+ this.logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
1083
+ const inputs = await provingState.getCheckpointRootRollupInputs();
1035
1084
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointRootRollupProof', {
1036
1085
  [Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
1037
1086
  }, (signal)=>{
@@ -1044,11 +1093,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
1044
1093
  const computedEndBlobAccumulatorState = provingState.getEndBlobAccumulator().toBlobAccumulator();
1045
1094
  const circuitEndBlobAccumulatorState = result.inputs.endBlobAccumulator;
1046
1095
  if (!circuitEndBlobAccumulatorState.equals(computedEndBlobAccumulatorState)) {
1047
- logger.error(`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(computedEndBlobAccumulatorState)}`);
1096
+ this.logger.error(`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(computedEndBlobAccumulatorState)}`);
1048
1097
  provingState.reject(`Blob accumulator state mismatch.`);
1049
1098
  return;
1050
1099
  }
1051
- logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
1100
+ this.logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
1052
1101
  const leafLocation = provingState.setCheckpointRootRollupProof(result);
1053
1102
  const epochProvingState = provingState.parentEpoch;
1054
1103
  if (epochProvingState.totalNumCheckpoints === 1) {
@@ -1060,37 +1109,37 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
1060
1109
  }
1061
1110
  enqueueCheckpointMergeRollup(provingState, location) {
1062
1111
  if (!provingState.verifyState()) {
1063
- logger.debug('Not running checkpoint merge rollup. State no longer valid.');
1112
+ this.logger.debug('Not running checkpoint merge rollup. State no longer valid.');
1064
1113
  return;
1065
1114
  }
1066
1115
  if (!provingState.tryStartProvingCheckpointMerge(location)) {
1067
- logger.debug('Checkpoint merge rollup already started.');
1116
+ this.logger.debug('Checkpoint merge rollup already started.');
1068
1117
  return;
1069
1118
  }
1070
1119
  const inputs = provingState.getCheckpointMergeRollupInputs(location);
1071
1120
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointMergeRollupProof', {
1072
1121
  [Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-merge'
1073
1122
  }, (signal)=>this.prover.getCheckpointMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
1074
- logger.debug('Completed proof for checkpoint merge rollup.');
1123
+ this.logger.debug('Completed proof for checkpoint merge rollup.');
1075
1124
  provingState.setCheckpointMergeRollupProof(location, result);
1076
1125
  this.checkAndEnqueueNextCheckpointMergeRollup(provingState, location);
1077
1126
  });
1078
1127
  }
1079
1128
  enqueueEpochPadding(provingState) {
1080
1129
  if (!provingState.verifyState()) {
1081
- logger.debug('Not running epoch padding. State no longer valid.');
1130
+ this.logger.debug('Not running epoch padding. State no longer valid.');
1082
1131
  return;
1083
1132
  }
1084
1133
  if (!provingState.tryStartProvingPaddingCheckpoint()) {
1085
- logger.debug('Padding checkpoint already started.');
1134
+ this.logger.debug('Padding checkpoint already started.');
1086
1135
  return;
1087
1136
  }
1088
- logger.debug('Padding epoch proof with a padding block root proof.');
1137
+ this.logger.debug('Padding epoch proof with a padding block root proof.');
1089
1138
  const inputs = provingState.getPaddingCheckpointInputs();
1090
1139
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointPaddingRollupProof', {
1091
1140
  [Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-padding'
1092
1141
  }, (signal)=>this.prover.getCheckpointPaddingRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
1093
- logger.debug('Completed proof for padding checkpoint.');
1142
+ this.logger.debug('Completed proof for padding checkpoint.');
1094
1143
  provingState.setCheckpointPaddingProof(result);
1095
1144
  this.checkAndEnqueueRootRollup(provingState);
1096
1145
  });
@@ -1098,15 +1147,15 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
1098
1147
  // Executes the root rollup circuit
1099
1148
  enqueueRootRollup(provingState) {
1100
1149
  if (!provingState.verifyState()) {
1101
- logger.debug('Not running root rollup, state no longer valid');
1150
+ this.logger.debug('Not running root rollup, state no longer valid');
1102
1151
  return;
1103
1152
  }
1104
- logger.debug(`Preparing root rollup`);
1153
+ this.logger.debug(`Preparing root rollup`);
1105
1154
  const inputs = provingState.getRootRollupInputs();
1106
1155
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getRootRollupProof', {
1107
1156
  [Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-root'
1108
1157
  }, (signal)=>this.prover.getRootRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
1109
- logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
1158
+ this.logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
1110
1159
  provingState.setRootRollupProof(result);
1111
1160
  provingState.resolve({
1112
1161
  status: 'success'
@@ -1126,27 +1175,27 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
1126
1175
  }
1127
1176
  checkAndEnqueueBlockRootRollup(provingState) {
1128
1177
  if (!provingState.isReadyForBlockRootRollup()) {
1129
- logger.debug('Not ready for block root rollup');
1178
+ this.logger.debug('Not ready for block root rollup');
1130
1179
  return;
1131
1180
  }
1132
1181
  this.enqueueBlockRootRollup(provingState);
1133
1182
  }
1134
- checkAndEnqueueNextBlockMergeRollup(provingState, currentLocation) {
1183
+ async checkAndEnqueueNextBlockMergeRollup(provingState, currentLocation) {
1135
1184
  if (!provingState.isReadyForBlockMerge(currentLocation)) {
1136
1185
  return;
1137
1186
  }
1138
1187
  const parentLocation = provingState.getParentLocation(currentLocation);
1139
1188
  if (parentLocation.level === 0) {
1140
- this.checkAndEnqueueCheckpointRootRollup(provingState);
1189
+ await this.checkAndEnqueueCheckpointRootRollup(provingState);
1141
1190
  } else {
1142
1191
  this.enqueueBlockMergeRollup(provingState, parentLocation);
1143
1192
  }
1144
1193
  }
1145
- checkAndEnqueueCheckpointRootRollup(provingState) {
1194
+ async checkAndEnqueueCheckpointRootRollup(provingState) {
1146
1195
  if (!provingState.isReadyForCheckpointRoot()) {
1147
1196
  return;
1148
1197
  }
1149
- this.enqueueCheckpointRootRollup(provingState);
1198
+ await this.enqueueCheckpointRootRollup(provingState);
1150
1199
  }
1151
1200
  checkAndEnqueueNextCheckpointMergeRollup(provingState, currentLocation) {
1152
1201
  if (!provingState.isReadyForCheckpointMerge(currentLocation)) {
@@ -1161,7 +1210,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
1161
1210
  }
1162
1211
  checkAndEnqueueRootRollup(provingState) {
1163
1212
  if (!provingState.isReadyForRootRollup()) {
1164
- logger.debug('Not ready for root rollup');
1213
+ this.logger.debug('Not ready for root rollup');
1165
1214
  return;
1166
1215
  }
1167
1216
  this.enqueueRootRollup(provingState);
@@ -1173,7 +1222,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
1173
1222
  * @param txIndex - The index of the transaction being proven
1174
1223
  */ enqueueVM(provingState, txIndex) {
1175
1224
  if (!provingState.verifyState()) {
1176
- logger.debug(`Not running VM circuit as state is no longer valid`);
1225
+ this.logger.debug(`Not running VM circuit as state is no longer valid`);
1177
1226
  return;
1178
1227
  }
1179
1228
  const txProvingState = provingState.getTxProvingState(txIndex);
@@ -1184,7 +1233,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
1184
1233
  return await this.prover.getAvmProof(inputs, signal, provingState.epochNumber);
1185
1234
  });
1186
1235
  this.deferredProving(provingState, doAvmProving, (proof)=>{
1187
- logger.debug(`Proven VM for tx index: ${txIndex}`);
1236
+ this.logger.debug(`Proven VM for tx index: ${txIndex}`);
1188
1237
  txProvingState.setAvmProof(proof);
1189
1238
  this.checkAndEnqueueBaseRollup(provingState, txIndex);
1190
1239
  });
@@ -1195,7 +1244,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
1195
1244
  return;
1196
1245
  }
1197
1246
  // We must have completed all proving (chonk verifier proof and (if required) vm proof are generated), we now move to the base rollup.
1198
- logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
1247
+ this.logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
1199
1248
  this.enqueueBaseRollup(provingState, txIndex);
1200
1249
  }
1201
1250
  }