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