@aztec/prover-client 0.0.1-commit.e6bd8901 → 0.0.1-commit.f146247c
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 +7 -4
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +13 -7
- 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/orchestrator/block-building-helpers.js +1 -1
- package/dest/orchestrator/orchestrator.d.ts +4 -2
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +65 -64
- package/dest/prover-client/prover-client.d.ts +1 -1
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +7 -4
- 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/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_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 +11 -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/package.json +15 -15
- package/src/light/lightweight_checkpoint_builder.ts +17 -2
- package/src/mocks/fixtures.ts +2 -1
- package/src/orchestrator/block-building-helpers.ts +1 -1
- package/src/orchestrator/orchestrator.ts +66 -65
- package/src/prover-client/prover-client.ts +16 -5
- package/src/proving_broker/broker_prover_facade.ts +6 -3
- package/src/proving_broker/proving_agent.ts +5 -2
- package/src/proving_broker/proving_broker_instrumentation.ts +10 -6
- package/src/proving_broker/proving_job_controller.ts +9 -3
|
@@ -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
|
type WorldStateFork = {
|
|
77
75
|
fork: MerkleTreeWriteOperations;
|
|
78
76
|
cleanupPromise: Promise<void> | undefined;
|
|
@@ -100,6 +98,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
100
98
|
private metrics: ProvingOrchestratorMetrics;
|
|
101
99
|
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
102
100
|
private dbs: Map<BlockNumber, WorldStateFork> = new Map();
|
|
101
|
+
private logger: Logger;
|
|
103
102
|
|
|
104
103
|
constructor(
|
|
105
104
|
private dbProvider: ReadonlyWorldStateAccess & ForkMerkleTreeOperations,
|
|
@@ -107,7 +106,9 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
107
106
|
private readonly proverId: EthAddress,
|
|
108
107
|
private readonly cancelJobsOnStop: boolean = false,
|
|
109
108
|
telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
109
|
+
bindings?: LoggerBindings,
|
|
110
110
|
) {
|
|
111
|
+
this.logger = createLogger('prover-client:orchestrator', bindings);
|
|
111
112
|
this.metrics = new ProvingOrchestratorMetrics(telemetryClient, 'ProvingOrchestrator');
|
|
112
113
|
}
|
|
113
114
|
|
|
@@ -141,7 +142,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
141
142
|
|
|
142
143
|
const { promise: _promise, resolve, reject } = promiseWithResolvers<ProvingResult>();
|
|
143
144
|
const promise = _promise.catch((reason): ProvingResult => ({ status: 'failure', reason }));
|
|
144
|
-
logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
145
|
+
this.logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
|
|
145
146
|
this.provingState = new EpochProvingState(
|
|
146
147
|
epochNumber,
|
|
147
148
|
totalNumCheckpoints,
|
|
@@ -233,7 +234,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
233
234
|
}
|
|
234
235
|
|
|
235
236
|
const constants = checkpointProvingState.constants;
|
|
236
|
-
logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
237
|
+
this.logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
|
|
237
238
|
|
|
238
239
|
// Fork the db only when it's not already set. The db for the first block is set in `startNewCheckpoint`.
|
|
239
240
|
if (!this.dbs.has(blockNumber)) {
|
|
@@ -294,7 +295,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
294
295
|
if (!txs.length) {
|
|
295
296
|
// To avoid an ugly throw below. If we require an empty block, we can just call setBlockCompleted
|
|
296
297
|
// on a block with no txs. We cannot do that here because we cannot find the blockNumber without any txs.
|
|
297
|
-
logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
298
|
+
this.logger.warn(`Provided no txs to orchestrator addTxs.`);
|
|
298
299
|
return;
|
|
299
300
|
}
|
|
300
301
|
|
|
@@ -314,7 +315,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
314
315
|
throw new Error(`Block ${blockNumber} has been initialized with transactions.`);
|
|
315
316
|
}
|
|
316
317
|
|
|
317
|
-
logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
318
|
+
this.logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
|
|
318
319
|
|
|
319
320
|
const db = this.dbs.get(blockNumber)!.fork;
|
|
320
321
|
const lastArchive = provingState.lastArchiveTreeSnapshot;
|
|
@@ -329,7 +330,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
329
330
|
|
|
330
331
|
validateTx(tx);
|
|
331
332
|
|
|
332
|
-
logger.debug(`Received transaction: ${tx.hash}`);
|
|
333
|
+
this.logger.debug(`Received transaction: ${tx.hash}`);
|
|
333
334
|
|
|
334
335
|
const startSpongeBlob = spongeBlobState.clone();
|
|
335
336
|
const [hints, treeSnapshots] = await this.prepareBaseRollupInputs(
|
|
@@ -350,10 +351,10 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
350
351
|
const txIndex = provingState.addNewTx(txProvingState);
|
|
351
352
|
if (txProvingState.requireAvmProof) {
|
|
352
353
|
this.getOrEnqueueChonkVerifier(provingState, txIndex);
|
|
353
|
-
logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
354
|
+
this.logger.debug(`Enqueueing public VM for tx ${txIndex}`);
|
|
354
355
|
this.enqueueVM(provingState, txIndex);
|
|
355
356
|
} else {
|
|
356
|
-
logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
357
|
+
this.logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
|
|
357
358
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
358
359
|
}
|
|
359
360
|
} catch (err: any) {
|
|
@@ -396,7 +397,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
396
397
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
397
398
|
>
|
|
398
399
|
>();
|
|
399
|
-
logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
400
|
+
this.logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
|
|
400
401
|
this.doEnqueueChonkVerifier(txHash, privateInputs, proof => {
|
|
401
402
|
tubeProof.resolve(proof);
|
|
402
403
|
});
|
|
@@ -436,11 +437,11 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
436
437
|
}
|
|
437
438
|
|
|
438
439
|
// Given we've applied every change from this block, now assemble the block header:
|
|
439
|
-
logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
440
|
+
this.logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
|
|
440
441
|
const header = await provingState.buildBlockHeader();
|
|
441
442
|
|
|
442
443
|
if (expectedHeader && !header.equals(expectedHeader)) {
|
|
443
|
-
logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
444
|
+
this.logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
|
|
444
445
|
throw new Error('Block header mismatch');
|
|
445
446
|
}
|
|
446
447
|
|
|
@@ -448,7 +449,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
448
449
|
const db = this.dbs.get(provingState.blockNumber)!.fork;
|
|
449
450
|
|
|
450
451
|
// Update the archive tree, so we're ready to start processing the next block:
|
|
451
|
-
logger.verbose(
|
|
452
|
+
this.logger.verbose(
|
|
452
453
|
`Updating archive tree with block ${provingState.blockNumber} header ${(await header.hash()).toString()}`,
|
|
453
454
|
);
|
|
454
455
|
await db.updateArchive(header);
|
|
@@ -462,19 +463,19 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
462
463
|
protected async verifyBuiltBlockAgainstSyncedState(provingState: BlockProvingState) {
|
|
463
464
|
const builtBlockHeader = provingState.getBuiltBlockHeader();
|
|
464
465
|
if (!builtBlockHeader) {
|
|
465
|
-
logger.debug('Block header not built yet, skipping header check.');
|
|
466
|
+
this.logger.debug('Block header not built yet, skipping header check.');
|
|
466
467
|
return;
|
|
467
468
|
}
|
|
468
469
|
|
|
469
470
|
const output = provingState.getBlockRootRollupOutput();
|
|
470
471
|
if (!output) {
|
|
471
|
-
logger.debug('Block root rollup proof not built yet, skipping header check.');
|
|
472
|
+
this.logger.debug('Block root rollup proof not built yet, skipping header check.');
|
|
472
473
|
return;
|
|
473
474
|
}
|
|
474
475
|
const header = await buildHeaderFromCircuitOutputs(output);
|
|
475
476
|
|
|
476
477
|
if (!(await header.hash()).equals(await builtBlockHeader.hash())) {
|
|
477
|
-
logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
478
|
+
this.logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
|
|
478
479
|
provingState.reject(`Block header hash mismatch.`);
|
|
479
480
|
return;
|
|
480
481
|
}
|
|
@@ -486,7 +487,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
486
487
|
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
487
488
|
const syncedArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.dbProvider.getSnapshot(blockNumber));
|
|
488
489
|
if (!syncedArchive.equals(newArchive)) {
|
|
489
|
-
logger.error(
|
|
490
|
+
this.logger.error(
|
|
490
491
|
`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(
|
|
491
492
|
syncedArchive,
|
|
492
493
|
)} but built ${inspect(newArchive)}`,
|
|
@@ -497,7 +498,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
497
498
|
|
|
498
499
|
const circuitArchive = output.newArchive;
|
|
499
500
|
if (!newArchive.equals(circuitArchive)) {
|
|
500
|
-
logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
501
|
+
this.logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
|
|
501
502
|
provingState.reject(`New archive mismatch.`);
|
|
502
503
|
return;
|
|
503
504
|
}
|
|
@@ -554,7 +555,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
554
555
|
}
|
|
555
556
|
|
|
556
557
|
private async cleanupDBFork(blockNumber: BlockNumber): Promise<void> {
|
|
557
|
-
logger.debug(`Cleaning up world state fork for ${blockNumber}`);
|
|
558
|
+
this.logger.debug(`Cleaning up world state fork for ${blockNumber}`);
|
|
558
559
|
const fork = this.dbs.get(blockNumber);
|
|
559
560
|
if (!fork) {
|
|
560
561
|
return;
|
|
@@ -567,7 +568,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
567
568
|
await fork.cleanupPromise;
|
|
568
569
|
this.dbs.delete(blockNumber);
|
|
569
570
|
} catch (err) {
|
|
570
|
-
logger.error(`Error closing db for block ${blockNumber}`, err);
|
|
571
|
+
this.logger.error(`Error closing db for block ${blockNumber}`, err);
|
|
571
572
|
}
|
|
572
573
|
}
|
|
573
574
|
|
|
@@ -583,7 +584,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
583
584
|
callback: (result: T) => void | Promise<void>,
|
|
584
585
|
) {
|
|
585
586
|
if (!provingState.verifyState()) {
|
|
586
|
-
logger.debug(`Not enqueuing job, state no longer valid`);
|
|
587
|
+
this.logger.debug(`Not enqueuing job, state no longer valid`);
|
|
587
588
|
return;
|
|
588
589
|
}
|
|
589
590
|
|
|
@@ -601,7 +602,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
601
602
|
|
|
602
603
|
const result = await request(controller.signal);
|
|
603
604
|
if (!provingState.verifyState()) {
|
|
604
|
-
logger.debug(`State no longer valid, discarding result`);
|
|
605
|
+
this.logger.debug(`State no longer valid, discarding result`);
|
|
605
606
|
return;
|
|
606
607
|
}
|
|
607
608
|
|
|
@@ -619,7 +620,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
619
620
|
return;
|
|
620
621
|
}
|
|
621
622
|
|
|
622
|
-
logger.error(`Error thrown when proving job`, err);
|
|
623
|
+
this.logger.error(`Error thrown when proving job`, err);
|
|
623
624
|
provingState!.reject(`${err}`);
|
|
624
625
|
} finally {
|
|
625
626
|
const index = this.pendingProvingJobs.indexOf(controller);
|
|
@@ -704,12 +705,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
704
705
|
// Executes the next level of merge if all inputs are available
|
|
705
706
|
private enqueueBaseRollup(provingState: BlockProvingState, txIndex: number) {
|
|
706
707
|
if (!provingState.verifyState()) {
|
|
707
|
-
logger.debug('Not running base rollup, state invalid');
|
|
708
|
+
this.logger.debug('Not running base rollup, state invalid');
|
|
708
709
|
return;
|
|
709
710
|
}
|
|
710
711
|
|
|
711
712
|
if (!provingState.tryStartProvingBase(txIndex)) {
|
|
712
|
-
logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
713
|
+
this.logger.debug(`Base rollup for tx ${txIndex} already started.`);
|
|
713
714
|
return;
|
|
714
715
|
}
|
|
715
716
|
|
|
@@ -717,7 +718,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
717
718
|
const { processedTx } = txProvingState;
|
|
718
719
|
const { rollupType, inputs } = txProvingState.getBaseRollupTypeAndInputs();
|
|
719
720
|
|
|
720
|
-
logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
721
|
+
this.logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
721
722
|
|
|
722
723
|
this.deferredProving(
|
|
723
724
|
provingState,
|
|
@@ -741,7 +742,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
741
742
|
},
|
|
742
743
|
),
|
|
743
744
|
result => {
|
|
744
|
-
logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
745
|
+
this.logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
|
|
745
746
|
validatePartialState(result.inputs.endTreeSnapshots, txProvingState.treeSnapshots);
|
|
746
747
|
const leafLocation = provingState.setBaseRollupProof(txIndex, result);
|
|
747
748
|
if (provingState.totalNumTxs === 1) {
|
|
@@ -757,7 +758,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
757
758
|
// Once completed, will enqueue the the public tx base rollup.
|
|
758
759
|
private getOrEnqueueChonkVerifier(provingState: BlockProvingState, txIndex: number) {
|
|
759
760
|
if (!provingState.verifyState()) {
|
|
760
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
761
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
761
762
|
return;
|
|
762
763
|
}
|
|
763
764
|
|
|
@@ -770,19 +771,19 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
770
771
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
771
772
|
>,
|
|
772
773
|
) => {
|
|
773
|
-
logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, { txHash });
|
|
774
|
+
this.logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, { txHash });
|
|
774
775
|
txProvingState.setPublicChonkVerifierProof(result);
|
|
775
776
|
this.provingState?.cachedChonkVerifierProofs.delete(txHash);
|
|
776
777
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
777
778
|
};
|
|
778
779
|
|
|
779
780
|
if (this.provingState?.cachedChonkVerifierProofs.has(txHash)) {
|
|
780
|
-
logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, { txHash });
|
|
781
|
+
this.logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, { txHash });
|
|
781
782
|
void this.provingState!.cachedChonkVerifierProofs.get(txHash)!.then(handleResult);
|
|
782
783
|
return;
|
|
783
784
|
}
|
|
784
785
|
|
|
785
|
-
logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
786
|
+
this.logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
|
|
786
787
|
this.doEnqueueChonkVerifier(txHash, txProvingState.getPublicChonkVerifierPrivateInputs(), handleResult);
|
|
787
788
|
}
|
|
788
789
|
|
|
@@ -798,7 +799,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
798
799
|
provingState: EpochProvingState | BlockProvingState = this.provingState!,
|
|
799
800
|
) {
|
|
800
801
|
if (!provingState.verifyState()) {
|
|
801
|
-
logger.debug('Not running chonk verifier circuit, state invalid');
|
|
802
|
+
this.logger.debug('Not running chonk verifier circuit, state invalid');
|
|
802
803
|
return;
|
|
803
804
|
}
|
|
804
805
|
|
|
@@ -821,12 +822,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
821
822
|
// Enqueues the next level of merge if all inputs are available
|
|
822
823
|
private enqueueMergeRollup(provingState: BlockProvingState, location: TreeNodeLocation) {
|
|
823
824
|
if (!provingState.verifyState()) {
|
|
824
|
-
logger.debug('Not running merge rollup. State no longer valid.');
|
|
825
|
+
this.logger.debug('Not running merge rollup. State no longer valid.');
|
|
825
826
|
return;
|
|
826
827
|
}
|
|
827
828
|
|
|
828
829
|
if (!provingState.tryStartProvingMerge(location)) {
|
|
829
|
-
logger.debug('Merge rollup already started.');
|
|
830
|
+
this.logger.debug('Merge rollup already started.');
|
|
830
831
|
return;
|
|
831
832
|
}
|
|
832
833
|
|
|
@@ -852,18 +853,18 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
852
853
|
// Executes the block root rollup circuit
|
|
853
854
|
private enqueueBlockRootRollup(provingState: BlockProvingState) {
|
|
854
855
|
if (!provingState.verifyState()) {
|
|
855
|
-
logger.debug('Not running block root rollup, state no longer valid');
|
|
856
|
+
this.logger.debug('Not running block root rollup, state no longer valid');
|
|
856
857
|
return;
|
|
857
858
|
}
|
|
858
859
|
|
|
859
860
|
if (!provingState.tryStartProvingBlockRoot()) {
|
|
860
|
-
logger.debug('Block root rollup already started.');
|
|
861
|
+
this.logger.debug('Block root rollup already started.');
|
|
861
862
|
return;
|
|
862
863
|
}
|
|
863
864
|
|
|
864
865
|
const { rollupType, inputs } = provingState.getBlockRootRollupTypeAndInputs();
|
|
865
866
|
|
|
866
|
-
logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
867
|
+
this.logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
|
|
867
868
|
|
|
868
869
|
this.deferredProving(
|
|
869
870
|
provingState,
|
|
@@ -888,7 +889,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
888
889
|
},
|
|
889
890
|
),
|
|
890
891
|
async result => {
|
|
891
|
-
logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
892
|
+
this.logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
|
|
892
893
|
|
|
893
894
|
const leafLocation = provingState.setBlockRootRollupProof(result);
|
|
894
895
|
const checkpointProvingState = provingState.parentCheckpoint;
|
|
@@ -916,12 +917,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
916
917
|
baseParityIndex: number,
|
|
917
918
|
) {
|
|
918
919
|
if (!provingState.verifyState()) {
|
|
919
|
-
logger.debug('Not running base parity. State no longer valid.');
|
|
920
|
+
this.logger.debug('Not running base parity. State no longer valid.');
|
|
920
921
|
return;
|
|
921
922
|
}
|
|
922
923
|
|
|
923
924
|
if (!provingState.tryStartProvingBaseParity(baseParityIndex)) {
|
|
924
|
-
logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
925
|
+
this.logger.warn(`Base parity ${baseParityIndex} already started.`);
|
|
925
926
|
return;
|
|
926
927
|
}
|
|
927
928
|
|
|
@@ -956,12 +957,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
956
957
|
// Enqueues the root rollup proof if all inputs are available
|
|
957
958
|
private enqueueRootParityCircuit(provingState: BlockProvingState) {
|
|
958
959
|
if (!provingState.verifyState()) {
|
|
959
|
-
logger.debug('Not running root parity. State no longer valid.');
|
|
960
|
+
this.logger.debug('Not running root parity. State no longer valid.');
|
|
960
961
|
return;
|
|
961
962
|
}
|
|
962
963
|
|
|
963
964
|
if (!provingState.tryStartProvingRootParity()) {
|
|
964
|
-
logger.debug('Root parity already started.');
|
|
965
|
+
this.logger.debug('Root parity already started.');
|
|
965
966
|
return;
|
|
966
967
|
}
|
|
967
968
|
|
|
@@ -988,12 +989,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
988
989
|
// Enqueues the next level of merge if all inputs are available
|
|
989
990
|
private enqueueBlockMergeRollup(provingState: CheckpointProvingState, location: TreeNodeLocation) {
|
|
990
991
|
if (!provingState.verifyState()) {
|
|
991
|
-
logger.debug('Not running block merge rollup. State no longer valid.');
|
|
992
|
+
this.logger.debug('Not running block merge rollup. State no longer valid.');
|
|
992
993
|
return;
|
|
993
994
|
}
|
|
994
995
|
|
|
995
996
|
if (!provingState.tryStartProvingBlockMerge(location)) {
|
|
996
|
-
logger.debug('Block merge rollup already started.');
|
|
997
|
+
this.logger.debug('Block merge rollup already started.');
|
|
997
998
|
return;
|
|
998
999
|
}
|
|
999
1000
|
|
|
@@ -1017,18 +1018,18 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1017
1018
|
|
|
1018
1019
|
private enqueueCheckpointRootRollup(provingState: CheckpointProvingState) {
|
|
1019
1020
|
if (!provingState.verifyState()) {
|
|
1020
|
-
logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
1021
|
+
this.logger.debug('Not running checkpoint root rollup. State no longer valid.');
|
|
1021
1022
|
return;
|
|
1022
1023
|
}
|
|
1023
1024
|
|
|
1024
1025
|
if (!provingState.tryStartProvingCheckpointRoot()) {
|
|
1025
|
-
logger.debug('Checkpoint root rollup already started.');
|
|
1026
|
+
this.logger.debug('Checkpoint root rollup already started.');
|
|
1026
1027
|
return;
|
|
1027
1028
|
}
|
|
1028
1029
|
|
|
1029
1030
|
const rollupType = provingState.getCheckpointRootRollupType();
|
|
1030
1031
|
|
|
1031
|
-
logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
1032
|
+
this.logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
|
|
1032
1033
|
|
|
1033
1034
|
const inputs = provingState.getCheckpointRootRollupInputs();
|
|
1034
1035
|
|
|
@@ -1052,7 +1053,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1052
1053
|
const computedEndBlobAccumulatorState = provingState.getEndBlobAccumulator()!.toBlobAccumulator();
|
|
1053
1054
|
const circuitEndBlobAccumulatorState = result.inputs.endBlobAccumulator;
|
|
1054
1055
|
if (!circuitEndBlobAccumulatorState.equals(computedEndBlobAccumulatorState)) {
|
|
1055
|
-
logger.error(
|
|
1056
|
+
this.logger.error(
|
|
1056
1057
|
`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(
|
|
1057
1058
|
computedEndBlobAccumulatorState,
|
|
1058
1059
|
)}`,
|
|
@@ -1061,7 +1062,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1061
1062
|
return;
|
|
1062
1063
|
}
|
|
1063
1064
|
|
|
1064
|
-
logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
1065
|
+
this.logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
|
|
1065
1066
|
|
|
1066
1067
|
const leafLocation = provingState.setCheckpointRootRollupProof(result);
|
|
1067
1068
|
const epochProvingState = provingState.parentEpoch;
|
|
@@ -1077,12 +1078,12 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1077
1078
|
|
|
1078
1079
|
private enqueueCheckpointMergeRollup(provingState: EpochProvingState, location: TreeNodeLocation) {
|
|
1079
1080
|
if (!provingState.verifyState()) {
|
|
1080
|
-
logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1081
|
+
this.logger.debug('Not running checkpoint merge rollup. State no longer valid.');
|
|
1081
1082
|
return;
|
|
1082
1083
|
}
|
|
1083
1084
|
|
|
1084
1085
|
if (!provingState.tryStartProvingCheckpointMerge(location)) {
|
|
1085
|
-
logger.debug('Checkpoint merge rollup already started.');
|
|
1086
|
+
this.logger.debug('Checkpoint merge rollup already started.');
|
|
1086
1087
|
return;
|
|
1087
1088
|
}
|
|
1088
1089
|
|
|
@@ -1099,7 +1100,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1099
1100
|
signal => this.prover.getCheckpointMergeRollupProof(inputs, signal, provingState.epochNumber),
|
|
1100
1101
|
),
|
|
1101
1102
|
result => {
|
|
1102
|
-
logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1103
|
+
this.logger.debug('Completed proof for checkpoint merge rollup.');
|
|
1103
1104
|
provingState.setCheckpointMergeRollupProof(location, result);
|
|
1104
1105
|
this.checkAndEnqueueNextCheckpointMergeRollup(provingState, location);
|
|
1105
1106
|
},
|
|
@@ -1108,16 +1109,16 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1108
1109
|
|
|
1109
1110
|
private enqueueEpochPadding(provingState: EpochProvingState) {
|
|
1110
1111
|
if (!provingState.verifyState()) {
|
|
1111
|
-
logger.debug('Not running epoch padding. State no longer valid.');
|
|
1112
|
+
this.logger.debug('Not running epoch padding. State no longer valid.');
|
|
1112
1113
|
return;
|
|
1113
1114
|
}
|
|
1114
1115
|
|
|
1115
1116
|
if (!provingState.tryStartProvingPaddingCheckpoint()) {
|
|
1116
|
-
logger.debug('Padding checkpoint already started.');
|
|
1117
|
+
this.logger.debug('Padding checkpoint already started.');
|
|
1117
1118
|
return;
|
|
1118
1119
|
}
|
|
1119
1120
|
|
|
1120
|
-
logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1121
|
+
this.logger.debug('Padding epoch proof with a padding block root proof.');
|
|
1121
1122
|
|
|
1122
1123
|
const inputs = provingState.getPaddingCheckpointInputs();
|
|
1123
1124
|
|
|
@@ -1132,7 +1133,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1132
1133
|
signal => this.prover.getCheckpointPaddingRollupProof(inputs, signal, provingState.epochNumber),
|
|
1133
1134
|
),
|
|
1134
1135
|
result => {
|
|
1135
|
-
logger.debug('Completed proof for padding checkpoint.');
|
|
1136
|
+
this.logger.debug('Completed proof for padding checkpoint.');
|
|
1136
1137
|
provingState.setCheckpointPaddingProof(result);
|
|
1137
1138
|
this.checkAndEnqueueRootRollup(provingState);
|
|
1138
1139
|
},
|
|
@@ -1142,11 +1143,11 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1142
1143
|
// Executes the root rollup circuit
|
|
1143
1144
|
private enqueueRootRollup(provingState: EpochProvingState) {
|
|
1144
1145
|
if (!provingState.verifyState()) {
|
|
1145
|
-
logger.debug('Not running root rollup, state no longer valid');
|
|
1146
|
+
this.logger.debug('Not running root rollup, state no longer valid');
|
|
1146
1147
|
return;
|
|
1147
1148
|
}
|
|
1148
1149
|
|
|
1149
|
-
logger.debug(`Preparing root rollup`);
|
|
1150
|
+
this.logger.debug(`Preparing root rollup`);
|
|
1150
1151
|
|
|
1151
1152
|
const inputs = provingState.getRootRollupInputs();
|
|
1152
1153
|
|
|
@@ -1161,7 +1162,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1161
1162
|
signal => this.prover.getRootRollupProof(inputs, signal, provingState.epochNumber),
|
|
1162
1163
|
),
|
|
1163
1164
|
result => {
|
|
1164
|
-
logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1165
|
+
this.logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
|
|
1165
1166
|
provingState.setRootRollupProof(result);
|
|
1166
1167
|
provingState.resolve({ status: 'success' });
|
|
1167
1168
|
},
|
|
@@ -1183,7 +1184,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1183
1184
|
|
|
1184
1185
|
private checkAndEnqueueBlockRootRollup(provingState: BlockProvingState) {
|
|
1185
1186
|
if (!provingState.isReadyForBlockRootRollup()) {
|
|
1186
|
-
logger.debug('Not ready for block root rollup');
|
|
1187
|
+
this.logger.debug('Not ready for block root rollup');
|
|
1187
1188
|
return;
|
|
1188
1189
|
}
|
|
1189
1190
|
|
|
@@ -1226,7 +1227,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1226
1227
|
|
|
1227
1228
|
private checkAndEnqueueRootRollup(provingState: EpochProvingState) {
|
|
1228
1229
|
if (!provingState.isReadyForRootRollup()) {
|
|
1229
|
-
logger.debug('Not ready for root rollup');
|
|
1230
|
+
this.logger.debug('Not ready for root rollup');
|
|
1230
1231
|
return;
|
|
1231
1232
|
}
|
|
1232
1233
|
|
|
@@ -1241,7 +1242,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1241
1242
|
*/
|
|
1242
1243
|
private enqueueVM(provingState: BlockProvingState, txIndex: number) {
|
|
1243
1244
|
if (!provingState.verifyState()) {
|
|
1244
|
-
logger.debug(`Not running VM circuit as state is no longer valid`);
|
|
1245
|
+
this.logger.debug(`Not running VM circuit as state is no longer valid`);
|
|
1245
1246
|
return;
|
|
1246
1247
|
}
|
|
1247
1248
|
|
|
@@ -1260,7 +1261,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1260
1261
|
);
|
|
1261
1262
|
|
|
1262
1263
|
this.deferredProving(provingState, doAvmProving, proof => {
|
|
1263
|
-
logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
1264
|
+
this.logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
1264
1265
|
txProvingState.setAvmProof(proof);
|
|
1265
1266
|
this.checkAndEnqueueBaseRollup(provingState, txIndex);
|
|
1266
1267
|
});
|
|
@@ -1273,7 +1274,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
1273
1274
|
}
|
|
1274
1275
|
|
|
1275
1276
|
// We must have completed all proving (chonk verifier proof and (if required) vm proof are generated), we now move to the base rollup.
|
|
1276
|
-
logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
1277
|
+
this.logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
1277
1278
|
|
|
1278
1279
|
this.enqueueBaseRollup(provingState, txIndex);
|
|
1279
1280
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ACVMConfig, type BBConfig, BBNativeRollupProver, TestCircuitProver } from '@aztec/bb-prover';
|
|
2
2
|
import { times } from '@aztec/foundation/collection';
|
|
3
3
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { NativeACVMSimulator } from '@aztec/simulator/server';
|
|
6
6
|
import {
|
|
7
7
|
type ActualProverConfig,
|
|
@@ -38,20 +38,28 @@ export class ProverClient implements EpochProverManager {
|
|
|
38
38
|
private orchestratorClient: ProvingJobProducer,
|
|
39
39
|
private agentClient?: ProvingJobConsumer,
|
|
40
40
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
41
|
-
private log = createLogger('prover-client:tx-prover'),
|
|
41
|
+
private log: Logger = createLogger('prover-client:tx-prover'),
|
|
42
42
|
) {
|
|
43
43
|
this.proofStore = new InlineProofStore();
|
|
44
44
|
this.failedProofStore = this.config.failedProofStore ? createProofStore(this.config.failedProofStore) : undefined;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
public createEpochProver(): EpochProver {
|
|
48
|
-
const
|
|
48
|
+
const bindings = this.log.getBindings();
|
|
49
|
+
const facade = new BrokerCircuitProverFacade(
|
|
50
|
+
this.orchestratorClient,
|
|
51
|
+
this.proofStore,
|
|
52
|
+
this.failedProofStore,
|
|
53
|
+
undefined,
|
|
54
|
+
bindings,
|
|
55
|
+
);
|
|
49
56
|
const orchestrator = new ProvingOrchestrator(
|
|
50
57
|
this.worldState,
|
|
51
58
|
facade,
|
|
52
59
|
this.config.proverId,
|
|
53
60
|
this.config.cancelJobsOnStop,
|
|
54
61
|
this.telemetry,
|
|
62
|
+
bindings,
|
|
55
63
|
);
|
|
56
64
|
return new ServerEpochProver(facade, orchestrator);
|
|
57
65
|
}
|
|
@@ -134,9 +142,11 @@ export class ProverClient implements EpochProverManager {
|
|
|
134
142
|
|
|
135
143
|
const proofStore = new InlineProofStore();
|
|
136
144
|
const prover = await buildServerCircuitProver(this.config, this.telemetry);
|
|
145
|
+
const bindings = this.log.getBindings();
|
|
137
146
|
this.agents = times(
|
|
138
147
|
this.config.proverAgentCount,
|
|
139
|
-
() =>
|
|
148
|
+
() =>
|
|
149
|
+
new ProvingAgent(this.agentClient!, proofStore, prover, [], this.config.proverAgentPollIntervalMs, bindings),
|
|
140
150
|
);
|
|
141
151
|
|
|
142
152
|
await Promise.all(this.agents.map(agent => agent.start()));
|
|
@@ -155,8 +165,9 @@ export function buildServerCircuitProver(
|
|
|
155
165
|
return BBNativeRollupProver.new(config, telemetry);
|
|
156
166
|
}
|
|
157
167
|
|
|
168
|
+
const logger = createLogger('prover-client:acvm-native');
|
|
158
169
|
const simulator = config.acvmBinaryPath
|
|
159
|
-
? new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath)
|
|
170
|
+
? new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath, undefined, logger)
|
|
160
171
|
: undefined;
|
|
161
172
|
|
|
162
173
|
return Promise.resolve(new TestCircuitProver(simulator, config, telemetry));
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
} from '@aztec/constants';
|
|
7
7
|
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
8
8
|
import { sha256 } from '@aztec/foundation/crypto/sha256';
|
|
9
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
9
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
10
10
|
import { type PromiseWithResolvers, RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
11
11
|
import { truncate } from '@aztec/foundation/string';
|
|
12
12
|
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
@@ -68,14 +68,17 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
68
68
|
private runningPromise?: RunningPromise;
|
|
69
69
|
private timeOfLastSnapshotSync = Date.now();
|
|
70
70
|
private jobsToRetrieve: Set<ProvingJobId> = new Set();
|
|
71
|
+
private log: Logger;
|
|
71
72
|
|
|
72
73
|
constructor(
|
|
73
74
|
private broker: ProvingJobProducer,
|
|
74
75
|
private proofStore: ProofStore = new InlineProofStore(),
|
|
75
76
|
private failedProofStore?: ProofStore,
|
|
76
77
|
private pollIntervalMs = 1000,
|
|
77
|
-
|
|
78
|
-
) {
|
|
78
|
+
bindings?: LoggerBindings,
|
|
79
|
+
) {
|
|
80
|
+
this.log = createLogger('prover-client:broker-circuit-prover-facade', bindings);
|
|
81
|
+
}
|
|
79
82
|
|
|
80
83
|
/**
|
|
81
84
|
* This is a critical section. This function can not be async since it writes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbortError } from '@aztec/foundation/error';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
4
4
|
import { truncate } from '@aztec/foundation/string';
|
|
5
5
|
import { ProvingError } from '@aztec/stdlib/errors';
|
|
@@ -23,6 +23,7 @@ import { ProvingJobController, ProvingJobControllerStatus } from './proving_job_
|
|
|
23
23
|
export class ProvingAgent {
|
|
24
24
|
private currentJobController?: ProvingJobController;
|
|
25
25
|
private runningPromise: RunningPromise;
|
|
26
|
+
private log: Logger;
|
|
26
27
|
|
|
27
28
|
constructor(
|
|
28
29
|
/** The source of proving jobs */
|
|
@@ -35,8 +36,9 @@ export class ProvingAgent {
|
|
|
35
36
|
private proofAllowList: Array<ProvingRequestType> = [],
|
|
36
37
|
/** How long to wait between jobs */
|
|
37
38
|
private pollIntervalMs = 1000,
|
|
38
|
-
|
|
39
|
+
bindings?: LoggerBindings,
|
|
39
40
|
) {
|
|
41
|
+
this.log = createLogger('prover-client:proving-agent', bindings);
|
|
40
42
|
this.runningPromise = new RunningPromise(this.work.bind(this), this.log, this.pollIntervalMs);
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -159,6 +161,7 @@ export class ProvingAgent {
|
|
|
159
161
|
// no need to await this here. The controller will stay alive (in DONE state) until the result is send to the broker
|
|
160
162
|
void this.runningPromise.trigger();
|
|
161
163
|
},
|
|
164
|
+
this.log.getBindings(),
|
|
162
165
|
);
|
|
163
166
|
|
|
164
167
|
if (abortedProofJobId) {
|