@aztec/prover-client 0.0.1-commit.fcb71a6 → 0.0.1-commit.ff7989d6c
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 +18 -6
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +73 -18
- 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 +4 -2
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +17 -3
- 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 +4 -4
- package/dest/orchestrator/block-proving-state.d.ts +4 -1
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +7 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts +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 +541 -126
- package/dest/orchestrator/orchestrator_metrics.d.ts +1 -1
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +2 -6
- package/dest/orchestrator/tx-proving-state.d.ts +5 -4
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +6 -6
- 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 +7 -5
- 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 +5 -9
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +4 -19
- 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 +30 -11
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +389 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +15 -35
- 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 +5 -5
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +3 -3
- package/package.json +16 -17
- package/src/light/lightweight_checkpoint_builder.ts +115 -19
- package/src/mocks/fixtures.ts +2 -1
- package/src/mocks/test_context.ts +12 -2
- package/src/orchestrator/block-building-helpers.ts +4 -4
- package/src/orchestrator/block-proving-state.ts +9 -0
- package/src/orchestrator/checkpoint-proving-state.ts +51 -5
- package/src/orchestrator/epoch-proving-state.ts +59 -9
- package/src/orchestrator/orchestrator.ts +141 -106
- package/src/orchestrator/orchestrator_metrics.ts +2 -6
- package/src/orchestrator/tx-proving-state.ts +8 -11
- package/src/prover-client/prover-client.ts +28 -21
- package/src/proving_broker/broker_prover_facade.ts +8 -6
- 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 +6 -19
- package/src/proving_broker/proving_broker.ts +31 -9
- package/src/proving_broker/proving_broker_database/persisted.ts +15 -1
- package/src/proving_broker/proving_broker_instrumentation.ts +14 -35
- package/src/proving_broker/proving_job_controller.ts +9 -3
- package/src/proving_broker/rpc.ts +14 -0
- package/src/test/mock_prover.ts +1 -8
- 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 -108
- 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/dest/proving_broker/proving_agent_instrumentation.d.ts +0 -8
- package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +0 -1
- package/dest/proving_broker/proving_agent_instrumentation.js +0 -16
- package/src/block-factory/index.ts +0 -1
- package/src/block-factory/light.ts +0 -137
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
- package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
|
@@ -10,7 +10,7 @@ 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
15
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
16
16
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
@@ -71,8 +71,6 @@ import { EpochProvingState, type ProvingResult, type TreeSnapshots } from './epo
|
|
|
71
71
|
import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
|
|
72
72
|
import { TxProvingState } from './tx-proving-state.js';
|
|
73
73
|
|
|
74
|
-
const logger = createLogger('prover-client:orchestrator');
|
|
75
|
-
|
|
76
74
|
/**
|
|
77
75
|
* Implements an event driven proving scheduler to build the recursive proof tree. The idea being:
|
|
78
76
|
* 1. Transactions are provided to the scheduler post simulation.
|
|
@@ -95,13 +93,17 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
95
93
|
private metrics: ProvingOrchestratorMetrics;
|
|
96
94
|
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
97
95
|
private dbs: Map<BlockNumber, MerkleTreeWriteOperations> = new Map();
|
|
96
|
+
private logger: Logger;
|
|
98
97
|
|
|
99
98
|
constructor(
|
|
100
99
|
private dbProvider: ReadonlyWorldStateAccess & ForkMerkleTreeOperations,
|
|
101
100
|
private prover: ServerCircuitProver,
|
|
102
101
|
private readonly proverId: EthAddress,
|
|
102
|
+
private readonly cancelJobsOnStop: boolean = false,
|
|
103
103
|
telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
104
|
+
bindings?: LoggerBindings,
|
|
104
105
|
) {
|
|
106
|
+
this.logger = createLogger('prover-client:orchestrator', bindings);
|
|
105
107
|
this.metrics = new ProvingOrchestratorMetrics(telemetryClient, 'ProvingOrchestrator');
|
|
106
108
|
}
|
|
107
109
|
|
|
@@ -113,6 +115,10 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
113
115
|
return this.proverId;
|
|
114
116
|
}
|
|
115
117
|
|
|
118
|
+
public getNumActiveForks() {
|
|
119
|
+
return this.dbs.size;
|
|
120
|
+
}
|
|
121
|
+
|
|
116
122
|
public stop(): Promise<void> {
|
|
117
123
|
this.cancel();
|
|
118
124
|
return Promise.resolve();
|
|
@@ -131,7 +137,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
131
137
|
|
|
132
138
|
const { promise: _promise, resolve, reject } = promiseWithResolvers<ProvingResult>();
|
|
133
139
|
const promise = _promise.catch((reason): ProvingResult => ({ status: 'failure', reason }));
|
|
134
|
-
logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
140
|
+
this.logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
135
141
|
this.provingState = new EpochProvingState(
|
|
136
142
|
epochNumber,
|
|
137
143
|
totalNumCheckpoints,
|
|
@@ -143,6 +149,14 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
143
149
|
this.provingPromise = promise;
|
|
144
150
|
}
|
|
145
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Starts a new checkpoint.
|
|
154
|
+
* @param checkpointIndex - The index of the checkpoint in the epoch.
|
|
155
|
+
* @param constants - The constants for this checkpoint.
|
|
156
|
+
* @param l1ToL2Messages - The set of L1 to L2 messages to be inserted at the beginning of this checkpoint.
|
|
157
|
+
* @param totalNumBlocks - The total number of blocks expected in the checkpoint (must be at least one).
|
|
158
|
+
* @param headerOfLastBlockInPreviousCheckpoint - The header of the last block in the previous checkpoint.
|
|
159
|
+
*/
|
|
146
160
|
public async startNewCheckpoint(
|
|
147
161
|
checkpointIndex: number,
|
|
148
162
|
constants: CheckpointConstantData,
|
|
@@ -215,7 +229,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
215
229
|
}
|
|
216
230
|
|
|
217
231
|
const constants = checkpointProvingState.constants;
|
|
218
|
-
logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
232
|
+
this.logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
219
233
|
|
|
220
234
|
// Fork the db only when it's not already set. The db for the first block is set in `startNewCheckpoint`.
|
|
221
235
|
if (!this.dbs.has(blockNumber)) {
|
|
@@ -223,7 +237,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
223
237
|
const db = await this.dbProvider.fork(BlockNumber(blockNumber - 1));
|
|
224
238
|
this.dbs.set(blockNumber, db);
|
|
225
239
|
}
|
|
226
|
-
const db = this.
|
|
240
|
+
const db = this.getDbForBlock(blockNumber);
|
|
227
241
|
|
|
228
242
|
// Get archive snapshot and sibling path before any txs in this block lands.
|
|
229
243
|
const lastArchiveTreeSnapshot = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
@@ -255,7 +269,8 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
255
269
|
await endSpongeBlob.absorb(blockEndBlobFields);
|
|
256
270
|
blockProvingState.setEndSpongeBlob(endSpongeBlob);
|
|
257
271
|
|
|
258
|
-
//
|
|
272
|
+
// Try to accumulate the out hashes and blobs as far as we can:
|
|
273
|
+
await this.provingState.accumulateCheckpointOutHashes();
|
|
259
274
|
await this.provingState.setBlobAccumulators();
|
|
260
275
|
}
|
|
261
276
|
}
|
|
@@ -275,7 +290,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
275
290
|
if (!txs.length) {
|
|
276
291
|
// To avoid an ugly throw below. If we require an empty block, we can just call setBlockCompleted
|
|
277
292
|
// on a block with no txs. We cannot do that here because we cannot find the blockNumber without any txs.
|
|
278
|
-
logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
293
|
+
this.logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
279
294
|
return;
|
|
280
295
|
}
|
|
281
296
|
|
|
@@ -295,9 +310,9 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
295
310
|
throw new Error(`Block ${blockNumber} has been initialized with transactions.`);
|
|
296
311
|
}
|
|
297
312
|
|
|
298
|
-
logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
313
|
+
this.logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
299
314
|
|
|
300
|
-
const db = this.
|
|
315
|
+
const db = this.getDbForBlock(blockNumber);
|
|
301
316
|
const lastArchive = provingState.lastArchiveTreeSnapshot;
|
|
302
317
|
const newL1ToL2MessageTreeSnapshot = provingState.newL1ToL2MessageTreeSnapshot;
|
|
303
318
|
const spongeBlobState = provingState.getStartSpongeBlob().clone();
|
|
@@ -310,7 +325,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
310
325
|
|
|
311
326
|
validateTx(tx);
|
|
312
327
|
|
|
313
|
-
logger.debug(`Received transaction: ${tx.hash}`);
|
|
328
|
+
this.logger.debug(`Received transaction: ${tx.hash}`);
|
|
314
329
|
|
|
315
330
|
const startSpongeBlob = spongeBlobState.clone();
|
|
316
331
|
const [hints, treeSnapshots] = await this.prepareBaseRollupInputs(
|
|
@@ -331,10 +346,10 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
331
346
|
const txIndex = provingState.addNewTx(txProvingState);
|
|
332
347
|
if (txProvingState.requireAvmProof) {
|
|
333
348
|
this.getOrEnqueueChonkVerifier(provingState, txIndex);
|
|
334
|
-
logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
349
|
+
this.logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
335
350
|
this.enqueueVM(provingState, txIndex);
|
|
336
351
|
} else {
|
|
337
|
-
logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
352
|
+
this.logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
338
353
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
339
354
|
}
|
|
340
355
|
} catch (err: any) {
|
|
@@ -352,7 +367,8 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
352
367
|
|
|
353
368
|
provingState.setEndSpongeBlob(spongeBlobState);
|
|
354
369
|
|
|
355
|
-
// Txs have been added to the block. Now try to accumulate the blobs as far as we can:
|
|
370
|
+
// Txs have been added to the block. Now try to accumulate the out hashes and blobs as far as we can:
|
|
371
|
+
await this.provingState.accumulateCheckpointOutHashes();
|
|
356
372
|
await this.provingState.setBlobAccumulators();
|
|
357
373
|
}
|
|
358
374
|
|
|
@@ -376,7 +392,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
376
392
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
377
393
|
>
|
|
378
394
|
>();
|
|
379
|
-
logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
395
|
+
this.logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
380
396
|
this.doEnqueueChonkVerifier(txHash, privateInputs, proof => {
|
|
381
397
|
tubeProof.resolve(proof);
|
|
382
398
|
});
|
|
@@ -416,22 +432,28 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
416
432
|
}
|
|
417
433
|
|
|
418
434
|
// Given we've applied every change from this block, now assemble the block header:
|
|
419
|
-
logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
435
|
+
this.logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
420
436
|
const header = await provingState.buildBlockHeader();
|
|
421
437
|
|
|
422
438
|
if (expectedHeader && !header.equals(expectedHeader)) {
|
|
423
|
-
logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
439
|
+
this.logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
424
440
|
throw new Error('Block header mismatch');
|
|
425
441
|
}
|
|
426
442
|
|
|
427
|
-
// Get db for this block
|
|
428
|
-
const db = this.
|
|
443
|
+
// Get db for this block and remove from map — no other code should use it after this point.
|
|
444
|
+
const db = this.getDbForBlock(provingState.blockNumber);
|
|
445
|
+
this.dbs.delete(provingState.blockNumber);
|
|
429
446
|
|
|
430
|
-
// Update the archive tree,
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
447
|
+
// Update the archive tree, capture the snapshot, and close the fork deterministically.
|
|
448
|
+
try {
|
|
449
|
+
this.logger.verbose(
|
|
450
|
+
`Updating archive tree with block ${provingState.blockNumber} header ${(await header.hash()).toString()}`,
|
|
451
|
+
);
|
|
452
|
+
await db.updateArchive(header);
|
|
453
|
+
provingState.setBuiltArchive(await getTreeSnapshot(MerkleTreeId.ARCHIVE, db));
|
|
454
|
+
} finally {
|
|
455
|
+
await db.close();
|
|
456
|
+
}
|
|
435
457
|
|
|
436
458
|
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
437
459
|
|
|
@@ -442,31 +464,34 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
442
464
|
protected async verifyBuiltBlockAgainstSyncedState(provingState: BlockProvingState) {
|
|
443
465
|
const builtBlockHeader = provingState.getBuiltBlockHeader();
|
|
444
466
|
if (!builtBlockHeader) {
|
|
445
|
-
logger.debug('Block header not built yet, skipping header check.');
|
|
467
|
+
this.logger.debug('Block header not built yet, skipping header check.');
|
|
446
468
|
return;
|
|
447
469
|
}
|
|
448
470
|
|
|
449
471
|
const output = provingState.getBlockRootRollupOutput();
|
|
450
472
|
if (!output) {
|
|
451
|
-
logger.debug('Block root rollup proof not built yet, skipping header check.');
|
|
473
|
+
this.logger.debug('Block root rollup proof not built yet, skipping header check.');
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
const newArchive = provingState.getBuiltArchive();
|
|
478
|
+
if (!newArchive) {
|
|
479
|
+
this.logger.debug('Archive snapshot not yet captured, skipping header check.');
|
|
452
480
|
return;
|
|
453
481
|
}
|
|
482
|
+
|
|
454
483
|
const header = await buildHeaderFromCircuitOutputs(output);
|
|
455
484
|
|
|
456
485
|
if (!(await header.hash()).equals(await builtBlockHeader.hash())) {
|
|
457
|
-
logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
486
|
+
this.logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
458
487
|
provingState.reject(`Block header hash mismatch.`);
|
|
459
488
|
return;
|
|
460
489
|
}
|
|
461
490
|
|
|
462
|
-
// Get db for this block
|
|
463
491
|
const blockNumber = provingState.blockNumber;
|
|
464
|
-
const db = this.dbs.get(blockNumber)!;
|
|
465
|
-
|
|
466
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
467
492
|
const syncedArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.dbProvider.getSnapshot(blockNumber));
|
|
468
493
|
if (!syncedArchive.equals(newArchive)) {
|
|
469
|
-
logger.error(
|
|
494
|
+
this.logger.error(
|
|
470
495
|
`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(
|
|
471
496
|
syncedArchive,
|
|
472
497
|
)} but built ${inspect(newArchive)}`,
|
|
@@ -477,32 +502,38 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
477
502
|
|
|
478
503
|
const circuitArchive = output.newArchive;
|
|
479
504
|
if (!newArchive.equals(circuitArchive)) {
|
|
480
|
-
logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
505
|
+
this.logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
481
506
|
provingState.reject(`New archive mismatch.`);
|
|
482
507
|
return;
|
|
483
508
|
}
|
|
484
|
-
|
|
485
|
-
// TODO(palla/prover): This closes the fork only on the happy path. If this epoch orchestrator
|
|
486
|
-
// is aborted and never reaches this point, it will leak the fork. We need to add a global cleanup,
|
|
487
|
-
// but have to make sure it only runs once all operations are completed, otherwise some function here
|
|
488
|
-
// will attempt to access the fork after it was closed.
|
|
489
|
-
logger.debug(`Cleaning up world state fork for ${blockNumber}`);
|
|
490
|
-
void this.dbs
|
|
491
|
-
.get(blockNumber)
|
|
492
|
-
?.close()
|
|
493
|
-
.then(() => this.dbs.delete(blockNumber))
|
|
494
|
-
.catch(err => logger.error(`Error closing db for block ${blockNumber}`, err));
|
|
495
509
|
}
|
|
496
510
|
|
|
497
511
|
/**
|
|
498
|
-
* Cancel any further proving
|
|
512
|
+
* Cancel any further proving.
|
|
513
|
+
* If cancelJobsOnStop is true, aborts all pending jobs with the broker (which marks them as 'Aborted').
|
|
514
|
+
* If cancelJobsOnStop is false (default), jobs remain in the broker queue and can be reused on restart/reorg.
|
|
499
515
|
*/
|
|
500
516
|
public cancel() {
|
|
501
|
-
|
|
502
|
-
controller.
|
|
517
|
+
if (this.cancelJobsOnStop) {
|
|
518
|
+
for (const controller of this.pendingProvingJobs) {
|
|
519
|
+
controller.abort();
|
|
520
|
+
}
|
|
503
521
|
}
|
|
504
522
|
|
|
505
523
|
this.provingState?.cancel();
|
|
524
|
+
|
|
525
|
+
for (const [blockNumber, db] of this.dbs.entries()) {
|
|
526
|
+
void db.close().catch(err => this.logger.error(`Error closing db for block ${blockNumber}`, err));
|
|
527
|
+
}
|
|
528
|
+
this.dbs.clear();
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
private getDbForBlock(blockNumber: BlockNumber): MerkleTreeWriteOperations {
|
|
532
|
+
const db = this.dbs.get(blockNumber);
|
|
533
|
+
if (!db) {
|
|
534
|
+
throw new Error(`World state fork for block ${blockNumber} not found.`);
|
|
535
|
+
}
|
|
536
|
+
return db;
|
|
506
537
|
}
|
|
507
538
|
|
|
508
539
|
/**
|
|
@@ -546,7 +577,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
546
577
|
callback: (result: T) => void | Promise<void>,
|
|
547
578
|
) {
|
|
548
579
|
if (!provingState.verifyState()) {
|
|
549
|
-
logger.debug(`Not enqueuing job, state no longer valid`);
|
|
580
|
+
this.logger.debug(`Not enqueuing job, state no longer valid`);
|
|
550
581
|
return;
|
|
551
582
|
}
|
|
552
583
|
|
|
@@ -564,7 +595,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
564
595
|
|
|
565
596
|
const result = await request(controller.signal);
|
|
566
597
|
if (!provingState.verifyState()) {
|
|
567
|
-
logger.debug(`State no longer valid, discarding result`);
|
|
598
|
+
this.logger.debug(`State no longer valid, discarding result`);
|
|
568
599
|
return;
|
|
569
600
|
}
|
|
570
601
|
|
|
@@ -582,7 +613,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
582
613
|
return;
|
|
583
614
|
}
|
|
584
615
|
|
|
585
|
-
logger.error(`Error thrown when proving job`, err);
|
|
616
|
+
this.logger.error(`Error thrown when proving job`, err);
|
|
586
617
|
provingState!.reject(`${err}`);
|
|
587
618
|
} finally {
|
|
588
619
|
const index = this.pendingProvingJobs.indexOf(controller);
|
|
@@ -667,12 +698,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
667
698
|
// Executes the next level of merge if all inputs are available
|
|
668
699
|
private enqueueBaseRollup(provingState: BlockProvingState, txIndex: number) {
|
|
669
700
|
if (!provingState.verifyState()) {
|
|
670
|
-
logger.debug('Not running base rollup, state invalid');
|
|
701
|
+
this.logger.debug('Not running base rollup, state invalid');
|
|
671
702
|
return;
|
|
672
703
|
}
|
|
673
704
|
|
|
674
705
|
if (!provingState.tryStartProvingBase(txIndex)) {
|
|
675
|
-
logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
706
|
+
this.logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
676
707
|
return;
|
|
677
708
|
}
|
|
678
709
|
|
|
@@ -680,7 +711,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
680
711
|
const { processedTx } = txProvingState;
|
|
681
712
|
const { rollupType, inputs } = txProvingState.getBaseRollupTypeAndInputs();
|
|
682
713
|
|
|
683
|
-
logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
714
|
+
this.logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
684
715
|
|
|
685
716
|
this.deferredProving(
|
|
686
717
|
provingState,
|
|
@@ -704,7 +735,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
704
735
|
},
|
|
705
736
|
),
|
|
706
737
|
result => {
|
|
707
|
-
logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
738
|
+
this.logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
708
739
|
validatePartialState(result.inputs.endTreeSnapshots, txProvingState.treeSnapshots);
|
|
709
740
|
const leafLocation = provingState.setBaseRollupProof(txIndex, result);
|
|
710
741
|
if (provingState.totalNumTxs === 1) {
|
|
@@ -720,7 +751,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
720
751
|
// Once completed, will enqueue the the public tx base rollup.
|
|
721
752
|
private getOrEnqueueChonkVerifier(provingState: BlockProvingState, txIndex: number) {
|
|
722
753
|
if (!provingState.verifyState()) {
|
|
723
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
754
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
724
755
|
return;
|
|
725
756
|
}
|
|
726
757
|
|
|
@@ -733,19 +764,19 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
733
764
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
734
765
|
>,
|
|
735
766
|
) => {
|
|
736
|
-
logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, { txHash });
|
|
767
|
+
this.logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, { txHash });
|
|
737
768
|
txProvingState.setPublicChonkVerifierProof(result);
|
|
738
769
|
this.provingState?.cachedChonkVerifierProofs.delete(txHash);
|
|
739
770
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
740
771
|
};
|
|
741
772
|
|
|
742
773
|
if (this.provingState?.cachedChonkVerifierProofs.has(txHash)) {
|
|
743
|
-
logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, { txHash });
|
|
774
|
+
this.logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, { txHash });
|
|
744
775
|
void this.provingState!.cachedChonkVerifierProofs.get(txHash)!.then(handleResult);
|
|
745
776
|
return;
|
|
746
777
|
}
|
|
747
778
|
|
|
748
|
-
logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
779
|
+
this.logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
749
780
|
this.doEnqueueChonkVerifier(txHash, txProvingState.getPublicChonkVerifierPrivateInputs(), handleResult);
|
|
750
781
|
}
|
|
751
782
|
|
|
@@ -761,7 +792,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
761
792
|
provingState: EpochProvingState | BlockProvingState = this.provingState!,
|
|
762
793
|
) {
|
|
763
794
|
if (!provingState.verifyState()) {
|
|
764
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
795
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
765
796
|
return;
|
|
766
797
|
}
|
|
767
798
|
|
|
@@ -784,12 +815,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
784
815
|
// Enqueues the next level of merge if all inputs are available
|
|
785
816
|
private enqueueMergeRollup(provingState: BlockProvingState, location: TreeNodeLocation) {
|
|
786
817
|
if (!provingState.verifyState()) {
|
|
787
|
-
logger.debug('Not running merge rollup. State no longer valid.');
|
|
818
|
+
this.logger.debug('Not running merge rollup. State no longer valid.');
|
|
788
819
|
return;
|
|
789
820
|
}
|
|
790
821
|
|
|
791
822
|
if (!provingState.tryStartProvingMerge(location)) {
|
|
792
|
-
logger.debug('Merge rollup already started.');
|
|
823
|
+
this.logger.debug('Merge rollup already started.');
|
|
793
824
|
return;
|
|
794
825
|
}
|
|
795
826
|
|
|
@@ -815,18 +846,18 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
815
846
|
// Executes the block root rollup circuit
|
|
816
847
|
private enqueueBlockRootRollup(provingState: BlockProvingState) {
|
|
817
848
|
if (!provingState.verifyState()) {
|
|
818
|
-
logger.debug('Not running block root rollup, state no longer valid');
|
|
849
|
+
this.logger.debug('Not running block root rollup, state no longer valid');
|
|
819
850
|
return;
|
|
820
851
|
}
|
|
821
852
|
|
|
822
853
|
if (!provingState.tryStartProvingBlockRoot()) {
|
|
823
|
-
logger.debug('Block root rollup already started.');
|
|
854
|
+
this.logger.debug('Block root rollup already started.');
|
|
824
855
|
return;
|
|
825
856
|
}
|
|
826
857
|
|
|
827
858
|
const { rollupType, inputs } = provingState.getBlockRootRollupTypeAndInputs();
|
|
828
859
|
|
|
829
|
-
logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
860
|
+
this.logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
830
861
|
|
|
831
862
|
this.deferredProving(
|
|
832
863
|
provingState,
|
|
@@ -851,18 +882,19 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
851
882
|
},
|
|
852
883
|
),
|
|
853
884
|
async result => {
|
|
854
|
-
|
|
855
|
-
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
856
|
-
|
|
857
|
-
logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
885
|
+
this.logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
858
886
|
|
|
859
887
|
const leafLocation = provingState.setBlockRootRollupProof(result);
|
|
860
888
|
const checkpointProvingState = provingState.parentCheckpoint;
|
|
861
889
|
|
|
890
|
+
// Verification is called from both here and setBlockCompleted. Whichever runs last
|
|
891
|
+
// will be the first to see all three pieces (header, proof output, archive) and run the checks.
|
|
892
|
+
await this.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
893
|
+
|
|
862
894
|
if (checkpointProvingState.totalNumBlocks === 1) {
|
|
863
|
-
this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
895
|
+
await this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
|
|
864
896
|
} else {
|
|
865
|
-
this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
897
|
+
await this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
|
|
866
898
|
}
|
|
867
899
|
},
|
|
868
900
|
);
|
|
@@ -876,12 +908,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
876
908
|
baseParityIndex: number,
|
|
877
909
|
) {
|
|
878
910
|
if (!provingState.verifyState()) {
|
|
879
|
-
logger.debug('Not running base parity. State no longer valid.');
|
|
911
|
+
this.logger.debug('Not running base parity. State no longer valid.');
|
|
880
912
|
return;
|
|
881
913
|
}
|
|
882
914
|
|
|
883
915
|
if (!provingState.tryStartProvingBaseParity(baseParityIndex)) {
|
|
884
|
-
logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
916
|
+
this.logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
885
917
|
return;
|
|
886
918
|
}
|
|
887
919
|
|
|
@@ -916,12 +948,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
916
948
|
// Enqueues the root rollup proof if all inputs are available
|
|
917
949
|
private enqueueRootParityCircuit(provingState: BlockProvingState) {
|
|
918
950
|
if (!provingState.verifyState()) {
|
|
919
|
-
logger.debug('Not running root parity. State no longer valid.');
|
|
951
|
+
this.logger.debug('Not running root parity. State no longer valid.');
|
|
920
952
|
return;
|
|
921
953
|
}
|
|
922
954
|
|
|
923
955
|
if (!provingState.tryStartProvingRootParity()) {
|
|
924
|
-
logger.debug('Root parity already started.');
|
|
956
|
+
this.logger.debug('Root parity already started.');
|
|
925
957
|
return;
|
|
926
958
|
}
|
|
927
959
|
|
|
@@ -948,12 +980,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
948
980
|
// Enqueues the next level of merge if all inputs are available
|
|
949
981
|
private enqueueBlockMergeRollup(provingState: CheckpointProvingState, location: TreeNodeLocation) {
|
|
950
982
|
if (!provingState.verifyState()) {
|
|
951
|
-
logger.debug('Not running block merge rollup. State no longer valid.');
|
|
983
|
+
this.logger.debug('Not running block merge rollup. State no longer valid.');
|
|
952
984
|
return;
|
|
953
985
|
}
|
|
954
986
|
|
|
955
987
|
if (!provingState.tryStartProvingBlockMerge(location)) {
|
|
956
|
-
logger.debug('Block merge rollup already started.');
|
|
988
|
+
this.logger.debug('Block merge rollup already started.');
|
|
957
989
|
return;
|
|
958
990
|
}
|
|
959
991
|
|
|
@@ -968,29 +1000,29 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
968
1000
|
},
|
|
969
1001
|
signal => this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber),
|
|
970
1002
|
),
|
|
971
|
-
result => {
|
|
1003
|
+
async result => {
|
|
972
1004
|
provingState.setBlockMergeRollupProof(location, result);
|
|
973
|
-
this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
1005
|
+
await this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
974
1006
|
},
|
|
975
1007
|
);
|
|
976
1008
|
}
|
|
977
1009
|
|
|
978
|
-
private enqueueCheckpointRootRollup(provingState: CheckpointProvingState) {
|
|
1010
|
+
private async enqueueCheckpointRootRollup(provingState: CheckpointProvingState) {
|
|
979
1011
|
if (!provingState.verifyState()) {
|
|
980
|
-
logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
1012
|
+
this.logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
981
1013
|
return;
|
|
982
1014
|
}
|
|
983
1015
|
|
|
984
1016
|
if (!provingState.tryStartProvingCheckpointRoot()) {
|
|
985
|
-
logger.debug('Checkpoint root rollup already started.');
|
|
1017
|
+
this.logger.debug('Checkpoint root rollup already started.');
|
|
986
1018
|
return;
|
|
987
1019
|
}
|
|
988
1020
|
|
|
989
1021
|
const rollupType = provingState.getCheckpointRootRollupType();
|
|
990
1022
|
|
|
991
|
-
logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
1023
|
+
this.logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
992
1024
|
|
|
993
|
-
const inputs = provingState.getCheckpointRootRollupInputs();
|
|
1025
|
+
const inputs = await provingState.getCheckpointRootRollupInputs();
|
|
994
1026
|
|
|
995
1027
|
this.deferredProving(
|
|
996
1028
|
provingState,
|
|
@@ -1012,7 +1044,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1012
1044
|
const computedEndBlobAccumulatorState = provingState.getEndBlobAccumulator()!.toBlobAccumulator();
|
|
1013
1045
|
const circuitEndBlobAccumulatorState = result.inputs.endBlobAccumulator;
|
|
1014
1046
|
if (!circuitEndBlobAccumulatorState.equals(computedEndBlobAccumulatorState)) {
|
|
1015
|
-
logger.error(
|
|
1047
|
+
this.logger.error(
|
|
1016
1048
|
`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(
|
|
1017
1049
|
computedEndBlobAccumulatorState,
|
|
1018
1050
|
)}`,
|
|
@@ -1021,7 +1053,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1021
1053
|
return;
|
|
1022
1054
|
}
|
|
1023
1055
|
|
|
1024
|
-
logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
1056
|
+
this.logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
1025
1057
|
|
|
1026
1058
|
const leafLocation = provingState.setCheckpointRootRollupProof(result);
|
|
1027
1059
|
const epochProvingState = provingState.parentEpoch;
|
|
@@ -1037,12 +1069,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1037
1069
|
|
|
1038
1070
|
private enqueueCheckpointMergeRollup(provingState: EpochProvingState, location: TreeNodeLocation) {
|
|
1039
1071
|
if (!provingState.verifyState()) {
|
|
1040
|
-
logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1072
|
+
this.logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1041
1073
|
return;
|
|
1042
1074
|
}
|
|
1043
1075
|
|
|
1044
1076
|
if (!provingState.tryStartProvingCheckpointMerge(location)) {
|
|
1045
|
-
logger.debug('Checkpoint merge rollup already started.');
|
|
1077
|
+
this.logger.debug('Checkpoint merge rollup already started.');
|
|
1046
1078
|
return;
|
|
1047
1079
|
}
|
|
1048
1080
|
|
|
@@ -1059,7 +1091,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1059
1091
|
signal => this.prover.getCheckpointMergeRollupProof(inputs, signal, provingState.epochNumber),
|
|
1060
1092
|
),
|
|
1061
1093
|
result => {
|
|
1062
|
-
logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1094
|
+
this.logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1063
1095
|
provingState.setCheckpointMergeRollupProof(location, result);
|
|
1064
1096
|
this.checkAndEnqueueNextCheckpointMergeRollup(provingState, location);
|
|
1065
1097
|
},
|
|
@@ -1068,16 +1100,16 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1068
1100
|
|
|
1069
1101
|
private enqueueEpochPadding(provingState: EpochProvingState) {
|
|
1070
1102
|
if (!provingState.verifyState()) {
|
|
1071
|
-
logger.debug('Not running epoch padding. State no longer valid.');
|
|
1103
|
+
this.logger.debug('Not running epoch padding. State no longer valid.');
|
|
1072
1104
|
return;
|
|
1073
1105
|
}
|
|
1074
1106
|
|
|
1075
1107
|
if (!provingState.tryStartProvingPaddingCheckpoint()) {
|
|
1076
|
-
logger.debug('Padding checkpoint already started.');
|
|
1108
|
+
this.logger.debug('Padding checkpoint already started.');
|
|
1077
1109
|
return;
|
|
1078
1110
|
}
|
|
1079
1111
|
|
|
1080
|
-
logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1112
|
+
this.logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1081
1113
|
|
|
1082
1114
|
const inputs = provingState.getPaddingCheckpointInputs();
|
|
1083
1115
|
|
|
@@ -1092,7 +1124,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1092
1124
|
signal => this.prover.getCheckpointPaddingRollupProof(inputs, signal, provingState.epochNumber),
|
|
1093
1125
|
),
|
|
1094
1126
|
result => {
|
|
1095
|
-
logger.debug('Completed proof for padding checkpoint.');
|
|
1127
|
+
this.logger.debug('Completed proof for padding checkpoint.');
|
|
1096
1128
|
provingState.setCheckpointPaddingProof(result);
|
|
1097
1129
|
this.checkAndEnqueueRootRollup(provingState);
|
|
1098
1130
|
},
|
|
@@ -1102,11 +1134,11 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1102
1134
|
// Executes the root rollup circuit
|
|
1103
1135
|
private enqueueRootRollup(provingState: EpochProvingState) {
|
|
1104
1136
|
if (!provingState.verifyState()) {
|
|
1105
|
-
logger.debug('Not running root rollup, state no longer valid');
|
|
1137
|
+
this.logger.debug('Not running root rollup, state no longer valid');
|
|
1106
1138
|
return;
|
|
1107
1139
|
}
|
|
1108
1140
|
|
|
1109
|
-
logger.debug(`Preparing root rollup`);
|
|
1141
|
+
this.logger.debug(`Preparing root rollup`);
|
|
1110
1142
|
|
|
1111
1143
|
const inputs = provingState.getRootRollupInputs();
|
|
1112
1144
|
|
|
@@ -1121,7 +1153,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1121
1153
|
signal => this.prover.getRootRollupProof(inputs, signal, provingState.epochNumber),
|
|
1122
1154
|
),
|
|
1123
1155
|
result => {
|
|
1124
|
-
logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1156
|
+
this.logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1125
1157
|
provingState.setRootRollupProof(result);
|
|
1126
1158
|
provingState.resolve({ status: 'success' });
|
|
1127
1159
|
},
|
|
@@ -1143,32 +1175,35 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1143
1175
|
|
|
1144
1176
|
private checkAndEnqueueBlockRootRollup(provingState: BlockProvingState) {
|
|
1145
1177
|
if (!provingState.isReadyForBlockRootRollup()) {
|
|
1146
|
-
logger.debug('Not ready for block root rollup');
|
|
1178
|
+
this.logger.debug('Not ready for block root rollup');
|
|
1147
1179
|
return;
|
|
1148
1180
|
}
|
|
1149
1181
|
|
|
1150
1182
|
this.enqueueBlockRootRollup(provingState);
|
|
1151
1183
|
}
|
|
1152
1184
|
|
|
1153
|
-
private checkAndEnqueueNextBlockMergeRollup(
|
|
1185
|
+
private async checkAndEnqueueNextBlockMergeRollup(
|
|
1186
|
+
provingState: CheckpointProvingState,
|
|
1187
|
+
currentLocation: TreeNodeLocation,
|
|
1188
|
+
) {
|
|
1154
1189
|
if (!provingState.isReadyForBlockMerge(currentLocation)) {
|
|
1155
1190
|
return;
|
|
1156
1191
|
}
|
|
1157
1192
|
|
|
1158
1193
|
const parentLocation = provingState.getParentLocation(currentLocation);
|
|
1159
1194
|
if (parentLocation.level === 0) {
|
|
1160
|
-
this.checkAndEnqueueCheckpointRootRollup(provingState);
|
|
1195
|
+
await this.checkAndEnqueueCheckpointRootRollup(provingState);
|
|
1161
1196
|
} else {
|
|
1162
1197
|
this.enqueueBlockMergeRollup(provingState, parentLocation);
|
|
1163
1198
|
}
|
|
1164
1199
|
}
|
|
1165
1200
|
|
|
1166
|
-
private checkAndEnqueueCheckpointRootRollup(provingState: CheckpointProvingState) {
|
|
1201
|
+
private async checkAndEnqueueCheckpointRootRollup(provingState: CheckpointProvingState) {
|
|
1167
1202
|
if (!provingState.isReadyForCheckpointRoot()) {
|
|
1168
1203
|
return;
|
|
1169
1204
|
}
|
|
1170
1205
|
|
|
1171
|
-
this.enqueueCheckpointRootRollup(provingState);
|
|
1206
|
+
await this.enqueueCheckpointRootRollup(provingState);
|
|
1172
1207
|
}
|
|
1173
1208
|
|
|
1174
1209
|
private checkAndEnqueueNextCheckpointMergeRollup(provingState: EpochProvingState, currentLocation: TreeNodeLocation) {
|
|
@@ -1186,7 +1221,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1186
1221
|
|
|
1187
1222
|
private checkAndEnqueueRootRollup(provingState: EpochProvingState) {
|
|
1188
1223
|
if (!provingState.isReadyForRootRollup()) {
|
|
1189
|
-
logger.debug('Not ready for root rollup');
|
|
1224
|
+
this.logger.debug('Not ready for root rollup');
|
|
1190
1225
|
return;
|
|
1191
1226
|
}
|
|
1192
1227
|
|
|
@@ -1201,7 +1236,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1201
1236
|
*/
|
|
1202
1237
|
private enqueueVM(provingState: BlockProvingState, txIndex: number) {
|
|
1203
1238
|
if (!provingState.verifyState()) {
|
|
1204
|
-
logger.debug(`Not running VM circuit as state is no longer valid`);
|
|
1239
|
+
this.logger.debug(`Not running VM circuit as state is no longer valid`);
|
|
1205
1240
|
return;
|
|
1206
1241
|
}
|
|
1207
1242
|
|
|
@@ -1219,9 +1254,9 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1219
1254
|
},
|
|
1220
1255
|
);
|
|
1221
1256
|
|
|
1222
|
-
this.deferredProving(provingState, doAvmProving,
|
|
1223
|
-
logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
1224
|
-
txProvingState.setAvmProof(
|
|
1257
|
+
this.deferredProving(provingState, doAvmProving, proof => {
|
|
1258
|
+
this.logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
1259
|
+
txProvingState.setAvmProof(proof);
|
|
1225
1260
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
1226
1261
|
});
|
|
1227
1262
|
}
|
|
@@ -1233,7 +1268,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1233
1268
|
}
|
|
1234
1269
|
|
|
1235
1270
|
// We must have completed all proving (chonk verifier proof and (if required) vm proof are generated), we now move to the base rollup.
|
|
1236
|
-
logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
1271
|
+
this.logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
1237
1272
|
|
|
1238
1273
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
1239
1274
|
}
|