@aztec/prover-client 0.71.0 → 0.73.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.
- package/dest/bin/get-proof-inputs.js +3 -3
- package/dest/config.js +2 -2
- package/dest/mocks/test_context.d.ts +4 -3
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +11 -8
- package/dest/orchestrator/block-building-helpers.d.ts +3 -3
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +14 -13
- package/dest/orchestrator/block-proving-state.d.ts +14 -15
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +84 -64
- package/dest/orchestrator/epoch-proving-state.d.ts +7 -7
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +18 -36
- package/dest/orchestrator/orchestrator.d.ts +4 -3
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +77 -90
- package/dest/orchestrator/tx-proving-state.d.ts +2 -2
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +14 -14
- package/dest/prover-agent/rpc.d.ts +1 -1
- package/dest/prover-agent/rpc.d.ts.map +1 -1
- package/dest/prover-agent/rpc.js +6 -6
- package/dest/prover-client/server-epoch-prover.d.ts +2 -2
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +4 -4
- package/dest/proving_broker/broker_prover_facade.js +3 -3
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +3 -4
- package/dest/proving_broker/proving_broker_database/memory.d.ts +1 -1
- package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/memory.js +3 -3
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +12 -12
- package/dest/proving_broker/proving_broker_database.d.ts +1 -1
- package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
- package/dest/proving_broker/rpc.d.ts +3 -3
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +7 -7
- package/dest/test/mock_prover.d.ts +1 -1
- package/package.json +11 -11
- package/src/bin/get-proof-inputs.ts +2 -2
- package/src/config.ts +1 -1
- package/src/mocks/test_context.ts +14 -9
- package/src/orchestrator/block-building-helpers.ts +13 -14
- package/src/orchestrator/block-proving-state.ts +95 -69
- package/src/orchestrator/epoch-proving-state.ts +26 -52
- package/src/orchestrator/orchestrator.ts +101 -122
- package/src/orchestrator/tx-proving-state.ts +14 -14
- package/src/prover-agent/rpc.ts +5 -5
- package/src/prover-client/server-epoch-prover.ts +8 -4
- package/src/proving_broker/broker_prover_facade.ts +3 -3
- package/src/proving_broker/proof_store/inline_proof_store.ts +1 -1
- package/src/proving_broker/proving_broker.ts +2 -4
- package/src/proving_broker/proving_broker_database/memory.ts +2 -2
- package/src/proving_broker/proving_broker_database/persisted.ts +15 -15
- package/src/proving_broker/proving_broker_database.ts +1 -1
- package/src/proving_broker/rpc.ts +13 -6
|
@@ -55,7 +55,7 @@ type ProvingJob = {
|
|
|
55
55
|
type: ProvingRequestType;
|
|
56
56
|
inputsUri: ProofUri;
|
|
57
57
|
promise: PromiseWithResolvers<any>;
|
|
58
|
-
abortFn?: () =>
|
|
58
|
+
abortFn?: () => void;
|
|
59
59
|
signal?: AbortSignal;
|
|
60
60
|
};
|
|
61
61
|
|
|
@@ -117,9 +117,9 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
117
117
|
// Create a promise for this job id, regardless of whether it was enqueued at the broker
|
|
118
118
|
// The running promise will monitor for the job to be completed and resolve it either way
|
|
119
119
|
const promise = promiseWithResolvers<ProvingJobResultsMap[T]>();
|
|
120
|
-
const abortFn =
|
|
120
|
+
const abortFn = () => {
|
|
121
121
|
signal?.removeEventListener('abort', abortFn);
|
|
122
|
-
|
|
122
|
+
void this.broker.cancelProvingJob(id).catch(err => this.log.warn(`Error cancelling job id=${id}`, err));
|
|
123
123
|
};
|
|
124
124
|
const job: ProvingJob = {
|
|
125
125
|
id,
|
|
@@ -52,7 +52,7 @@ export class InlineProofStore implements ProofStore {
|
|
|
52
52
|
return (PREFIX + SEPARATOR + encoded) as ProofUri;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
private decode<T>(uri: ProofUri, schema: ZodFor<T>): T {
|
|
55
|
+
private decode<T>(uri: ProofUri, schema: ZodFor<T>): Promise<T> {
|
|
56
56
|
const [prefix, data] = uri.split(SEPARATOR);
|
|
57
57
|
if (prefix !== PREFIX) {
|
|
58
58
|
throw new Error('Invalid proof input URI: ' + prefix);
|
|
@@ -147,13 +147,13 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
147
147
|
return count;
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
-
public start(): Promise<void> {
|
|
150
|
+
public async start(): Promise<void> {
|
|
151
151
|
if (this.started) {
|
|
152
152
|
this.logger.info('Proving Broker already started');
|
|
153
153
|
return Promise.resolve();
|
|
154
154
|
}
|
|
155
155
|
this.logger.info('Proving Broker started');
|
|
156
|
-
for (const [item, result] of this.database.allProvingJobs()) {
|
|
156
|
+
for await (const [item, result] of this.database.allProvingJobs()) {
|
|
157
157
|
this.logger.info(`Restoring proving job id=${item.id} settled=${!!result}`, {
|
|
158
158
|
provingJobId: item.id,
|
|
159
159
|
status: result ? result.status : 'pending',
|
|
@@ -178,8 +178,6 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
178
178
|
this.instrumentation.monitorActiveJobs(this.countActiveJobs);
|
|
179
179
|
|
|
180
180
|
this.started = true;
|
|
181
|
-
|
|
182
|
-
return Promise.resolve();
|
|
183
181
|
}
|
|
184
182
|
|
|
185
183
|
public async stop(): Promise<void> {
|
|
@@ -51,8 +51,8 @@ export class InMemoryBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
51
51
|
return this.deleteProvingJobs(toDelete);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
*allProvingJobs():
|
|
55
|
-
for (const item of this.jobs.values()) {
|
|
54
|
+
async *allProvingJobs(): AsyncIterableIterator<[ProvingJob, ProvingJobSettledResult | undefined]> {
|
|
55
|
+
for await (const item of this.jobs.values()) {
|
|
56
56
|
yield [item, this.results.get(item.id)] as const;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
} from '@aztec/circuit-types';
|
|
8
8
|
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
9
9
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
11
|
+
import { AztecLMDBStoreV2 } from '@aztec/kv-store/lmdb-v2';
|
|
12
12
|
import { Attributes, LmdbMetrics, type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
13
13
|
|
|
14
14
|
import { mkdir, readdir } from 'fs/promises';
|
|
@@ -18,10 +18,10 @@ import { type ProverBrokerConfig } from '../config.js';
|
|
|
18
18
|
import { type ProvingBrokerDatabase } from '../proving_broker_database.js';
|
|
19
19
|
|
|
20
20
|
class SingleEpochDatabase {
|
|
21
|
-
private jobs:
|
|
22
|
-
private jobResults:
|
|
21
|
+
private jobs: AztecAsyncMap<ProvingJobId, string>;
|
|
22
|
+
private jobResults: AztecAsyncMap<ProvingJobId, string>;
|
|
23
23
|
|
|
24
|
-
constructor(public readonly store:
|
|
24
|
+
constructor(public readonly store: AztecAsyncKVStore) {
|
|
25
25
|
this.jobs = store.openMap('proving_jobs');
|
|
26
26
|
this.jobResults = store.openMap('proving_job_results');
|
|
27
27
|
}
|
|
@@ -34,11 +34,11 @@ class SingleEpochDatabase {
|
|
|
34
34
|
await this.jobs.set(job.id, jsonStringify(job));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
*allProvingJobs():
|
|
38
|
-
for (const jobStr of this.jobs.
|
|
39
|
-
const job = jsonParseWithSchema(jobStr, ProvingJob);
|
|
40
|
-
const resultStr = this.jobResults.
|
|
41
|
-
const result = resultStr ? jsonParseWithSchema(resultStr, ProvingJobSettledResult) : undefined;
|
|
37
|
+
async *allProvingJobs(): AsyncIterableIterator<[ProvingJob, ProvingJobSettledResult | undefined]> {
|
|
38
|
+
for await (const jobStr of this.jobs.valuesAsync()) {
|
|
39
|
+
const job = await jsonParseWithSchema(jobStr, ProvingJob);
|
|
40
|
+
const resultStr = await this.jobResults.getAsync(job.id);
|
|
41
|
+
const result = resultStr ? await jsonParseWithSchema(resultStr, ProvingJobSettledResult) : undefined;
|
|
42
42
|
yield [job, result];
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -80,8 +80,8 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
private estimateSize() {
|
|
84
|
-
const sizes = Array.from(this.epochs.values()).map(x => x.estimateSize());
|
|
83
|
+
private async estimateSize() {
|
|
84
|
+
const sizes = await Promise.all(Array.from(this.epochs.values()).map(x => x.estimateSize()));
|
|
85
85
|
return {
|
|
86
86
|
mappingSize: this.config.dataStoreMapSizeKB,
|
|
87
87
|
numItems: sizes.reduce((prev, curr) => prev + curr.numItems, 0),
|
|
@@ -110,7 +110,7 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
110
110
|
logger.info(
|
|
111
111
|
`Loading broker database for epoch ${epochNumber} from ${fullDirectory} with map size ${config.dataStoreMapSizeKB}KB`,
|
|
112
112
|
);
|
|
113
|
-
const db =
|
|
113
|
+
const db = await AztecLMDBStoreV2.new(fullDirectory, config.dataStoreMapSizeKB);
|
|
114
114
|
const epochDb = new SingleEpochDatabase(db);
|
|
115
115
|
epochs.set(epochNumber, epochDb);
|
|
116
116
|
}
|
|
@@ -144,14 +144,14 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
144
144
|
this.logger.info(
|
|
145
145
|
`Creating broker database for epoch ${job.epochNumber} at ${newEpochDirectory} with map size ${this.config.dataStoreMapSizeKB}`,
|
|
146
146
|
);
|
|
147
|
-
const db =
|
|
147
|
+
const db = await AztecLMDBStoreV2.new(newEpochDirectory, this.config.dataStoreMapSizeKB);
|
|
148
148
|
epochDb = new SingleEpochDatabase(db);
|
|
149
149
|
this.epochs.set(job.epochNumber, epochDb);
|
|
150
150
|
}
|
|
151
151
|
await epochDb.addProvingJob(job);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
*allProvingJobs():
|
|
154
|
+
async *allProvingJobs(): AsyncIterableIterator<[ProvingJob, ProvingJobSettledResult | undefined]> {
|
|
155
155
|
const iterators = Array.from(this.epochs.values()).map(x => x.allProvingJobs());
|
|
156
156
|
for (const it of iterators) {
|
|
157
157
|
yield* it;
|
|
@@ -19,7 +19,7 @@ export interface ProvingBrokerDatabase {
|
|
|
19
19
|
/**
|
|
20
20
|
* Returns an iterator over all saved proving jobs
|
|
21
21
|
*/
|
|
22
|
-
allProvingJobs():
|
|
22
|
+
allProvingJobs(): AsyncIterableIterator<[ProvingJob, ProvingJobSettledResult | undefined]>;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Saves the result of a proof request
|
|
@@ -9,9 +9,10 @@ import {
|
|
|
9
9
|
ProvingJobStatus,
|
|
10
10
|
ProvingRequestType,
|
|
11
11
|
} from '@aztec/circuit-types';
|
|
12
|
-
import { createSafeJsonRpcClient
|
|
13
|
-
import { type SafeJsonRpcServer
|
|
12
|
+
import { createSafeJsonRpcClient } from '@aztec/foundation/json-rpc/client';
|
|
13
|
+
import { type SafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
14
14
|
import { type ApiSchemaFor, optional } from '@aztec/foundation/schemas';
|
|
15
|
+
import { createTracedJsonRpcServer, makeTracedFetch } from '@aztec/telemetry-client';
|
|
15
16
|
|
|
16
17
|
import { z } from 'zod';
|
|
17
18
|
|
|
@@ -47,17 +48,23 @@ export const ProvingJobBrokerSchema: ApiSchemaFor<ProvingJobBroker> = {
|
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
export function createProvingBrokerServer(broker: ProvingJobBroker): SafeJsonRpcServer {
|
|
50
|
-
return
|
|
51
|
+
return createTracedJsonRpcServer(broker, ProvingJobBrokerSchema);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
export function createProvingJobBrokerClient(url: string, fetch =
|
|
54
|
+
export function createProvingJobBrokerClient(url: string, fetch = makeTracedFetch([1, 2, 3], false)): ProvingJobBroker {
|
|
54
55
|
return createSafeJsonRpcClient(url, ProvingJobBrokerSchema, false, 'proverBroker', fetch);
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
export function createProvingJobProducerClient(
|
|
58
|
+
export function createProvingJobProducerClient(
|
|
59
|
+
url: string,
|
|
60
|
+
fetch = makeTracedFetch([1, 2, 3], false),
|
|
61
|
+
): ProvingJobProducer {
|
|
58
62
|
return createSafeJsonRpcClient(url, ProvingJobProducerSchema, false, 'provingJobProducer', fetch);
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
export function createProvingJobConsumerClient(
|
|
65
|
+
export function createProvingJobConsumerClient(
|
|
66
|
+
url: string,
|
|
67
|
+
fetch = makeTracedFetch([1, 2, 3], false),
|
|
68
|
+
): ProvingJobConsumer {
|
|
62
69
|
return createSafeJsonRpcClient(url, ProvingJobConsumerSchema, false, 'provingJobConsumer', fetch);
|
|
63
70
|
}
|