@aztec/prover-client 0.0.1-commit.3100065 → 0.0.1-commit.330febf
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/mocks/fixtures.d.ts +1 -1
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +3 -3
- 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 +2 -1
- package/dest/orchestrator/block-building-helpers.d.ts +1 -1
- 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 +8 -1
- package/dest/proving_broker/proving_broker.d.ts +2 -1
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +145 -70
- package/dest/proving_broker/proving_broker_database/memory.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/memory.js +4 -1
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +3 -1
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +25 -1
- package/dest/proving_broker/proving_broker_database.d.ts +13 -1
- package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
- package/dest/proving_broker/rpc.d.ts +13 -4
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +14 -3
- package/dest/test/mock_prover.d.ts +1 -1
- package/package.json +15 -15
- package/src/mocks/fixtures.ts +2 -4
- package/src/mocks/test_context.ts +2 -1
- package/src/proving_broker/broker_prover_facade.ts +8 -1
- package/src/proving_broker/proving_broker.ts +138 -69
- package/src/proving_broker/proving_broker_database/memory.ts +6 -2
- package/src/proving_broker/proving_broker_database/persisted.ts +29 -1
- package/src/proving_broker/proving_broker_database.ts +14 -0
- package/src/proving_broker/rpc.ts +16 -0
|
@@ -70,6 +70,16 @@ class SingleEpochDatabase {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
async getProvingJobInputs(id: ProvingJobId): Promise<ProofUri | undefined> {
|
|
74
|
+
const jobStr = await this.jobs.getAsync(id);
|
|
75
|
+
return jobStr ? jsonParseWithSchema(jobStr, ProvingJob).inputsUri : undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async getProvingJobResult(id: ProvingJobId): Promise<ProvingJobSettledResult | undefined> {
|
|
79
|
+
const resultStr = await this.jobResults.getAsync(id);
|
|
80
|
+
return resultStr ? jsonParseWithSchema(resultStr, ProvingJobSettledResult) : undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
73
83
|
async setProvingJobError(id: ProvingJobId, reason: string): Promise<void> {
|
|
74
84
|
const result: ProvingJobSettledResult = { status: 'rejected', reason };
|
|
75
85
|
await this.jobResults.set(id, jsonStringify(result));
|
|
@@ -219,8 +229,13 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
219
229
|
}
|
|
220
230
|
}
|
|
221
231
|
|
|
232
|
+
// Key jobs by the id-derived epoch, the same epoch results are written under (setProvingJobResult et
|
|
233
|
+
// al.). This keeps a job's inputs and its result co-located in one epoch database so both can be read
|
|
234
|
+
// back with a single keyed lookup (getProvingJobInputs/getProvingJobResult) rather than a scan. The id
|
|
235
|
+
// embeds the epoch and equals `job.epochNumber` at every construction site, so this matches the prior
|
|
236
|
+
// storage epoch while making the id the single source of truth for placement.
|
|
222
237
|
addProvingJob(job: ProvingJob): Promise<void> {
|
|
223
|
-
return this.batchQueue.put(job, job.
|
|
238
|
+
return this.batchQueue.put(job, getEpochFromProvingJobId(job.id));
|
|
224
239
|
}
|
|
225
240
|
|
|
226
241
|
async *allProvingJobs(): AsyncIterableIterator<[ProvingJob, ProvingJobSettledResult | undefined]> {
|
|
@@ -230,6 +245,19 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
230
245
|
}
|
|
231
246
|
}
|
|
232
247
|
|
|
248
|
+
// A job id is `${epochNumber}:${type}:${inputsHash}`, so its epoch is recoverable directly and maps to
|
|
249
|
+
// exactly one epoch database. Results are already written under this same id-derived epoch (see
|
|
250
|
+
// setProvingJobResult et al.), and a job's `epochNumber` equals its id-epoch at every construction site,
|
|
251
|
+
// so inputs live there too. Use `epochs.get` (not `getEpochDatabase`, which would create the store on a
|
|
252
|
+
// miss) so a read for an unknown id has no side effects.
|
|
253
|
+
getProvingJobInputs(id: ProvingJobId): Promise<ProofUri | undefined> {
|
|
254
|
+
return this.epochs.get(getEpochFromProvingJobId(id))?.getProvingJobInputs(id) ?? Promise.resolve(undefined);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
getProvingJobResult(id: ProvingJobId): Promise<ProvingJobSettledResult | undefined> {
|
|
258
|
+
return this.epochs.get(getEpochFromProvingJobId(id))?.getProvingJobResult(id) ?? Promise.resolve(undefined);
|
|
259
|
+
}
|
|
260
|
+
|
|
233
261
|
setProvingJobError(id: ProvingJobId, reason: string): Promise<void> {
|
|
234
262
|
return this.batchQueue.put([id, { status: 'rejected', reason }], getEpochFromProvingJobId(id));
|
|
235
263
|
}
|
|
@@ -22,6 +22,20 @@ export interface ProvingBrokerDatabase {
|
|
|
22
22
|
*/
|
|
23
23
|
allProvingJobs(): AsyncIterableIterator<[ProvingJob, ProvingJobSettledResult | undefined]>;
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Reads a single job's inputs URI by id, or undefined if the job is unknown. The broker keeps only
|
|
27
|
+
* job metadata in memory and reads the (large) inputs from here on demand when dispatching to an agent.
|
|
28
|
+
* @param id - The ID of the proof request
|
|
29
|
+
*/
|
|
30
|
+
getProvingJobInputs(id: ProvingJobId): Promise<ProofUri | undefined>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Reads a single job's settled result by id, or undefined if not settled. The broker keeps only the
|
|
34
|
+
* settled status in memory and reads the (large) fulfilled proof from here on demand.
|
|
35
|
+
* @param id - The ID of the proof request
|
|
36
|
+
*/
|
|
37
|
+
getProvingJobResult(id: ProvingJobId): Promise<ProvingJobSettledResult | undefined>;
|
|
38
|
+
|
|
25
39
|
/**
|
|
26
40
|
* Saves the result of a proof request
|
|
27
41
|
* @param id - The ID of the proof request to save the result for
|
|
@@ -18,6 +18,16 @@ import { makeTracedFetch } from '@aztec/telemetry-client';
|
|
|
18
18
|
|
|
19
19
|
import { z } from 'zod';
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Max JSON-RPC request body the broker clients will send.
|
|
23
|
+
*
|
|
24
|
+
* Job inputs and proof results travel inline as `data:` URIs on this path, so a single call is routinely larger than
|
|
25
|
+
* the 1 mb the generic JSON-RPC client allows — that default sizes batches of small node requests against the node
|
|
26
|
+
* server's own default. An AVM (`PUBLIC_VM`) result is around 1.3 mb today. This value must stay at or below the
|
|
27
|
+
* broker server's `RPC_MAX_BODY_SIZE`, which deployments set to 50mb.
|
|
28
|
+
*/
|
|
29
|
+
export const PROVER_BROKER_MAX_REQUEST_BODY_SIZE = 50 * 1024 * 1024;
|
|
30
|
+
|
|
21
31
|
/** Indefinite backoff for broker communication: 1, 1, 1, 2, 4, 4, 4, ... seconds. */
|
|
22
32
|
export function* proverBrokerBackoff() {
|
|
23
33
|
const v = [1, 1, 1, 2, 4];
|
|
@@ -83,10 +93,12 @@ export function createProvingJobBrokerClient(
|
|
|
83
93
|
url: string,
|
|
84
94
|
versions: Partial<ComponentsVersions>,
|
|
85
95
|
fetch = makeTracedFetch(proverBrokerBackoff, false),
|
|
96
|
+
maxRequestBodySize = PROVER_BROKER_MAX_REQUEST_BODY_SIZE,
|
|
86
97
|
): ProvingJobBroker {
|
|
87
98
|
return createSafeJsonRpcClient(url, ProvingJobBrokerSchema, {
|
|
88
99
|
namespaceMethods: 'proverBroker',
|
|
89
100
|
fetch,
|
|
101
|
+
maxRequestBodySize,
|
|
90
102
|
onResponse: getVersioningResponseHandler(versions),
|
|
91
103
|
});
|
|
92
104
|
}
|
|
@@ -95,10 +107,12 @@ export function createProvingJobProducerClient(
|
|
|
95
107
|
url: string,
|
|
96
108
|
versions: Partial<ComponentsVersions>,
|
|
97
109
|
fetch = makeTracedFetch(proverBrokerBackoff, false),
|
|
110
|
+
maxRequestBodySize = PROVER_BROKER_MAX_REQUEST_BODY_SIZE,
|
|
98
111
|
): ProvingJobProducer {
|
|
99
112
|
return createSafeJsonRpcClient(url, ProvingJobProducerSchema, {
|
|
100
113
|
namespaceMethods: 'provingJobProducer',
|
|
101
114
|
fetch,
|
|
115
|
+
maxRequestBodySize,
|
|
102
116
|
onResponse: getVersioningResponseHandler(versions),
|
|
103
117
|
});
|
|
104
118
|
}
|
|
@@ -107,10 +121,12 @@ export function createProvingJobConsumerClient(
|
|
|
107
121
|
url: string,
|
|
108
122
|
versions: Partial<ComponentsVersions>,
|
|
109
123
|
fetch = makeTracedFetch(proverBrokerBackoff, false),
|
|
124
|
+
maxRequestBodySize = PROVER_BROKER_MAX_REQUEST_BODY_SIZE,
|
|
110
125
|
): ProvingJobConsumer {
|
|
111
126
|
return createSafeJsonRpcClient(url, ProvingJobConsumerSchema, {
|
|
112
127
|
namespaceMethods: 'provingJobConsumer',
|
|
113
128
|
fetch,
|
|
129
|
+
maxRequestBodySize,
|
|
114
130
|
onResponse: getVersioningResponseHandler(versions),
|
|
115
131
|
});
|
|
116
132
|
}
|