@aztec/prover-client 0.0.1-commit.ee80a48 → 0.0.1-commit.f103f88

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 (74) hide show
  1. package/dest/config.d.ts +1 -1
  2. package/dest/config.d.ts.map +1 -1
  3. package/dest/config.js +12 -2
  4. package/dest/light/lightweight_checkpoint_builder.d.ts +10 -5
  5. package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
  6. package/dest/light/lightweight_checkpoint_builder.js +41 -18
  7. package/dest/mocks/test_context.d.ts +1 -1
  8. package/dest/mocks/test_context.d.ts.map +1 -1
  9. package/dest/mocks/test_context.js +17 -9
  10. package/dest/orchestrator/block-building-helpers.d.ts +4 -4
  11. package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
  12. package/dest/orchestrator/block-building-helpers.js +2 -2
  13. package/dest/orchestrator/block-proving-state.d.ts +4 -1
  14. package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
  15. package/dest/orchestrator/block-proving-state.js +7 -0
  16. package/dest/orchestrator/checkpoint-proving-state.d.ts +3 -3
  17. package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
  18. package/dest/orchestrator/checkpoint-proving-state.js +3 -3
  19. package/dest/orchestrator/epoch-proving-state.d.ts +3 -3
  20. package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
  21. package/dest/orchestrator/epoch-proving-state.js +5 -3
  22. package/dest/orchestrator/orchestrator.d.ts +5 -3
  23. package/dest/orchestrator/orchestrator.d.ts.map +1 -1
  24. package/dest/orchestrator/orchestrator.js +64 -57
  25. package/dest/prover-client/prover-client.d.ts +4 -4
  26. package/dest/prover-client/prover-client.d.ts.map +1 -1
  27. package/dest/prover-client/prover-client.js +9 -7
  28. package/dest/proving_broker/broker_prover_facade.d.ts +1 -1
  29. package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
  30. package/dest/proving_broker/broker_prover_facade.js +13 -19
  31. package/dest/proving_broker/config.d.ts +10 -2
  32. package/dest/proving_broker/config.d.ts.map +1 -1
  33. package/dest/proving_broker/config.js +15 -4
  34. package/dest/proving_broker/proof_store/factory.d.ts +2 -5
  35. package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
  36. package/dest/proving_broker/proof_store/factory.js +7 -30
  37. package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
  38. package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
  39. package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
  40. package/dest/proving_broker/proof_store/index.d.ts +2 -2
  41. package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
  42. package/dest/proving_broker/proof_store/index.js +1 -1
  43. package/dest/proving_broker/proving_broker.d.ts +7 -4
  44. package/dest/proving_broker/proving_broker.d.ts.map +1 -1
  45. package/dest/proving_broker/proving_broker.js +56 -8
  46. package/dest/proving_broker/proving_broker_instrumentation.d.ts +3 -1
  47. package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
  48. package/dest/proving_broker/proving_broker_instrumentation.js +7 -0
  49. package/dest/proving_broker/rpc.d.ts +6 -2
  50. package/dest/proving_broker/rpc.d.ts.map +1 -1
  51. package/dest/proving_broker/rpc.js +24 -15
  52. package/dest/test/mock_prover.d.ts +4 -4
  53. package/package.json +17 -18
  54. package/src/config.ts +13 -2
  55. package/src/light/lightweight_checkpoint_builder.ts +42 -19
  56. package/src/mocks/test_context.ts +12 -10
  57. package/src/orchestrator/block-building-helpers.ts +2 -2
  58. package/src/orchestrator/block-proving-state.ts +9 -0
  59. package/src/orchestrator/checkpoint-proving-state.ts +4 -4
  60. package/src/orchestrator/epoch-proving-state.ts +6 -4
  61. package/src/orchestrator/orchestrator.ts +72 -63
  62. package/src/prover-client/prover-client.ts +8 -9
  63. package/src/proving_broker/broker_prover_facade.ts +17 -20
  64. package/src/proving_broker/config.ts +15 -2
  65. package/src/proving_broker/proof_store/factory.ts +10 -32
  66. package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
  67. package/src/proving_broker/proof_store/index.ts +1 -1
  68. package/src/proving_broker/proving_broker.ts +55 -5
  69. package/src/proving_broker/proving_broker_instrumentation.ts +9 -0
  70. package/src/proving_broker/rpc.ts +26 -3
  71. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +0 -14
  72. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +0 -1
  73. package/dest/proving_broker/proof_store/gcs_proof_store.js +0 -52
  74. package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
@@ -7,6 +7,7 @@ import {
7
7
  type GetProvingJobResponse,
8
8
  type ProofUri,
9
9
  type ProvingJob,
10
+ type ProvingJobBrokerDebug,
10
11
  type ProvingJobConsumer,
11
12
  type ProvingJobFilter,
12
13
  type ProvingJobId,
@@ -36,7 +37,7 @@ type EnqueuedProvingJob = Pick<ProvingJob, 'id' | 'epochNumber'>;
36
37
  * A broker that manages proof requests and distributes them to workers based on their priority.
37
38
  * It takes a backend that is responsible for storing and retrieving proof requests and results.
38
39
  */
39
- export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Traceable {
40
+ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, ProvingJobBrokerDebug, Traceable {
40
41
  private queues: ProvingQueues = {
41
42
  [ProvingRequestType.PUBLIC_VM]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
42
43
  [ProvingRequestType.PUBLIC_CHONK_VERIFIER]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
@@ -114,6 +115,8 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
114
115
 
115
116
  private started = false;
116
117
 
118
+ private debugReplayEnabled: boolean;
119
+
117
120
  public constructor(
118
121
  private database: ProvingBrokerDatabase,
119
122
  {
@@ -121,6 +124,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
121
124
  proverBrokerPollIntervalMs,
122
125
  proverBrokerJobMaxRetries,
123
126
  proverBrokerMaxEpochsToKeepResultsFor,
127
+ proverBrokerDebugReplayEnabled,
124
128
  }: Required<
125
129
  Pick<
126
130
  ProverBrokerConfig,
@@ -128,6 +132,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
128
132
  | 'proverBrokerPollIntervalMs'
129
133
  | 'proverBrokerJobMaxRetries'
130
134
  | 'proverBrokerMaxEpochsToKeepResultsFor'
135
+ | 'proverBrokerDebugReplayEnabled'
131
136
  >
132
137
  > = defaultProverBrokerConfig,
133
138
  client: TelemetryClient = getTelemetryClient(),
@@ -139,6 +144,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
139
144
  this.jobTimeoutMs = proverBrokerJobTimeoutMs!;
140
145
  this.maxRetries = proverBrokerJobMaxRetries!;
141
146
  this.maxEpochsToKeepResultsFor = proverBrokerMaxEpochsToKeepResultsFor!;
147
+ this.debugReplayEnabled = proverBrokerDebugReplayEnabled ?? false;
142
148
  }
143
149
 
144
150
  private measureQueueDepth: MonitorCallback = (type: ProvingRequestType) => {
@@ -241,6 +247,29 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
241
247
  return Promise.resolve(this.#reportProvingJobProgress(id, startedAt, filter));
242
248
  }
243
249
 
250
+ public async replayProvingJob(
251
+ jobId: ProvingJobId,
252
+ type: ProvingRequestType,
253
+ epochNumber: EpochNumber,
254
+ inputsUri: ProofUri,
255
+ ): Promise<ProvingJobStatus> {
256
+ if (!this.debugReplayEnabled) {
257
+ throw new Error('Debug replay not enabled. Set PROVER_BROKER_DEBUG_REPLAY_ENABLED=true');
258
+ }
259
+
260
+ this.logger.info(`Replaying proving job`, { provingJobId: jobId, epochNumber, inputsUri });
261
+
262
+ // Clear existing state and enqueue
263
+ this.cleanUpProvingJobState([jobId]);
264
+
265
+ const job: ProvingJob = { id: jobId, type, epochNumber, inputsUri };
266
+ this.jobsCache.set(jobId, job);
267
+ await this.database.addProvingJob(job);
268
+ this.enqueueJobInternal(job);
269
+
270
+ return { status: 'in-queue' };
271
+ }
272
+
244
273
  async #enqueueProvingJob(job: ProvingJob): Promise<ProvingJobStatus> {
245
274
  // We return the job status at the start of this call
246
275
  const jobStatus = this.#getProvingJobStatus(job.id);
@@ -285,7 +314,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
285
314
  // notify listeners of the cancellation
286
315
  if (!this.resultsCache.has(id)) {
287
316
  this.logger.info(`Cancelling job id=${id}`, { provingJobId: id });
288
- await this.#reportProvingJobError(id, 'Aborted', false);
317
+ await this.#reportProvingJobError(id, 'Aborted', false, undefined, true);
289
318
  }
290
319
  }
291
320
 
@@ -366,6 +395,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
366
395
  err: string,
367
396
  retry = false,
368
397
  filter?: ProvingJobFilter,
398
+ aborted = false,
369
399
  ): Promise<GetProvingJobResponse | undefined> {
370
400
  const info = this.inProgress.get(id);
371
401
  const item = this.jobsCache.get(id);
@@ -426,7 +456,11 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
426
456
  this.promises.get(id)!.resolve(result);
427
457
  this.completedJobNotifications.push(id);
428
458
 
429
- this.instrumentation.incRejectedJobs(item.type);
459
+ if (aborted) {
460
+ this.instrumentation.incAbortedJobs(item.type);
461
+ } else {
462
+ this.instrumentation.incRejectedJobs(item.type);
463
+ }
430
464
  if (info) {
431
465
  const duration = this.msTimeSource() - info.startedAt;
432
466
  this.instrumentation.recordJobDuration(item.type, duration);
@@ -598,10 +632,26 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
598
632
  const now = this.msTimeSource();
599
633
  const msSinceLastUpdate = now - metadata.lastUpdatedAt;
600
634
  if (msSinceLastUpdate >= this.jobTimeoutMs) {
601
- this.logger.warn(`Proving job id=${id} timed out. Adding it back to the queue.`, { provingJobId: id });
602
635
  this.inProgress.delete(id);
603
- this.enqueueJobInternal(item);
604
636
  this.instrumentation.incTimedOutJobs(item.type);
637
+
638
+ const retries = this.retries.get(id) ?? 0;
639
+ if (retries + 1 < this.maxRetries && !this.isJobStale(item)) {
640
+ this.logger.warn(`Proving job id=${id} timed out. Re-enqueueing (retry ${retries + 1}/${this.maxRetries}).`, {
641
+ provingJobId: id,
642
+ });
643
+ this.retries.set(id, retries + 1);
644
+ this.enqueueJobInternal(item);
645
+ } else {
646
+ this.logger.error(`Proving job id=${id} timed out after ${retries + 1} attempts. Marking as failed.`, {
647
+ provingJobId: id,
648
+ });
649
+ const result: ProvingJobSettledResult = { status: 'rejected', reason: 'Timed out' };
650
+ this.resultsCache.set(id, result);
651
+ this.promises.get(id)?.resolve(result);
652
+ this.completedJobNotifications.push(id);
653
+ this.instrumentation.incRejectedJobs(item.type);
654
+ }
605
655
  }
606
656
  }
607
657
  }
@@ -18,6 +18,7 @@ export class ProvingBrokerInstrumentation {
18
18
  private activeJobs: ObservableGauge;
19
19
  private resolvedJobs: UpDownCounter;
20
20
  private rejectedJobs: UpDownCounter;
21
+ private abortedJobs: UpDownCounter;
21
22
  private timedOutJobs: UpDownCounter;
22
23
  private cachedJobs: UpDownCounter;
23
24
  private totalJobs: UpDownCounter;
@@ -39,6 +40,8 @@ export class ProvingBrokerInstrumentation {
39
40
 
40
41
  this.rejectedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_REJECTED_JOBS, provingJobAttrs);
41
42
 
43
+ this.abortedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_ABORTED_JOBS, provingJobAttrs);
44
+
42
45
  this.retriedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_RETRIED_JOBS, provingJobAttrs);
43
46
 
44
47
  this.timedOutJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_TIMED_OUT_JOBS, provingJobAttrs);
@@ -72,6 +75,12 @@ export class ProvingBrokerInstrumentation {
72
75
  });
73
76
  }
74
77
 
78
+ incAbortedJobs(proofType: ProvingRequestType) {
79
+ this.abortedJobs.add(1, {
80
+ [Attributes.PROVING_JOB_TYPE]: ProvingRequestType[proofType],
81
+ });
82
+ }
83
+
75
84
  incRetriedJobs(proofType: ProvingRequestType) {
76
85
  this.retriedJobs.add(1, {
77
86
  [Attributes.PROVING_JOB_TYPE]: ProvingRequestType[proofType],
@@ -1,9 +1,11 @@
1
+ import { EpochNumberSchema } from '@aztec/foundation/branded-types';
1
2
  import { createSafeJsonRpcClient } from '@aztec/foundation/json-rpc/client';
2
3
  import {
3
4
  type GetProvingJobResponse,
4
5
  ProofUri,
5
6
  ProvingJob,
6
7
  type ProvingJobBroker,
8
+ type ProvingJobBrokerDebug,
7
9
  type ProvingJobConsumer,
8
10
  ProvingJobId,
9
11
  type ProvingJobProducer,
@@ -16,6 +18,15 @@ import { makeTracedFetch } from '@aztec/telemetry-client';
16
18
 
17
19
  import { z } from 'zod';
18
20
 
21
+ /** Indefinite backoff for broker communication: 1, 1, 1, 2, 4, 4, 4, ... seconds. */
22
+ export function* proverBrokerBackoff() {
23
+ const v = [1, 1, 1, 2, 4];
24
+ let i = 0;
25
+ while (true) {
26
+ yield v[Math.min(i++, v.length - 1)];
27
+ }
28
+ }
29
+
19
30
  const ProvingJobFilterSchema = z.object({
20
31
  allowList: z.array(z.nativeEnum(ProvingRequestType)),
21
32
  });
@@ -53,10 +64,22 @@ export const ProvingJobBrokerSchema: ApiSchemaFor<ProvingJobBroker> = {
53
64
  ...ProvingJobProducerSchema,
54
65
  };
55
66
 
67
+ export const ProvingJobBrokerDebugSchema: ApiSchemaFor<ProvingJobBrokerDebug> = {
68
+ replayProvingJob: z
69
+ .function()
70
+ .args(ProvingJobId, z.nativeEnum(ProvingRequestType), EpochNumberSchema, ProofUri)
71
+ .returns(ProvingJobStatus),
72
+ };
73
+
74
+ export const ProvingJobBrokerSchemaWithDebug: ApiSchemaFor<ProvingJobBroker & ProvingJobBrokerDebug> = {
75
+ ...ProvingJobBrokerSchema,
76
+ ...ProvingJobBrokerDebugSchema,
77
+ };
78
+
56
79
  export function createProvingJobBrokerClient(
57
80
  url: string,
58
81
  versions: Partial<ComponentsVersions>,
59
- fetch = makeTracedFetch([1, 2, 3], false),
82
+ fetch = makeTracedFetch(proverBrokerBackoff, false),
60
83
  ): ProvingJobBroker {
61
84
  return createSafeJsonRpcClient(url, ProvingJobBrokerSchema, {
62
85
  namespaceMethods: 'proverBroker',
@@ -68,7 +91,7 @@ export function createProvingJobBrokerClient(
68
91
  export function createProvingJobProducerClient(
69
92
  url: string,
70
93
  versions: Partial<ComponentsVersions>,
71
- fetch = makeTracedFetch([1, 2, 3], false),
94
+ fetch = makeTracedFetch(proverBrokerBackoff, false),
72
95
  ): ProvingJobProducer {
73
96
  return createSafeJsonRpcClient(url, ProvingJobProducerSchema, {
74
97
  namespaceMethods: 'provingJobProducer',
@@ -80,7 +103,7 @@ export function createProvingJobProducerClient(
80
103
  export function createProvingJobConsumerClient(
81
104
  url: string,
82
105
  versions: Partial<ComponentsVersions>,
83
- fetch = makeTracedFetch([1, 2, 3], false),
106
+ fetch = makeTracedFetch(proverBrokerBackoff, false),
84
107
  ): ProvingJobConsumer {
85
108
  return createSafeJsonRpcClient(url, ProvingJobConsumerSchema, {
86
109
  namespaceMethods: 'provingJobConsumer',
@@ -1,14 +0,0 @@
1
- import { type ProofUri, type ProvingJobId, type ProvingJobInputs, type ProvingJobInputsMap, type ProvingJobResult, type ProvingJobResultsMap } from '@aztec/stdlib/interfaces/server';
2
- import { ProvingRequestType } from '@aztec/stdlib/proofs';
3
- import type { ProofStore } from './proof_store.js';
4
- export declare class GoogleCloudStorageProofStore implements ProofStore {
5
- private readonly bucketName;
6
- private readonly path;
7
- private readonly storage;
8
- constructor(bucketName: string, path: string);
9
- saveProofInput<T extends ProvingRequestType>(id: ProvingJobId, type: T, inputs: ProvingJobInputsMap[T]): Promise<ProofUri>;
10
- saveProofOutput<T extends ProvingRequestType>(_id: ProvingJobId, _type: T, _result: ProvingJobResultsMap[T]): Promise<ProofUri>;
11
- getProofInput(uri: ProofUri): Promise<ProvingJobInputs>;
12
- getProofOutput(_uri: ProofUri): Promise<ProvingJobResult>;
13
- }
14
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2NzX3Byb29mX3N0b3JlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcHJvdmluZ19icm9rZXIvcHJvb2Zfc3RvcmUvZ2NzX3Byb29mX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFDTCxLQUFLLFFBQVEsRUFDYixLQUFLLFlBQVksRUFDakIsS0FBSyxnQkFBZ0IsRUFDckIsS0FBSyxtQkFBbUIsRUFDeEIsS0FBSyxnQkFBZ0IsRUFDckIsS0FBSyxvQkFBb0IsRUFFMUIsTUFBTSxpQ0FBaUMsQ0FBQztBQUN6QyxPQUFPLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUsxRCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUtuRCxxQkFBYSw0QkFBNkIsWUFBVyxVQUFVO0lBSTNELE9BQU8sQ0FBQyxRQUFRLENBQUMsVUFBVTtJQUMzQixPQUFPLENBQUMsUUFBUSxDQUFDLElBQUk7SUFKdkIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxPQUFPLENBQVU7SUFFbEMsWUFDbUIsVUFBVSxFQUFFLE1BQU0sRUFDbEIsSUFBSSxFQUFFLE1BQU0sRUFHOUI7SUFFWSxjQUFjLENBQUMsQ0FBQyxTQUFTLGtCQUFrQixFQUN0RCxFQUFFLEVBQUUsWUFBWSxFQUNoQixJQUFJLEVBQUUsQ0FBQyxFQUNQLE1BQU0sRUFBRSxtQkFBbUIsQ0FBQyxDQUFDLENBQUMsR0FDN0IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUtuQjtJQUVELGVBQWUsQ0FBQyxDQUFDLFNBQVMsa0JBQWtCLEVBQzFDLEdBQUcsRUFBRSxZQUFZLEVBQ2pCLEtBQUssRUFBRSxDQUFDLEVBQ1IsT0FBTyxFQUFFLG9CQUFvQixDQUFDLENBQUMsQ0FBQyxHQUMvQixPQUFPLENBQUMsUUFBUSxDQUFDLENBRW5CO0lBRVksYUFBYSxDQUFDLEdBQUcsRUFBRSxRQUFRLEdBQUcsT0FBTyxDQUFDLGdCQUFnQixDQUFDLENBc0JuRTtJQUVELGNBQWMsQ0FBQyxJQUFJLEVBQUUsUUFBUSxHQUFHLE9BQU8sQ0FBQyxnQkFBZ0IsQ0FBQyxDQUV4RDtDQUNGIn0=
@@ -1 +0,0 @@
1
- {"version":3,"file":"gcs_proof_store.d.ts","sourceRoot":"","sources":["../../../src/proving_broker/proof_store/gcs_proof_store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EAE1B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAK1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKnD,qBAAa,4BAA6B,YAAW,UAAU;IAI3D,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAElC,YACmB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EAG9B;IAEY,cAAc,CAAC,CAAC,SAAS,kBAAkB,EACtD,EAAE,EAAE,YAAY,EAChB,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAC7B,OAAO,CAAC,QAAQ,CAAC,CAKnB;IAED,eAAe,CAAC,CAAC,SAAS,kBAAkB,EAC1C,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC/B,OAAO,CAAC,QAAQ,CAAC,CAEnB;IAEY,aAAa,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAsBnE;IAED,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAExD;CACF"}
@@ -1,52 +0,0 @@
1
- import { getProvingJobInputClassFor } from '@aztec/stdlib/interfaces/server';
2
- import { ProvingRequestType } from '@aztec/stdlib/proofs';
3
- import { Storage } from '@google-cloud/storage';
4
- import { join } from 'path';
5
- const INPUTS_PATH = 'inputs';
6
- // REFACTOR(#13067): Use the stdlib/file-store instead of referencing google-cloud-storage directly.
7
- export class GoogleCloudStorageProofStore {
8
- bucketName;
9
- path;
10
- storage;
11
- constructor(bucketName, path){
12
- this.bucketName = bucketName;
13
- this.path = path;
14
- this.storage = new Storage();
15
- }
16
- async saveProofInput(id, type, inputs) {
17
- const path = join(this.path, INPUTS_PATH, ProvingRequestType[type], id);
18
- const file = this.storage.bucket(this.bucketName).file(path);
19
- await file.save(inputs.toBuffer());
20
- return file.cloudStorageURI.toString();
21
- }
22
- saveProofOutput(_id, _type, _result) {
23
- throw new Error('Not implemented');
24
- }
25
- async getProofInput(uri) {
26
- try {
27
- const url = new URL(uri);
28
- const bucket = this.storage.bucket(url.host);
29
- const path = url.pathname.replace(/^\/+/, '');
30
- const file = bucket.file(path);
31
- if (!await file.exists()) {
32
- throw new Error(`File at ${uri} does not exist`);
33
- }
34
- const typeString = path.split('/').at(-2);
35
- const type = typeString ? ProvingRequestType[typeString] : undefined;
36
- if (type === undefined) {
37
- throw new Error(`Unrecognized proof type ${type} in path ${path}`);
38
- }
39
- const contents = await file.download();
40
- const inputs = getProvingJobInputClassFor(type).fromBuffer(contents[0]);
41
- return {
42
- inputs,
43
- type
44
- };
45
- } catch (err) {
46
- throw new Error(`Error getting proof input at ${uri}: ${err}`);
47
- }
48
- }
49
- getProofOutput(_uri) {
50
- throw new Error('Not implemented');
51
- }
52
- }
@@ -1,76 +0,0 @@
1
- import {
2
- type ProofUri,
3
- type ProvingJobId,
4
- type ProvingJobInputs,
5
- type ProvingJobInputsMap,
6
- type ProvingJobResult,
7
- type ProvingJobResultsMap,
8
- getProvingJobInputClassFor,
9
- } from '@aztec/stdlib/interfaces/server';
10
- import { ProvingRequestType } from '@aztec/stdlib/proofs';
11
-
12
- import { Storage } from '@google-cloud/storage';
13
- import { join } from 'path';
14
-
15
- import type { ProofStore } from './proof_store.js';
16
-
17
- const INPUTS_PATH = 'inputs';
18
-
19
- // REFACTOR(#13067): Use the stdlib/file-store instead of referencing google-cloud-storage directly.
20
- export class GoogleCloudStorageProofStore implements ProofStore {
21
- private readonly storage: Storage;
22
-
23
- constructor(
24
- private readonly bucketName: string,
25
- private readonly path: string,
26
- ) {
27
- this.storage = new Storage();
28
- }
29
-
30
- public async saveProofInput<T extends ProvingRequestType>(
31
- id: ProvingJobId,
32
- type: T,
33
- inputs: ProvingJobInputsMap[T],
34
- ): Promise<ProofUri> {
35
- const path = join(this.path, INPUTS_PATH, ProvingRequestType[type], id);
36
- const file = this.storage.bucket(this.bucketName).file(path);
37
- await file.save(inputs.toBuffer());
38
- return file.cloudStorageURI.toString() as ProofUri;
39
- }
40
-
41
- saveProofOutput<T extends ProvingRequestType>(
42
- _id: ProvingJobId,
43
- _type: T,
44
- _result: ProvingJobResultsMap[T],
45
- ): Promise<ProofUri> {
46
- throw new Error('Not implemented');
47
- }
48
-
49
- public async getProofInput(uri: ProofUri): Promise<ProvingJobInputs> {
50
- try {
51
- const url = new URL(uri);
52
- const bucket = this.storage.bucket(url.host);
53
- const path = url.pathname.replace(/^\/+/, '');
54
- const file = bucket.file(path);
55
- if (!(await file.exists())) {
56
- throw new Error(`File at ${uri} does not exist`);
57
- }
58
-
59
- const typeString = path.split('/').at(-2);
60
- const type = typeString ? ProvingRequestType[typeString as keyof typeof ProvingRequestType] : undefined;
61
- if (type === undefined) {
62
- throw new Error(`Unrecognized proof type ${type} in path ${path}`);
63
- }
64
-
65
- const contents = await file.download();
66
- const inputs = getProvingJobInputClassFor(type).fromBuffer(contents[0]);
67
- return { inputs, type } as ProvingJobInputs;
68
- } catch (err) {
69
- throw new Error(`Error getting proof input at ${uri}: ${err}`);
70
- }
71
- }
72
-
73
- getProofOutput(_uri: ProofUri): Promise<ProvingJobResult> {
74
- throw new Error('Not implemented');
75
- }
76
- }