@aztec/prover-client 0.0.1-commit.d431d1c → 0.0.1-commit.d939eb5aa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +12 -2
- package/dest/light/lightweight_checkpoint_builder.d.ts +14 -6
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +51 -22
- package/dest/mocks/fixtures.d.ts +1 -1
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +2 -1
- package/dest/mocks/test_context.d.ts +1 -1
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +17 -9
- package/dest/orchestrator/block-building-helpers.d.ts +4 -4
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +3 -3
- package/dest/orchestrator/block-proving-state.d.ts +4 -1
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +7 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts +3 -3
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +3 -3
- package/dest/orchestrator/epoch-proving-state.d.ts +3 -3
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +5 -3
- package/dest/orchestrator/orchestrator.d.ts +11 -4
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +132 -109
- package/dest/prover-client/prover-client.d.ts +4 -4
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +15 -10
- package/dest/proving_broker/broker_prover_facade.d.ts +4 -3
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +16 -22
- package/dest/proving_broker/config.d.ts +14 -2
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +21 -4
- package/dest/proving_broker/proof_store/factory.d.ts +2 -5
- package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/factory.js +7 -30
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
- package/dest/proving_broker/proof_store/index.d.ts +2 -2
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -1
- package/dest/proving_broker/proving_agent.d.ts +4 -3
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +4 -4
- package/dest/proving_broker/proving_broker.d.ts +7 -4
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +56 -8
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +3 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +18 -7
- package/dest/proving_broker/proving_job_controller.d.ts +4 -3
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +6 -3
- package/dest/proving_broker/rpc.d.ts +6 -2
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +24 -15
- package/dest/test/mock_prover.d.ts +4 -4
- package/package.json +17 -18
- package/src/config.ts +13 -2
- package/src/light/lightweight_checkpoint_builder.ts +63 -25
- package/src/mocks/fixtures.ts +2 -1
- package/src/mocks/test_context.ts +12 -10
- package/src/orchestrator/block-building-helpers.ts +3 -3
- package/src/orchestrator/block-proving-state.ts +9 -0
- package/src/orchestrator/checkpoint-proving-state.ts +4 -4
- package/src/orchestrator/epoch-proving-state.ts +6 -4
- package/src/orchestrator/orchestrator.ts +140 -117
- package/src/prover-client/prover-client.ts +31 -15
- package/src/proving_broker/broker_prover_facade.ts +23 -23
- package/src/proving_broker/config.ts +24 -2
- package/src/proving_broker/proof_store/factory.ts +10 -32
- package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
- package/src/proving_broker/proof_store/index.ts +1 -1
- package/src/proving_broker/proving_agent.ts +5 -2
- package/src/proving_broker/proving_broker.ts +55 -5
- package/src/proving_broker/proving_broker_instrumentation.ts +19 -6
- package/src/proving_broker/proving_job_controller.ts +9 -3
- package/src/proving_broker/rpc.ts +26 -3
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +0 -14
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +0 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.js +0 -52
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
|
@@ -10,9 +10,11 @@ import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
|
10
10
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
11
11
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
12
12
|
import { AbortError } from '@aztec/foundation/error';
|
|
13
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
13
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
14
14
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
15
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
15
16
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
17
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
16
18
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
17
19
|
import { elapsed } from '@aztec/foundation/timer';
|
|
18
20
|
import type { TreeNodeLocation } from '@aztec/foundation/trees';
|
|
@@ -71,8 +73,6 @@ import { EpochProvingState, type ProvingResult, type TreeSnapshots } from './epo
|
|
|
71
73
|
import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
|
|
72
74
|
import { TxProvingState } from './tx-proving-state.js';
|
|
73
75
|
|
|
74
|
-
const logger = createLogger('prover-client:orchestrator');
|
|
75
|
-
|
|
76
76
|
/**
|
|
77
77
|
* Implements an event driven proving scheduler to build the recursive proof tree. The idea being:
|
|
78
78
|
* 1. Transactions are provided to the scheduler post simulation.
|
|
@@ -95,14 +95,21 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
95
95
|
private metrics: ProvingOrchestratorMetrics;
|
|
96
96
|
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
97
97
|
private dbs: Map<BlockNumber, MerkleTreeWriteOperations> = new Map();
|
|
98
|
+
private logger: Logger;
|
|
99
|
+
private deferredJobQueue = new SerialQueue();
|
|
98
100
|
|
|
99
101
|
constructor(
|
|
100
102
|
private dbProvider: ReadonlyWorldStateAccess & ForkMerkleTreeOperations,
|
|
101
103
|
private prover: ServerCircuitProver,
|
|
102
104
|
private readonly proverId: EthAddress,
|
|
105
|
+
private readonly cancelJobsOnStop: boolean = false,
|
|
106
|
+
private readonly enqueueConcurrency: number,
|
|
103
107
|
telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
108
|
+
bindings?: LoggerBindings,
|
|
104
109
|
) {
|
|
110
|
+
this.logger = createLogger('prover-client:orchestrator', bindings);
|
|
105
111
|
this.metrics = new ProvingOrchestratorMetrics(telemetryClient, 'ProvingOrchestrator');
|
|
112
|
+
this.deferredJobQueue.start(this.enqueueConcurrency);
|
|
106
113
|
}
|
|
107
114
|
|
|
108
115
|
get tracer(): Tracer {
|
|
@@ -117,9 +124,11 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
117
124
|
return this.dbs.size;
|
|
118
125
|
}
|
|
119
126
|
|
|
120
|
-
public stop(): Promise<void> {
|
|
127
|
+
public async stop(): Promise<void> {
|
|
128
|
+
// Grab the old queue before cancel() replaces it, so we can await its draining.
|
|
129
|
+
const oldQueue = this.deferredJobQueue;
|
|
121
130
|
this.cancel();
|
|
122
|
-
|
|
131
|
+
await oldQueue.cancel();
|
|
123
132
|
}
|
|
124
133
|
|
|
125
134
|
public startNewEpoch(
|
|
@@ -135,7 +144,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
135
144
|
|
|
136
145
|
const { promise: _promise, resolve, reject } = promiseWithResolvers<ProvingResult>();
|
|
137
146
|
const promise = _promise.catch((reason): ProvingResult => ({ status: 'failure', reason }));
|
|
138
|
-
logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
147
|
+
this.logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
139
148
|
this.provingState = new EpochProvingState(
|
|
140
149
|
epochNumber,
|
|
141
150
|
totalNumCheckpoints,
|
|
@@ -227,7 +236,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
227
236
|
}
|
|
228
237
|
|
|
229
238
|
const constants = checkpointProvingState.constants;
|
|
230
|
-
logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
239
|
+
this.logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
231
240
|
|
|
232
241
|
// Fork the db only when it's not already set. The db for the first block is set in `startNewCheckpoint`.
|
|
233
242
|
if (!this.dbs.has(blockNumber)) {
|
|
@@ -235,7 +244,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
235
244
|
const db = await this.dbProvider.fork(BlockNumber(blockNumber - 1));
|
|
236
245
|
this.dbs.set(blockNumber, db);
|
|
237
246
|
}
|
|
238
|
-
const db = this.
|
|
247
|
+
const db = this.getDbForBlock(blockNumber);
|
|
239
248
|
|
|
240
249
|
// Get archive snapshot and sibling path before any txs in this block lands.
|
|
241
250
|
const lastArchiveTreeSnapshot = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
@@ -288,7 +297,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
288
297
|
if (!txs.length) {
|
|
289
298
|
// To avoid an ugly throw below. If we require an empty block, we can just call setBlockCompleted
|
|
290
299
|
// on a block with no txs. We cannot do that here because we cannot find the blockNumber without any txs.
|
|
291
|
-
logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
300
|
+
this.logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
292
301
|
return;
|
|
293
302
|
}
|
|
294
303
|
|
|
@@ -308,9 +317,9 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
308
317
|
throw new Error(`Block ${blockNumber} has been initialized with transactions.`);
|
|
309
318
|
}
|
|
310
319
|
|
|
311
|
-
logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
320
|
+
this.logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
312
321
|
|
|
313
|
-
const db = this.
|
|
322
|
+
const db = this.getDbForBlock(blockNumber);
|
|
314
323
|
const lastArchive = provingState.lastArchiveTreeSnapshot;
|
|
315
324
|
const newL1ToL2MessageTreeSnapshot = provingState.newL1ToL2MessageTreeSnapshot;
|
|
316
325
|
const spongeBlobState = provingState.getStartSpongeBlob().clone();
|
|
@@ -323,7 +332,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
323
332
|
|
|
324
333
|
validateTx(tx);
|
|
325
334
|
|
|
326
|
-
logger.debug(`Received transaction: ${tx.hash}`);
|
|
335
|
+
this.logger.debug(`Received transaction: ${tx.hash}`);
|
|
327
336
|
|
|
328
337
|
const startSpongeBlob = spongeBlobState.clone();
|
|
329
338
|
const [hints, treeSnapshots] = await this.prepareBaseRollupInputs(
|
|
@@ -344,10 +353,10 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
344
353
|
const txIndex = provingState.addNewTx(txProvingState);
|
|
345
354
|
if (txProvingState.requireAvmProof) {
|
|
346
355
|
this.getOrEnqueueChonkVerifier(provingState, txIndex);
|
|
347
|
-
logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
356
|
+
this.logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
348
357
|
this.enqueueVM(provingState, txIndex);
|
|
349
358
|
} else {
|
|
350
|
-
logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
359
|
+
this.logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
351
360
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
352
361
|
}
|
|
353
362
|
} catch (err: any) {
|
|
@@ -390,7 +399,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
390
399
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
391
400
|
>
|
|
392
401
|
>();
|
|
393
|
-
logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
402
|
+
this.logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
394
403
|
this.doEnqueueChonkVerifier(txHash, privateInputs, proof => {
|
|
395
404
|
tubeProof.resolve(proof);
|
|
396
405
|
});
|
|
@@ -430,22 +439,28 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
430
439
|
}
|
|
431
440
|
|
|
432
441
|
// Given we've applied every change from this block, now assemble the block header:
|
|
433
|
-
logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
442
|
+
this.logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
434
443
|
const header = await provingState.buildBlockHeader();
|
|
435
444
|
|
|
436
445
|
if (expectedHeader && !header.equals(expectedHeader)) {
|
|
437
|
-
logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
446
|
+
this.logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
438
447
|
throw new Error('Block header mismatch');
|
|
439
448
|
}
|
|
440
449
|
|
|
441
|
-
// Get db for this block
|
|
442
|
-
const db = this.
|
|
450
|
+
// Get db for this block and remove from map — no other code should use it after this point.
|
|
451
|
+
const db = this.getDbForBlock(provingState.blockNumber);
|
|
452
|
+
this.dbs.delete(provingState.blockNumber);
|
|
443
453
|
|
|
444
|
-
// Update the archive tree,
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
454
|
+
// Update the archive tree, capture the snapshot, and close the fork deterministically.
|
|
455
|
+
try {
|
|
456
|
+
this.logger.verbose(
|
|
457
|
+
`Updating archive tree with block ${provingState.blockNumber} header ${(await header.hash()).toString()}`,
|
|
458
|
+
);
|
|
459
|
+
await db.updateArchive(header);
|
|
460
|
+
provingState.setBuiltArchive(await getTreeSnapshot(MerkleTreeId.ARCHIVE, db));
|
|
461
|
+
} finally {
|
|
462
|
+
await db.close();
|
|
463
|
+
}
|
|
449
464
|
|
|
450
465
|
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
451
466
|
|
|
@@ -456,31 +471,34 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
456
471
|
protected async verifyBuiltBlockAgainstSyncedState(provingState: BlockProvingState) {
|
|
457
472
|
const builtBlockHeader = provingState.getBuiltBlockHeader();
|
|
458
473
|
if (!builtBlockHeader) {
|
|
459
|
-
logger.debug('Block header not built yet, skipping header check.');
|
|
474
|
+
this.logger.debug('Block header not built yet, skipping header check.');
|
|
460
475
|
return;
|
|
461
476
|
}
|
|
462
477
|
|
|
463
478
|
const output = provingState.getBlockRootRollupOutput();
|
|
464
479
|
if (!output) {
|
|
465
|
-
logger.debug('Block root rollup proof not built yet, skipping header check.');
|
|
480
|
+
this.logger.debug('Block root rollup proof not built yet, skipping header check.');
|
|
466
481
|
return;
|
|
467
482
|
}
|
|
483
|
+
|
|
484
|
+
const newArchive = provingState.getBuiltArchive();
|
|
485
|
+
if (!newArchive) {
|
|
486
|
+
this.logger.debug('Archive snapshot not yet captured, skipping header check.');
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
|
|
468
490
|
const header = await buildHeaderFromCircuitOutputs(output);
|
|
469
491
|
|
|
470
492
|
if (!(await header.hash()).equals(await builtBlockHeader.hash())) {
|
|
471
|
-
logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
493
|
+
this.logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
472
494
|
provingState.reject(`Block header hash mismatch.`);
|
|
473
495
|
return;
|
|
474
496
|
}
|
|
475
497
|
|
|
476
|
-
// Get db for this block
|
|
477
498
|
const blockNumber = provingState.blockNumber;
|
|
478
|
-
const db = this.dbs.get(blockNumber)!;
|
|
479
|
-
|
|
480
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
481
499
|
const syncedArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.dbProvider.getSnapshot(blockNumber));
|
|
482
500
|
if (!syncedArchive.equals(newArchive)) {
|
|
483
|
-
logger.error(
|
|
501
|
+
this.logger.error(
|
|
484
502
|
`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(
|
|
485
503
|
syncedArchive,
|
|
486
504
|
)} but built ${inspect(newArchive)}`,
|
|
@@ -491,27 +509,43 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
491
509
|
|
|
492
510
|
const circuitArchive = output.newArchive;
|
|
493
511
|
if (!newArchive.equals(circuitArchive)) {
|
|
494
|
-
logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
512
|
+
this.logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
495
513
|
provingState.reject(`New archive mismatch.`);
|
|
496
514
|
return;
|
|
497
515
|
}
|
|
498
|
-
|
|
499
|
-
// TODO(palla/prover): This closes the fork only on the happy path. If this epoch orchestrator
|
|
500
|
-
// is aborted and never reaches this point, it will leak the fork. We need to add a global cleanup,
|
|
501
|
-
// but have to make sure it only runs once all operations are completed, otherwise some function here
|
|
502
|
-
// will attempt to access the fork after it was closed.
|
|
503
|
-
void this.cleanupDBFork(blockNumber);
|
|
504
516
|
}
|
|
505
517
|
|
|
506
518
|
/**
|
|
507
|
-
* Cancel any further proving
|
|
519
|
+
* Cancel any further proving.
|
|
520
|
+
* If cancelJobsOnStop is true, aborts all pending jobs with the broker (which marks them as 'Aborted').
|
|
521
|
+
* If cancelJobsOnStop is false (default), jobs remain in the broker queue and can be reused on restart/reorg.
|
|
508
522
|
*/
|
|
509
523
|
public cancel() {
|
|
510
|
-
|
|
511
|
-
|
|
524
|
+
void this.deferredJobQueue.cancel();
|
|
525
|
+
// Recreate the queue so it can accept jobs for subsequent epochs.
|
|
526
|
+
this.deferredJobQueue = new SerialQueue();
|
|
527
|
+
this.deferredJobQueue.start(this.enqueueConcurrency);
|
|
528
|
+
|
|
529
|
+
if (this.cancelJobsOnStop) {
|
|
530
|
+
for (const controller of this.pendingProvingJobs) {
|
|
531
|
+
controller.abort();
|
|
532
|
+
}
|
|
512
533
|
}
|
|
513
534
|
|
|
514
535
|
this.provingState?.cancel();
|
|
536
|
+
|
|
537
|
+
for (const [blockNumber, db] of this.dbs.entries()) {
|
|
538
|
+
void db.close().catch(err => this.logger.error(`Error closing db for block ${blockNumber}`, err));
|
|
539
|
+
}
|
|
540
|
+
this.dbs.clear();
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
private getDbForBlock(blockNumber: BlockNumber): MerkleTreeWriteOperations {
|
|
544
|
+
const db = this.dbs.get(blockNumber);
|
|
545
|
+
if (!db) {
|
|
546
|
+
throw new Error(`World state fork for block ${blockNumber} not found.`);
|
|
547
|
+
}
|
|
548
|
+
return db;
|
|
515
549
|
}
|
|
516
550
|
|
|
517
551
|
/**
|
|
@@ -543,21 +577,6 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
543
577
|
return epochProofResult;
|
|
544
578
|
}
|
|
545
579
|
|
|
546
|
-
private async cleanupDBFork(blockNumber: BlockNumber): Promise<void> {
|
|
547
|
-
logger.debug(`Cleaning up world state fork for ${blockNumber}`);
|
|
548
|
-
const fork = this.dbs.get(blockNumber);
|
|
549
|
-
if (!fork) {
|
|
550
|
-
return;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
try {
|
|
554
|
-
await fork.close();
|
|
555
|
-
this.dbs.delete(blockNumber);
|
|
556
|
-
} catch (err) {
|
|
557
|
-
logger.error(`Error closing db for block ${blockNumber}`, err);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
580
|
/**
|
|
562
581
|
* Enqueue a job to be scheduled
|
|
563
582
|
* @param provingState - The proving state object being operated on
|
|
@@ -570,7 +589,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
570
589
|
callback: (result: T) => void | Promise<void>,
|
|
571
590
|
) {
|
|
572
591
|
if (!provingState.verifyState()) {
|
|
573
|
-
logger.debug(`Not enqueuing job, state no longer valid`);
|
|
592
|
+
this.logger.debug(`Not enqueuing job, state no longer valid`);
|
|
574
593
|
return;
|
|
575
594
|
}
|
|
576
595
|
|
|
@@ -588,7 +607,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
588
607
|
|
|
589
608
|
const result = await request(controller.signal);
|
|
590
609
|
if (!provingState.verifyState()) {
|
|
591
|
-
logger.debug(`State no longer valid, discarding result`);
|
|
610
|
+
this.logger.debug(`State no longer valid, discarding result`);
|
|
592
611
|
return;
|
|
593
612
|
}
|
|
594
613
|
|
|
@@ -606,7 +625,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
606
625
|
return;
|
|
607
626
|
}
|
|
608
627
|
|
|
609
|
-
logger.error(`Error thrown when proving job`, err);
|
|
628
|
+
this.logger.error(`Error thrown when proving job`, err);
|
|
610
629
|
provingState!.reject(`${err}`);
|
|
611
630
|
} finally {
|
|
612
631
|
const index = this.pendingProvingJobs.indexOf(controller);
|
|
@@ -616,8 +635,11 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
616
635
|
}
|
|
617
636
|
};
|
|
618
637
|
|
|
619
|
-
|
|
620
|
-
|
|
638
|
+
void this.deferredJobQueue.put(async () => {
|
|
639
|
+
void safeJob();
|
|
640
|
+
// we yield here to the macro task queue such to give Nodejs a chance to run other operatoins in between enqueues
|
|
641
|
+
await sleep(0);
|
|
642
|
+
});
|
|
621
643
|
}
|
|
622
644
|
|
|
623
645
|
private async updateL1ToL2MessageTree(l1ToL2Messages: Fr[], db: MerkleTreeWriteOperations) {
|
|
@@ -691,12 +713,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
691
713
|
// Executes the next level of merge if all inputs are available
|
|
692
714
|
private enqueueBaseRollup(provingState: BlockProvingState, txIndex: number) {
|
|
693
715
|
if (!provingState.verifyState()) {
|
|
694
|
-
logger.debug('Not running base rollup, state invalid');
|
|
716
|
+
this.logger.debug('Not running base rollup, state invalid');
|
|
695
717
|
return;
|
|
696
718
|
}
|
|
697
719
|
|
|
698
720
|
if (!provingState.tryStartProvingBase(txIndex)) {
|
|
699
|
-
logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
721
|
+
this.logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
700
722
|
return;
|
|
701
723
|
}
|
|
702
724
|
|
|
@@ -704,7 +726,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
704
726
|
const { processedTx } = txProvingState;
|
|
705
727
|
const { rollupType, inputs } = txProvingState.getBaseRollupTypeAndInputs();
|
|
706
728
|
|
|
707
|
-
logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
729
|
+
this.logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
708
730
|
|
|
709
731
|
this.deferredProving(
|
|
710
732
|
provingState,
|
|
@@ -728,7 +750,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
728
750
|
},
|
|
729
751
|
),
|
|
730
752
|
result => {
|
|
731
|
-
logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
753
|
+
this.logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
732
754
|
validatePartialState(result.inputs.endTreeSnapshots, txProvingState.treeSnapshots);
|
|
733
755
|
const leafLocation = provingState.setBaseRollupProof(txIndex, result);
|
|
734
756
|
if (provingState.totalNumTxs === 1) {
|
|
@@ -744,7 +766,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
744
766
|
// Once completed, will enqueue the the public tx base rollup.
|
|
745
767
|
private getOrEnqueueChonkVerifier(provingState: BlockProvingState, txIndex: number) {
|
|
746
768
|
if (!provingState.verifyState()) {
|
|
747
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
769
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
748
770
|
return;
|
|
749
771
|
}
|
|
750
772
|
|
|
@@ -757,19 +779,19 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
757
779
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
758
780
|
>,
|
|
759
781
|
) => {
|
|
760
|
-
logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, { txHash });
|
|
782
|
+
this.logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, { txHash });
|
|
761
783
|
txProvingState.setPublicChonkVerifierProof(result);
|
|
762
784
|
this.provingState?.cachedChonkVerifierProofs.delete(txHash);
|
|
763
785
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
764
786
|
};
|
|
765
787
|
|
|
766
788
|
if (this.provingState?.cachedChonkVerifierProofs.has(txHash)) {
|
|
767
|
-
logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, { txHash });
|
|
789
|
+
this.logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, { txHash });
|
|
768
790
|
void this.provingState!.cachedChonkVerifierProofs.get(txHash)!.then(handleResult);
|
|
769
791
|
return;
|
|
770
792
|
}
|
|
771
793
|
|
|
772
|
-
logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
794
|
+
this.logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
773
795
|
this.doEnqueueChonkVerifier(txHash, txProvingState.getPublicChonkVerifierPrivateInputs(), handleResult);
|
|
774
796
|
}
|
|
775
797
|
|
|
@@ -785,7 +807,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
785
807
|
provingState: EpochProvingState | BlockProvingState = this.provingState!,
|
|
786
808
|
) {
|
|
787
809
|
if (!provingState.verifyState()) {
|
|
788
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
810
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
789
811
|
return;
|
|
790
812
|
}
|
|
791
813
|
|
|
@@ -808,12 +830,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
808
830
|
// Enqueues the next level of merge if all inputs are available
|
|
809
831
|
private enqueueMergeRollup(provingState: BlockProvingState, location: TreeNodeLocation) {
|
|
810
832
|
if (!provingState.verifyState()) {
|
|
811
|
-
logger.debug('Not running merge rollup. State no longer valid.');
|
|
833
|
+
this.logger.debug('Not running merge rollup. State no longer valid.');
|
|
812
834
|
return;
|
|
813
835
|
}
|
|
814
836
|
|
|
815
837
|
if (!provingState.tryStartProvingMerge(location)) {
|
|
816
|
-
logger.debug('Merge rollup already started.');
|
|
838
|
+
this.logger.debug('Merge rollup already started.');
|
|
817
839
|
return;
|
|
818
840
|
}
|
|
819
841
|
|
|
@@ -839,18 +861,18 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
839
861
|
// Executes the block root rollup circuit
|
|
840
862
|
private enqueueBlockRootRollup(provingState: BlockProvingState) {
|
|
841
863
|
if (!provingState.verifyState()) {
|
|
842
|
-
logger.debug('Not running block root rollup, state no longer valid');
|
|
864
|
+
this.logger.debug('Not running block root rollup, state no longer valid');
|
|
843
865
|
return;
|
|
844
866
|
}
|
|
845
867
|
|
|
846
868
|
if (!provingState.tryStartProvingBlockRoot()) {
|
|
847
|
-
logger.debug('Block root rollup already started.');
|
|
869
|
+
this.logger.debug('Block root rollup already started.');
|
|
848
870
|
return;
|
|
849
871
|
}
|
|
850
872
|
|
|
851
873
|
const { rollupType, inputs } = provingState.getBlockRootRollupTypeAndInputs();
|
|
852
874
|
|
|
853
|
-
logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
875
|
+
this.logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
854
876
|
|
|
855
877
|
this.deferredProving(
|
|
856
878
|
provingState,
|
|
@@ -875,22 +897,20 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
875
897
|
},
|
|
876
898
|
),
|
|
877
899
|
async result => {
|
|
878
|
-
logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
900
|
+
this.logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
879
901
|
|
|
880
902
|
const leafLocation = provingState.setBlockRootRollupProof(result);
|
|
881
903
|
const checkpointProvingState = provingState.parentCheckpoint;
|
|
882
904
|
|
|
883
|
-
//
|
|
905
|
+
// Verification is called from both here and setBlockCompleted. Whichever runs last
|
|
906
|
+
// will be the first to see all three pieces (header, proof output, archive) and run the checks.
|
|
884
907
|
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
885
908
|
|
|
886
909
|
if (checkpointProvingState.totalNumBlocks === 1) {
|
|
887
|
-
this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
910
|
+
await this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
888
911
|
} else {
|
|
889
|
-
this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
912
|
+
await this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
890
913
|
}
|
|
891
|
-
|
|
892
|
-
// We are finished with the block at this point, ensure the fork is cleaned up
|
|
893
|
-
void this.cleanupDBFork(provingState.blockNumber);
|
|
894
914
|
},
|
|
895
915
|
);
|
|
896
916
|
}
|
|
@@ -903,12 +923,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
903
923
|
baseParityIndex: number,
|
|
904
924
|
) {
|
|
905
925
|
if (!provingState.verifyState()) {
|
|
906
|
-
logger.debug('Not running base parity. State no longer valid.');
|
|
926
|
+
this.logger.debug('Not running base parity. State no longer valid.');
|
|
907
927
|
return;
|
|
908
928
|
}
|
|
909
929
|
|
|
910
930
|
if (!provingState.tryStartProvingBaseParity(baseParityIndex)) {
|
|
911
|
-
logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
931
|
+
this.logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
912
932
|
return;
|
|
913
933
|
}
|
|
914
934
|
|
|
@@ -943,12 +963,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
943
963
|
// Enqueues the root rollup proof if all inputs are available
|
|
944
964
|
private enqueueRootParityCircuit(provingState: BlockProvingState) {
|
|
945
965
|
if (!provingState.verifyState()) {
|
|
946
|
-
logger.debug('Not running root parity. State no longer valid.');
|
|
966
|
+
this.logger.debug('Not running root parity. State no longer valid.');
|
|
947
967
|
return;
|
|
948
968
|
}
|
|
949
969
|
|
|
950
970
|
if (!provingState.tryStartProvingRootParity()) {
|
|
951
|
-
logger.debug('Root parity already started.');
|
|
971
|
+
this.logger.debug('Root parity already started.');
|
|
952
972
|
return;
|
|
953
973
|
}
|
|
954
974
|
|
|
@@ -975,12 +995,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
975
995
|
// Enqueues the next level of merge if all inputs are available
|
|
976
996
|
private enqueueBlockMergeRollup(provingState: CheckpointProvingState, location: TreeNodeLocation) {
|
|
977
997
|
if (!provingState.verifyState()) {
|
|
978
|
-
logger.debug('Not running block merge rollup. State no longer valid.');
|
|
998
|
+
this.logger.debug('Not running block merge rollup. State no longer valid.');
|
|
979
999
|
return;
|
|
980
1000
|
}
|
|
981
1001
|
|
|
982
1002
|
if (!provingState.tryStartProvingBlockMerge(location)) {
|
|
983
|
-
logger.debug('Block merge rollup already started.');
|
|
1003
|
+
this.logger.debug('Block merge rollup already started.');
|
|
984
1004
|
return;
|
|
985
1005
|
}
|
|
986
1006
|
|
|
@@ -995,29 +1015,29 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
995
1015
|
},
|
|
996
1016
|
signal => this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber),
|
|
997
1017
|
),
|
|
998
|
-
result => {
|
|
1018
|
+
async result => {
|
|
999
1019
|
provingState.setBlockMergeRollupProof(location, result);
|
|
1000
|
-
this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
1020
|
+
await this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
1001
1021
|
},
|
|
1002
1022
|
);
|
|
1003
1023
|
}
|
|
1004
1024
|
|
|
1005
|
-
private enqueueCheckpointRootRollup(provingState: CheckpointProvingState) {
|
|
1025
|
+
private async enqueueCheckpointRootRollup(provingState: CheckpointProvingState) {
|
|
1006
1026
|
if (!provingState.verifyState()) {
|
|
1007
|
-
logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
1027
|
+
this.logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
1008
1028
|
return;
|
|
1009
1029
|
}
|
|
1010
1030
|
|
|
1011
1031
|
if (!provingState.tryStartProvingCheckpointRoot()) {
|
|
1012
|
-
logger.debug('Checkpoint root rollup already started.');
|
|
1032
|
+
this.logger.debug('Checkpoint root rollup already started.');
|
|
1013
1033
|
return;
|
|
1014
1034
|
}
|
|
1015
1035
|
|
|
1016
1036
|
const rollupType = provingState.getCheckpointRootRollupType();
|
|
1017
1037
|
|
|
1018
|
-
logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
1038
|
+
this.logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
1019
1039
|
|
|
1020
|
-
const inputs = provingState.getCheckpointRootRollupInputs();
|
|
1040
|
+
const inputs = await provingState.getCheckpointRootRollupInputs();
|
|
1021
1041
|
|
|
1022
1042
|
this.deferredProving(
|
|
1023
1043
|
provingState,
|
|
@@ -1039,7 +1059,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1039
1059
|
const computedEndBlobAccumulatorState = provingState.getEndBlobAccumulator()!.toBlobAccumulator();
|
|
1040
1060
|
const circuitEndBlobAccumulatorState = result.inputs.endBlobAccumulator;
|
|
1041
1061
|
if (!circuitEndBlobAccumulatorState.equals(computedEndBlobAccumulatorState)) {
|
|
1042
|
-
logger.error(
|
|
1062
|
+
this.logger.error(
|
|
1043
1063
|
`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(
|
|
1044
1064
|
computedEndBlobAccumulatorState,
|
|
1045
1065
|
)}`,
|
|
@@ -1048,7 +1068,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1048
1068
|
return;
|
|
1049
1069
|
}
|
|
1050
1070
|
|
|
1051
|
-
logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
1071
|
+
this.logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
1052
1072
|
|
|
1053
1073
|
const leafLocation = provingState.setCheckpointRootRollupProof(result);
|
|
1054
1074
|
const epochProvingState = provingState.parentEpoch;
|
|
@@ -1064,12 +1084,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1064
1084
|
|
|
1065
1085
|
private enqueueCheckpointMergeRollup(provingState: EpochProvingState, location: TreeNodeLocation) {
|
|
1066
1086
|
if (!provingState.verifyState()) {
|
|
1067
|
-
logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1087
|
+
this.logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1068
1088
|
return;
|
|
1069
1089
|
}
|
|
1070
1090
|
|
|
1071
1091
|
if (!provingState.tryStartProvingCheckpointMerge(location)) {
|
|
1072
|
-
logger.debug('Checkpoint merge rollup already started.');
|
|
1092
|
+
this.logger.debug('Checkpoint merge rollup already started.');
|
|
1073
1093
|
return;
|
|
1074
1094
|
}
|
|
1075
1095
|
|
|
@@ -1086,7 +1106,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1086
1106
|
signal => this.prover.getCheckpointMergeRollupProof(inputs, signal, provingState.epochNumber),
|
|
1087
1107
|
),
|
|
1088
1108
|
result => {
|
|
1089
|
-
logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1109
|
+
this.logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1090
1110
|
provingState.setCheckpointMergeRollupProof(location, result);
|
|
1091
1111
|
this.checkAndEnqueueNextCheckpointMergeRollup(provingState, location);
|
|
1092
1112
|
},
|
|
@@ -1095,16 +1115,16 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1095
1115
|
|
|
1096
1116
|
private enqueueEpochPadding(provingState: EpochProvingState) {
|
|
1097
1117
|
if (!provingState.verifyState()) {
|
|
1098
|
-
logger.debug('Not running epoch padding. State no longer valid.');
|
|
1118
|
+
this.logger.debug('Not running epoch padding. State no longer valid.');
|
|
1099
1119
|
return;
|
|
1100
1120
|
}
|
|
1101
1121
|
|
|
1102
1122
|
if (!provingState.tryStartProvingPaddingCheckpoint()) {
|
|
1103
|
-
logger.debug('Padding checkpoint already started.');
|
|
1123
|
+
this.logger.debug('Padding checkpoint already started.');
|
|
1104
1124
|
return;
|
|
1105
1125
|
}
|
|
1106
1126
|
|
|
1107
|
-
logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1127
|
+
this.logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1108
1128
|
|
|
1109
1129
|
const inputs = provingState.getPaddingCheckpointInputs();
|
|
1110
1130
|
|
|
@@ -1119,7 +1139,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1119
1139
|
signal => this.prover.getCheckpointPaddingRollupProof(inputs, signal, provingState.epochNumber),
|
|
1120
1140
|
),
|
|
1121
1141
|
result => {
|
|
1122
|
-
logger.debug('Completed proof for padding checkpoint.');
|
|
1142
|
+
this.logger.debug('Completed proof for padding checkpoint.');
|
|
1123
1143
|
provingState.setCheckpointPaddingProof(result);
|
|
1124
1144
|
this.checkAndEnqueueRootRollup(provingState);
|
|
1125
1145
|
},
|
|
@@ -1129,11 +1149,11 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1129
1149
|
// Executes the root rollup circuit
|
|
1130
1150
|
private enqueueRootRollup(provingState: EpochProvingState) {
|
|
1131
1151
|
if (!provingState.verifyState()) {
|
|
1132
|
-
logger.debug('Not running root rollup, state no longer valid');
|
|
1152
|
+
this.logger.debug('Not running root rollup, state no longer valid');
|
|
1133
1153
|
return;
|
|
1134
1154
|
}
|
|
1135
1155
|
|
|
1136
|
-
logger.debug(`Preparing root rollup`);
|
|
1156
|
+
this.logger.debug(`Preparing root rollup`);
|
|
1137
1157
|
|
|
1138
1158
|
const inputs = provingState.getRootRollupInputs();
|
|
1139
1159
|
|
|
@@ -1148,7 +1168,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1148
1168
|
signal => this.prover.getRootRollupProof(inputs, signal, provingState.epochNumber),
|
|
1149
1169
|
),
|
|
1150
1170
|
result => {
|
|
1151
|
-
logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1171
|
+
this.logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1152
1172
|
provingState.setRootRollupProof(result);
|
|
1153
1173
|
provingState.resolve({ status: 'success' });
|
|
1154
1174
|
},
|
|
@@ -1170,32 +1190,35 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1170
1190
|
|
|
1171
1191
|
private checkAndEnqueueBlockRootRollup(provingState: BlockProvingState) {
|
|
1172
1192
|
if (!provingState.isReadyForBlockRootRollup()) {
|
|
1173
|
-
logger.debug('Not ready for block root rollup');
|
|
1193
|
+
this.logger.debug('Not ready for block root rollup');
|
|
1174
1194
|
return;
|
|
1175
1195
|
}
|
|
1176
1196
|
|
|
1177
1197
|
this.enqueueBlockRootRollup(provingState);
|
|
1178
1198
|
}
|
|
1179
1199
|
|
|
1180
|
-
private checkAndEnqueueNextBlockMergeRollup(
|
|
1200
|
+
private async checkAndEnqueueNextBlockMergeRollup(
|
|
1201
|
+
provingState: CheckpointProvingState,
|
|
1202
|
+
currentLocation: TreeNodeLocation,
|
|
1203
|
+
) {
|
|
1181
1204
|
if (!provingState.isReadyForBlockMerge(currentLocation)) {
|
|
1182
1205
|
return;
|
|
1183
1206
|
}
|
|
1184
1207
|
|
|
1185
1208
|
const parentLocation = provingState.getParentLocation(currentLocation);
|
|
1186
1209
|
if (parentLocation.level === 0) {
|
|
1187
|
-
this.checkAndEnqueueCheckpointRootRollup(provingState);
|
|
1210
|
+
await this.checkAndEnqueueCheckpointRootRollup(provingState);
|
|
1188
1211
|
} else {
|
|
1189
1212
|
this.enqueueBlockMergeRollup(provingState, parentLocation);
|
|
1190
1213
|
}
|
|
1191
1214
|
}
|
|
1192
1215
|
|
|
1193
|
-
private checkAndEnqueueCheckpointRootRollup(provingState: CheckpointProvingState) {
|
|
1216
|
+
private async checkAndEnqueueCheckpointRootRollup(provingState: CheckpointProvingState) {
|
|
1194
1217
|
if (!provingState.isReadyForCheckpointRoot()) {
|
|
1195
1218
|
return;
|
|
1196
1219
|
}
|
|
1197
1220
|
|
|
1198
|
-
this.enqueueCheckpointRootRollup(provingState);
|
|
1221
|
+
await this.enqueueCheckpointRootRollup(provingState);
|
|
1199
1222
|
}
|
|
1200
1223
|
|
|
1201
1224
|
private checkAndEnqueueNextCheckpointMergeRollup(provingState: EpochProvingState, currentLocation: TreeNodeLocation) {
|
|
@@ -1213,7 +1236,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1213
1236
|
|
|
1214
1237
|
private checkAndEnqueueRootRollup(provingState: EpochProvingState) {
|
|
1215
1238
|
if (!provingState.isReadyForRootRollup()) {
|
|
1216
|
-
logger.debug('Not ready for root rollup');
|
|
1239
|
+
this.logger.debug('Not ready for root rollup');
|
|
1217
1240
|
return;
|
|
1218
1241
|
}
|
|
1219
1242
|
|
|
@@ -1228,7 +1251,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1228
1251
|
*/
|
|
1229
1252
|
private enqueueVM(provingState: BlockProvingState, txIndex: number) {
|
|
1230
1253
|
if (!provingState.verifyState()) {
|
|
1231
|
-
logger.debug(`Not running VM circuit as state is no longer valid`);
|
|
1254
|
+
this.logger.debug(`Not running VM circuit as state is no longer valid`);
|
|
1232
1255
|
return;
|
|
1233
1256
|
}
|
|
1234
1257
|
|
|
@@ -1247,7 +1270,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1247
1270
|
);
|
|
1248
1271
|
|
|
1249
1272
|
this.deferredProving(provingState, doAvmProving, proof => {
|
|
1250
|
-
logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
1273
|
+
this.logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
1251
1274
|
txProvingState.setAvmProof(proof);
|
|
1252
1275
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
1253
1276
|
});
|
|
@@ -1260,7 +1283,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1260
1283
|
}
|
|
1261
1284
|
|
|
1262
1285
|
// We must have completed all proving (chonk verifier proof and (if required) vm proof are generated), we now move to the base rollup.
|
|
1263
|
-
logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
1286
|
+
this.logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
1264
1287
|
|
|
1265
1288
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
1266
1289
|
}
|