@aztec/prover-client 0.0.1-commit.0b941701 → 0.0.1-commit.10bd49492
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.
- package/dest/light/lightweight_checkpoint_builder.d.ts +13 -5
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +45 -20
- package/dest/mocks/fixtures.d.ts +1 -1
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +2 -1
- package/dest/mocks/test_context.js +6 -3
- package/dest/orchestrator/block-building-helpers.d.ts +4 -4
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +4 -4
- package/dest/orchestrator/block-proving-state.d.ts +4 -1
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +7 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts +3 -3
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +3 -3
- package/dest/orchestrator/epoch-proving-state.d.ts +3 -3
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +5 -3
- package/dest/orchestrator/orchestrator.d.ts +7 -3
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +122 -117
- package/dest/prover-client/prover-client.d.ts +4 -4
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +15 -10
- package/dest/proving_broker/broker_prover_facade.d.ts +4 -3
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +6 -6
- package/dest/proving_broker/config.d.ts +10 -2
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +14 -3
- package/dest/proving_broker/proof_store/factory.d.ts +2 -5
- package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/factory.js +7 -30
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
- package/dest/proving_broker/proof_store/index.d.ts +2 -2
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -1
- package/dest/proving_broker/proving_agent.d.ts +4 -3
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +4 -4
- package/dest/proving_broker/proving_broker.d.ts +7 -4
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +36 -4
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +3 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +18 -7
- package/dest/proving_broker/proving_job_controller.d.ts +4 -3
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +6 -3
- package/dest/proving_broker/rpc.d.ts +4 -2
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +8 -0
- package/dest/test/mock_prover.d.ts +4 -4
- package/package.json +17 -18
- package/src/light/lightweight_checkpoint_builder.ts +52 -21
- package/src/mocks/fixtures.ts +2 -1
- package/src/mocks/test_context.ts +3 -3
- package/src/orchestrator/block-building-helpers.ts +4 -4
- package/src/orchestrator/block-proving-state.ts +9 -0
- package/src/orchestrator/checkpoint-proving-state.ts +4 -4
- package/src/orchestrator/epoch-proving-state.ts +6 -4
- package/src/orchestrator/orchestrator.ts +132 -125
- package/src/prover-client/prover-client.ts +24 -14
- package/src/proving_broker/broker_prover_facade.ts +15 -7
- package/src/proving_broker/config.ts +14 -1
- package/src/proving_broker/proof_store/factory.ts +10 -32
- package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
- package/src/proving_broker/proof_store/index.ts +1 -1
- package/src/proving_broker/proving_agent.ts +5 -2
- package/src/proving_broker/proving_broker.ts +37 -3
- package/src/proving_broker/proving_broker_instrumentation.ts +19 -6
- package/src/proving_broker/proving_job_controller.ts +9 -3
- package/src/proving_broker/rpc.ts +14 -0
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +0 -14
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +0 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.js +0 -52
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
|
@@ -378,6 +378,7 @@ 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';
|
|
382
383
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
383
384
|
import { elapsed } from '@aztec/foundation/timer';
|
|
@@ -389,7 +390,6 @@ import { buildHeaderFromCircuitOutputs, getLastSiblingPath, getPublicChonkVerifi
|
|
|
389
390
|
import { EpochProvingState } from './epoch-proving-state.js';
|
|
390
391
|
import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
|
|
391
392
|
import { TxProvingState } from './tx-proving-state.js';
|
|
392
|
-
const logger = createLogger('prover-client:orchestrator');
|
|
393
393
|
_dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
394
394
|
[Attributes.BLOCK_NUMBER]: blockNumber
|
|
395
395
|
})), _dec1 = trackSpan('ProvingOrchestrator.addTxs', (txs)=>({
|
|
@@ -415,6 +415,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
415
415
|
prover;
|
|
416
416
|
proverId;
|
|
417
417
|
cancelJobsOnStop;
|
|
418
|
+
enqueueConcurrency;
|
|
418
419
|
static{
|
|
419
420
|
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
420
421
|
[
|
|
@@ -450,16 +451,22 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
450
451
|
metrics;
|
|
451
452
|
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
452
453
|
dbs;
|
|
453
|
-
|
|
454
|
+
logger;
|
|
455
|
+
deferredJobQueue;
|
|
456
|
+
constructor(dbProvider, prover, proverId, cancelJobsOnStop = false, enqueueConcurrency, telemetryClient = getTelemetryClient(), bindings){
|
|
454
457
|
this.dbProvider = dbProvider;
|
|
455
458
|
this.prover = prover;
|
|
456
459
|
this.proverId = proverId;
|
|
457
460
|
this.cancelJobsOnStop = cancelJobsOnStop;
|
|
461
|
+
this.enqueueConcurrency = enqueueConcurrency;
|
|
458
462
|
this.provingState = (_initProto(this), undefined);
|
|
459
463
|
this.pendingProvingJobs = [];
|
|
460
464
|
this.provingPromise = undefined;
|
|
461
465
|
this.dbs = new Map();
|
|
466
|
+
this.deferredJobQueue = new SerialQueue();
|
|
467
|
+
this.logger = createLogger('prover-client:orchestrator', bindings);
|
|
462
468
|
this.metrics = new ProvingOrchestratorMetrics(telemetryClient, 'ProvingOrchestrator');
|
|
469
|
+
this.deferredJobQueue.start(this.enqueueConcurrency);
|
|
463
470
|
}
|
|
464
471
|
get tracer() {
|
|
465
472
|
return this.metrics.tracer;
|
|
@@ -470,9 +477,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
470
477
|
getNumActiveForks() {
|
|
471
478
|
return this.dbs.size;
|
|
472
479
|
}
|
|
473
|
-
stop() {
|
|
480
|
+
async stop() {
|
|
481
|
+
// Grab the old queue before cancel() replaces it, so we can await its draining.
|
|
482
|
+
const oldQueue = this.deferredJobQueue;
|
|
474
483
|
this.cancel();
|
|
475
|
-
|
|
484
|
+
await oldQueue.cancel();
|
|
476
485
|
}
|
|
477
486
|
startNewEpoch(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges) {
|
|
478
487
|
if (this.provingState?.verifyState()) {
|
|
@@ -483,7 +492,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
483
492
|
status: 'failure',
|
|
484
493
|
reason
|
|
485
494
|
}));
|
|
486
|
-
logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
495
|
+
this.logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
487
496
|
this.provingState = new EpochProvingState(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges, (provingState)=>this.checkAndEnqueueCheckpointRootRollup(provingState), resolve, reject);
|
|
488
497
|
this.provingPromise = promise;
|
|
489
498
|
}
|
|
@@ -505,10 +514,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
505
514
|
const lastBlockNumber = headerOfLastBlockInPreviousCheckpoint.globalVariables.blockNumber;
|
|
506
515
|
const db = await this.dbProvider.fork(lastBlockNumber);
|
|
507
516
|
const firstBlockNumber = BlockNumber(lastBlockNumber + 1);
|
|
508
|
-
this.dbs.set(firstBlockNumber,
|
|
509
|
-
fork: db,
|
|
510
|
-
cleanupPromise: undefined
|
|
511
|
-
});
|
|
517
|
+
this.dbs.set(firstBlockNumber, db);
|
|
512
518
|
// Get archive sibling path before any block in this checkpoint lands.
|
|
513
519
|
const lastArchiveSiblingPath = await getLastSiblingPath(MerkleTreeId.ARCHIVE, db);
|
|
514
520
|
// Insert all the l1 to l2 messages into the db. And get the states before and after the insertion.
|
|
@@ -533,17 +539,14 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
533
539
|
throw new Error(`Checkpoint not accepting further blocks.`);
|
|
534
540
|
}
|
|
535
541
|
const constants = checkpointProvingState.constants;
|
|
536
|
-
logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
542
|
+
this.logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
537
543
|
// Fork the db only when it's not already set. The db for the first block is set in `startNewCheckpoint`.
|
|
538
544
|
if (!this.dbs.has(blockNumber)) {
|
|
539
545
|
// Fork world state at the end of the immediately previous block
|
|
540
546
|
const db = await this.dbProvider.fork(BlockNumber(blockNumber - 1));
|
|
541
|
-
this.dbs.set(blockNumber,
|
|
542
|
-
fork: db,
|
|
543
|
-
cleanupPromise: undefined
|
|
544
|
-
});
|
|
547
|
+
this.dbs.set(blockNumber, db);
|
|
545
548
|
}
|
|
546
|
-
const db = this.
|
|
549
|
+
const db = this.getDbForBlock(blockNumber);
|
|
547
550
|
// Get archive snapshot and sibling path before any txs in this block lands.
|
|
548
551
|
const lastArchiveTreeSnapshot = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
549
552
|
const lastArchiveSiblingPath = await getRootTreeSiblingPath(MerkleTreeId.ARCHIVE, db);
|
|
@@ -578,7 +581,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
578
581
|
if (!txs.length) {
|
|
579
582
|
// To avoid an ugly throw below. If we require an empty block, we can just call setBlockCompleted
|
|
580
583
|
// on a block with no txs. We cannot do that here because we cannot find the blockNumber without any txs.
|
|
581
|
-
logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
584
|
+
this.logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
582
585
|
return;
|
|
583
586
|
}
|
|
584
587
|
const blockNumber = BlockNumber(txs[0].globalVariables.blockNumber);
|
|
@@ -592,8 +595,8 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
592
595
|
if (!provingState.isAcceptingTxs()) {
|
|
593
596
|
throw new Error(`Block ${blockNumber} has been initialized with transactions.`);
|
|
594
597
|
}
|
|
595
|
-
logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
596
|
-
const db = this.
|
|
598
|
+
this.logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
599
|
+
const db = this.getDbForBlock(blockNumber);
|
|
597
600
|
const lastArchive = provingState.lastArchiveTreeSnapshot;
|
|
598
601
|
const newL1ToL2MessageTreeSnapshot = provingState.newL1ToL2MessageTreeSnapshot;
|
|
599
602
|
const spongeBlobState = provingState.getStartSpongeBlob().clone();
|
|
@@ -603,7 +606,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
603
606
|
throw new Error(`Invalid proving state when adding a tx`);
|
|
604
607
|
}
|
|
605
608
|
validateTx(tx);
|
|
606
|
-
logger.debug(`Received transaction: ${tx.hash}`);
|
|
609
|
+
this.logger.debug(`Received transaction: ${tx.hash}`);
|
|
607
610
|
const startSpongeBlob = spongeBlobState.clone();
|
|
608
611
|
const [hints, treeSnapshots] = await this.prepareBaseRollupInputs(tx, lastArchive, newL1ToL2MessageTreeSnapshot, startSpongeBlob, db);
|
|
609
612
|
if (!provingState.verifyState()) {
|
|
@@ -614,10 +617,10 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
614
617
|
const txIndex = provingState.addNewTx(txProvingState);
|
|
615
618
|
if (txProvingState.requireAvmProof) {
|
|
616
619
|
this.getOrEnqueueChonkVerifier(provingState, txIndex);
|
|
617
|
-
logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
620
|
+
this.logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
618
621
|
this.enqueueVM(provingState, txIndex);
|
|
619
622
|
} else {
|
|
620
|
-
logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
623
|
+
this.logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
621
624
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
622
625
|
}
|
|
623
626
|
} catch (err) {
|
|
@@ -647,7 +650,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
647
650
|
const txHash = tx.getTxHash().toString();
|
|
648
651
|
const privateInputs = getPublicChonkVerifierPrivateInputsFromTx(tx, this.proverId.toField());
|
|
649
652
|
const tubeProof = promiseWithResolvers();
|
|
650
|
-
logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
653
|
+
this.logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
651
654
|
this.doEnqueueChonkVerifier(txHash, privateInputs, (proof)=>{
|
|
652
655
|
tubeProof.resolve(proof);
|
|
653
656
|
});
|
|
@@ -676,17 +679,23 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
676
679
|
throw new Error(`Block ${blockNumber} is still accepting txs. Call setBlockCompleted after all txs have been added.`);
|
|
677
680
|
}
|
|
678
681
|
// Given we've applied every change from this block, now assemble the block header:
|
|
679
|
-
logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
682
|
+
this.logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
680
683
|
const header = await provingState.buildBlockHeader();
|
|
681
684
|
if (expectedHeader && !header.equals(expectedHeader)) {
|
|
682
|
-
logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
685
|
+
this.logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
683
686
|
throw new Error('Block header mismatch');
|
|
684
687
|
}
|
|
685
|
-
// Get db for this block
|
|
686
|
-
const db = this.
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
688
|
+
// Get db for this block and remove from map — no other code should use it after this point.
|
|
689
|
+
const db = this.getDbForBlock(provingState.blockNumber);
|
|
690
|
+
this.dbs.delete(provingState.blockNumber);
|
|
691
|
+
// Update the archive tree, capture the snapshot, and close the fork deterministically.
|
|
692
|
+
try {
|
|
693
|
+
this.logger.verbose(`Updating archive tree with block ${provingState.blockNumber} header ${(await header.hash()).toString()}`);
|
|
694
|
+
await db.updateArchive(header);
|
|
695
|
+
provingState.setBuiltArchive(await getTreeSnapshot(MerkleTreeId.ARCHIVE, db));
|
|
696
|
+
} finally{
|
|
697
|
+
await db.close();
|
|
698
|
+
}
|
|
690
699
|
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
691
700
|
return header;
|
|
692
701
|
}
|
|
@@ -694,53 +703,65 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
694
703
|
async verifyBuiltBlockAgainstSyncedState(provingState) {
|
|
695
704
|
const builtBlockHeader = provingState.getBuiltBlockHeader();
|
|
696
705
|
if (!builtBlockHeader) {
|
|
697
|
-
logger.debug('Block header not built yet, skipping header check.');
|
|
706
|
+
this.logger.debug('Block header not built yet, skipping header check.');
|
|
698
707
|
return;
|
|
699
708
|
}
|
|
700
709
|
const output = provingState.getBlockRootRollupOutput();
|
|
701
710
|
if (!output) {
|
|
702
|
-
logger.debug('Block root rollup proof not built yet, skipping header check.');
|
|
711
|
+
this.logger.debug('Block root rollup proof not built yet, skipping header check.');
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
const newArchive = provingState.getBuiltArchive();
|
|
715
|
+
if (!newArchive) {
|
|
716
|
+
this.logger.debug('Archive snapshot not yet captured, skipping header check.');
|
|
703
717
|
return;
|
|
704
718
|
}
|
|
705
719
|
const header = await buildHeaderFromCircuitOutputs(output);
|
|
706
720
|
if (!(await header.hash()).equals(await builtBlockHeader.hash())) {
|
|
707
|
-
logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
721
|
+
this.logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
708
722
|
provingState.reject(`Block header hash mismatch.`);
|
|
709
723
|
return;
|
|
710
724
|
}
|
|
711
|
-
// Get db for this block
|
|
712
725
|
const blockNumber = provingState.blockNumber;
|
|
713
|
-
const db = this.dbs.get(blockNumber).fork;
|
|
714
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
715
726
|
const syncedArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.dbProvider.getSnapshot(blockNumber));
|
|
716
727
|
if (!syncedArchive.equals(newArchive)) {
|
|
717
|
-
logger.error(`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(syncedArchive)} but built ${inspect(newArchive)}`);
|
|
728
|
+
this.logger.error(`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(syncedArchive)} but built ${inspect(newArchive)}`);
|
|
718
729
|
provingState.reject(`Archive tree mismatch.`);
|
|
719
730
|
return;
|
|
720
731
|
}
|
|
721
732
|
const circuitArchive = output.newArchive;
|
|
722
733
|
if (!newArchive.equals(circuitArchive)) {
|
|
723
|
-
logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
734
|
+
this.logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
724
735
|
provingState.reject(`New archive mismatch.`);
|
|
725
736
|
return;
|
|
726
737
|
}
|
|
727
|
-
// TODO(palla/prover): This closes the fork only on the happy path. If this epoch orchestrator
|
|
728
|
-
// is aborted and never reaches this point, it will leak the fork. We need to add a global cleanup,
|
|
729
|
-
// but have to make sure it only runs once all operations are completed, otherwise some function here
|
|
730
|
-
// will attempt to access the fork after it was closed.
|
|
731
|
-
void this.cleanupDBFork(blockNumber);
|
|
732
738
|
}
|
|
733
739
|
/**
|
|
734
740
|
* Cancel any further proving.
|
|
735
741
|
* If cancelJobsOnStop is true, aborts all pending jobs with the broker (which marks them as 'Aborted').
|
|
736
742
|
* If cancelJobsOnStop is false (default), jobs remain in the broker queue and can be reused on restart/reorg.
|
|
737
743
|
*/ cancel() {
|
|
744
|
+
void this.deferredJobQueue.cancel();
|
|
745
|
+
// Recreate the queue so it can accept jobs for subsequent epochs.
|
|
746
|
+
this.deferredJobQueue = new SerialQueue();
|
|
747
|
+
this.deferredJobQueue.start(this.enqueueConcurrency);
|
|
738
748
|
if (this.cancelJobsOnStop) {
|
|
739
749
|
for (const controller of this.pendingProvingJobs){
|
|
740
750
|
controller.abort();
|
|
741
751
|
}
|
|
742
752
|
}
|
|
743
753
|
this.provingState?.cancel();
|
|
754
|
+
for (const [blockNumber, db] of this.dbs.entries()){
|
|
755
|
+
void db.close().catch((err)=>this.logger.error(`Error closing db for block ${blockNumber}`, err));
|
|
756
|
+
}
|
|
757
|
+
this.dbs.clear();
|
|
758
|
+
}
|
|
759
|
+
getDbForBlock(blockNumber) {
|
|
760
|
+
const db = this.dbs.get(blockNumber);
|
|
761
|
+
if (!db) {
|
|
762
|
+
throw new Error(`World state fork for block ${blockNumber} not found.`);
|
|
763
|
+
}
|
|
764
|
+
return db;
|
|
744
765
|
}
|
|
745
766
|
/**
|
|
746
767
|
* Returns the proof for the current epoch.
|
|
@@ -760,22 +781,6 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
760
781
|
});
|
|
761
782
|
return epochProofResult;
|
|
762
783
|
}
|
|
763
|
-
async cleanupDBFork(blockNumber) {
|
|
764
|
-
logger.debug(`Cleaning up world state fork for ${blockNumber}`);
|
|
765
|
-
const fork = this.dbs.get(blockNumber);
|
|
766
|
-
if (!fork) {
|
|
767
|
-
return;
|
|
768
|
-
}
|
|
769
|
-
try {
|
|
770
|
-
if (!fork.cleanupPromise) {
|
|
771
|
-
fork.cleanupPromise = fork.fork.close();
|
|
772
|
-
}
|
|
773
|
-
await fork.cleanupPromise;
|
|
774
|
-
this.dbs.delete(blockNumber);
|
|
775
|
-
} catch (err) {
|
|
776
|
-
logger.error(`Error closing db for block ${blockNumber}`, err);
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
784
|
/**
|
|
780
785
|
* Enqueue a job to be scheduled
|
|
781
786
|
* @param provingState - The proving state object being operated on
|
|
@@ -783,7 +788,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
783
788
|
* @param job - The actual job, returns a promise notifying of the job's completion
|
|
784
789
|
*/ deferredProving(provingState, request, callback) {
|
|
785
790
|
if (!provingState.verifyState()) {
|
|
786
|
-
logger.debug(`Not enqueuing job, state no longer valid`);
|
|
791
|
+
this.logger.debug(`Not enqueuing job, state no longer valid`);
|
|
787
792
|
return;
|
|
788
793
|
}
|
|
789
794
|
const controller = new AbortController();
|
|
@@ -798,7 +803,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
798
803
|
}
|
|
799
804
|
const result = await request(controller.signal);
|
|
800
805
|
if (!provingState.verifyState()) {
|
|
801
|
-
logger.debug(`State no longer valid, discarding result`);
|
|
806
|
+
this.logger.debug(`State no longer valid, discarding result`);
|
|
802
807
|
return;
|
|
803
808
|
}
|
|
804
809
|
// we could have been cancelled whilst waiting for the result
|
|
@@ -813,7 +818,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
813
818
|
// drop this result
|
|
814
819
|
return;
|
|
815
820
|
}
|
|
816
|
-
logger.error(`Error thrown when proving job`, err);
|
|
821
|
+
this.logger.error(`Error thrown when proving job`, err);
|
|
817
822
|
provingState.reject(`${err}`);
|
|
818
823
|
} finally{
|
|
819
824
|
const index = this.pendingProvingJobs.indexOf(controller);
|
|
@@ -822,8 +827,9 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
822
827
|
}
|
|
823
828
|
}
|
|
824
829
|
};
|
|
825
|
-
//
|
|
826
|
-
|
|
830
|
+
// Enqueue onto the serial queue with limited workers to avoid starving the event loop.
|
|
831
|
+
// Workers yield between jobs via await, allowing I/O callbacks to process.
|
|
832
|
+
void this.deferredJobQueue.put(()=>safeJob());
|
|
827
833
|
}
|
|
828
834
|
async updateL1ToL2MessageTree(l1ToL2Messages, db) {
|
|
829
835
|
const l1ToL2MessagesPadded = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 'Too many L1 to L2 messages');
|
|
@@ -869,17 +875,17 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
869
875
|
// Executes the next level of merge if all inputs are available
|
|
870
876
|
enqueueBaseRollup(provingState, txIndex) {
|
|
871
877
|
if (!provingState.verifyState()) {
|
|
872
|
-
logger.debug('Not running base rollup, state invalid');
|
|
878
|
+
this.logger.debug('Not running base rollup, state invalid');
|
|
873
879
|
return;
|
|
874
880
|
}
|
|
875
881
|
if (!provingState.tryStartProvingBase(txIndex)) {
|
|
876
|
-
logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
882
|
+
this.logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
877
883
|
return;
|
|
878
884
|
}
|
|
879
885
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
880
886
|
const { processedTx } = txProvingState;
|
|
881
887
|
const { rollupType, inputs } = txProvingState.getBaseRollupTypeAndInputs();
|
|
882
|
-
logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
888
|
+
this.logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
883
889
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, `ProvingOrchestrator.prover.${inputs instanceof PrivateTxBaseRollupPrivateInputs ? 'getPrivateTxBaseRollupProof' : 'getPublicTxBaseRollupProof'}`, {
|
|
884
890
|
[Attributes.TX_HASH]: processedTx.hash.toString(),
|
|
885
891
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
@@ -890,7 +896,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
890
896
|
return this.prover.getPublicTxBaseRollupProof(inputs, signal, provingState.epochNumber);
|
|
891
897
|
}
|
|
892
898
|
}), (result)=>{
|
|
893
|
-
logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
899
|
+
this.logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
894
900
|
validatePartialState(result.inputs.endTreeSnapshots, txProvingState.treeSnapshots);
|
|
895
901
|
const leafLocation = provingState.setBaseRollupProof(txIndex, result);
|
|
896
902
|
if (provingState.totalNumTxs === 1) {
|
|
@@ -904,14 +910,14 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
904
910
|
// Once completed, will enqueue the the public tx base rollup.
|
|
905
911
|
getOrEnqueueChonkVerifier(provingState, txIndex) {
|
|
906
912
|
if (!provingState.verifyState()) {
|
|
907
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
913
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
908
914
|
return;
|
|
909
915
|
}
|
|
910
916
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
911
917
|
const txHash = txProvingState.processedTx.hash.toString();
|
|
912
918
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH;
|
|
913
919
|
const handleResult = (result)=>{
|
|
914
|
-
logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
|
|
920
|
+
this.logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
|
|
915
921
|
txHash
|
|
916
922
|
});
|
|
917
923
|
txProvingState.setPublicChonkVerifierProof(result);
|
|
@@ -919,18 +925,18 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
919
925
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
920
926
|
};
|
|
921
927
|
if (this.provingState?.cachedChonkVerifierProofs.has(txHash)) {
|
|
922
|
-
logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, {
|
|
928
|
+
this.logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, {
|
|
923
929
|
txHash
|
|
924
930
|
});
|
|
925
931
|
void this.provingState.cachedChonkVerifierProofs.get(txHash).then(handleResult);
|
|
926
932
|
return;
|
|
927
933
|
}
|
|
928
|
-
logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
934
|
+
this.logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
929
935
|
this.doEnqueueChonkVerifier(txHash, txProvingState.getPublicChonkVerifierPrivateInputs(), handleResult);
|
|
930
936
|
}
|
|
931
937
|
doEnqueueChonkVerifier(txHash, inputs, handler, provingState = this.provingState) {
|
|
932
938
|
if (!provingState.verifyState()) {
|
|
933
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
939
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
934
940
|
return;
|
|
935
941
|
}
|
|
936
942
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getPublicChonkVerifierProof', {
|
|
@@ -942,11 +948,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
942
948
|
// Enqueues the next level of merge if all inputs are available
|
|
943
949
|
enqueueMergeRollup(provingState, location) {
|
|
944
950
|
if (!provingState.verifyState()) {
|
|
945
|
-
logger.debug('Not running merge rollup. State no longer valid.');
|
|
951
|
+
this.logger.debug('Not running merge rollup. State no longer valid.');
|
|
946
952
|
return;
|
|
947
953
|
}
|
|
948
954
|
if (!provingState.tryStartProvingMerge(location)) {
|
|
949
|
-
logger.debug('Merge rollup already started.');
|
|
955
|
+
this.logger.debug('Merge rollup already started.');
|
|
950
956
|
return;
|
|
951
957
|
}
|
|
952
958
|
const inputs = provingState.getMergeRollupInputs(location);
|
|
@@ -960,15 +966,15 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
960
966
|
// Executes the block root rollup circuit
|
|
961
967
|
enqueueBlockRootRollup(provingState) {
|
|
962
968
|
if (!provingState.verifyState()) {
|
|
963
|
-
logger.debug('Not running block root rollup, state no longer valid');
|
|
969
|
+
this.logger.debug('Not running block root rollup, state no longer valid');
|
|
964
970
|
return;
|
|
965
971
|
}
|
|
966
972
|
if (!provingState.tryStartProvingBlockRoot()) {
|
|
967
|
-
logger.debug('Block root rollup already started.');
|
|
973
|
+
this.logger.debug('Block root rollup already started.');
|
|
968
974
|
return;
|
|
969
975
|
}
|
|
970
976
|
const { rollupType, inputs } = provingState.getBlockRootRollupTypeAndInputs();
|
|
971
|
-
logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
977
|
+
this.logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
972
978
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockRootRollupProof', {
|
|
973
979
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
974
980
|
}, (signal)=>{
|
|
@@ -984,29 +990,28 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
984
990
|
return this.prover.getBlockRootRollupProof(inputs, signal, provingState.epochNumber);
|
|
985
991
|
}
|
|
986
992
|
}), async (result)=>{
|
|
987
|
-
logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
993
|
+
this.logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
988
994
|
const leafLocation = provingState.setBlockRootRollupProof(result);
|
|
989
995
|
const checkpointProvingState = provingState.parentCheckpoint;
|
|
990
|
-
//
|
|
996
|
+
// Verification is called from both here and setBlockCompleted. Whichever runs last
|
|
997
|
+
// will be the first to see all three pieces (header, proof output, archive) and run the checks.
|
|
991
998
|
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
992
999
|
if (checkpointProvingState.totalNumBlocks === 1) {
|
|
993
|
-
this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
1000
|
+
await this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
994
1001
|
} else {
|
|
995
|
-
this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
1002
|
+
await this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
996
1003
|
}
|
|
997
|
-
// We are finished with the block at this point, ensure the fork is cleaned up
|
|
998
|
-
void this.cleanupDBFork(provingState.blockNumber);
|
|
999
1004
|
});
|
|
1000
1005
|
}
|
|
1001
1006
|
// Executes the base parity circuit and stores the intermediate state for the root parity circuit
|
|
1002
1007
|
// Enqueues the root parity circuit if all inputs are available
|
|
1003
1008
|
enqueueBaseParityCircuit(checkpointProvingState, provingState, baseParityIndex) {
|
|
1004
1009
|
if (!provingState.verifyState()) {
|
|
1005
|
-
logger.debug('Not running base parity. State no longer valid.');
|
|
1010
|
+
this.logger.debug('Not running base parity. State no longer valid.');
|
|
1006
1011
|
return;
|
|
1007
1012
|
}
|
|
1008
1013
|
if (!provingState.tryStartProvingBaseParity(baseParityIndex)) {
|
|
1009
|
-
logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
1014
|
+
this.logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
1010
1015
|
return;
|
|
1011
1016
|
}
|
|
1012
1017
|
const inputs = checkpointProvingState.getBaseParityInputs(baseParityIndex);
|
|
@@ -1027,11 +1032,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1027
1032
|
// Enqueues the root rollup proof if all inputs are available
|
|
1028
1033
|
enqueueRootParityCircuit(provingState) {
|
|
1029
1034
|
if (!provingState.verifyState()) {
|
|
1030
|
-
logger.debug('Not running root parity. State no longer valid.');
|
|
1035
|
+
this.logger.debug('Not running root parity. State no longer valid.');
|
|
1031
1036
|
return;
|
|
1032
1037
|
}
|
|
1033
1038
|
if (!provingState.tryStartProvingRootParity()) {
|
|
1034
|
-
logger.debug('Root parity already started.');
|
|
1039
|
+
this.logger.debug('Root parity already started.');
|
|
1035
1040
|
return;
|
|
1036
1041
|
}
|
|
1037
1042
|
const inputs = provingState.getParityRootInputs();
|
|
@@ -1046,33 +1051,33 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1046
1051
|
// Enqueues the next level of merge if all inputs are available
|
|
1047
1052
|
enqueueBlockMergeRollup(provingState, location) {
|
|
1048
1053
|
if (!provingState.verifyState()) {
|
|
1049
|
-
logger.debug('Not running block merge rollup. State no longer valid.');
|
|
1054
|
+
this.logger.debug('Not running block merge rollup. State no longer valid.');
|
|
1050
1055
|
return;
|
|
1051
1056
|
}
|
|
1052
1057
|
if (!provingState.tryStartProvingBlockMerge(location)) {
|
|
1053
|
-
logger.debug('Block merge rollup already started.');
|
|
1058
|
+
this.logger.debug('Block merge rollup already started.');
|
|
1054
1059
|
return;
|
|
1055
1060
|
}
|
|
1056
1061
|
const inputs = provingState.getBlockMergeRollupInputs(location);
|
|
1057
1062
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockMergeRollupProof', {
|
|
1058
1063
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-block-merge'
|
|
1059
|
-
}, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1064
|
+
}, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), async (result)=>{
|
|
1060
1065
|
provingState.setBlockMergeRollupProof(location, result);
|
|
1061
|
-
this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
1066
|
+
await this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
1062
1067
|
});
|
|
1063
1068
|
}
|
|
1064
|
-
enqueueCheckpointRootRollup(provingState) {
|
|
1069
|
+
async enqueueCheckpointRootRollup(provingState) {
|
|
1065
1070
|
if (!provingState.verifyState()) {
|
|
1066
|
-
logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
1071
|
+
this.logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
1067
1072
|
return;
|
|
1068
1073
|
}
|
|
1069
1074
|
if (!provingState.tryStartProvingCheckpointRoot()) {
|
|
1070
|
-
logger.debug('Checkpoint root rollup already started.');
|
|
1075
|
+
this.logger.debug('Checkpoint root rollup already started.');
|
|
1071
1076
|
return;
|
|
1072
1077
|
}
|
|
1073
1078
|
const rollupType = provingState.getCheckpointRootRollupType();
|
|
1074
|
-
logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
1075
|
-
const inputs = provingState.getCheckpointRootRollupInputs();
|
|
1079
|
+
this.logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
1080
|
+
const inputs = await provingState.getCheckpointRootRollupInputs();
|
|
1076
1081
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointRootRollupProof', {
|
|
1077
1082
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
1078
1083
|
}, (signal)=>{
|
|
@@ -1085,11 +1090,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1085
1090
|
const computedEndBlobAccumulatorState = provingState.getEndBlobAccumulator().toBlobAccumulator();
|
|
1086
1091
|
const circuitEndBlobAccumulatorState = result.inputs.endBlobAccumulator;
|
|
1087
1092
|
if (!circuitEndBlobAccumulatorState.equals(computedEndBlobAccumulatorState)) {
|
|
1088
|
-
logger.error(`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(computedEndBlobAccumulatorState)}`);
|
|
1093
|
+
this.logger.error(`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(computedEndBlobAccumulatorState)}`);
|
|
1089
1094
|
provingState.reject(`Blob accumulator state mismatch.`);
|
|
1090
1095
|
return;
|
|
1091
1096
|
}
|
|
1092
|
-
logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
1097
|
+
this.logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
1093
1098
|
const leafLocation = provingState.setCheckpointRootRollupProof(result);
|
|
1094
1099
|
const epochProvingState = provingState.parentEpoch;
|
|
1095
1100
|
if (epochProvingState.totalNumCheckpoints === 1) {
|
|
@@ -1101,37 +1106,37 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1101
1106
|
}
|
|
1102
1107
|
enqueueCheckpointMergeRollup(provingState, location) {
|
|
1103
1108
|
if (!provingState.verifyState()) {
|
|
1104
|
-
logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1109
|
+
this.logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1105
1110
|
return;
|
|
1106
1111
|
}
|
|
1107
1112
|
if (!provingState.tryStartProvingCheckpointMerge(location)) {
|
|
1108
|
-
logger.debug('Checkpoint merge rollup already started.');
|
|
1113
|
+
this.logger.debug('Checkpoint merge rollup already started.');
|
|
1109
1114
|
return;
|
|
1110
1115
|
}
|
|
1111
1116
|
const inputs = provingState.getCheckpointMergeRollupInputs(location);
|
|
1112
1117
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointMergeRollupProof', {
|
|
1113
1118
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-merge'
|
|
1114
1119
|
}, (signal)=>this.prover.getCheckpointMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1115
|
-
logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1120
|
+
this.logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1116
1121
|
provingState.setCheckpointMergeRollupProof(location, result);
|
|
1117
1122
|
this.checkAndEnqueueNextCheckpointMergeRollup(provingState, location);
|
|
1118
1123
|
});
|
|
1119
1124
|
}
|
|
1120
1125
|
enqueueEpochPadding(provingState) {
|
|
1121
1126
|
if (!provingState.verifyState()) {
|
|
1122
|
-
logger.debug('Not running epoch padding. State no longer valid.');
|
|
1127
|
+
this.logger.debug('Not running epoch padding. State no longer valid.');
|
|
1123
1128
|
return;
|
|
1124
1129
|
}
|
|
1125
1130
|
if (!provingState.tryStartProvingPaddingCheckpoint()) {
|
|
1126
|
-
logger.debug('Padding checkpoint already started.');
|
|
1131
|
+
this.logger.debug('Padding checkpoint already started.');
|
|
1127
1132
|
return;
|
|
1128
1133
|
}
|
|
1129
|
-
logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1134
|
+
this.logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1130
1135
|
const inputs = provingState.getPaddingCheckpointInputs();
|
|
1131
1136
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointPaddingRollupProof', {
|
|
1132
1137
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-padding'
|
|
1133
1138
|
}, (signal)=>this.prover.getCheckpointPaddingRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1134
|
-
logger.debug('Completed proof for padding checkpoint.');
|
|
1139
|
+
this.logger.debug('Completed proof for padding checkpoint.');
|
|
1135
1140
|
provingState.setCheckpointPaddingProof(result);
|
|
1136
1141
|
this.checkAndEnqueueRootRollup(provingState);
|
|
1137
1142
|
});
|
|
@@ -1139,15 +1144,15 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1139
1144
|
// Executes the root rollup circuit
|
|
1140
1145
|
enqueueRootRollup(provingState) {
|
|
1141
1146
|
if (!provingState.verifyState()) {
|
|
1142
|
-
logger.debug('Not running root rollup, state no longer valid');
|
|
1147
|
+
this.logger.debug('Not running root rollup, state no longer valid');
|
|
1143
1148
|
return;
|
|
1144
1149
|
}
|
|
1145
|
-
logger.debug(`Preparing root rollup`);
|
|
1150
|
+
this.logger.debug(`Preparing root rollup`);
|
|
1146
1151
|
const inputs = provingState.getRootRollupInputs();
|
|
1147
1152
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getRootRollupProof', {
|
|
1148
1153
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-root'
|
|
1149
1154
|
}, (signal)=>this.prover.getRootRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1150
|
-
logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1155
|
+
this.logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1151
1156
|
provingState.setRootRollupProof(result);
|
|
1152
1157
|
provingState.resolve({
|
|
1153
1158
|
status: 'success'
|
|
@@ -1167,27 +1172,27 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1167
1172
|
}
|
|
1168
1173
|
checkAndEnqueueBlockRootRollup(provingState) {
|
|
1169
1174
|
if (!provingState.isReadyForBlockRootRollup()) {
|
|
1170
|
-
logger.debug('Not ready for block root rollup');
|
|
1175
|
+
this.logger.debug('Not ready for block root rollup');
|
|
1171
1176
|
return;
|
|
1172
1177
|
}
|
|
1173
1178
|
this.enqueueBlockRootRollup(provingState);
|
|
1174
1179
|
}
|
|
1175
|
-
checkAndEnqueueNextBlockMergeRollup(provingState, currentLocation) {
|
|
1180
|
+
async checkAndEnqueueNextBlockMergeRollup(provingState, currentLocation) {
|
|
1176
1181
|
if (!provingState.isReadyForBlockMerge(currentLocation)) {
|
|
1177
1182
|
return;
|
|
1178
1183
|
}
|
|
1179
1184
|
const parentLocation = provingState.getParentLocation(currentLocation);
|
|
1180
1185
|
if (parentLocation.level === 0) {
|
|
1181
|
-
this.checkAndEnqueueCheckpointRootRollup(provingState);
|
|
1186
|
+
await this.checkAndEnqueueCheckpointRootRollup(provingState);
|
|
1182
1187
|
} else {
|
|
1183
1188
|
this.enqueueBlockMergeRollup(provingState, parentLocation);
|
|
1184
1189
|
}
|
|
1185
1190
|
}
|
|
1186
|
-
checkAndEnqueueCheckpointRootRollup(provingState) {
|
|
1191
|
+
async checkAndEnqueueCheckpointRootRollup(provingState) {
|
|
1187
1192
|
if (!provingState.isReadyForCheckpointRoot()) {
|
|
1188
1193
|
return;
|
|
1189
1194
|
}
|
|
1190
|
-
this.enqueueCheckpointRootRollup(provingState);
|
|
1195
|
+
await this.enqueueCheckpointRootRollup(provingState);
|
|
1191
1196
|
}
|
|
1192
1197
|
checkAndEnqueueNextCheckpointMergeRollup(provingState, currentLocation) {
|
|
1193
1198
|
if (!provingState.isReadyForCheckpointMerge(currentLocation)) {
|
|
@@ -1202,7 +1207,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1202
1207
|
}
|
|
1203
1208
|
checkAndEnqueueRootRollup(provingState) {
|
|
1204
1209
|
if (!provingState.isReadyForRootRollup()) {
|
|
1205
|
-
logger.debug('Not ready for root rollup');
|
|
1210
|
+
this.logger.debug('Not ready for root rollup');
|
|
1206
1211
|
return;
|
|
1207
1212
|
}
|
|
1208
1213
|
this.enqueueRootRollup(provingState);
|
|
@@ -1214,7 +1219,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1214
1219
|
* @param txIndex - The index of the transaction being proven
|
|
1215
1220
|
*/ enqueueVM(provingState, txIndex) {
|
|
1216
1221
|
if (!provingState.verifyState()) {
|
|
1217
|
-
logger.debug(`Not running VM circuit as state is no longer valid`);
|
|
1222
|
+
this.logger.debug(`Not running VM circuit as state is no longer valid`);
|
|
1218
1223
|
return;
|
|
1219
1224
|
}
|
|
1220
1225
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
@@ -1225,7 +1230,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1225
1230
|
return await this.prover.getAvmProof(inputs, signal, provingState.epochNumber);
|
|
1226
1231
|
});
|
|
1227
1232
|
this.deferredProving(provingState, doAvmProving, (proof)=>{
|
|
1228
|
-
logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
1233
|
+
this.logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
1229
1234
|
txProvingState.setAvmProof(proof);
|
|
1230
1235
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
1231
1236
|
});
|
|
@@ -1236,7 +1241,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1236
1241
|
return;
|
|
1237
1242
|
}
|
|
1238
1243
|
// We must have completed all proving (chonk verifier proof and (if required) vm proof are generated), we now move to the base rollup.
|
|
1239
|
-
logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
1244
|
+
this.logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
1240
1245
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
1241
1246
|
}
|
|
1242
1247
|
}
|