@aztec/prover-client 0.47.0 → 0.48.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.
Files changed (54) hide show
  1. package/dest/config.d.ts +2 -0
  2. package/dest/config.d.ts.map +1 -1
  3. package/dest/config.js +28 -30
  4. package/dest/mocks/fixtures.d.ts.map +1 -1
  5. package/dest/mocks/fixtures.js +11 -7
  6. package/dest/mocks/test_context.d.ts +3 -3
  7. package/dest/mocks/test_context.d.ts.map +1 -1
  8. package/dest/mocks/test_context.js +6 -24
  9. package/dest/orchestrator/block-building-helpers.d.ts +3 -3
  10. package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
  11. package/dest/orchestrator/block-building-helpers.js +6 -5
  12. package/dest/orchestrator/orchestrator.d.ts +11 -6
  13. package/dest/orchestrator/orchestrator.d.ts.map +1 -1
  14. package/dest/orchestrator/orchestrator.js +115 -89
  15. package/dest/orchestrator/orchestrator_metrics.d.ts +8 -0
  16. package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -0
  17. package/dest/orchestrator/orchestrator_metrics.js +19 -0
  18. package/dest/orchestrator/proving-state.d.ts +3 -1
  19. package/dest/orchestrator/proving-state.d.ts.map +1 -1
  20. package/dest/orchestrator/proving-state.js +5 -1
  21. package/dest/orchestrator/tx-proving-state.d.ts +3 -2
  22. package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
  23. package/dest/orchestrator/tx-proving-state.js +26 -8
  24. package/dest/prover-agent/memory-proving-queue.d.ts +15 -13
  25. package/dest/prover-agent/memory-proving-queue.d.ts.map +1 -1
  26. package/dest/prover-agent/memory-proving-queue.js +37 -55
  27. package/dest/prover-agent/prover-agent.d.ts.map +1 -1
  28. package/dest/prover-agent/prover-agent.js +30 -8
  29. package/dest/prover-agent/queue_metrics.d.ts +10 -0
  30. package/dest/prover-agent/queue_metrics.d.ts.map +1 -0
  31. package/dest/prover-agent/queue_metrics.js +23 -0
  32. package/dest/prover-agent/rpc.d.ts.map +1 -1
  33. package/dest/prover-agent/rpc.js +4 -2
  34. package/dest/tx-prover/factory.d.ts +1 -3
  35. package/dest/tx-prover/factory.d.ts.map +1 -1
  36. package/dest/tx-prover/factory.js +3 -3
  37. package/dest/tx-prover/tx-prover.d.ts +8 -33
  38. package/dest/tx-prover/tx-prover.d.ts.map +1 -1
  39. package/dest/tx-prover/tx-prover.js +18 -46
  40. package/package.json +10 -10
  41. package/src/config.ts +28 -47
  42. package/src/mocks/fixtures.ts +14 -4
  43. package/src/mocks/test_context.ts +7 -27
  44. package/src/orchestrator/block-building-helpers.ts +6 -5
  45. package/src/orchestrator/orchestrator.ts +197 -103
  46. package/src/orchestrator/orchestrator_metrics.ts +32 -0
  47. package/src/orchestrator/proving-state.ts +5 -0
  48. package/src/orchestrator/tx-proving-state.ts +33 -7
  49. package/src/prover-agent/memory-proving-queue.ts +54 -70
  50. package/src/prover-agent/prover-agent.ts +42 -7
  51. package/src/prover-agent/queue_metrics.ts +29 -0
  52. package/src/prover-agent/rpc.ts +3 -0
  53. package/src/tx-prover/factory.ts +2 -9
  54. package/src/tx-prover/tx-prover.ts +21 -64
@@ -1,16 +1,14 @@
1
1
  import { BBNativeRollupProver, TestCircuitProver } from '@aztec/bb-prover';
2
- import { type L2BlockSource, type ProcessedTx } from '@aztec/circuit-types';
3
2
  import {
4
- type BlockResult,
3
+ type BlockProver,
5
4
  type ProverClient,
6
5
  type ProvingJobSource,
7
- type ProvingTicket,
8
6
  type ServerCircuitProver,
9
7
  } from '@aztec/circuit-types/interfaces';
10
- import { type Fr, type GlobalVariables } from '@aztec/circuits.js';
8
+ import { Fr } from '@aztec/circuits.js';
11
9
  import { NativeACVMSimulator } from '@aztec/simulator';
12
10
  import { type TelemetryClient } from '@aztec/telemetry-client';
13
- import { type WorldStateSynchronizer } from '@aztec/world-state';
11
+ import { type MerkleTreeOperations } from '@aztec/world-state';
14
12
 
15
13
  import { type ProverClientConfig } from '../config.js';
16
14
  import { ProvingOrchestrator } from '../orchestrator/orchestrator.js';
@@ -18,21 +16,29 @@ import { MemoryProvingQueue } from '../prover-agent/memory-proving-queue.js';
18
16
  import { ProverAgent } from '../prover-agent/prover-agent.js';
19
17
 
20
18
  /**
21
- * A prover accepting individual transaction requests
19
+ * A prover factory.
20
+ * TODO(palla/prover-node): Rename this class
22
21
  */
23
22
  export class TxProver implements ProverClient {
24
- private orchestrator: ProvingOrchestrator;
25
23
  private queue: MemoryProvingQueue;
26
24
  private running = false;
27
25
 
28
26
  private constructor(
29
27
  private config: ProverClientConfig,
30
- private worldStateSynchronizer: WorldStateSynchronizer,
31
28
  private telemetry: TelemetryClient,
32
29
  private agent?: ProverAgent,
33
30
  ) {
34
- this.queue = new MemoryProvingQueue(config.proverJobTimeoutMs, config.proverJobPollIntervalMs);
35
- this.orchestrator = new ProvingOrchestrator(worldStateSynchronizer.getLatest(), this.queue, telemetry);
31
+ // TODO(palla/prover-node): Cache the paddingTx here, and not in each proving orchestrator,
32
+ // so it can be reused across multiple ones and not recomputed every time.
33
+ this.queue = new MemoryProvingQueue(telemetry, config.proverJobTimeoutMs, config.proverJobPollIntervalMs);
34
+ }
35
+
36
+ public createBlockProver(db: MerkleTreeOperations): BlockProver {
37
+ return new ProvingOrchestrator(db, this.queue, this.telemetry, this.config.proverId);
38
+ }
39
+
40
+ public getProverId(): Fr {
41
+ return this.config.proverId ?? Fr.ZERO;
36
42
  }
37
43
 
38
44
  async updateProverConfig(config: Partial<ProverClientConfig>): Promise<void> {
@@ -48,7 +54,7 @@ export class TxProver implements ProverClient {
48
54
  }
49
55
 
50
56
  if (!this.config.realProofs && newConfig.realProofs) {
51
- this.orchestrator.reset();
57
+ // TODO(palla/prover-node): Reset padding tx here once we cache it at this class
52
58
  }
53
59
 
54
60
  this.config = newConfig;
@@ -76,6 +82,8 @@ export class TxProver implements ProverClient {
76
82
  return;
77
83
  }
78
84
  this.running = false;
85
+
86
+ // TODO(palla/prover-node): Keep a reference to all proving orchestrators that are alive and stop them?
79
87
  await this.agent?.stop();
80
88
  await this.queue.stop();
81
89
  }
@@ -87,12 +95,7 @@ export class TxProver implements ProverClient {
87
95
  * @param worldStateSynchronizer - An instance of the world state
88
96
  * @returns An instance of the prover, constructed and started.
89
97
  */
90
- public static async new(
91
- config: ProverClientConfig,
92
- worldStateSynchronizer: WorldStateSynchronizer,
93
- blockSource: L2BlockSource,
94
- telemetry: TelemetryClient,
95
- ) {
98
+ public static async new(config: ProverClientConfig, telemetry: TelemetryClient) {
96
99
  const agent = config.proverAgentEnabled
97
100
  ? new ProverAgent(
98
101
  await TxProver.buildCircuitProver(config, telemetry),
@@ -101,7 +104,7 @@ export class TxProver implements ProverClient {
101
104
  )
102
105
  : undefined;
103
106
 
104
- const prover = new TxProver(config, worldStateSynchronizer, telemetry, agent);
107
+ const prover = new TxProver(config, telemetry, agent);
105
108
  await prover.start();
106
109
  return prover;
107
110
  }
@@ -121,52 +124,6 @@ export class TxProver implements ProverClient {
121
124
  return new TestCircuitProver(telemetry, simulationProvider);
122
125
  }
123
126
 
124
- /**
125
- * Cancels any block that is currently being built and prepares for a new one to be built
126
- * @param numTxs - The complete size of the block, must be a power of 2
127
- * @param globalVariables - The global variables for this block
128
- * @param l1ToL2Messages - The set of L1 to L2 messages to be included in this block
129
- */
130
- public async startNewBlock(
131
- numTxs: number,
132
- globalVariables: GlobalVariables,
133
- newL1ToL2Messages: Fr[],
134
- ): Promise<ProvingTicket> {
135
- const previousBlockNumber = globalVariables.blockNumber.toNumber() - 1;
136
- await this.worldStateSynchronizer.syncImmediate(previousBlockNumber);
137
- return this.orchestrator.startNewBlock(numTxs, globalVariables, newL1ToL2Messages);
138
- }
139
-
140
- /**
141
- * Add a processed transaction to the current block
142
- * @param tx - The transaction to be added
143
- */
144
- public addNewTx(tx: ProcessedTx): Promise<void> {
145
- return this.orchestrator.addNewTx(tx);
146
- }
147
-
148
- /**
149
- * Cancels the block currently being proven. Proofs already bring built may continue but further proofs should not be started.
150
- */
151
- public cancelBlock(): void {
152
- this.orchestrator.cancelBlock();
153
- }
154
-
155
- /**
156
- * Performs the final archive tree insertion for this block and returns the L2Block and Proof instances
157
- */
158
- public finaliseBlock(): Promise<BlockResult> {
159
- return this.orchestrator.finaliseBlock();
160
- }
161
-
162
- /**
163
- * Mark the block as having all the transactions it is going to contain.
164
- * Will pad the block to it's complete size with empty transactions and prove all the way to the root rollup.
165
- */
166
- public setBlockCompleted(): Promise<void> {
167
- return this.orchestrator.setBlockCompleted();
168
- }
169
-
170
127
  public getProvingJobSource(): ProvingJobSource {
171
128
  return this.queue;
172
129
  }