@aztec/prover-client 0.0.1-commit.d431d1c → 0.0.1-commit.d939eb5aa
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/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +12 -2
- package/dest/light/lightweight_checkpoint_builder.d.ts +14 -6
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +51 -22
- 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.d.ts +1 -1
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +17 -9
- 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 +3 -3
- 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 +11 -4
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +132 -109
- 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 +16 -22
- package/dest/proving_broker/config.d.ts +14 -2
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +21 -4
- 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 +56 -8
- 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 +6 -2
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +24 -15
- package/dest/test/mock_prover.d.ts +4 -4
- package/package.json +17 -18
- package/src/config.ts +13 -2
- package/src/light/lightweight_checkpoint_builder.ts +63 -25
- package/src/mocks/fixtures.ts +2 -1
- package/src/mocks/test_context.ts +12 -10
- package/src/orchestrator/block-building-helpers.ts +3 -3
- 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 +140 -117
- package/src/prover-client/prover-client.ts +31 -15
- package/src/proving_broker/broker_prover_facade.ts +23 -23
- package/src/proving_broker/config.ts +24 -2
- 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 +55 -5
- 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 +26 -3
- 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,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
|
-
|
|
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;
|
|
@@ -468,9 +478,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
468
478
|
getNumActiveForks() {
|
|
469
479
|
return this.dbs.size;
|
|
470
480
|
}
|
|
471
|
-
stop() {
|
|
481
|
+
async stop() {
|
|
482
|
+
// Grab the old queue before cancel() replaces it, so we can await its draining.
|
|
483
|
+
const oldQueue = this.deferredJobQueue;
|
|
472
484
|
this.cancel();
|
|
473
|
-
|
|
485
|
+
await oldQueue.cancel();
|
|
474
486
|
}
|
|
475
487
|
startNewEpoch(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges) {
|
|
476
488
|
if (this.provingState?.verifyState()) {
|
|
@@ -481,7 +493,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
481
493
|
status: 'failure',
|
|
482
494
|
reason
|
|
483
495
|
}));
|
|
484
|
-
logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
496
|
+
this.logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
485
497
|
this.provingState = new EpochProvingState(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges, (provingState)=>this.checkAndEnqueueCheckpointRootRollup(provingState), resolve, reject);
|
|
486
498
|
this.provingPromise = promise;
|
|
487
499
|
}
|
|
@@ -528,14 +540,14 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
528
540
|
throw new Error(`Checkpoint not accepting further blocks.`);
|
|
529
541
|
}
|
|
530
542
|
const constants = checkpointProvingState.constants;
|
|
531
|
-
logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
543
|
+
this.logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
532
544
|
// Fork the db only when it's not already set. The db for the first block is set in `startNewCheckpoint`.
|
|
533
545
|
if (!this.dbs.has(blockNumber)) {
|
|
534
546
|
// Fork world state at the end of the immediately previous block
|
|
535
547
|
const db = await this.dbProvider.fork(BlockNumber(blockNumber - 1));
|
|
536
548
|
this.dbs.set(blockNumber, db);
|
|
537
549
|
}
|
|
538
|
-
const db = this.
|
|
550
|
+
const db = this.getDbForBlock(blockNumber);
|
|
539
551
|
// Get archive snapshot and sibling path before any txs in this block lands.
|
|
540
552
|
const lastArchiveTreeSnapshot = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
541
553
|
const lastArchiveSiblingPath = await getRootTreeSiblingPath(MerkleTreeId.ARCHIVE, db);
|
|
@@ -570,7 +582,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
570
582
|
if (!txs.length) {
|
|
571
583
|
// To avoid an ugly throw below. If we require an empty block, we can just call setBlockCompleted
|
|
572
584
|
// on a block with no txs. We cannot do that here because we cannot find the blockNumber without any txs.
|
|
573
|
-
logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
585
|
+
this.logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
574
586
|
return;
|
|
575
587
|
}
|
|
576
588
|
const blockNumber = BlockNumber(txs[0].globalVariables.blockNumber);
|
|
@@ -584,8 +596,8 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
584
596
|
if (!provingState.isAcceptingTxs()) {
|
|
585
597
|
throw new Error(`Block ${blockNumber} has been initialized with transactions.`);
|
|
586
598
|
}
|
|
587
|
-
logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
588
|
-
const db = this.
|
|
599
|
+
this.logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
600
|
+
const db = this.getDbForBlock(blockNumber);
|
|
589
601
|
const lastArchive = provingState.lastArchiveTreeSnapshot;
|
|
590
602
|
const newL1ToL2MessageTreeSnapshot = provingState.newL1ToL2MessageTreeSnapshot;
|
|
591
603
|
const spongeBlobState = provingState.getStartSpongeBlob().clone();
|
|
@@ -595,7 +607,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
595
607
|
throw new Error(`Invalid proving state when adding a tx`);
|
|
596
608
|
}
|
|
597
609
|
validateTx(tx);
|
|
598
|
-
logger.debug(`Received transaction: ${tx.hash}`);
|
|
610
|
+
this.logger.debug(`Received transaction: ${tx.hash}`);
|
|
599
611
|
const startSpongeBlob = spongeBlobState.clone();
|
|
600
612
|
const [hints, treeSnapshots] = await this.prepareBaseRollupInputs(tx, lastArchive, newL1ToL2MessageTreeSnapshot, startSpongeBlob, db);
|
|
601
613
|
if (!provingState.verifyState()) {
|
|
@@ -606,10 +618,10 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
606
618
|
const txIndex = provingState.addNewTx(txProvingState);
|
|
607
619
|
if (txProvingState.requireAvmProof) {
|
|
608
620
|
this.getOrEnqueueChonkVerifier(provingState, txIndex);
|
|
609
|
-
logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
621
|
+
this.logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
610
622
|
this.enqueueVM(provingState, txIndex);
|
|
611
623
|
} else {
|
|
612
|
-
logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
624
|
+
this.logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
613
625
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
614
626
|
}
|
|
615
627
|
} catch (err) {
|
|
@@ -639,7 +651,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
639
651
|
const txHash = tx.getTxHash().toString();
|
|
640
652
|
const privateInputs = getPublicChonkVerifierPrivateInputsFromTx(tx, this.proverId.toField());
|
|
641
653
|
const tubeProof = promiseWithResolvers();
|
|
642
|
-
logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
654
|
+
this.logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
643
655
|
this.doEnqueueChonkVerifier(txHash, privateInputs, (proof)=>{
|
|
644
656
|
tubeProof.resolve(proof);
|
|
645
657
|
});
|
|
@@ -668,17 +680,23 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
668
680
|
throw new Error(`Block ${blockNumber} is still accepting txs. Call setBlockCompleted after all txs have been added.`);
|
|
669
681
|
}
|
|
670
682
|
// Given we've applied every change from this block, now assemble the block header:
|
|
671
|
-
logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
683
|
+
this.logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
672
684
|
const header = await provingState.buildBlockHeader();
|
|
673
685
|
if (expectedHeader && !header.equals(expectedHeader)) {
|
|
674
|
-
logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
686
|
+
this.logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
675
687
|
throw new Error('Block header mismatch');
|
|
676
688
|
}
|
|
677
|
-
// Get db for this block
|
|
678
|
-
const db = this.
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
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
|
+
}
|
|
682
700
|
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
683
701
|
return header;
|
|
684
702
|
}
|
|
@@ -686,49 +704,65 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
686
704
|
async verifyBuiltBlockAgainstSyncedState(provingState) {
|
|
687
705
|
const builtBlockHeader = provingState.getBuiltBlockHeader();
|
|
688
706
|
if (!builtBlockHeader) {
|
|
689
|
-
logger.debug('Block header not built yet, skipping header check.');
|
|
707
|
+
this.logger.debug('Block header not built yet, skipping header check.');
|
|
690
708
|
return;
|
|
691
709
|
}
|
|
692
710
|
const output = provingState.getBlockRootRollupOutput();
|
|
693
711
|
if (!output) {
|
|
694
|
-
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.');
|
|
695
718
|
return;
|
|
696
719
|
}
|
|
697
720
|
const header = await buildHeaderFromCircuitOutputs(output);
|
|
698
721
|
if (!(await header.hash()).equals(await builtBlockHeader.hash())) {
|
|
699
|
-
logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
722
|
+
this.logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
700
723
|
provingState.reject(`Block header hash mismatch.`);
|
|
701
724
|
return;
|
|
702
725
|
}
|
|
703
|
-
// Get db for this block
|
|
704
726
|
const blockNumber = provingState.blockNumber;
|
|
705
|
-
const db = this.dbs.get(blockNumber);
|
|
706
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
707
727
|
const syncedArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.dbProvider.getSnapshot(blockNumber));
|
|
708
728
|
if (!syncedArchive.equals(newArchive)) {
|
|
709
|
-
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)}`);
|
|
710
730
|
provingState.reject(`Archive tree mismatch.`);
|
|
711
731
|
return;
|
|
712
732
|
}
|
|
713
733
|
const circuitArchive = output.newArchive;
|
|
714
734
|
if (!newArchive.equals(circuitArchive)) {
|
|
715
|
-
logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
735
|
+
this.logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
716
736
|
provingState.reject(`New archive mismatch.`);
|
|
717
737
|
return;
|
|
718
738
|
}
|
|
719
|
-
// TODO(palla/prover): This closes the fork only on the happy path. If this epoch orchestrator
|
|
720
|
-
// is aborted and never reaches this point, it will leak the fork. We need to add a global cleanup,
|
|
721
|
-
// but have to make sure it only runs once all operations are completed, otherwise some function here
|
|
722
|
-
// will attempt to access the fork after it was closed.
|
|
723
|
-
void this.cleanupDBFork(blockNumber);
|
|
724
739
|
}
|
|
725
740
|
/**
|
|
726
|
-
* 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.
|
|
727
744
|
*/ cancel() {
|
|
728
|
-
|
|
729
|
-
|
|
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
|
+
}
|
|
730
753
|
}
|
|
731
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;
|
|
732
766
|
}
|
|
733
767
|
/**
|
|
734
768
|
* Returns the proof for the current epoch.
|
|
@@ -748,19 +782,6 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
748
782
|
});
|
|
749
783
|
return epochProofResult;
|
|
750
784
|
}
|
|
751
|
-
async cleanupDBFork(blockNumber) {
|
|
752
|
-
logger.debug(`Cleaning up world state fork for ${blockNumber}`);
|
|
753
|
-
const fork = this.dbs.get(blockNumber);
|
|
754
|
-
if (!fork) {
|
|
755
|
-
return;
|
|
756
|
-
}
|
|
757
|
-
try {
|
|
758
|
-
await fork.close();
|
|
759
|
-
this.dbs.delete(blockNumber);
|
|
760
|
-
} catch (err) {
|
|
761
|
-
logger.error(`Error closing db for block ${blockNumber}`, err);
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
785
|
/**
|
|
765
786
|
* Enqueue a job to be scheduled
|
|
766
787
|
* @param provingState - The proving state object being operated on
|
|
@@ -768,7 +789,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
768
789
|
* @param job - The actual job, returns a promise notifying of the job's completion
|
|
769
790
|
*/ deferredProving(provingState, request, callback) {
|
|
770
791
|
if (!provingState.verifyState()) {
|
|
771
|
-
logger.debug(`Not enqueuing job, state no longer valid`);
|
|
792
|
+
this.logger.debug(`Not enqueuing job, state no longer valid`);
|
|
772
793
|
return;
|
|
773
794
|
}
|
|
774
795
|
const controller = new AbortController();
|
|
@@ -783,7 +804,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
783
804
|
}
|
|
784
805
|
const result = await request(controller.signal);
|
|
785
806
|
if (!provingState.verifyState()) {
|
|
786
|
-
logger.debug(`State no longer valid, discarding result`);
|
|
807
|
+
this.logger.debug(`State no longer valid, discarding result`);
|
|
787
808
|
return;
|
|
788
809
|
}
|
|
789
810
|
// we could have been cancelled whilst waiting for the result
|
|
@@ -798,7 +819,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
798
819
|
// drop this result
|
|
799
820
|
return;
|
|
800
821
|
}
|
|
801
|
-
logger.error(`Error thrown when proving job`, err);
|
|
822
|
+
this.logger.error(`Error thrown when proving job`, err);
|
|
802
823
|
provingState.reject(`${err}`);
|
|
803
824
|
} finally{
|
|
804
825
|
const index = this.pendingProvingJobs.indexOf(controller);
|
|
@@ -807,8 +828,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
807
828
|
}
|
|
808
829
|
}
|
|
809
830
|
};
|
|
810
|
-
|
|
811
|
-
|
|
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
|
+
});
|
|
812
836
|
}
|
|
813
837
|
async updateL1ToL2MessageTree(l1ToL2Messages, db) {
|
|
814
838
|
const l1ToL2MessagesPadded = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 'Too many L1 to L2 messages');
|
|
@@ -854,17 +878,17 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
854
878
|
// Executes the next level of merge if all inputs are available
|
|
855
879
|
enqueueBaseRollup(provingState, txIndex) {
|
|
856
880
|
if (!provingState.verifyState()) {
|
|
857
|
-
logger.debug('Not running base rollup, state invalid');
|
|
881
|
+
this.logger.debug('Not running base rollup, state invalid');
|
|
858
882
|
return;
|
|
859
883
|
}
|
|
860
884
|
if (!provingState.tryStartProvingBase(txIndex)) {
|
|
861
|
-
logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
885
|
+
this.logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
862
886
|
return;
|
|
863
887
|
}
|
|
864
888
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
865
889
|
const { processedTx } = txProvingState;
|
|
866
890
|
const { rollupType, inputs } = txProvingState.getBaseRollupTypeAndInputs();
|
|
867
|
-
logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
891
|
+
this.logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
868
892
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, `ProvingOrchestrator.prover.${inputs instanceof PrivateTxBaseRollupPrivateInputs ? 'getPrivateTxBaseRollupProof' : 'getPublicTxBaseRollupProof'}`, {
|
|
869
893
|
[Attributes.TX_HASH]: processedTx.hash.toString(),
|
|
870
894
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
@@ -875,7 +899,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
875
899
|
return this.prover.getPublicTxBaseRollupProof(inputs, signal, provingState.epochNumber);
|
|
876
900
|
}
|
|
877
901
|
}), (result)=>{
|
|
878
|
-
logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
902
|
+
this.logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
879
903
|
validatePartialState(result.inputs.endTreeSnapshots, txProvingState.treeSnapshots);
|
|
880
904
|
const leafLocation = provingState.setBaseRollupProof(txIndex, result);
|
|
881
905
|
if (provingState.totalNumTxs === 1) {
|
|
@@ -889,14 +913,14 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
889
913
|
// Once completed, will enqueue the the public tx base rollup.
|
|
890
914
|
getOrEnqueueChonkVerifier(provingState, txIndex) {
|
|
891
915
|
if (!provingState.verifyState()) {
|
|
892
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
916
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
893
917
|
return;
|
|
894
918
|
}
|
|
895
919
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
896
920
|
const txHash = txProvingState.processedTx.hash.toString();
|
|
897
921
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH;
|
|
898
922
|
const handleResult = (result)=>{
|
|
899
|
-
logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
|
|
923
|
+
this.logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
|
|
900
924
|
txHash
|
|
901
925
|
});
|
|
902
926
|
txProvingState.setPublicChonkVerifierProof(result);
|
|
@@ -904,18 +928,18 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
904
928
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
905
929
|
};
|
|
906
930
|
if (this.provingState?.cachedChonkVerifierProofs.has(txHash)) {
|
|
907
|
-
logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, {
|
|
931
|
+
this.logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, {
|
|
908
932
|
txHash
|
|
909
933
|
});
|
|
910
934
|
void this.provingState.cachedChonkVerifierProofs.get(txHash).then(handleResult);
|
|
911
935
|
return;
|
|
912
936
|
}
|
|
913
|
-
logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
937
|
+
this.logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
914
938
|
this.doEnqueueChonkVerifier(txHash, txProvingState.getPublicChonkVerifierPrivateInputs(), handleResult);
|
|
915
939
|
}
|
|
916
940
|
doEnqueueChonkVerifier(txHash, inputs, handler, provingState = this.provingState) {
|
|
917
941
|
if (!provingState.verifyState()) {
|
|
918
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
942
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
919
943
|
return;
|
|
920
944
|
}
|
|
921
945
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getPublicChonkVerifierProof', {
|
|
@@ -927,11 +951,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
927
951
|
// Enqueues the next level of merge if all inputs are available
|
|
928
952
|
enqueueMergeRollup(provingState, location) {
|
|
929
953
|
if (!provingState.verifyState()) {
|
|
930
|
-
logger.debug('Not running merge rollup. State no longer valid.');
|
|
954
|
+
this.logger.debug('Not running merge rollup. State no longer valid.');
|
|
931
955
|
return;
|
|
932
956
|
}
|
|
933
957
|
if (!provingState.tryStartProvingMerge(location)) {
|
|
934
|
-
logger.debug('Merge rollup already started.');
|
|
958
|
+
this.logger.debug('Merge rollup already started.');
|
|
935
959
|
return;
|
|
936
960
|
}
|
|
937
961
|
const inputs = provingState.getMergeRollupInputs(location);
|
|
@@ -945,15 +969,15 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
945
969
|
// Executes the block root rollup circuit
|
|
946
970
|
enqueueBlockRootRollup(provingState) {
|
|
947
971
|
if (!provingState.verifyState()) {
|
|
948
|
-
logger.debug('Not running block root rollup, state no longer valid');
|
|
972
|
+
this.logger.debug('Not running block root rollup, state no longer valid');
|
|
949
973
|
return;
|
|
950
974
|
}
|
|
951
975
|
if (!provingState.tryStartProvingBlockRoot()) {
|
|
952
|
-
logger.debug('Block root rollup already started.');
|
|
976
|
+
this.logger.debug('Block root rollup already started.');
|
|
953
977
|
return;
|
|
954
978
|
}
|
|
955
979
|
const { rollupType, inputs } = provingState.getBlockRootRollupTypeAndInputs();
|
|
956
|
-
logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
980
|
+
this.logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
957
981
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockRootRollupProof', {
|
|
958
982
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
959
983
|
}, (signal)=>{
|
|
@@ -969,29 +993,28 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
969
993
|
return this.prover.getBlockRootRollupProof(inputs, signal, provingState.epochNumber);
|
|
970
994
|
}
|
|
971
995
|
}), async (result)=>{
|
|
972
|
-
logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
996
|
+
this.logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
973
997
|
const leafLocation = provingState.setBlockRootRollupProof(result);
|
|
974
998
|
const checkpointProvingState = provingState.parentCheckpoint;
|
|
975
|
-
//
|
|
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.
|
|
976
1001
|
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
977
1002
|
if (checkpointProvingState.totalNumBlocks === 1) {
|
|
978
|
-
this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
1003
|
+
await this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
979
1004
|
} else {
|
|
980
|
-
this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
1005
|
+
await this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
981
1006
|
}
|
|
982
|
-
// We are finished with the block at this point, ensure the fork is cleaned up
|
|
983
|
-
void this.cleanupDBFork(provingState.blockNumber);
|
|
984
1007
|
});
|
|
985
1008
|
}
|
|
986
1009
|
// Executes the base parity circuit and stores the intermediate state for the root parity circuit
|
|
987
1010
|
// Enqueues the root parity circuit if all inputs are available
|
|
988
1011
|
enqueueBaseParityCircuit(checkpointProvingState, provingState, baseParityIndex) {
|
|
989
1012
|
if (!provingState.verifyState()) {
|
|
990
|
-
logger.debug('Not running base parity. State no longer valid.');
|
|
1013
|
+
this.logger.debug('Not running base parity. State no longer valid.');
|
|
991
1014
|
return;
|
|
992
1015
|
}
|
|
993
1016
|
if (!provingState.tryStartProvingBaseParity(baseParityIndex)) {
|
|
994
|
-
logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
1017
|
+
this.logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
995
1018
|
return;
|
|
996
1019
|
}
|
|
997
1020
|
const inputs = checkpointProvingState.getBaseParityInputs(baseParityIndex);
|
|
@@ -1012,11 +1035,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1012
1035
|
// Enqueues the root rollup proof if all inputs are available
|
|
1013
1036
|
enqueueRootParityCircuit(provingState) {
|
|
1014
1037
|
if (!provingState.verifyState()) {
|
|
1015
|
-
logger.debug('Not running root parity. State no longer valid.');
|
|
1038
|
+
this.logger.debug('Not running root parity. State no longer valid.');
|
|
1016
1039
|
return;
|
|
1017
1040
|
}
|
|
1018
1041
|
if (!provingState.tryStartProvingRootParity()) {
|
|
1019
|
-
logger.debug('Root parity already started.');
|
|
1042
|
+
this.logger.debug('Root parity already started.');
|
|
1020
1043
|
return;
|
|
1021
1044
|
}
|
|
1022
1045
|
const inputs = provingState.getParityRootInputs();
|
|
@@ -1031,33 +1054,33 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1031
1054
|
// Enqueues the next level of merge if all inputs are available
|
|
1032
1055
|
enqueueBlockMergeRollup(provingState, location) {
|
|
1033
1056
|
if (!provingState.verifyState()) {
|
|
1034
|
-
logger.debug('Not running block merge rollup. State no longer valid.');
|
|
1057
|
+
this.logger.debug('Not running block merge rollup. State no longer valid.');
|
|
1035
1058
|
return;
|
|
1036
1059
|
}
|
|
1037
1060
|
if (!provingState.tryStartProvingBlockMerge(location)) {
|
|
1038
|
-
logger.debug('Block merge rollup already started.');
|
|
1061
|
+
this.logger.debug('Block merge rollup already started.');
|
|
1039
1062
|
return;
|
|
1040
1063
|
}
|
|
1041
1064
|
const inputs = provingState.getBlockMergeRollupInputs(location);
|
|
1042
1065
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockMergeRollupProof', {
|
|
1043
1066
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-block-merge'
|
|
1044
|
-
}, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1067
|
+
}, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), async (result)=>{
|
|
1045
1068
|
provingState.setBlockMergeRollupProof(location, result);
|
|
1046
|
-
this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
1069
|
+
await this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
1047
1070
|
});
|
|
1048
1071
|
}
|
|
1049
|
-
enqueueCheckpointRootRollup(provingState) {
|
|
1072
|
+
async enqueueCheckpointRootRollup(provingState) {
|
|
1050
1073
|
if (!provingState.verifyState()) {
|
|
1051
|
-
logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
1074
|
+
this.logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
1052
1075
|
return;
|
|
1053
1076
|
}
|
|
1054
1077
|
if (!provingState.tryStartProvingCheckpointRoot()) {
|
|
1055
|
-
logger.debug('Checkpoint root rollup already started.');
|
|
1078
|
+
this.logger.debug('Checkpoint root rollup already started.');
|
|
1056
1079
|
return;
|
|
1057
1080
|
}
|
|
1058
1081
|
const rollupType = provingState.getCheckpointRootRollupType();
|
|
1059
|
-
logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
1060
|
-
const inputs = provingState.getCheckpointRootRollupInputs();
|
|
1082
|
+
this.logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
1083
|
+
const inputs = await provingState.getCheckpointRootRollupInputs();
|
|
1061
1084
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointRootRollupProof', {
|
|
1062
1085
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
1063
1086
|
}, (signal)=>{
|
|
@@ -1070,11 +1093,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1070
1093
|
const computedEndBlobAccumulatorState = provingState.getEndBlobAccumulator().toBlobAccumulator();
|
|
1071
1094
|
const circuitEndBlobAccumulatorState = result.inputs.endBlobAccumulator;
|
|
1072
1095
|
if (!circuitEndBlobAccumulatorState.equals(computedEndBlobAccumulatorState)) {
|
|
1073
|
-
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)}`);
|
|
1074
1097
|
provingState.reject(`Blob accumulator state mismatch.`);
|
|
1075
1098
|
return;
|
|
1076
1099
|
}
|
|
1077
|
-
logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
1100
|
+
this.logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
1078
1101
|
const leafLocation = provingState.setCheckpointRootRollupProof(result);
|
|
1079
1102
|
const epochProvingState = provingState.parentEpoch;
|
|
1080
1103
|
if (epochProvingState.totalNumCheckpoints === 1) {
|
|
@@ -1086,37 +1109,37 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1086
1109
|
}
|
|
1087
1110
|
enqueueCheckpointMergeRollup(provingState, location) {
|
|
1088
1111
|
if (!provingState.verifyState()) {
|
|
1089
|
-
logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1112
|
+
this.logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1090
1113
|
return;
|
|
1091
1114
|
}
|
|
1092
1115
|
if (!provingState.tryStartProvingCheckpointMerge(location)) {
|
|
1093
|
-
logger.debug('Checkpoint merge rollup already started.');
|
|
1116
|
+
this.logger.debug('Checkpoint merge rollup already started.');
|
|
1094
1117
|
return;
|
|
1095
1118
|
}
|
|
1096
1119
|
const inputs = provingState.getCheckpointMergeRollupInputs(location);
|
|
1097
1120
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointMergeRollupProof', {
|
|
1098
1121
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-merge'
|
|
1099
1122
|
}, (signal)=>this.prover.getCheckpointMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1100
|
-
logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1123
|
+
this.logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1101
1124
|
provingState.setCheckpointMergeRollupProof(location, result);
|
|
1102
1125
|
this.checkAndEnqueueNextCheckpointMergeRollup(provingState, location);
|
|
1103
1126
|
});
|
|
1104
1127
|
}
|
|
1105
1128
|
enqueueEpochPadding(provingState) {
|
|
1106
1129
|
if (!provingState.verifyState()) {
|
|
1107
|
-
logger.debug('Not running epoch padding. State no longer valid.');
|
|
1130
|
+
this.logger.debug('Not running epoch padding. State no longer valid.');
|
|
1108
1131
|
return;
|
|
1109
1132
|
}
|
|
1110
1133
|
if (!provingState.tryStartProvingPaddingCheckpoint()) {
|
|
1111
|
-
logger.debug('Padding checkpoint already started.');
|
|
1134
|
+
this.logger.debug('Padding checkpoint already started.');
|
|
1112
1135
|
return;
|
|
1113
1136
|
}
|
|
1114
|
-
logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1137
|
+
this.logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1115
1138
|
const inputs = provingState.getPaddingCheckpointInputs();
|
|
1116
1139
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointPaddingRollupProof', {
|
|
1117
1140
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-padding'
|
|
1118
1141
|
}, (signal)=>this.prover.getCheckpointPaddingRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1119
|
-
logger.debug('Completed proof for padding checkpoint.');
|
|
1142
|
+
this.logger.debug('Completed proof for padding checkpoint.');
|
|
1120
1143
|
provingState.setCheckpointPaddingProof(result);
|
|
1121
1144
|
this.checkAndEnqueueRootRollup(provingState);
|
|
1122
1145
|
});
|
|
@@ -1124,15 +1147,15 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1124
1147
|
// Executes the root rollup circuit
|
|
1125
1148
|
enqueueRootRollup(provingState) {
|
|
1126
1149
|
if (!provingState.verifyState()) {
|
|
1127
|
-
logger.debug('Not running root rollup, state no longer valid');
|
|
1150
|
+
this.logger.debug('Not running root rollup, state no longer valid');
|
|
1128
1151
|
return;
|
|
1129
1152
|
}
|
|
1130
|
-
logger.debug(`Preparing root rollup`);
|
|
1153
|
+
this.logger.debug(`Preparing root rollup`);
|
|
1131
1154
|
const inputs = provingState.getRootRollupInputs();
|
|
1132
1155
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getRootRollupProof', {
|
|
1133
1156
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-root'
|
|
1134
1157
|
}, (signal)=>this.prover.getRootRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1135
|
-
logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1158
|
+
this.logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1136
1159
|
provingState.setRootRollupProof(result);
|
|
1137
1160
|
provingState.resolve({
|
|
1138
1161
|
status: 'success'
|
|
@@ -1152,27 +1175,27 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1152
1175
|
}
|
|
1153
1176
|
checkAndEnqueueBlockRootRollup(provingState) {
|
|
1154
1177
|
if (!provingState.isReadyForBlockRootRollup()) {
|
|
1155
|
-
logger.debug('Not ready for block root rollup');
|
|
1178
|
+
this.logger.debug('Not ready for block root rollup');
|
|
1156
1179
|
return;
|
|
1157
1180
|
}
|
|
1158
1181
|
this.enqueueBlockRootRollup(provingState);
|
|
1159
1182
|
}
|
|
1160
|
-
checkAndEnqueueNextBlockMergeRollup(provingState, currentLocation) {
|
|
1183
|
+
async checkAndEnqueueNextBlockMergeRollup(provingState, currentLocation) {
|
|
1161
1184
|
if (!provingState.isReadyForBlockMerge(currentLocation)) {
|
|
1162
1185
|
return;
|
|
1163
1186
|
}
|
|
1164
1187
|
const parentLocation = provingState.getParentLocation(currentLocation);
|
|
1165
1188
|
if (parentLocation.level === 0) {
|
|
1166
|
-
this.checkAndEnqueueCheckpointRootRollup(provingState);
|
|
1189
|
+
await this.checkAndEnqueueCheckpointRootRollup(provingState);
|
|
1167
1190
|
} else {
|
|
1168
1191
|
this.enqueueBlockMergeRollup(provingState, parentLocation);
|
|
1169
1192
|
}
|
|
1170
1193
|
}
|
|
1171
|
-
checkAndEnqueueCheckpointRootRollup(provingState) {
|
|
1194
|
+
async checkAndEnqueueCheckpointRootRollup(provingState) {
|
|
1172
1195
|
if (!provingState.isReadyForCheckpointRoot()) {
|
|
1173
1196
|
return;
|
|
1174
1197
|
}
|
|
1175
|
-
this.enqueueCheckpointRootRollup(provingState);
|
|
1198
|
+
await this.enqueueCheckpointRootRollup(provingState);
|
|
1176
1199
|
}
|
|
1177
1200
|
checkAndEnqueueNextCheckpointMergeRollup(provingState, currentLocation) {
|
|
1178
1201
|
if (!provingState.isReadyForCheckpointMerge(currentLocation)) {
|
|
@@ -1187,7 +1210,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1187
1210
|
}
|
|
1188
1211
|
checkAndEnqueueRootRollup(provingState) {
|
|
1189
1212
|
if (!provingState.isReadyForRootRollup()) {
|
|
1190
|
-
logger.debug('Not ready for root rollup');
|
|
1213
|
+
this.logger.debug('Not ready for root rollup');
|
|
1191
1214
|
return;
|
|
1192
1215
|
}
|
|
1193
1216
|
this.enqueueRootRollup(provingState);
|
|
@@ -1199,7 +1222,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1199
1222
|
* @param txIndex - The index of the transaction being proven
|
|
1200
1223
|
*/ enqueueVM(provingState, txIndex) {
|
|
1201
1224
|
if (!provingState.verifyState()) {
|
|
1202
|
-
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`);
|
|
1203
1226
|
return;
|
|
1204
1227
|
}
|
|
1205
1228
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
@@ -1210,7 +1233,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1210
1233
|
return await this.prover.getAvmProof(inputs, signal, provingState.epochNumber);
|
|
1211
1234
|
});
|
|
1212
1235
|
this.deferredProving(provingState, doAvmProving, (proof)=>{
|
|
1213
|
-
logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
1236
|
+
this.logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
1214
1237
|
txProvingState.setAvmProof(proof);
|
|
1215
1238
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
1216
1239
|
});
|
|
@@ -1221,7 +1244,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1221
1244
|
return;
|
|
1222
1245
|
}
|
|
1223
1246
|
// We must have completed all proving (chonk verifier proof and (if required) vm proof are generated), we now move to the base rollup.
|
|
1224
|
-
logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
1247
|
+
this.logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
1225
1248
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
1226
1249
|
}
|
|
1227
1250
|
}
|