@aztec/prover-node 0.0.1-commit.3469e52 → 0.0.1-commit.3895657bc

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.
Files changed (38) hide show
  1. package/dest/actions/rerun-epoch-proving-job.d.ts +4 -3
  2. package/dest/actions/rerun-epoch-proving-job.d.ts.map +1 -1
  3. package/dest/actions/rerun-epoch-proving-job.js +5 -3
  4. package/dest/actions/upload-epoch-proof-failure.d.ts +2 -2
  5. package/dest/actions/upload-epoch-proof-failure.d.ts.map +1 -1
  6. package/dest/bin/run-failed-epoch.js +5 -2
  7. package/dest/config.d.ts +5 -8
  8. package/dest/config.d.ts.map +1 -1
  9. package/dest/config.js +15 -18
  10. package/dest/factory.d.ts +19 -13
  11. package/dest/factory.d.ts.map +1 -1
  12. package/dest/factory.js +15 -59
  13. package/dest/job/epoch-proving-job.d.ts +3 -2
  14. package/dest/job/epoch-proving-job.d.ts.map +1 -1
  15. package/dest/job/epoch-proving-job.js +29 -15
  16. package/dest/metrics.d.ts +1 -1
  17. package/dest/metrics.d.ts.map +1 -1
  18. package/dest/metrics.js +11 -3
  19. package/dest/prover-node-publisher.d.ts +6 -5
  20. package/dest/prover-node-publisher.d.ts.map +1 -1
  21. package/dest/prover-node-publisher.js +5 -4
  22. package/dest/prover-node.d.ts +19 -9
  23. package/dest/prover-node.d.ts.map +1 -1
  24. package/dest/prover-node.js +12 -9
  25. package/dest/prover-publisher-factory.d.ts +6 -4
  26. package/dest/prover-publisher-factory.d.ts.map +1 -1
  27. package/dest/prover-publisher-factory.js +4 -2
  28. package/package.json +22 -22
  29. package/src/actions/rerun-epoch-proving-job.ts +6 -4
  30. package/src/actions/upload-epoch-proof-failure.ts +1 -1
  31. package/src/bin/run-failed-epoch.ts +4 -1
  32. package/src/config.ts +22 -30
  33. package/src/factory.ts +48 -101
  34. package/src/job/epoch-proving-job.ts +45 -23
  35. package/src/metrics.ts +6 -2
  36. package/src/prover-node-publisher.ts +7 -5
  37. package/src/prover-node.ts +15 -9
  38. package/src/prover-publisher-factory.ts +13 -7
@@ -1,13 +1,12 @@
1
1
  import type { Archiver } from '@aztec/archiver';
2
2
  import type { RollupContract } from '@aztec/ethereum/contracts';
3
+ import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
3
4
  import { BlockNumber, CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
4
5
  import { assertRequired, compact, pick, sum } from '@aztec/foundation/collection';
5
6
  import type { Fr } from '@aztec/foundation/curves/bn254';
6
7
  import { memoize } from '@aztec/foundation/decorators';
7
8
  import { createLogger } from '@aztec/foundation/log';
8
9
  import { DateProvider } from '@aztec/foundation/timer';
9
- import type { DataStoreConfig } from '@aztec/kv-store/config';
10
- import type { P2PClient } from '@aztec/p2p';
11
10
  import { PublicProcessorFactory } from '@aztec/simulator/server';
12
11
  import type { L2BlockSource } from '@aztec/stdlib/block';
13
12
  import type { Checkpoint } from '@aztec/stdlib/checkpoint';
@@ -17,14 +16,15 @@ import { getProofSubmissionDeadlineTimestamp } from '@aztec/stdlib/epoch-helpers
17
16
  import {
18
17
  type EpochProverManager,
19
18
  EpochProvingJobTerminalState,
19
+ type ITxProvider,
20
20
  type ProverNodeApi,
21
21
  type Service,
22
22
  type WorldStateSyncStatus,
23
23
  type WorldStateSynchronizer,
24
24
  tryStop,
25
25
  } from '@aztec/stdlib/interfaces/server';
26
+ import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
26
27
  import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
27
- import type { P2PClientType } from '@aztec/stdlib/p2p';
28
28
  import type { Tx } from '@aztec/stdlib/tx';
29
29
  import {
30
30
  Attributes,
@@ -55,7 +55,6 @@ type DataStoreOptions = Pick<DataStoreConfig, 'dataDirectory'> & Pick<ChainConfi
55
55
  */
56
56
  export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable {
57
57
  private log = createLogger('prover-node');
58
- private dateProvider = new DateProvider();
59
58
 
60
59
  private jobs: Map<string, EpochProvingJob> = new Map();
61
60
  private config: ProverNodeOptions;
@@ -73,12 +72,14 @@ export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable
73
72
  protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
74
73
  protected readonly contractDataSource: ContractDataSource,
75
74
  protected readonly worldState: WorldStateSynchronizer,
76
- protected readonly p2pClient: Pick<P2PClient<P2PClientType.Prover>, 'getTxProvider'> & Partial<Service>,
75
+ protected readonly p2pClient: { getTxProvider(): ITxProvider } & Partial<Service>,
77
76
  protected readonly epochsMonitor: EpochMonitor,
78
77
  protected readonly rollupContract: RollupContract,
79
78
  protected readonly l1Metrics: L1Metrics,
80
79
  config: Partial<ProverNodeOptions> = {},
81
80
  protected readonly telemetryClient: TelemetryClient = getTelemetryClient(),
81
+ private delayer?: Delayer,
82
+ private readonly dateProvider: DateProvider = new DateProvider(),
82
83
  ) {
83
84
  this.config = {
84
85
  proverNodePollingIntervalMs: 1_000,
@@ -111,6 +112,11 @@ export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable
111
112
  return this.p2pClient;
112
113
  }
113
114
 
115
+ /** Returns the shared tx delayer for prover L1 txs, if enabled. Test-only. */
116
+ public getDelayer(): Delayer | undefined {
117
+ return this.delayer;
118
+ }
119
+
114
120
  /**
115
121
  * Handles an epoch being completed by starting a proof for it if there are no active jobs for it.
116
122
  * @param epochNumber - The epoch number that was just completed.
@@ -155,17 +161,15 @@ export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable
155
161
 
156
162
  /**
157
163
  * Stops the prover node and all its dependencies.
164
+ * Resources not owned by this node (shared with the parent aztec-node) are skipped.
158
165
  */
159
166
  async stop() {
160
167
  this.log.info('Stopping ProverNode');
161
168
  await this.epochsMonitor.stop();
162
169
  await this.prover.stop();
163
- await tryStop(this.p2pClient);
164
- await tryStop(this.l2BlockSource);
165
170
  await tryStop(this.publisherFactory);
166
171
  this.publisher?.interrupt();
167
172
  await Promise.all(Array.from(this.jobs.values()).map(job => job.stop()));
168
- await this.worldState.stop();
169
173
  this.rewardsMetrics.stop();
170
174
  this.l1Metrics.stop();
171
175
  await this.telemetryClient.stop();
@@ -288,6 +292,7 @@ export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable
288
292
  this.contractDataSource,
289
293
  this.dateProvider,
290
294
  this.telemetryClient,
295
+ this.log.getBindings(),
291
296
  );
292
297
 
293
298
  // Set deadline for this job to run. It will abort if it takes too long.
@@ -311,7 +316,7 @@ export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable
311
316
  const l1ToL2Messages = await this.gatherMessages(epochNumber, checkpoints);
312
317
  const [firstBlock] = checkpoints[0].blocks;
313
318
  const previousBlockHeader = await this.gatherPreviousBlockHeader(epochNumber, firstBlock.number - 1);
314
- const [lastPublishedCheckpoint] = await this.l2BlockSource.getPublishedCheckpoints(checkpoints.at(-1)!.number, 1);
319
+ const [lastPublishedCheckpoint] = await this.l2BlockSource.getCheckpoints(checkpoints.at(-1)!.number, 1);
315
320
  const attestations = lastPublishedCheckpoint?.attestations ?? [];
316
321
 
317
322
  return { checkpoints, txs, l1ToL2Messages, epochNumber, previousBlockHeader, attestations };
@@ -384,6 +389,7 @@ export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable
384
389
  this.jobMetrics,
385
390
  deadline,
386
391
  { parallelBlockLimit, skipSubmitProof: proverNodeDisableProofPublish, ...opts },
392
+ this.log.getBindings(),
387
393
  );
388
394
  }
389
395
 
@@ -1,19 +1,21 @@
1
1
  import type { RollupContract } from '@aztec/ethereum/contracts';
2
2
  import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
3
3
  import type { PublisherManager } from '@aztec/ethereum/publisher-manager';
4
- import type { PublisherConfig, TxSenderConfig } from '@aztec/sequencer-client';
4
+ import type { LoggerBindings } from '@aztec/foundation/log';
5
+ import type { ProverPublisherConfig, ProverTxSenderConfig } from '@aztec/sequencer-client';
5
6
  import type { TelemetryClient } from '@aztec/telemetry-client';
6
7
 
7
8
  import { ProverNodePublisher } from './prover-node-publisher.js';
8
9
 
9
10
  export class ProverPublisherFactory {
10
11
  constructor(
11
- private config: TxSenderConfig & PublisherConfig,
12
+ private config: ProverTxSenderConfig & ProverPublisherConfig,
12
13
  private deps: {
13
14
  rollupContract: RollupContract;
14
15
  publisherManager: PublisherManager<L1TxUtils>;
15
16
  telemetry?: TelemetryClient;
16
17
  },
18
+ private bindings?: LoggerBindings,
17
19
  ) {}
18
20
 
19
21
  public async start() {
@@ -30,10 +32,14 @@ export class ProverPublisherFactory {
30
32
  */
31
33
  public async create(): Promise<ProverNodePublisher> {
32
34
  const l1Publisher = await this.deps.publisherManager.getAvailablePublisher();
33
- return new ProverNodePublisher(this.config, {
34
- rollupContract: this.deps.rollupContract,
35
- l1TxUtils: l1Publisher,
36
- telemetry: this.deps.telemetry,
37
- });
35
+ return new ProverNodePublisher(
36
+ this.config,
37
+ {
38
+ rollupContract: this.deps.rollupContract,
39
+ l1TxUtils: l1Publisher,
40
+ telemetry: this.deps.telemetry,
41
+ },
42
+ this.bindings,
43
+ );
38
44
  }
39
45
  }