@aztec/prover-client 0.0.1-commit.f295ac2 → 0.0.1-commit.f8ca9b2f3
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/light/lightweight_checkpoint_builder.d.ts +9 -6
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +15 -9
- package/dest/mocks/fixtures.d.ts +1 -1
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +2 -1
- package/dest/orchestrator/block-building-helpers.d.ts +1 -1
- package/dest/orchestrator/block-building-helpers.js +1 -1
- package/dest/orchestrator/epoch-proving-state.d.ts +2 -2
- 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 +8 -3
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +90 -74
- package/dest/prover-client/prover-client.d.ts +3 -3
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +15 -10
- package/dest/proving_broker/broker_prover_facade.d.ts +4 -3
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +3 -3
- package/dest/proving_broker/config.d.ts +13 -1
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +19 -2
- 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_agent.d.ts +4 -3
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +4 -4
- 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 +29 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +11 -7
- package/dest/proving_broker/proving_job_controller.d.ts +4 -3
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +6 -3
- package/dest/proving_broker/rpc.d.ts +4 -2
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +8 -0
- package/dest/test/mock_prover.d.ts +3 -3
- package/package.json +15 -15
- package/src/light/lightweight_checkpoint_builder.ts +22 -7
- package/src/mocks/fixtures.ts +2 -1
- package/src/orchestrator/block-building-helpers.ts +1 -1
- package/src/orchestrator/epoch-proving-state.ts +5 -3
- package/src/orchestrator/orchestrator.ts +89 -75
- package/src/prover-client/prover-client.ts +29 -14
- package/src/proving_broker/broker_prover_facade.ts +6 -3
- package/src/proving_broker/config.ts +22 -0
- 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_agent.ts +5 -2
- package/src/proving_broker/proving_broker.ts +30 -1
- package/src/proving_broker/proving_broker_instrumentation.ts +10 -6
- package/src/proving_broker/proving_job_controller.ts +9 -3
- package/src/proving_broker/rpc.ts +14 -0
- 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
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
} from '@aztec/constants';
|
|
7
7
|
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
8
8
|
import { sha256 } from '@aztec/foundation/crypto/sha256';
|
|
9
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
9
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
10
10
|
import { type PromiseWithResolvers, RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
11
11
|
import { truncate } from '@aztec/foundation/string';
|
|
12
12
|
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
@@ -68,14 +68,17 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
68
68
|
private runningPromise?: RunningPromise;
|
|
69
69
|
private timeOfLastSnapshotSync = Date.now();
|
|
70
70
|
private jobsToRetrieve: Set<ProvingJobId> = new Set();
|
|
71
|
+
private log: Logger;
|
|
71
72
|
|
|
72
73
|
constructor(
|
|
73
74
|
private broker: ProvingJobProducer,
|
|
74
75
|
private proofStore: ProofStore = new InlineProofStore(),
|
|
75
76
|
private failedProofStore?: ProofStore,
|
|
76
77
|
private pollIntervalMs = 1000,
|
|
77
|
-
|
|
78
|
-
) {
|
|
78
|
+
bindings?: LoggerBindings,
|
|
79
|
+
) {
|
|
80
|
+
this.log = createLogger('prover-client:broker-circuit-prover-facade', bindings);
|
|
81
|
+
}
|
|
79
82
|
|
|
80
83
|
/**
|
|
81
84
|
* This is a critical section. This function can not be async since it writes
|
|
@@ -31,6 +31,8 @@ export const ProverBrokerConfig = z.object({
|
|
|
31
31
|
proverBrokerBatchIntervalMs: z.number().int().nonnegative(),
|
|
32
32
|
/** The maximum number of epochs to keep results for */
|
|
33
33
|
proverBrokerMaxEpochsToKeepResultsFor: z.number().int().nonnegative(),
|
|
34
|
+
/** Enable debug replay mode for replaying proving jobs from stored inputs */
|
|
35
|
+
proverBrokerDebugReplayEnabled: z.boolean(),
|
|
34
36
|
});
|
|
35
37
|
|
|
36
38
|
export type ProverBrokerConfig = z.infer<typeof ProverBrokerConfig> &
|
|
@@ -74,6 +76,11 @@ export const proverBrokerConfigMappings: ConfigMappingsType<ProverBrokerConfig>
|
|
|
74
76
|
parseEnv: (val: string | undefined) => (val ? +val : undefined),
|
|
75
77
|
description: "The size of the prover broker's database. Will override the dataStoreMapSizeKb if set.",
|
|
76
78
|
},
|
|
79
|
+
proverBrokerDebugReplayEnabled: {
|
|
80
|
+
env: 'PROVER_BROKER_DEBUG_REPLAY_ENABLED',
|
|
81
|
+
description: 'Enable debug replay mode for replaying proving jobs from stored inputs',
|
|
82
|
+
...booleanConfigHelper(false),
|
|
83
|
+
},
|
|
77
84
|
...dataConfigMappings,
|
|
78
85
|
...l1ReaderConfigMappings,
|
|
79
86
|
...pickConfigMappings(chainConfigMappings, ['rollupVersion']),
|
|
@@ -100,6 +107,10 @@ export const ProverAgentConfig = z.object({
|
|
|
100
107
|
proverTestDelayFactor: z.number(),
|
|
101
108
|
/** The delay (ms) to inject during fake proof verification */
|
|
102
109
|
proverTestVerificationDelayMs: z.number().optional(),
|
|
110
|
+
/** Whether to abort pending proving jobs when the orchestrator is cancelled */
|
|
111
|
+
cancelJobsOnStop: z.boolean(),
|
|
112
|
+
/** Where to store proving results. Must be accessible to both prover node and agents. If not set will inline-encode the parameters */
|
|
113
|
+
proofStore: z.string().optional(),
|
|
103
114
|
});
|
|
104
115
|
|
|
105
116
|
export type ProverAgentConfig = z.infer<typeof ProverAgentConfig>;
|
|
@@ -153,4 +164,15 @@ export const proverAgentConfigMappings: ConfigMappingsType<ProverAgentConfig> =
|
|
|
153
164
|
description: 'The delay (ms) to inject during fake proof verification',
|
|
154
165
|
...numberConfigHelper(10),
|
|
155
166
|
},
|
|
167
|
+
cancelJobsOnStop: {
|
|
168
|
+
env: 'PROVER_CANCEL_JOBS_ON_STOP',
|
|
169
|
+
description:
|
|
170
|
+
'Whether to abort pending proving jobs when the orchestrator is cancelled. ' +
|
|
171
|
+
'When false (default), jobs remain in the broker queue and can be reused on restart/reorg.',
|
|
172
|
+
...booleanConfigHelper(false),
|
|
173
|
+
},
|
|
174
|
+
proofStore: {
|
|
175
|
+
env: 'PROVER_PROOF_STORE',
|
|
176
|
+
description: 'Optional proof input store for the prover',
|
|
177
|
+
},
|
|
156
178
|
};
|
|
@@ -1,42 +1,20 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { createFileStore } from '@aztec/stdlib/file-store';
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
+
import { FileStoreProofStore } from './file_store_proof_store.js';
|
|
4
5
|
import { InlineProofStore } from './inline_proof_store.js';
|
|
5
6
|
import type { ProofStore } from './proof_store.js';
|
|
6
7
|
|
|
7
|
-
export function createProofStore(
|
|
8
|
-
|
|
8
|
+
export async function createProofStore(
|
|
9
|
+
config: string | undefined,
|
|
10
|
+
logger = createLogger('prover-client:proof-store'),
|
|
11
|
+
): Promise<ProofStore> {
|
|
12
|
+
if (!config) {
|
|
9
13
|
logger.info('Creating inline proof store');
|
|
10
14
|
return new InlineProofStore();
|
|
11
|
-
} else if (config.startsWith('gs://')) {
|
|
12
|
-
try {
|
|
13
|
-
const url = new URL(config);
|
|
14
|
-
const bucket = url.host;
|
|
15
|
-
const path = url.pathname.replace(/^\/+/, '');
|
|
16
|
-
logger.info(`Creating google cloud proof store at ${bucket}`, { bucket, path });
|
|
17
|
-
return new GoogleCloudStorageProofStore(bucket, path);
|
|
18
|
-
} catch {
|
|
19
|
-
throw new Error(
|
|
20
|
-
`Invalid google cloud proof store definition: '${config}'. Supported values are 'gs://bucket-name/path/to/store'.`,
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
} else {
|
|
24
|
-
throw new Error(`Unknown proof store config: '${config}'. Supported values are 'gs://bucket-name/path/to/store'.`);
|
|
25
15
|
}
|
|
26
|
-
}
|
|
27
16
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
): Pick<ProofStore, 'getProofInput' | 'getProofOutput'> {
|
|
32
|
-
if (uri.startsWith('data://')) {
|
|
33
|
-
return createProofStore(undefined, logger);
|
|
34
|
-
} else if (uri.startsWith('gs://')) {
|
|
35
|
-
const url = new URL(uri);
|
|
36
|
-
const basePath = url.pathname.replace(/^\/+/, '').split('/').slice(0, -3);
|
|
37
|
-
url.pathname = basePath.join('/');
|
|
38
|
-
return createProofStore(uri, logger);
|
|
39
|
-
} else {
|
|
40
|
-
throw new Error(`Unknown proof store config: '${uri}'. Supported protocols are 'data://' and 'gs://'.`);
|
|
41
|
-
}
|
|
17
|
+
const fileStore = await createFileStore(config, logger);
|
|
18
|
+
logger.info(`Creating file store proof store at ${config}`);
|
|
19
|
+
return new FileStoreProofStore(fileStore);
|
|
42
20
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
2
|
+
import type { FileStore } from '@aztec/stdlib/file-store';
|
|
3
|
+
import {
|
|
4
|
+
type ProofUri,
|
|
5
|
+
type ProvingJobId,
|
|
6
|
+
type ProvingJobInputs,
|
|
7
|
+
type ProvingJobInputsMap,
|
|
8
|
+
ProvingJobResult,
|
|
9
|
+
type ProvingJobResultsMap,
|
|
10
|
+
getProvingJobInputClassFor,
|
|
11
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
12
|
+
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
13
|
+
|
|
14
|
+
import type { ProofStore } from './proof_store.js';
|
|
15
|
+
|
|
16
|
+
const INPUTS_PATH = 'inputs';
|
|
17
|
+
const OUTPUTS_PATH = 'outputs';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A proof store implementation backed by a generic FileStore.
|
|
21
|
+
* Supports any storage backend (GCS, S3, local filesystem) via the FileStore abstraction.
|
|
22
|
+
*/
|
|
23
|
+
export class FileStoreProofStore implements ProofStore {
|
|
24
|
+
constructor(private readonly fileStore: FileStore) {}
|
|
25
|
+
|
|
26
|
+
async saveProofInput<T extends ProvingRequestType>(
|
|
27
|
+
id: ProvingJobId,
|
|
28
|
+
type: T,
|
|
29
|
+
inputs: ProvingJobInputsMap[T],
|
|
30
|
+
): Promise<ProofUri> {
|
|
31
|
+
const path = `${INPUTS_PATH}/${ProvingRequestType[type]}/${id}`;
|
|
32
|
+
const uri = await this.fileStore.save(path, inputs.toBuffer());
|
|
33
|
+
return uri as ProofUri;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async saveProofOutput<T extends ProvingRequestType>(
|
|
37
|
+
id: ProvingJobId,
|
|
38
|
+
type: T,
|
|
39
|
+
result: ProvingJobResultsMap[T],
|
|
40
|
+
): Promise<ProofUri> {
|
|
41
|
+
const jobResult = { type, result } as ProvingJobResult;
|
|
42
|
+
const json = jsonStringify(jobResult);
|
|
43
|
+
const path = `${OUTPUTS_PATH}/${ProvingRequestType[type]}/${id}.json`;
|
|
44
|
+
const uri = await this.fileStore.save(path, Buffer.from(json, 'utf-8'));
|
|
45
|
+
return uri as ProofUri;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async getProofInput(uri: ProofUri): Promise<ProvingJobInputs> {
|
|
49
|
+
try {
|
|
50
|
+
const buffer = await this.fileStore.read(uri);
|
|
51
|
+
const type = this.extractTypeFromUri(uri);
|
|
52
|
+
const inputs = getProvingJobInputClassFor(type).fromBuffer(buffer);
|
|
53
|
+
return { inputs, type } as ProvingJobInputs;
|
|
54
|
+
} catch (err) {
|
|
55
|
+
throw new Error(`Error getting proof input at ${uri}: ${err}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async getProofOutput(uri: ProofUri): Promise<ProvingJobResult> {
|
|
60
|
+
try {
|
|
61
|
+
const buffer = await this.fileStore.read(uri);
|
|
62
|
+
return jsonParseWithSchema(buffer.toString('utf-8'), ProvingJobResult);
|
|
63
|
+
} catch (err) {
|
|
64
|
+
throw new Error(`Error getting proof output at ${uri}: ${err}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private extractTypeFromUri(uri: string): ProvingRequestType {
|
|
69
|
+
const url = new URL(uri);
|
|
70
|
+
const pathParts = url.pathname.split('/').filter(Boolean);
|
|
71
|
+
const typeString = pathParts.at(-2);
|
|
72
|
+
const type = typeString ? ProvingRequestType[typeString as keyof typeof ProvingRequestType] : undefined;
|
|
73
|
+
if (type === undefined) {
|
|
74
|
+
throw new Error(`Unrecognized proof type ${typeString} in URI ${uri}`);
|
|
75
|
+
}
|
|
76
|
+
return type;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbortError } from '@aztec/foundation/error';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
4
4
|
import { truncate } from '@aztec/foundation/string';
|
|
5
5
|
import { ProvingError } from '@aztec/stdlib/errors';
|
|
@@ -23,6 +23,7 @@ import { ProvingJobController, ProvingJobControllerStatus } from './proving_job_
|
|
|
23
23
|
export class ProvingAgent {
|
|
24
24
|
private currentJobController?: ProvingJobController;
|
|
25
25
|
private runningPromise: RunningPromise;
|
|
26
|
+
private log: Logger;
|
|
26
27
|
|
|
27
28
|
constructor(
|
|
28
29
|
/** The source of proving jobs */
|
|
@@ -35,8 +36,9 @@ export class ProvingAgent {
|
|
|
35
36
|
private proofAllowList: Array<ProvingRequestType> = [],
|
|
36
37
|
/** How long to wait between jobs */
|
|
37
38
|
private pollIntervalMs = 1000,
|
|
38
|
-
|
|
39
|
+
bindings?: LoggerBindings,
|
|
39
40
|
) {
|
|
41
|
+
this.log = createLogger('prover-client:proving-agent', bindings);
|
|
40
42
|
this.runningPromise = new RunningPromise(this.work.bind(this), this.log, this.pollIntervalMs);
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -159,6 +161,7 @@ export class ProvingAgent {
|
|
|
159
161
|
// no need to await this here. The controller will stay alive (in DONE state) until the result is send to the broker
|
|
160
162
|
void this.runningPromise.trigger();
|
|
161
163
|
},
|
|
164
|
+
this.log.getBindings(),
|
|
162
165
|
);
|
|
163
166
|
|
|
164
167
|
if (abortedProofJobId) {
|
|
@@ -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);
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type ObservableResult,
|
|
9
9
|
type TelemetryClient,
|
|
10
10
|
type UpDownCounter,
|
|
11
|
+
createUpDownCounterWithDefault,
|
|
11
12
|
} from '@aztec/telemetry-client';
|
|
12
13
|
|
|
13
14
|
export type MonitorCallback = (proofType: ProvingRequestType) => number;
|
|
@@ -31,17 +32,20 @@ export class ProvingBrokerInstrumentation {
|
|
|
31
32
|
|
|
32
33
|
this.activeJobs = meter.createObservableGauge(Metrics.PROVING_QUEUE_ACTIVE_JOBS);
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
const provingJobTypes = Object.values(ProvingRequestType).filter(v => typeof v === 'string');
|
|
36
|
+
const provingJobAttrs = { [Attributes.PROVING_JOB_TYPE]: provingJobTypes };
|
|
35
37
|
|
|
36
|
-
this.
|
|
38
|
+
this.resolvedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_RESOLVED_JOBS, provingJobAttrs);
|
|
37
39
|
|
|
38
|
-
this.
|
|
40
|
+
this.rejectedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_REJECTED_JOBS, provingJobAttrs);
|
|
39
41
|
|
|
40
|
-
this.
|
|
42
|
+
this.retriedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_RETRIED_JOBS, provingJobAttrs);
|
|
41
43
|
|
|
42
|
-
this.
|
|
44
|
+
this.timedOutJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_TIMED_OUT_JOBS, provingJobAttrs);
|
|
43
45
|
|
|
44
|
-
this.
|
|
46
|
+
this.cachedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_CACHED_JOBS, provingJobAttrs);
|
|
47
|
+
|
|
48
|
+
this.totalJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_TOTAL_JOBS, provingJobAttrs);
|
|
45
49
|
|
|
46
50
|
this.jobWait = meter.createHistogram(Metrics.PROVING_QUEUE_JOB_WAIT);
|
|
47
51
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
3
3
|
import { AbortError } from '@aztec/foundation/error';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import type {
|
|
6
6
|
ProvingJobId,
|
|
7
7
|
ProvingJobInputs,
|
|
@@ -21,6 +21,7 @@ export class ProvingJobController {
|
|
|
21
21
|
private promise?: Promise<void>;
|
|
22
22
|
private abortController = new AbortController();
|
|
23
23
|
private result?: ProvingJobResultsMap[ProvingRequestType] | Error;
|
|
24
|
+
private log: Logger;
|
|
24
25
|
|
|
25
26
|
constructor(
|
|
26
27
|
private jobId: ProvingJobId,
|
|
@@ -29,8 +30,13 @@ export class ProvingJobController {
|
|
|
29
30
|
private startedAt: number,
|
|
30
31
|
private circuitProver: ServerCircuitProver,
|
|
31
32
|
private onComplete: () => void,
|
|
32
|
-
|
|
33
|
-
) {
|
|
33
|
+
bindings?: LoggerBindings,
|
|
34
|
+
) {
|
|
35
|
+
this.log = createLogger('prover-client:proving-agent:job-controller', {
|
|
36
|
+
instanceId: randomBytes(4).toString('hex'),
|
|
37
|
+
...bindings,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
34
40
|
|
|
35
41
|
public start(): void {
|
|
36
42
|
if (this.status !== ProvingJobControllerStatus.IDLE) {
|
|
@@ -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,
|
|
@@ -53,6 +55,18 @@ export const ProvingJobBrokerSchema: ApiSchemaFor<ProvingJobBroker> = {
|
|
|
53
55
|
...ProvingJobProducerSchema,
|
|
54
56
|
};
|
|
55
57
|
|
|
58
|
+
export const ProvingJobBrokerDebugSchema: ApiSchemaFor<ProvingJobBrokerDebug> = {
|
|
59
|
+
replayProvingJob: z
|
|
60
|
+
.function()
|
|
61
|
+
.args(ProvingJobId, z.nativeEnum(ProvingRequestType), EpochNumberSchema, ProofUri)
|
|
62
|
+
.returns(ProvingJobStatus),
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const ProvingJobBrokerSchemaWithDebug: ApiSchemaFor<ProvingJobBroker & ProvingJobBrokerDebug> = {
|
|
66
|
+
...ProvingJobBrokerSchema,
|
|
67
|
+
...ProvingJobBrokerDebugSchema,
|
|
68
|
+
};
|
|
69
|
+
|
|
56
70
|
export function createProvingJobBrokerClient(
|
|
57
71
|
url: string,
|
|
58
72
|
versions: Partial<ComponentsVersions>,
|
|
@@ -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
|
-
}
|