@aztec/prover-client 0.0.1-commit.96bb3f7 → 0.0.1-commit.96dac018d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/light/lightweight_checkpoint_builder.d.ts +15 -7
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +57 -24
- 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 +3 -2
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +10 -2
- package/dest/orchestrator/block-building-helpers.d.ts +5 -5
- 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 +17 -4
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +37 -4
- package/dest/orchestrator/epoch-proving-state.d.ts +7 -6
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +37 -1
- package/dest/orchestrator/orchestrator.d.ts +18 -3
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +128 -95
- package/dest/prover-client/prover-client.d.ts +3 -3
- 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 +3 -3
- package/dest/proving_broker/config.d.ts +13 -1
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +19 -2
- package/dest/proving_broker/proof_store/factory.d.ts +2 -5
- package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/factory.js +7 -30
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
- package/dest/proving_broker/proof_store/index.d.ts +2 -2
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -1
- package/dest/proving_broker/proving_agent.d.ts +4 -3
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +4 -4
- package/dest/proving_broker/proving_broker.d.ts +7 -4
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +36 -4
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +3 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +18 -7
- package/dest/proving_broker/proving_job_controller.d.ts +4 -3
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +6 -3
- package/dest/proving_broker/rpc.d.ts +4 -2
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +8 -0
- package/dest/test/mock_proof_store.d.ts +3 -3
- package/dest/test/mock_proof_store.d.ts.map +1 -1
- package/dest/test/mock_prover.d.ts +4 -4
- package/package.json +16 -17
- package/src/light/lightweight_checkpoint_builder.ts +82 -30
- package/src/mocks/fixtures.ts +2 -1
- package/src/mocks/test_context.ts +7 -2
- 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 +51 -5
- package/src/orchestrator/epoch-proving-state.ts +59 -9
- package/src/orchestrator/orchestrator.ts +139 -104
- package/src/prover-client/prover-client.ts +29 -14
- package/src/proving_broker/broker_prover_facade.ts +6 -3
- package/src/proving_broker/config.ts +22 -0
- package/src/proving_broker/proof_store/factory.ts +10 -32
- package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
- package/src/proving_broker/proof_store/index.ts +1 -1
- package/src/proving_broker/proving_agent.ts +5 -2
- package/src/proving_broker/proving_broker.ts +37 -3
- package/src/proving_broker/proving_broker_instrumentation.ts +19 -6
- package/src/proving_broker/proving_job_controller.ts +9 -3
- package/src/proving_broker/rpc.ts +14 -0
- package/dest/block-factory/index.d.ts +0 -2
- package/dest/block-factory/index.d.ts.map +0 -1
- package/dest/block-factory/index.js +0 -1
- package/dest/block-factory/light.d.ts +0 -38
- package/dest/block-factory/light.d.ts.map +0 -1
- package/dest/block-factory/light.js +0 -106
- 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/block-factory/index.ts +0 -1
- package/src/block-factory/light.ts +0 -136
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
|
@@ -389,7 +389,6 @@ import { buildHeaderFromCircuitOutputs, getLastSiblingPath, getPublicChonkVerifi
|
|
|
389
389
|
import { EpochProvingState } from './epoch-proving-state.js';
|
|
390
390
|
import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
|
|
391
391
|
import { TxProvingState } from './tx-proving-state.js';
|
|
392
|
-
const logger = createLogger('prover-client:orchestrator');
|
|
393
392
|
_dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
394
393
|
[Attributes.BLOCK_NUMBER]: blockNumber
|
|
395
394
|
})), _dec1 = trackSpan('ProvingOrchestrator.addTxs', (txs)=>({
|
|
@@ -414,6 +413,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
414
413
|
dbProvider;
|
|
415
414
|
prover;
|
|
416
415
|
proverId;
|
|
416
|
+
cancelJobsOnStop;
|
|
417
417
|
static{
|
|
418
418
|
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
419
419
|
[
|
|
@@ -449,14 +449,17 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
449
449
|
metrics;
|
|
450
450
|
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
451
451
|
dbs;
|
|
452
|
-
|
|
452
|
+
logger;
|
|
453
|
+
constructor(dbProvider, prover, proverId, cancelJobsOnStop = false, telemetryClient = getTelemetryClient(), bindings){
|
|
453
454
|
this.dbProvider = dbProvider;
|
|
454
455
|
this.prover = prover;
|
|
455
456
|
this.proverId = proverId;
|
|
457
|
+
this.cancelJobsOnStop = cancelJobsOnStop;
|
|
456
458
|
this.provingState = (_initProto(this), undefined);
|
|
457
459
|
this.pendingProvingJobs = [];
|
|
458
460
|
this.provingPromise = undefined;
|
|
459
461
|
this.dbs = new Map();
|
|
462
|
+
this.logger = createLogger('prover-client:orchestrator', bindings);
|
|
460
463
|
this.metrics = new ProvingOrchestratorMetrics(telemetryClient, 'ProvingOrchestrator');
|
|
461
464
|
}
|
|
462
465
|
get tracer() {
|
|
@@ -465,6 +468,9 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
465
468
|
getProverId() {
|
|
466
469
|
return this.proverId;
|
|
467
470
|
}
|
|
471
|
+
getNumActiveForks() {
|
|
472
|
+
return this.dbs.size;
|
|
473
|
+
}
|
|
468
474
|
stop() {
|
|
469
475
|
this.cancel();
|
|
470
476
|
return Promise.resolve();
|
|
@@ -478,11 +484,18 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
478
484
|
status: 'failure',
|
|
479
485
|
reason
|
|
480
486
|
}));
|
|
481
|
-
logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
487
|
+
this.logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
482
488
|
this.provingState = new EpochProvingState(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges, (provingState)=>this.checkAndEnqueueCheckpointRootRollup(provingState), resolve, reject);
|
|
483
489
|
this.provingPromise = promise;
|
|
484
490
|
}
|
|
485
|
-
|
|
491
|
+
/**
|
|
492
|
+
* Starts a new checkpoint.
|
|
493
|
+
* @param checkpointIndex - The index of the checkpoint in the epoch.
|
|
494
|
+
* @param constants - The constants for this checkpoint.
|
|
495
|
+
* @param l1ToL2Messages - The set of L1 to L2 messages to be inserted at the beginning of this checkpoint.
|
|
496
|
+
* @param totalNumBlocks - The total number of blocks expected in the checkpoint (must be at least one).
|
|
497
|
+
* @param headerOfLastBlockInPreviousCheckpoint - The header of the last block in the previous checkpoint.
|
|
498
|
+
*/ async startNewCheckpoint(checkpointIndex, constants, l1ToL2Messages, totalNumBlocks, headerOfLastBlockInPreviousCheckpoint) {
|
|
486
499
|
if (!this.provingState) {
|
|
487
500
|
throw new Error('Empty epoch proving state. Call startNewEpoch before starting a checkpoint.');
|
|
488
501
|
}
|
|
@@ -518,14 +531,14 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
518
531
|
throw new Error(`Checkpoint not accepting further blocks.`);
|
|
519
532
|
}
|
|
520
533
|
const constants = checkpointProvingState.constants;
|
|
521
|
-
logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
534
|
+
this.logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
522
535
|
// Fork the db only when it's not already set. The db for the first block is set in `startNewCheckpoint`.
|
|
523
536
|
if (!this.dbs.has(blockNumber)) {
|
|
524
537
|
// Fork world state at the end of the immediately previous block
|
|
525
538
|
const db = await this.dbProvider.fork(BlockNumber(blockNumber - 1));
|
|
526
539
|
this.dbs.set(blockNumber, db);
|
|
527
540
|
}
|
|
528
|
-
const db = this.
|
|
541
|
+
const db = this.getDbForBlock(blockNumber);
|
|
529
542
|
// Get archive snapshot and sibling path before any txs in this block lands.
|
|
530
543
|
const lastArchiveTreeSnapshot = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
531
544
|
const lastArchiveSiblingPath = await getRootTreeSiblingPath(MerkleTreeId.ARCHIVE, db);
|
|
@@ -545,7 +558,8 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
545
558
|
const blockEndBlobFields = blockProvingState.getBlockEndBlobFields();
|
|
546
559
|
await endSpongeBlob.absorb(blockEndBlobFields);
|
|
547
560
|
blockProvingState.setEndSpongeBlob(endSpongeBlob);
|
|
548
|
-
//
|
|
561
|
+
// Try to accumulate the out hashes and blobs as far as we can:
|
|
562
|
+
await this.provingState.accumulateCheckpointOutHashes();
|
|
549
563
|
await this.provingState.setBlobAccumulators();
|
|
550
564
|
}
|
|
551
565
|
}
|
|
@@ -559,7 +573,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
559
573
|
if (!txs.length) {
|
|
560
574
|
// To avoid an ugly throw below. If we require an empty block, we can just call setBlockCompleted
|
|
561
575
|
// on a block with no txs. We cannot do that here because we cannot find the blockNumber without any txs.
|
|
562
|
-
logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
576
|
+
this.logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
563
577
|
return;
|
|
564
578
|
}
|
|
565
579
|
const blockNumber = BlockNumber(txs[0].globalVariables.blockNumber);
|
|
@@ -573,8 +587,8 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
573
587
|
if (!provingState.isAcceptingTxs()) {
|
|
574
588
|
throw new Error(`Block ${blockNumber} has been initialized with transactions.`);
|
|
575
589
|
}
|
|
576
|
-
logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
577
|
-
const db = this.
|
|
590
|
+
this.logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
591
|
+
const db = this.getDbForBlock(blockNumber);
|
|
578
592
|
const lastArchive = provingState.lastArchiveTreeSnapshot;
|
|
579
593
|
const newL1ToL2MessageTreeSnapshot = provingState.newL1ToL2MessageTreeSnapshot;
|
|
580
594
|
const spongeBlobState = provingState.getStartSpongeBlob().clone();
|
|
@@ -584,7 +598,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
584
598
|
throw new Error(`Invalid proving state when adding a tx`);
|
|
585
599
|
}
|
|
586
600
|
validateTx(tx);
|
|
587
|
-
logger.debug(`Received transaction: ${tx.hash}`);
|
|
601
|
+
this.logger.debug(`Received transaction: ${tx.hash}`);
|
|
588
602
|
const startSpongeBlob = spongeBlobState.clone();
|
|
589
603
|
const [hints, treeSnapshots] = await this.prepareBaseRollupInputs(tx, lastArchive, newL1ToL2MessageTreeSnapshot, startSpongeBlob, db);
|
|
590
604
|
if (!provingState.verifyState()) {
|
|
@@ -595,10 +609,10 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
595
609
|
const txIndex = provingState.addNewTx(txProvingState);
|
|
596
610
|
if (txProvingState.requireAvmProof) {
|
|
597
611
|
this.getOrEnqueueChonkVerifier(provingState, txIndex);
|
|
598
|
-
logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
612
|
+
this.logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
599
613
|
this.enqueueVM(provingState, txIndex);
|
|
600
614
|
} else {
|
|
601
|
-
logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
615
|
+
this.logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
602
616
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
603
617
|
}
|
|
604
618
|
} catch (err) {
|
|
@@ -612,7 +626,8 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
612
626
|
const blockEndBlobFields = provingState.getBlockEndBlobFields();
|
|
613
627
|
await spongeBlobState.absorb(blockEndBlobFields);
|
|
614
628
|
provingState.setEndSpongeBlob(spongeBlobState);
|
|
615
|
-
// Txs have been added to the block. Now try to accumulate the blobs as far as we can:
|
|
629
|
+
// Txs have been added to the block. Now try to accumulate the out hashes and blobs as far as we can:
|
|
630
|
+
await this.provingState.accumulateCheckpointOutHashes();
|
|
616
631
|
await this.provingState.setBlobAccumulators();
|
|
617
632
|
}
|
|
618
633
|
/**
|
|
@@ -627,7 +642,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
627
642
|
const txHash = tx.getTxHash().toString();
|
|
628
643
|
const privateInputs = getPublicChonkVerifierPrivateInputsFromTx(tx, this.proverId.toField());
|
|
629
644
|
const tubeProof = promiseWithResolvers();
|
|
630
|
-
logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
645
|
+
this.logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
631
646
|
this.doEnqueueChonkVerifier(txHash, privateInputs, (proof)=>{
|
|
632
647
|
tubeProof.resolve(proof);
|
|
633
648
|
});
|
|
@@ -656,17 +671,23 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
656
671
|
throw new Error(`Block ${blockNumber} is still accepting txs. Call setBlockCompleted after all txs have been added.`);
|
|
657
672
|
}
|
|
658
673
|
// Given we've applied every change from this block, now assemble the block header:
|
|
659
|
-
logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
674
|
+
this.logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
660
675
|
const header = await provingState.buildBlockHeader();
|
|
661
676
|
if (expectedHeader && !header.equals(expectedHeader)) {
|
|
662
|
-
logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
677
|
+
this.logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
663
678
|
throw new Error('Block header mismatch');
|
|
664
679
|
}
|
|
665
|
-
// Get db for this block
|
|
666
|
-
const db = this.
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
680
|
+
// Get db for this block and remove from map — no other code should use it after this point.
|
|
681
|
+
const db = this.getDbForBlock(provingState.blockNumber);
|
|
682
|
+
this.dbs.delete(provingState.blockNumber);
|
|
683
|
+
// Update the archive tree, capture the snapshot, and close the fork deterministically.
|
|
684
|
+
try {
|
|
685
|
+
this.logger.verbose(`Updating archive tree with block ${provingState.blockNumber} header ${(await header.hash()).toString()}`);
|
|
686
|
+
await db.updateArchive(header);
|
|
687
|
+
provingState.setBuiltArchive(await getTreeSnapshot(MerkleTreeId.ARCHIVE, db));
|
|
688
|
+
} finally{
|
|
689
|
+
await db.close();
|
|
690
|
+
}
|
|
670
691
|
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
671
692
|
return header;
|
|
672
693
|
}
|
|
@@ -674,50 +695,61 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
674
695
|
async verifyBuiltBlockAgainstSyncedState(provingState) {
|
|
675
696
|
const builtBlockHeader = provingState.getBuiltBlockHeader();
|
|
676
697
|
if (!builtBlockHeader) {
|
|
677
|
-
logger.debug('Block header not built yet, skipping header check.');
|
|
698
|
+
this.logger.debug('Block header not built yet, skipping header check.');
|
|
678
699
|
return;
|
|
679
700
|
}
|
|
680
701
|
const output = provingState.getBlockRootRollupOutput();
|
|
681
702
|
if (!output) {
|
|
682
|
-
logger.debug('Block root rollup proof not built yet, skipping header check.');
|
|
703
|
+
this.logger.debug('Block root rollup proof not built yet, skipping header check.');
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
const newArchive = provingState.getBuiltArchive();
|
|
707
|
+
if (!newArchive) {
|
|
708
|
+
this.logger.debug('Archive snapshot not yet captured, skipping header check.');
|
|
683
709
|
return;
|
|
684
710
|
}
|
|
685
711
|
const header = await buildHeaderFromCircuitOutputs(output);
|
|
686
712
|
if (!(await header.hash()).equals(await builtBlockHeader.hash())) {
|
|
687
|
-
logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
713
|
+
this.logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
688
714
|
provingState.reject(`Block header hash mismatch.`);
|
|
689
715
|
return;
|
|
690
716
|
}
|
|
691
|
-
// Get db for this block
|
|
692
717
|
const blockNumber = provingState.blockNumber;
|
|
693
|
-
const db = this.dbs.get(blockNumber);
|
|
694
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
695
718
|
const syncedArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.dbProvider.getSnapshot(blockNumber));
|
|
696
719
|
if (!syncedArchive.equals(newArchive)) {
|
|
697
|
-
logger.error(`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(syncedArchive)} but built ${inspect(newArchive)}`);
|
|
720
|
+
this.logger.error(`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(syncedArchive)} but built ${inspect(newArchive)}`);
|
|
698
721
|
provingState.reject(`Archive tree mismatch.`);
|
|
699
722
|
return;
|
|
700
723
|
}
|
|
701
724
|
const circuitArchive = output.newArchive;
|
|
702
725
|
if (!newArchive.equals(circuitArchive)) {
|
|
703
|
-
logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
726
|
+
this.logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
704
727
|
provingState.reject(`New archive mismatch.`);
|
|
705
728
|
return;
|
|
706
729
|
}
|
|
707
|
-
// TODO(palla/prover): This closes the fork only on the happy path. If this epoch orchestrator
|
|
708
|
-
// is aborted and never reaches this point, it will leak the fork. We need to add a global cleanup,
|
|
709
|
-
// but have to make sure it only runs once all operations are completed, otherwise some function here
|
|
710
|
-
// will attempt to access the fork after it was closed.
|
|
711
|
-
logger.debug(`Cleaning up world state fork for ${blockNumber}`);
|
|
712
|
-
void this.dbs.get(blockNumber)?.close().then(()=>this.dbs.delete(blockNumber)).catch((err)=>logger.error(`Error closing db for block ${blockNumber}`, err));
|
|
713
730
|
}
|
|
714
731
|
/**
|
|
715
|
-
* Cancel any further proving
|
|
732
|
+
* Cancel any further proving.
|
|
733
|
+
* If cancelJobsOnStop is true, aborts all pending jobs with the broker (which marks them as 'Aborted').
|
|
734
|
+
* If cancelJobsOnStop is false (default), jobs remain in the broker queue and can be reused on restart/reorg.
|
|
716
735
|
*/ cancel() {
|
|
717
|
-
|
|
718
|
-
controller.
|
|
736
|
+
if (this.cancelJobsOnStop) {
|
|
737
|
+
for (const controller of this.pendingProvingJobs){
|
|
738
|
+
controller.abort();
|
|
739
|
+
}
|
|
719
740
|
}
|
|
720
741
|
this.provingState?.cancel();
|
|
742
|
+
for (const [blockNumber, db] of this.dbs.entries()){
|
|
743
|
+
void db.close().catch((err)=>this.logger.error(`Error closing db for block ${blockNumber}`, err));
|
|
744
|
+
}
|
|
745
|
+
this.dbs.clear();
|
|
746
|
+
}
|
|
747
|
+
getDbForBlock(blockNumber) {
|
|
748
|
+
const db = this.dbs.get(blockNumber);
|
|
749
|
+
if (!db) {
|
|
750
|
+
throw new Error(`World state fork for block ${blockNumber} not found.`);
|
|
751
|
+
}
|
|
752
|
+
return db;
|
|
721
753
|
}
|
|
722
754
|
/**
|
|
723
755
|
* Returns the proof for the current epoch.
|
|
@@ -744,7 +776,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
744
776
|
* @param job - The actual job, returns a promise notifying of the job's completion
|
|
745
777
|
*/ deferredProving(provingState, request, callback) {
|
|
746
778
|
if (!provingState.verifyState()) {
|
|
747
|
-
logger.debug(`Not enqueuing job, state no longer valid`);
|
|
779
|
+
this.logger.debug(`Not enqueuing job, state no longer valid`);
|
|
748
780
|
return;
|
|
749
781
|
}
|
|
750
782
|
const controller = new AbortController();
|
|
@@ -759,7 +791,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
759
791
|
}
|
|
760
792
|
const result = await request(controller.signal);
|
|
761
793
|
if (!provingState.verifyState()) {
|
|
762
|
-
logger.debug(`State no longer valid, discarding result`);
|
|
794
|
+
this.logger.debug(`State no longer valid, discarding result`);
|
|
763
795
|
return;
|
|
764
796
|
}
|
|
765
797
|
// we could have been cancelled whilst waiting for the result
|
|
@@ -774,7 +806,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
774
806
|
// drop this result
|
|
775
807
|
return;
|
|
776
808
|
}
|
|
777
|
-
logger.error(`Error thrown when proving job`, err);
|
|
809
|
+
this.logger.error(`Error thrown when proving job`, err);
|
|
778
810
|
provingState.reject(`${err}`);
|
|
779
811
|
} finally{
|
|
780
812
|
const index = this.pendingProvingJobs.indexOf(controller);
|
|
@@ -830,17 +862,17 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
830
862
|
// Executes the next level of merge if all inputs are available
|
|
831
863
|
enqueueBaseRollup(provingState, txIndex) {
|
|
832
864
|
if (!provingState.verifyState()) {
|
|
833
|
-
logger.debug('Not running base rollup, state invalid');
|
|
865
|
+
this.logger.debug('Not running base rollup, state invalid');
|
|
834
866
|
return;
|
|
835
867
|
}
|
|
836
868
|
if (!provingState.tryStartProvingBase(txIndex)) {
|
|
837
|
-
logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
869
|
+
this.logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
838
870
|
return;
|
|
839
871
|
}
|
|
840
872
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
841
873
|
const { processedTx } = txProvingState;
|
|
842
874
|
const { rollupType, inputs } = txProvingState.getBaseRollupTypeAndInputs();
|
|
843
|
-
logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
875
|
+
this.logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
844
876
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, `ProvingOrchestrator.prover.${inputs instanceof PrivateTxBaseRollupPrivateInputs ? 'getPrivateTxBaseRollupProof' : 'getPublicTxBaseRollupProof'}`, {
|
|
845
877
|
[Attributes.TX_HASH]: processedTx.hash.toString(),
|
|
846
878
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
@@ -851,7 +883,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
851
883
|
return this.prover.getPublicTxBaseRollupProof(inputs, signal, provingState.epochNumber);
|
|
852
884
|
}
|
|
853
885
|
}), (result)=>{
|
|
854
|
-
logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
886
|
+
this.logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
855
887
|
validatePartialState(result.inputs.endTreeSnapshots, txProvingState.treeSnapshots);
|
|
856
888
|
const leafLocation = provingState.setBaseRollupProof(txIndex, result);
|
|
857
889
|
if (provingState.totalNumTxs === 1) {
|
|
@@ -865,14 +897,14 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
865
897
|
// Once completed, will enqueue the the public tx base rollup.
|
|
866
898
|
getOrEnqueueChonkVerifier(provingState, txIndex) {
|
|
867
899
|
if (!provingState.verifyState()) {
|
|
868
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
900
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
869
901
|
return;
|
|
870
902
|
}
|
|
871
903
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
872
904
|
const txHash = txProvingState.processedTx.hash.toString();
|
|
873
905
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH;
|
|
874
906
|
const handleResult = (result)=>{
|
|
875
|
-
logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
|
|
907
|
+
this.logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
|
|
876
908
|
txHash
|
|
877
909
|
});
|
|
878
910
|
txProvingState.setPublicChonkVerifierProof(result);
|
|
@@ -880,18 +912,18 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
880
912
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
881
913
|
};
|
|
882
914
|
if (this.provingState?.cachedChonkVerifierProofs.has(txHash)) {
|
|
883
|
-
logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, {
|
|
915
|
+
this.logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, {
|
|
884
916
|
txHash
|
|
885
917
|
});
|
|
886
918
|
void this.provingState.cachedChonkVerifierProofs.get(txHash).then(handleResult);
|
|
887
919
|
return;
|
|
888
920
|
}
|
|
889
|
-
logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
921
|
+
this.logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
890
922
|
this.doEnqueueChonkVerifier(txHash, txProvingState.getPublicChonkVerifierPrivateInputs(), handleResult);
|
|
891
923
|
}
|
|
892
924
|
doEnqueueChonkVerifier(txHash, inputs, handler, provingState = this.provingState) {
|
|
893
925
|
if (!provingState.verifyState()) {
|
|
894
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
926
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
895
927
|
return;
|
|
896
928
|
}
|
|
897
929
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getPublicChonkVerifierProof', {
|
|
@@ -903,11 +935,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
903
935
|
// Enqueues the next level of merge if all inputs are available
|
|
904
936
|
enqueueMergeRollup(provingState, location) {
|
|
905
937
|
if (!provingState.verifyState()) {
|
|
906
|
-
logger.debug('Not running merge rollup. State no longer valid.');
|
|
938
|
+
this.logger.debug('Not running merge rollup. State no longer valid.');
|
|
907
939
|
return;
|
|
908
940
|
}
|
|
909
941
|
if (!provingState.tryStartProvingMerge(location)) {
|
|
910
|
-
logger.debug('Merge rollup already started.');
|
|
942
|
+
this.logger.debug('Merge rollup already started.');
|
|
911
943
|
return;
|
|
912
944
|
}
|
|
913
945
|
const inputs = provingState.getMergeRollupInputs(location);
|
|
@@ -921,15 +953,15 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
921
953
|
// Executes the block root rollup circuit
|
|
922
954
|
enqueueBlockRootRollup(provingState) {
|
|
923
955
|
if (!provingState.verifyState()) {
|
|
924
|
-
logger.debug('Not running block root rollup, state no longer valid');
|
|
956
|
+
this.logger.debug('Not running block root rollup, state no longer valid');
|
|
925
957
|
return;
|
|
926
958
|
}
|
|
927
959
|
if (!provingState.tryStartProvingBlockRoot()) {
|
|
928
|
-
logger.debug('Block root rollup already started.');
|
|
960
|
+
this.logger.debug('Block root rollup already started.');
|
|
929
961
|
return;
|
|
930
962
|
}
|
|
931
963
|
const { rollupType, inputs } = provingState.getBlockRootRollupTypeAndInputs();
|
|
932
|
-
logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
964
|
+
this.logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
933
965
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockRootRollupProof', {
|
|
934
966
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
935
967
|
}, (signal)=>{
|
|
@@ -945,15 +977,16 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
945
977
|
return this.prover.getBlockRootRollupProof(inputs, signal, provingState.epochNumber);
|
|
946
978
|
}
|
|
947
979
|
}), async (result)=>{
|
|
948
|
-
|
|
949
|
-
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
950
|
-
logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
980
|
+
this.logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
951
981
|
const leafLocation = provingState.setBlockRootRollupProof(result);
|
|
952
982
|
const checkpointProvingState = provingState.parentCheckpoint;
|
|
983
|
+
// Verification is called from both here and setBlockCompleted. Whichever runs last
|
|
984
|
+
// will be the first to see all three pieces (header, proof output, archive) and run the checks.
|
|
985
|
+
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
953
986
|
if (checkpointProvingState.totalNumBlocks === 1) {
|
|
954
|
-
this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
987
|
+
await this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
955
988
|
} else {
|
|
956
|
-
this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
989
|
+
await this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
957
990
|
}
|
|
958
991
|
});
|
|
959
992
|
}
|
|
@@ -961,11 +994,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
961
994
|
// Enqueues the root parity circuit if all inputs are available
|
|
962
995
|
enqueueBaseParityCircuit(checkpointProvingState, provingState, baseParityIndex) {
|
|
963
996
|
if (!provingState.verifyState()) {
|
|
964
|
-
logger.debug('Not running base parity. State no longer valid.');
|
|
997
|
+
this.logger.debug('Not running base parity. State no longer valid.');
|
|
965
998
|
return;
|
|
966
999
|
}
|
|
967
1000
|
if (!provingState.tryStartProvingBaseParity(baseParityIndex)) {
|
|
968
|
-
logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
1001
|
+
this.logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
969
1002
|
return;
|
|
970
1003
|
}
|
|
971
1004
|
const inputs = checkpointProvingState.getBaseParityInputs(baseParityIndex);
|
|
@@ -986,11 +1019,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
986
1019
|
// Enqueues the root rollup proof if all inputs are available
|
|
987
1020
|
enqueueRootParityCircuit(provingState) {
|
|
988
1021
|
if (!provingState.verifyState()) {
|
|
989
|
-
logger.debug('Not running root parity. State no longer valid.');
|
|
1022
|
+
this.logger.debug('Not running root parity. State no longer valid.');
|
|
990
1023
|
return;
|
|
991
1024
|
}
|
|
992
1025
|
if (!provingState.tryStartProvingRootParity()) {
|
|
993
|
-
logger.debug('Root parity already started.');
|
|
1026
|
+
this.logger.debug('Root parity already started.');
|
|
994
1027
|
return;
|
|
995
1028
|
}
|
|
996
1029
|
const inputs = provingState.getParityRootInputs();
|
|
@@ -1005,33 +1038,33 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1005
1038
|
// Enqueues the next level of merge if all inputs are available
|
|
1006
1039
|
enqueueBlockMergeRollup(provingState, location) {
|
|
1007
1040
|
if (!provingState.verifyState()) {
|
|
1008
|
-
logger.debug('Not running block merge rollup. State no longer valid.');
|
|
1041
|
+
this.logger.debug('Not running block merge rollup. State no longer valid.');
|
|
1009
1042
|
return;
|
|
1010
1043
|
}
|
|
1011
1044
|
if (!provingState.tryStartProvingBlockMerge(location)) {
|
|
1012
|
-
logger.debug('Block merge rollup already started.');
|
|
1045
|
+
this.logger.debug('Block merge rollup already started.');
|
|
1013
1046
|
return;
|
|
1014
1047
|
}
|
|
1015
1048
|
const inputs = provingState.getBlockMergeRollupInputs(location);
|
|
1016
1049
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockMergeRollupProof', {
|
|
1017
1050
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-block-merge'
|
|
1018
|
-
}, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1051
|
+
}, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), async (result)=>{
|
|
1019
1052
|
provingState.setBlockMergeRollupProof(location, result);
|
|
1020
|
-
this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
1053
|
+
await this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
1021
1054
|
});
|
|
1022
1055
|
}
|
|
1023
|
-
enqueueCheckpointRootRollup(provingState) {
|
|
1056
|
+
async enqueueCheckpointRootRollup(provingState) {
|
|
1024
1057
|
if (!provingState.verifyState()) {
|
|
1025
|
-
logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
1058
|
+
this.logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
1026
1059
|
return;
|
|
1027
1060
|
}
|
|
1028
1061
|
if (!provingState.tryStartProvingCheckpointRoot()) {
|
|
1029
|
-
logger.debug('Checkpoint root rollup already started.');
|
|
1062
|
+
this.logger.debug('Checkpoint root rollup already started.');
|
|
1030
1063
|
return;
|
|
1031
1064
|
}
|
|
1032
1065
|
const rollupType = provingState.getCheckpointRootRollupType();
|
|
1033
|
-
logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
1034
|
-
const inputs = provingState.getCheckpointRootRollupInputs();
|
|
1066
|
+
this.logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
1067
|
+
const inputs = await provingState.getCheckpointRootRollupInputs();
|
|
1035
1068
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointRootRollupProof', {
|
|
1036
1069
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
|
|
1037
1070
|
}, (signal)=>{
|
|
@@ -1044,11 +1077,11 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1044
1077
|
const computedEndBlobAccumulatorState = provingState.getEndBlobAccumulator().toBlobAccumulator();
|
|
1045
1078
|
const circuitEndBlobAccumulatorState = result.inputs.endBlobAccumulator;
|
|
1046
1079
|
if (!circuitEndBlobAccumulatorState.equals(computedEndBlobAccumulatorState)) {
|
|
1047
|
-
logger.error(`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(computedEndBlobAccumulatorState)}`);
|
|
1080
|
+
this.logger.error(`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(computedEndBlobAccumulatorState)}`);
|
|
1048
1081
|
provingState.reject(`Blob accumulator state mismatch.`);
|
|
1049
1082
|
return;
|
|
1050
1083
|
}
|
|
1051
|
-
logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
1084
|
+
this.logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
1052
1085
|
const leafLocation = provingState.setCheckpointRootRollupProof(result);
|
|
1053
1086
|
const epochProvingState = provingState.parentEpoch;
|
|
1054
1087
|
if (epochProvingState.totalNumCheckpoints === 1) {
|
|
@@ -1060,37 +1093,37 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1060
1093
|
}
|
|
1061
1094
|
enqueueCheckpointMergeRollup(provingState, location) {
|
|
1062
1095
|
if (!provingState.verifyState()) {
|
|
1063
|
-
logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1096
|
+
this.logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1064
1097
|
return;
|
|
1065
1098
|
}
|
|
1066
1099
|
if (!provingState.tryStartProvingCheckpointMerge(location)) {
|
|
1067
|
-
logger.debug('Checkpoint merge rollup already started.');
|
|
1100
|
+
this.logger.debug('Checkpoint merge rollup already started.');
|
|
1068
1101
|
return;
|
|
1069
1102
|
}
|
|
1070
1103
|
const inputs = provingState.getCheckpointMergeRollupInputs(location);
|
|
1071
1104
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointMergeRollupProof', {
|
|
1072
1105
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-merge'
|
|
1073
1106
|
}, (signal)=>this.prover.getCheckpointMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1074
|
-
logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1107
|
+
this.logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1075
1108
|
provingState.setCheckpointMergeRollupProof(location, result);
|
|
1076
1109
|
this.checkAndEnqueueNextCheckpointMergeRollup(provingState, location);
|
|
1077
1110
|
});
|
|
1078
1111
|
}
|
|
1079
1112
|
enqueueEpochPadding(provingState) {
|
|
1080
1113
|
if (!provingState.verifyState()) {
|
|
1081
|
-
logger.debug('Not running epoch padding. State no longer valid.');
|
|
1114
|
+
this.logger.debug('Not running epoch padding. State no longer valid.');
|
|
1082
1115
|
return;
|
|
1083
1116
|
}
|
|
1084
1117
|
if (!provingState.tryStartProvingPaddingCheckpoint()) {
|
|
1085
|
-
logger.debug('Padding checkpoint already started.');
|
|
1118
|
+
this.logger.debug('Padding checkpoint already started.');
|
|
1086
1119
|
return;
|
|
1087
1120
|
}
|
|
1088
|
-
logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1121
|
+
this.logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1089
1122
|
const inputs = provingState.getPaddingCheckpointInputs();
|
|
1090
1123
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointPaddingRollupProof', {
|
|
1091
1124
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-padding'
|
|
1092
1125
|
}, (signal)=>this.prover.getCheckpointPaddingRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1093
|
-
logger.debug('Completed proof for padding checkpoint.');
|
|
1126
|
+
this.logger.debug('Completed proof for padding checkpoint.');
|
|
1094
1127
|
provingState.setCheckpointPaddingProof(result);
|
|
1095
1128
|
this.checkAndEnqueueRootRollup(provingState);
|
|
1096
1129
|
});
|
|
@@ -1098,15 +1131,15 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1098
1131
|
// Executes the root rollup circuit
|
|
1099
1132
|
enqueueRootRollup(provingState) {
|
|
1100
1133
|
if (!provingState.verifyState()) {
|
|
1101
|
-
logger.debug('Not running root rollup, state no longer valid');
|
|
1134
|
+
this.logger.debug('Not running root rollup, state no longer valid');
|
|
1102
1135
|
return;
|
|
1103
1136
|
}
|
|
1104
|
-
logger.debug(`Preparing root rollup`);
|
|
1137
|
+
this.logger.debug(`Preparing root rollup`);
|
|
1105
1138
|
const inputs = provingState.getRootRollupInputs();
|
|
1106
1139
|
this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getRootRollupProof', {
|
|
1107
1140
|
[Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-root'
|
|
1108
1141
|
}, (signal)=>this.prover.getRootRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
|
|
1109
|
-
logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1142
|
+
this.logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1110
1143
|
provingState.setRootRollupProof(result);
|
|
1111
1144
|
provingState.resolve({
|
|
1112
1145
|
status: 'success'
|
|
@@ -1126,27 +1159,27 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1126
1159
|
}
|
|
1127
1160
|
checkAndEnqueueBlockRootRollup(provingState) {
|
|
1128
1161
|
if (!provingState.isReadyForBlockRootRollup()) {
|
|
1129
|
-
logger.debug('Not ready for block root rollup');
|
|
1162
|
+
this.logger.debug('Not ready for block root rollup');
|
|
1130
1163
|
return;
|
|
1131
1164
|
}
|
|
1132
1165
|
this.enqueueBlockRootRollup(provingState);
|
|
1133
1166
|
}
|
|
1134
|
-
checkAndEnqueueNextBlockMergeRollup(provingState, currentLocation) {
|
|
1167
|
+
async checkAndEnqueueNextBlockMergeRollup(provingState, currentLocation) {
|
|
1135
1168
|
if (!provingState.isReadyForBlockMerge(currentLocation)) {
|
|
1136
1169
|
return;
|
|
1137
1170
|
}
|
|
1138
1171
|
const parentLocation = provingState.getParentLocation(currentLocation);
|
|
1139
1172
|
if (parentLocation.level === 0) {
|
|
1140
|
-
this.checkAndEnqueueCheckpointRootRollup(provingState);
|
|
1173
|
+
await this.checkAndEnqueueCheckpointRootRollup(provingState);
|
|
1141
1174
|
} else {
|
|
1142
1175
|
this.enqueueBlockMergeRollup(provingState, parentLocation);
|
|
1143
1176
|
}
|
|
1144
1177
|
}
|
|
1145
|
-
checkAndEnqueueCheckpointRootRollup(provingState) {
|
|
1178
|
+
async checkAndEnqueueCheckpointRootRollup(provingState) {
|
|
1146
1179
|
if (!provingState.isReadyForCheckpointRoot()) {
|
|
1147
1180
|
return;
|
|
1148
1181
|
}
|
|
1149
|
-
this.enqueueCheckpointRootRollup(provingState);
|
|
1182
|
+
await this.enqueueCheckpointRootRollup(provingState);
|
|
1150
1183
|
}
|
|
1151
1184
|
checkAndEnqueueNextCheckpointMergeRollup(provingState, currentLocation) {
|
|
1152
1185
|
if (!provingState.isReadyForCheckpointMerge(currentLocation)) {
|
|
@@ -1161,7 +1194,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1161
1194
|
}
|
|
1162
1195
|
checkAndEnqueueRootRollup(provingState) {
|
|
1163
1196
|
if (!provingState.isReadyForRootRollup()) {
|
|
1164
|
-
logger.debug('Not ready for root rollup');
|
|
1197
|
+
this.logger.debug('Not ready for root rollup');
|
|
1165
1198
|
return;
|
|
1166
1199
|
}
|
|
1167
1200
|
this.enqueueRootRollup(provingState);
|
|
@@ -1173,7 +1206,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1173
1206
|
* @param txIndex - The index of the transaction being proven
|
|
1174
1207
|
*/ enqueueVM(provingState, txIndex) {
|
|
1175
1208
|
if (!provingState.verifyState()) {
|
|
1176
|
-
logger.debug(`Not running VM circuit as state is no longer valid`);
|
|
1209
|
+
this.logger.debug(`Not running VM circuit as state is no longer valid`);
|
|
1177
1210
|
return;
|
|
1178
1211
|
}
|
|
1179
1212
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
@@ -1184,7 +1217,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1184
1217
|
return await this.prover.getAvmProof(inputs, signal, provingState.epochNumber);
|
|
1185
1218
|
});
|
|
1186
1219
|
this.deferredProving(provingState, doAvmProving, (proof)=>{
|
|
1187
|
-
logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
1220
|
+
this.logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
1188
1221
|
txProvingState.setAvmProof(proof);
|
|
1189
1222
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
1190
1223
|
});
|
|
@@ -1195,7 +1228,7 @@ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
|
|
|
1195
1228
|
return;
|
|
1196
1229
|
}
|
|
1197
1230
|
// We must have completed all proving (chonk verifier proof and (if required) vm proof are generated), we now move to the base rollup.
|
|
1198
|
-
logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
1231
|
+
this.logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
1199
1232
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
1200
1233
|
}
|
|
1201
1234
|
}
|