@aztec/prover-node 0.65.1 → 0.66.0

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.
@@ -6,7 +6,7 @@ import {
6
6
  type L1ToL2MessageSource,
7
7
  type L2Block,
8
8
  type L2BlockSource,
9
- type MerkleTreeWriteOperations,
9
+ type ProverCache,
10
10
  type ProverCoordination,
11
11
  type ProverNodeApi,
12
12
  type Service,
@@ -15,6 +15,7 @@ import {
15
15
  } from '@aztec/circuit-types';
16
16
  import { type ContractDataSource } from '@aztec/circuits.js';
17
17
  import { compact } from '@aztec/foundation/collection';
18
+ import { sha256 } from '@aztec/foundation/crypto';
18
19
  import { createDebugLogger } from '@aztec/foundation/log';
19
20
  import { type Maybe } from '@aztec/foundation/types';
20
21
  import { type L1Publisher } from '@aztec/sequencer-client';
@@ -26,12 +27,14 @@ import { EpochProvingJob, type EpochProvingJobState } from './job/epoch-proving-
26
27
  import { ProverNodeMetrics } from './metrics.js';
27
28
  import { type ClaimsMonitor, type ClaimsMonitorHandler } from './monitors/claims-monitor.js';
28
29
  import { type EpochMonitor, type EpochMonitorHandler } from './monitors/epoch-monitor.js';
30
+ import { type ProverCacheManager } from './prover-cache/cache_manager.js';
29
31
  import { type QuoteProvider } from './quote-provider/index.js';
30
32
  import { type QuoteSigner } from './quote-signer.js';
31
33
 
32
34
  export type ProverNodeOptions = {
33
35
  pollingIntervalMs: number;
34
36
  maxPendingJobs: number;
37
+ maxParallelBlocksPerEpoch: number;
35
38
  };
36
39
 
37
40
  /**
@@ -62,11 +65,13 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler, Pr
62
65
  private readonly epochsMonitor: EpochMonitor,
63
66
  private readonly bondManager: BondManager,
64
67
  private readonly telemetryClient: TelemetryClient,
68
+ private readonly proverCacheManager: ProverCacheManager,
65
69
  options: Partial<ProverNodeOptions> = {},
66
70
  ) {
67
71
  this.options = {
68
72
  pollingIntervalMs: 1_000,
69
73
  maxPendingJobs: 100,
74
+ maxParallelBlocksPerEpoch: 32,
70
75
  ...compact(options),
71
76
  };
72
77
 
@@ -242,21 +247,20 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler, Pr
242
247
  // Fast forward world state to right before the target block and get a fork
243
248
  this.log.verbose(`Creating proving job for epoch ${epochNumber} for block range ${fromBlock} to ${toBlock}`);
244
249
  await this.worldState.syncImmediate(fromBlock - 1);
245
- // NB: separated the dbs as both a block builder and public processor need to track and update tree state
246
- // see public_processor.ts for context
247
- const publicDb = await this.worldState.fork(fromBlock - 1);
248
- const proverDb = await this.worldState.fork(fromBlock - 1);
249
250
 
250
251
  // Create a processor using the forked world state
251
252
  const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, this.telemetryClient);
252
253
 
254
+ const epochHash = sha256(Buffer.concat(blocks.map(block => block.hash().toBuffer())));
255
+ const proverCache = await this.proverCacheManager.openCache(epochNumber, epochHash);
256
+
253
257
  const cleanUp = async () => {
254
- await publicDb.close();
255
- await proverDb.close();
258
+ await proverCache.close();
259
+ await this.proverCacheManager.removeStaleCaches(epochNumber);
256
260
  this.jobs.delete(job.getId());
257
261
  };
258
262
 
259
- const job = this.doCreateEpochProvingJob(epochNumber, blocks, publicDb, proverDb, publicProcessorFactory, cleanUp);
263
+ const job = this.doCreateEpochProvingJob(epochNumber, blocks, proverCache, publicProcessorFactory, cleanUp);
260
264
  this.jobs.set(job.getId(), job);
261
265
  return job;
262
266
  }
@@ -265,22 +269,22 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler, Pr
265
269
  protected doCreateEpochProvingJob(
266
270
  epochNumber: bigint,
267
271
  blocks: L2Block[],
268
- publicDb: MerkleTreeWriteOperations,
269
- proverDb: MerkleTreeWriteOperations,
272
+ proverCache: ProverCache,
270
273
  publicProcessorFactory: PublicProcessorFactory,
271
274
  cleanUp: () => Promise<void>,
272
275
  ) {
273
276
  return new EpochProvingJob(
274
- publicDb,
277
+ this.worldState,
275
278
  epochNumber,
276
279
  blocks,
277
- this.prover.createEpochProver(proverDb),
280
+ this.prover.createEpochProver(proverCache),
278
281
  publicProcessorFactory,
279
282
  this.publisher,
280
283
  this.l2BlockSource,
281
284
  this.l1ToL2MessageSource,
282
285
  this.coordination,
283
286
  this.metrics,
287
+ { parallelBlockLimit: this.options.maxParallelBlocksPerEpoch },
284
288
  cleanUp,
285
289
  );
286
290
  }