@aztec/prover-client 0.0.1-commit.e3c1de76 → 0.0.1-commit.e588bc7e5
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.
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +12 -2
- package/dest/light/lightweight_checkpoint_builder.d.ts +10 -5
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +41 -18
- package/dest/mocks/test_context.d.ts +1 -1
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +10 -5
- package/dest/orchestrator/block-building-helpers.d.ts +4 -4
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +2 -2
- package/dest/orchestrator/block-proving-state.d.ts +4 -1
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +7 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts +3 -3
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +3 -3
- package/dest/orchestrator/epoch-proving-state.d.ts +3 -3
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +5 -3
- package/dest/orchestrator/orchestrator.d.ts +5 -3
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +64 -57
- package/dest/prover-client/prover-client.d.ts +4 -4
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +9 -7
- package/dest/proving_broker/broker_prover_facade.d.ts +1 -1
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +13 -19
- package/dest/proving_broker/config.d.ts +10 -2
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +14 -3
- package/dest/proving_broker/proof_store/factory.d.ts +2 -5
- package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/factory.js +7 -30
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
- package/dest/proving_broker/proof_store/index.d.ts +2 -2
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -1
- package/dest/proving_broker/proving_broker.d.ts +7 -4
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +36 -4
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +3 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +7 -0
- package/dest/proving_broker/rpc.d.ts +6 -2
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +24 -15
- package/dest/test/mock_prover.d.ts +4 -4
- package/package.json +17 -18
- package/src/config.ts +13 -2
- package/src/light/lightweight_checkpoint_builder.ts +42 -19
- package/src/mocks/test_context.ts +6 -4
- package/src/orchestrator/block-building-helpers.ts +2 -2
- package/src/orchestrator/block-proving-state.ts +9 -0
- package/src/orchestrator/checkpoint-proving-state.ts +4 -4
- package/src/orchestrator/epoch-proving-state.ts +6 -4
- package/src/orchestrator/orchestrator.ts +72 -63
- package/src/prover-client/prover-client.ts +8 -9
- package/src/proving_broker/broker_prover_facade.ts +17 -20
- package/src/proving_broker/config.ts +14 -1
- package/src/proving_broker/proof_store/factory.ts +10 -32
- package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
- package/src/proving_broker/proof_store/index.ts +1 -1
- package/src/proving_broker/proving_broker.ts +37 -3
- package/src/proving_broker/proving_broker_instrumentation.ts +9 -0
- package/src/proving_broker/rpc.ts +26 -3
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +0 -14
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +0 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.js +0 -52
- 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
|
-
|
|
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);
|
|
@@ -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(
|
|
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(
|
|
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(
|
|
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
|
-
}
|