@aztec/prover-client 0.0.1-commit.b655e406 → 0.0.1-commit.b9865e97

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 (174) hide show
  1. package/dest/config.d.ts +2 -2
  2. package/dest/config.d.ts.map +1 -1
  3. package/dest/config.js +17 -3
  4. package/dest/index.d.ts +1 -1
  5. package/dest/light/index.d.ts +2 -0
  6. package/dest/light/index.d.ts.map +1 -0
  7. package/dest/light/index.js +1 -0
  8. package/dest/light/lightweight_checkpoint_builder.d.ts +52 -0
  9. package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -0
  10. package/dest/light/lightweight_checkpoint_builder.js +231 -0
  11. package/dest/mocks/fixtures.d.ts +1 -4
  12. package/dest/mocks/fixtures.d.ts.map +1 -1
  13. package/dest/mocks/fixtures.js +9 -18
  14. package/dest/mocks/test_context.d.ts +31 -46
  15. package/dest/mocks/test_context.d.ts.map +1 -1
  16. package/dest/mocks/test_context.js +133 -123
  17. package/dest/orchestrator/block-building-helpers.d.ts +18 -20
  18. package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
  19. package/dest/orchestrator/block-building-helpers.js +90 -115
  20. package/dest/orchestrator/block-proving-state.d.ts +20 -11
  21. package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
  22. package/dest/orchestrator/block-proving-state.js +87 -19
  23. package/dest/orchestrator/checkpoint-proving-state.d.ts +29 -9
  24. package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
  25. package/dest/orchestrator/checkpoint-proving-state.js +62 -21
  26. package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts +107 -0
  27. package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts.map +1 -0
  28. package/dest/orchestrator/checkpoint-sub-tree-orchestrator.js +151 -0
  29. package/dest/orchestrator/epoch-proving-context.d.ts +51 -0
  30. package/dest/orchestrator/epoch-proving-context.d.ts.map +1 -0
  31. package/dest/orchestrator/epoch-proving-context.js +81 -0
  32. package/dest/orchestrator/epoch-proving-state.d.ts +12 -10
  33. package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
  34. package/dest/orchestrator/epoch-proving-state.js +40 -4
  35. package/dest/orchestrator/index.d.ts +4 -1
  36. package/dest/orchestrator/index.d.ts.map +1 -1
  37. package/dest/orchestrator/index.js +3 -0
  38. package/dest/orchestrator/orchestrator.d.ts +37 -32
  39. package/dest/orchestrator/orchestrator.d.ts.map +1 -1
  40. package/dest/orchestrator/orchestrator.js +568 -303
  41. package/dest/orchestrator/orchestrator_metrics.d.ts +1 -3
  42. package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
  43. package/dest/orchestrator/orchestrator_metrics.js +2 -15
  44. package/dest/orchestrator/proving-scheduler.d.ts +72 -0
  45. package/dest/orchestrator/proving-scheduler.d.ts.map +1 -0
  46. package/dest/orchestrator/proving-scheduler.js +117 -0
  47. package/dest/orchestrator/top-tree-orchestrator.d.ts +83 -0
  48. package/dest/orchestrator/top-tree-orchestrator.d.ts.map +1 -0
  49. package/dest/orchestrator/top-tree-orchestrator.js +182 -0
  50. package/dest/orchestrator/top-tree-proving-scheduler.d.ts +62 -0
  51. package/dest/orchestrator/top-tree-proving-scheduler.d.ts.map +1 -0
  52. package/dest/orchestrator/top-tree-proving-scheduler.js +73 -0
  53. package/dest/orchestrator/top-tree-proving-state.d.ts +61 -0
  54. package/dest/orchestrator/top-tree-proving-state.d.ts.map +1 -0
  55. package/dest/orchestrator/top-tree-proving-state.js +185 -0
  56. package/dest/orchestrator/tx-proving-state.d.ts +6 -5
  57. package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
  58. package/dest/orchestrator/tx-proving-state.js +7 -16
  59. package/dest/prover-client/factory.d.ts +3 -3
  60. package/dest/prover-client/factory.d.ts.map +1 -1
  61. package/dest/prover-client/index.d.ts +1 -1
  62. package/dest/prover-client/prover-client.d.ts +66 -7
  63. package/dest/prover-client/prover-client.d.ts.map +1 -1
  64. package/dest/prover-client/prover-client.js +64 -11
  65. package/dest/prover-client/server-epoch-prover.d.ts +8 -7
  66. package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
  67. package/dest/prover-client/server-epoch-prover.js +2 -2
  68. package/dest/proving_broker/broker_prover_facade.d.ts +25 -23
  69. package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
  70. package/dest/proving_broker/broker_prover_facade.js +21 -33
  71. package/dest/proving_broker/config.d.ts +14 -62
  72. package/dest/proving_broker/config.d.ts.map +1 -1
  73. package/dest/proving_broker/config.js +29 -6
  74. package/dest/proving_broker/factory.d.ts +1 -1
  75. package/dest/proving_broker/fixtures.d.ts +3 -2
  76. package/dest/proving_broker/fixtures.d.ts.map +1 -1
  77. package/dest/proving_broker/fixtures.js +3 -2
  78. package/dest/proving_broker/index.d.ts +2 -1
  79. package/dest/proving_broker/index.d.ts.map +1 -1
  80. package/dest/proving_broker/index.js +1 -0
  81. package/dest/proving_broker/proof_store/factory.d.ts +2 -5
  82. package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
  83. package/dest/proving_broker/proof_store/factory.js +7 -30
  84. package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
  85. package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
  86. package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
  87. package/dest/proving_broker/proof_store/index.d.ts +2 -2
  88. package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
  89. package/dest/proving_broker/proof_store/index.js +1 -1
  90. package/dest/proving_broker/proof_store/inline_proof_store.d.ts +1 -1
  91. package/dest/proving_broker/proof_store/inline_proof_store.d.ts.map +1 -1
  92. package/dest/proving_broker/proof_store/proof_store.d.ts +1 -1
  93. package/dest/proving_broker/proving_agent.d.ts +5 -9
  94. package/dest/proving_broker/proving_agent.d.ts.map +1 -1
  95. package/dest/proving_broker/proving_agent.js +4 -19
  96. package/dest/proving_broker/proving_broker.d.ts +8 -5
  97. package/dest/proving_broker/proving_broker.d.ts.map +1 -1
  98. package/dest/proving_broker/proving_broker.js +74 -22
  99. package/dest/proving_broker/proving_broker_database/memory.d.ts +3 -2
  100. package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
  101. package/dest/proving_broker/proving_broker_database/persisted.d.ts +5 -3
  102. package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
  103. package/dest/proving_broker/proving_broker_database/persisted.js +394 -5
  104. package/dest/proving_broker/proving_broker_database.d.ts +3 -2
  105. package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
  106. package/dest/proving_broker/proving_broker_instrumentation.d.ts +3 -1
  107. package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
  108. package/dest/proving_broker/proving_broker_instrumentation.js +22 -35
  109. package/dest/proving_broker/proving_job_controller.d.ts +5 -3
  110. package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
  111. package/dest/proving_broker/proving_job_controller.js +8 -6
  112. package/dest/proving_broker/rpc.d.ts +9 -5
  113. package/dest/proving_broker/rpc.d.ts.map +1 -1
  114. package/dest/proving_broker/rpc.js +87 -23
  115. package/dest/test/mock_proof_store.d.ts +1 -1
  116. package/dest/test/mock_proof_store.d.ts.map +1 -1
  117. package/dest/test/mock_prover.d.ts +5 -6
  118. package/dest/test/mock_prover.d.ts.map +1 -1
  119. package/dest/test/mock_prover.js +4 -4
  120. package/package.json +23 -22
  121. package/src/config.ts +19 -3
  122. package/src/light/index.ts +1 -0
  123. package/src/light/lightweight_checkpoint_builder.ts +320 -0
  124. package/src/mocks/fixtures.ts +9 -31
  125. package/src/mocks/test_context.ts +170 -185
  126. package/src/orchestrator/block-building-helpers.ts +129 -209
  127. package/src/orchestrator/block-proving-state.ts +109 -22
  128. package/src/orchestrator/checkpoint-proving-state.ts +89 -26
  129. package/src/orchestrator/checkpoint-sub-tree-orchestrator.ts +271 -0
  130. package/src/orchestrator/epoch-proving-context.ts +101 -0
  131. package/src/orchestrator/epoch-proving-state.ts +67 -15
  132. package/src/orchestrator/index.ts +8 -0
  133. package/src/orchestrator/orchestrator.ts +193 -354
  134. package/src/orchestrator/orchestrator_metrics.ts +2 -25
  135. package/src/orchestrator/proving-scheduler.ts +156 -0
  136. package/src/orchestrator/top-tree-orchestrator.ts +314 -0
  137. package/src/orchestrator/top-tree-proving-scheduler.ts +154 -0
  138. package/src/orchestrator/top-tree-proving-state.ts +220 -0
  139. package/src/orchestrator/tx-proving-state.ts +10 -27
  140. package/src/prover-client/factory.ts +6 -2
  141. package/src/prover-client/prover-client.ts +157 -24
  142. package/src/prover-client/server-epoch-prover.ts +6 -7
  143. package/src/proving_broker/broker_prover_facade.ts +46 -55
  144. package/src/proving_broker/config.ts +33 -3
  145. package/src/proving_broker/fixtures.ts +8 -3
  146. package/src/proving_broker/index.ts +1 -0
  147. package/src/proving_broker/proof_store/factory.ts +10 -32
  148. package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
  149. package/src/proving_broker/proof_store/index.ts +1 -1
  150. package/src/proving_broker/proving_agent.ts +6 -19
  151. package/src/proving_broker/proving_broker.ts +70 -17
  152. package/src/proving_broker/proving_broker_database/memory.ts +2 -1
  153. package/src/proving_broker/proving_broker_database/persisted.ts +22 -7
  154. package/src/proving_broker/proving_broker_database.ts +2 -1
  155. package/src/proving_broker/proving_broker_instrumentation.ts +23 -35
  156. package/src/proving_broker/proving_job_controller.ts +13 -7
  157. package/src/proving_broker/rpc.ts +46 -20
  158. package/src/test/mock_prover.ts +2 -14
  159. package/dest/block-factory/index.d.ts +0 -2
  160. package/dest/block-factory/index.d.ts.map +0 -1
  161. package/dest/block-factory/index.js +0 -1
  162. package/dest/block-factory/light.d.ts +0 -38
  163. package/dest/block-factory/light.d.ts.map +0 -1
  164. package/dest/block-factory/light.js +0 -94
  165. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +0 -14
  166. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +0 -1
  167. package/dest/proving_broker/proof_store/gcs_proof_store.js +0 -52
  168. package/dest/proving_broker/proving_agent_instrumentation.d.ts +0 -8
  169. package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +0 -1
  170. package/dest/proving_broker/proving_agent_instrumentation.js +0 -16
  171. package/src/block-factory/index.ts +0 -1
  172. package/src/block-factory/light.ts +0 -140
  173. package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
  174. package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
@@ -1,13 +1,20 @@
1
1
  import { BatchedBlob, BatchedBlobAccumulator, type FinalBlobBatchingChallenges } from '@aztec/blob-lib';
2
- import type {
3
- ARCHIVE_HEIGHT,
4
- L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
5
- NESTED_RECURSIVE_PROOF_LENGTH,
6
- NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
2
+ import {
3
+ type ARCHIVE_HEIGHT,
4
+ type L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
5
+ type NESTED_RECURSIVE_PROOF_LENGTH,
6
+ type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
7
+ OUT_HASH_TREE_HEIGHT,
7
8
  } from '@aztec/constants';
8
- import type { Fr } from '@aztec/foundation/fields';
9
+ import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
10
+ import { Fr } from '@aztec/foundation/curves/bn254';
9
11
  import type { Tuple } from '@aztec/foundation/serialize';
10
- import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
12
+ import {
13
+ MerkleTreeCalculator,
14
+ type TreeNodeLocation,
15
+ UnbalancedTreeStore,
16
+ shaMerkleHash,
17
+ } from '@aztec/foundation/trees';
11
18
  import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
12
19
  import type { Proof } from '@aztec/stdlib/proofs';
13
20
  import {
@@ -19,7 +26,7 @@ import {
19
26
  RootRollupPrivateInputs,
20
27
  type RootRollupPublicInputs,
21
28
  } from '@aztec/stdlib/rollup';
22
- import type { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
29
+ import { AppendOnlyTreeSnapshot, type MerkleTreeId } from '@aztec/stdlib/trees';
23
30
  import type { BlockHeader } from '@aztec/stdlib/tx';
24
31
 
25
32
  import { toProofData } from './block-building-helpers.js';
@@ -66,10 +73,10 @@ export class EpochProvingState {
66
73
  >();
67
74
 
68
75
  constructor(
69
- public readonly epochNumber: number,
76
+ public readonly epochNumber: EpochNumber,
70
77
  public readonly totalNumCheckpoints: number,
71
78
  private readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
72
- private onCheckpointBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => void,
79
+ private onCheckpointBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => Promise<void>,
73
80
  private completionCallback: (result: ProvingResult) => void,
74
81
  private rejectionCallback: (reason: string) => void,
75
82
  ) {
@@ -83,7 +90,6 @@ export class EpochProvingState {
83
90
  checkpointIndex: number,
84
91
  constants: CheckpointConstantData,
85
92
  totalNumBlocks: number,
86
- totalNumBlobFields: number,
87
93
  previousBlockHeader: BlockHeader,
88
94
  lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
89
95
  l1ToL2Messages: Fr[],
@@ -102,7 +108,6 @@ export class EpochProvingState {
102
108
  checkpointIndex,
103
109
  constants,
104
110
  totalNumBlocks,
105
- totalNumBlobFields,
106
111
  this.finalBlobBatchingChallenges,
107
112
  previousBlockHeader,
108
113
  lastArchiveSiblingPath,
@@ -127,13 +132,16 @@ export class EpochProvingState {
127
132
  return this.checkpoints[index];
128
133
  }
129
134
 
130
- public getCheckpointProvingStateByBlockNumber(blockNumber: number) {
135
+ public getCheckpointProvingStateByBlockNumber(blockNumber: BlockNumber) {
131
136
  return this.checkpoints.find(
132
- c => c && blockNumber >= c.firstBlockNumber && blockNumber < c.firstBlockNumber + c.totalNumBlocks,
137
+ c =>
138
+ c &&
139
+ Number(blockNumber) >= Number(c.firstBlockNumber) &&
140
+ Number(blockNumber) < Number(c.firstBlockNumber) + c.totalNumBlocks,
133
141
  );
134
142
  }
135
143
 
136
- public getBlockProvingStateByBlockNumber(blockNumber: number) {
144
+ public getBlockProvingStateByBlockNumber(blockNumber: BlockNumber) {
137
145
  return this.getCheckpointProvingStateByBlockNumber(blockNumber)?.getBlockProvingStateByBlockNumber(blockNumber);
138
146
  }
139
147
 
@@ -210,6 +218,50 @@ export class EpochProvingState {
210
218
  this.checkpointPaddingProof = { provingOutput };
211
219
  }
212
220
 
221
+ public async accumulateCheckpointOutHashes() {
222
+ const treeCalculator = await MerkleTreeCalculator.create(OUT_HASH_TREE_HEIGHT, undefined, (left, right) =>
223
+ Promise.resolve(shaMerkleHash(left, right)),
224
+ );
225
+
226
+ const computeOutHashHint = async (leaves: Fr[]) => {
227
+ const tree = await treeCalculator.computeTree(leaves.map(l => l.toBuffer()));
228
+ const nextAvailableLeafIndex = leaves.length;
229
+ return {
230
+ treeSnapshot: new AppendOnlyTreeSnapshot(Fr.fromBuffer(tree.root), nextAvailableLeafIndex),
231
+ siblingPath: tree.getSiblingPath(nextAvailableLeafIndex).map(Fr.fromBuffer) as Tuple<
232
+ Fr,
233
+ typeof OUT_HASH_TREE_HEIGHT
234
+ >,
235
+ };
236
+ };
237
+
238
+ let hint = this.checkpoints[0]?.getOutHashHint();
239
+ const outHashes = [];
240
+ for (let i = 0; i < this.totalNumCheckpoints; i++) {
241
+ const checkpoint = this.checkpoints[i];
242
+ if (!checkpoint) {
243
+ break;
244
+ }
245
+
246
+ // If hints are not set yet, it must be the first checkpoint. Compute the hints with an empty tree.
247
+ hint ??= await computeOutHashHint([]);
248
+ checkpoint.setOutHashHint(hint);
249
+
250
+ // Get the out hash for this checkpoint.
251
+ const outHash = checkpoint.accumulateBlockOutHashes();
252
+ if (!outHash) {
253
+ break;
254
+ }
255
+ outHashes.push(outHash);
256
+
257
+ // If this is NOT the last checkpoint, get or create the hint for the next checkpoint.
258
+ if (i !== this.totalNumCheckpoints - 1) {
259
+ hint = checkpoint.getOutHashHintForNextCheckpoint() ?? (await computeOutHashHint(outHashes));
260
+ checkpoint.setOutHashHintForNextCheckpoint(hint);
261
+ }
262
+ }
263
+ }
264
+
213
265
  public async setBlobAccumulators() {
214
266
  let previousAccumulator = this.startBlobAccumulator;
215
267
  // Accumulate blobs as far as we can for this epoch.
@@ -1 +1,9 @@
1
1
  export { ProvingOrchestrator } from './orchestrator.js';
2
+ export { CheckpointSubTreeOrchestrator, type SubTreeResult } from './checkpoint-sub-tree-orchestrator.js';
3
+ export { EpochProvingContext, type ChonkVerifierProofResult } from './epoch-proving-context.js';
4
+ export {
5
+ TopTreeOrchestrator,
6
+ TopTreeCancelledError,
7
+ type CheckpointTopTreeData,
8
+ type TopTreeResult,
9
+ } from './top-tree-orchestrator.js';