@aztec/prover-client 0.0.1-commit.b33fc05d0 → 0.0.1-commit.b3d3157a
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 +16 -2
- package/dest/light/lightweight_checkpoint_builder.d.ts +1 -1
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +16 -4
- package/dest/mocks/test_context.d.ts +3 -1
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +13 -6
- package/dest/orchestrator/block-building-helpers.d.ts +1 -1
- package/dest/orchestrator/checkpoint-proving-state.d.ts +8 -1
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +10 -1
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts +107 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.js +151 -0
- package/dest/orchestrator/epoch-proving-context.d.ts +51 -0
- package/dest/orchestrator/epoch-proving-context.d.ts.map +1 -0
- package/dest/orchestrator/epoch-proving-context.js +81 -0
- package/dest/orchestrator/epoch-proving-state.d.ts +1 -1
- package/dest/orchestrator/index.d.ts +4 -1
- package/dest/orchestrator/index.d.ts.map +1 -1
- package/dest/orchestrator/index.js +3 -0
- package/dest/orchestrator/orchestrator.d.ts +14 -26
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +32 -166
- package/dest/orchestrator/proving-scheduler.d.ts +72 -0
- package/dest/orchestrator/proving-scheduler.d.ts.map +1 -0
- package/dest/orchestrator/proving-scheduler.js +117 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts +83 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-orchestrator.js +182 -0
- package/dest/orchestrator/top-tree-proving-scheduler.d.ts +62 -0
- package/dest/orchestrator/top-tree-proving-scheduler.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-proving-scheduler.js +73 -0
- package/dest/orchestrator/top-tree-proving-state.d.ts +61 -0
- package/dest/orchestrator/top-tree-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-proving-state.js +185 -0
- package/dest/prover-client/prover-client.d.ts +61 -2
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +49 -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 +10 -16
- package/dest/proving_broker/config.d.ts +8 -72
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +2 -2
- package/dest/proving_broker/index.d.ts +2 -1
- package/dest/proving_broker/index.d.ts.map +1 -1
- package/dest/proving_broker/index.js +1 -0
- package/dest/proving_broker/proving_broker.d.ts +2 -2
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +32 -7
- package/dest/proving_broker/proving_broker_database/persisted.js +2 -2
- package/dest/proving_broker/rpc.d.ts +3 -1
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +80 -24
- package/dest/test/mock_prover.d.ts +3 -3
- package/package.json +17 -17
- package/src/config.ts +18 -2
- package/src/light/lightweight_checkpoint_builder.ts +21 -6
- package/src/mocks/test_context.ts +11 -7
- package/src/orchestrator/checkpoint-proving-state.ts +14 -1
- package/src/orchestrator/checkpoint-sub-tree-orchestrator.ts +271 -0
- package/src/orchestrator/epoch-proving-context.ts +101 -0
- package/src/orchestrator/index.ts +8 -0
- package/src/orchestrator/orchestrator.ts +46 -222
- package/src/orchestrator/proving-scheduler.ts +156 -0
- package/src/orchestrator/top-tree-orchestrator.ts +314 -0
- package/src/orchestrator/top-tree-proving-scheduler.ts +154 -0
- package/src/orchestrator/top-tree-proving-state.ts +220 -0
- package/src/prover-client/prover-client.ts +125 -1
- package/src/proving_broker/broker_prover_facade.ts +8 -16
- package/src/proving_broker/config.ts +2 -1
- package/src/proving_broker/index.ts +1 -0
- package/src/proving_broker/proving_broker.ts +27 -5
- package/src/proving_broker/proving_broker_database/persisted.ts +2 -2
- package/src/proving_broker/rpc.ts +36 -24
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ACVMConfig, type BBConfig, BBNativeRollupProver, TestCircuitProver } from '@aztec/bb-prover';
|
|
2
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { times } from '@aztec/foundation/collection';
|
|
4
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
5
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
6
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
7
|
import { NativeACVMSimulator } from '@aztec/simulator/server';
|
|
@@ -15,19 +17,64 @@ import {
|
|
|
15
17
|
type ServerCircuitProver,
|
|
16
18
|
tryStop,
|
|
17
19
|
} from '@aztec/stdlib/interfaces/server';
|
|
20
|
+
import type { CheckpointConstantData } from '@aztec/stdlib/rollup';
|
|
21
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
18
22
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
19
23
|
|
|
20
24
|
import type { ProverClientConfig } from '../config.js';
|
|
25
|
+
import { CheckpointSubTreeOrchestrator } from '../orchestrator/checkpoint-sub-tree-orchestrator.js';
|
|
26
|
+
import { EpochProvingContext } from '../orchestrator/epoch-proving-context.js';
|
|
21
27
|
import { ProvingOrchestrator } from '../orchestrator/orchestrator.js';
|
|
28
|
+
import { TopTreeOrchestrator } from '../orchestrator/top-tree-orchestrator.js';
|
|
22
29
|
import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
23
30
|
import { InlineProofStore, type ProofStore, createProofStore } from '../proving_broker/proof_store/index.js';
|
|
24
31
|
import { ProvingAgent } from '../proving_broker/proving_agent.js';
|
|
25
32
|
import { ServerEpochProver } from './server-epoch-prover.js';
|
|
26
33
|
|
|
34
|
+
/**
|
|
35
|
+
* The factory surface that `EpochProvingJob` (in `prover-node`) depends on. Implemented
|
|
36
|
+
* by `ProverClient`. Defined here rather than in stdlib because the return types
|
|
37
|
+
* (`CheckpointSubTreeOrchestrator`, `TopTreeOrchestrator`) are concrete classes from
|
|
38
|
+
* this package.
|
|
39
|
+
*
|
|
40
|
+
* A single `BrokerCircuitProverFacade` is owned by `ProverClient` and shared across
|
|
41
|
+
* every orchestrator (every sub-tree and every top-tree across every concurrent epoch
|
|
42
|
+
* job). The broker delivers each completed-job notification exactly once (drained on
|
|
43
|
+
* the first `getCompletedJobs` poll), so multiple facades polling the same broker
|
|
44
|
+
* race and lose notifications
|
|
45
|
+
*
|
|
46
|
+
* The facade's job map cleans up entries on resolve/reject, and the prover-node
|
|
47
|
+
* keeps `ProverClient` alive for its whole lifetime
|
|
48
|
+
*/
|
|
49
|
+
export interface EpochProverFactory {
|
|
50
|
+
getProverId(): EthAddress;
|
|
51
|
+
/**
|
|
52
|
+
* Constructs a per-epoch shared context for the caching of e.g. chonk verifier results
|
|
53
|
+
*/
|
|
54
|
+
createEpochProvingContext(epochNumber: EpochNumber): EpochProvingContext;
|
|
55
|
+
/**
|
|
56
|
+
* Constructs and starts a `CheckpointSubTreeOrchestrator` for a single checkpoint.
|
|
57
|
+
*/
|
|
58
|
+
createCheckpointSubTreeOrchestrator(
|
|
59
|
+
epochContext: EpochProvingContext,
|
|
60
|
+
checkpointConstants: CheckpointConstantData,
|
|
61
|
+
l1ToL2Messages: Fr[],
|
|
62
|
+
totalNumBlocks: number,
|
|
63
|
+
headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
64
|
+
): Promise<CheckpointSubTreeOrchestrator>;
|
|
65
|
+
createTopTreeOrchestrator(): TopTreeOrchestrator;
|
|
66
|
+
}
|
|
67
|
+
|
|
27
68
|
/** Manages proving of epochs by orchestrating the proving of individual blocks relying on a pool of prover agents. */
|
|
28
|
-
export class ProverClient implements EpochProverManager {
|
|
69
|
+
export class ProverClient implements EpochProverManager, EpochProverFactory {
|
|
29
70
|
private running = false;
|
|
30
71
|
private agents: ProvingAgent[] = [];
|
|
72
|
+
/**
|
|
73
|
+
* The single broker facade shared by every orchestrator created from this client.
|
|
74
|
+
* Constructed lazily on `start()` and torn down on `stop()` — see the comment on
|
|
75
|
+
* `EpochProverFactory` for why a single shared facade is required.
|
|
76
|
+
*/
|
|
77
|
+
private facade: BrokerCircuitProverFacade | undefined;
|
|
31
78
|
|
|
32
79
|
private constructor(
|
|
33
80
|
private config: ProverClientConfig,
|
|
@@ -40,6 +87,38 @@ export class ProverClient implements EpochProverManager {
|
|
|
40
87
|
private log: Logger = createLogger('prover-client:tx-prover'),
|
|
41
88
|
) {}
|
|
42
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Lazy-init the shared facade. The broker delivers each completed-job notification
|
|
92
|
+
* exactly once (drained on the first `getCompletedJobs` poll), so we cannot start
|
|
93
|
+
* a shared facade alongside the per-call facades that `createEpochProver` builds —
|
|
94
|
+
* they would race for notifications and one side would silently drop them. Starting
|
|
95
|
+
* the shared facade only on first use of one of the new factory methods keeps the
|
|
96
|
+
* legacy `createEpochProver` path race-free.
|
|
97
|
+
*/
|
|
98
|
+
private getFacade(): BrokerCircuitProverFacade {
|
|
99
|
+
if (!this.running) {
|
|
100
|
+
throw new Error('ProverClient is not running; call start() before constructing orchestrators.');
|
|
101
|
+
}
|
|
102
|
+
if (!this.facade) {
|
|
103
|
+
this.facade = new BrokerCircuitProverFacade(
|
|
104
|
+
this.orchestratorClient,
|
|
105
|
+
this.proofStore,
|
|
106
|
+
this.failedProofStore,
|
|
107
|
+
undefined,
|
|
108
|
+
this.log.getBindings(),
|
|
109
|
+
);
|
|
110
|
+
this.facade.start();
|
|
111
|
+
}
|
|
112
|
+
return this.facade;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Legacy single-class epoch prover. Each call constructs its own
|
|
117
|
+
* `BrokerCircuitProverFacade`; the new factory methods (`createCheckpointSubTreeOrchestrator`,
|
|
118
|
+
* `createTopTreeOrchestrator`, `createEpochProvingContext`) share a single facade
|
|
119
|
+
* owned by `ProverClient`. Both APIs coexist while the prover-node migrates onto
|
|
120
|
+
* the new pair.
|
|
121
|
+
*/
|
|
43
122
|
public createEpochProver(): EpochProver {
|
|
44
123
|
const bindings = this.log.getBindings();
|
|
45
124
|
const facade = new BrokerCircuitProverFacade(
|
|
@@ -61,6 +140,43 @@ export class ProverClient implements EpochProverManager {
|
|
|
61
140
|
return new ServerEpochProver(facade, orchestrator);
|
|
62
141
|
}
|
|
63
142
|
|
|
143
|
+
public createEpochProvingContext(epochNumber: EpochNumber): EpochProvingContext {
|
|
144
|
+
return new EpochProvingContext(this.getFacade(), epochNumber, this.log.getBindings());
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public createCheckpointSubTreeOrchestrator(
|
|
148
|
+
epochContext: EpochProvingContext,
|
|
149
|
+
checkpointConstants: CheckpointConstantData,
|
|
150
|
+
l1ToL2Messages: Fr[],
|
|
151
|
+
totalNumBlocks: number,
|
|
152
|
+
headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
153
|
+
): Promise<CheckpointSubTreeOrchestrator> {
|
|
154
|
+
return CheckpointSubTreeOrchestrator.start(
|
|
155
|
+
this.worldState,
|
|
156
|
+
this.getFacade(),
|
|
157
|
+
this.config.proverId,
|
|
158
|
+
epochContext,
|
|
159
|
+
this.config.cancelJobsOnStop,
|
|
160
|
+
this.config.enqueueConcurrency,
|
|
161
|
+
checkpointConstants,
|
|
162
|
+
l1ToL2Messages,
|
|
163
|
+
totalNumBlocks,
|
|
164
|
+
headerOfLastBlockInPreviousCheckpoint,
|
|
165
|
+
this.telemetry,
|
|
166
|
+
this.log.getBindings(),
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public createTopTreeOrchestrator(): TopTreeOrchestrator {
|
|
171
|
+
return new TopTreeOrchestrator(
|
|
172
|
+
this.getFacade(),
|
|
173
|
+
this.config.proverId,
|
|
174
|
+
this.config.enqueueConcurrency,
|
|
175
|
+
this.telemetry,
|
|
176
|
+
this.log.getBindings(),
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
64
180
|
public getProverId(): EthAddress {
|
|
65
181
|
return this.config.proverId;
|
|
66
182
|
}
|
|
@@ -100,6 +216,14 @@ export class ProverClient implements EpochProverManager {
|
|
|
100
216
|
}
|
|
101
217
|
this.running = false;
|
|
102
218
|
await this.stopAgents();
|
|
219
|
+
if (this.facade) {
|
|
220
|
+
try {
|
|
221
|
+
await this.facade.stop();
|
|
222
|
+
} catch (err) {
|
|
223
|
+
this.log.error('Error stopping shared broker facade', err);
|
|
224
|
+
}
|
|
225
|
+
this.facade = undefined;
|
|
226
|
+
}
|
|
103
227
|
await tryStop(this.orchestratorClient);
|
|
104
228
|
}
|
|
105
229
|
|
|
@@ -4,7 +4,9 @@ import type {
|
|
|
4
4
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
5
5
|
RECURSIVE_PROOF_LENGTH,
|
|
6
6
|
} from '@aztec/constants';
|
|
7
|
+
import { asyncPool } from '@aztec/foundation/async-pool';
|
|
7
8
|
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
9
|
+
import { chunk } from '@aztec/foundation/collection';
|
|
8
10
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
9
11
|
import { type PromiseWithResolvers, RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
10
12
|
import { truncate } from '@aztec/foundation/string';
|
|
@@ -226,17 +228,11 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
226
228
|
// We collect all returned notifications and return them
|
|
227
229
|
const allCompleted = new Set<ProvingJobId>();
|
|
228
230
|
try {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
const completed = await this.broker.getCompletedJobs(slice);
|
|
231
|
+
const batches = ids.length > 0 ? chunk(ids, SNAPSHOT_SYNC_CHECK_MAX_REQUEST_SIZE) : [[]];
|
|
232
|
+
await asyncPool(1, batches, async batch => {
|
|
233
|
+
const completed = await this.broker.getCompletedJobs(batch);
|
|
233
234
|
completed.forEach(id => allCompleted.add(id));
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
if (numRequests === 0) {
|
|
237
|
-
const final = await this.broker.getCompletedJobs([]);
|
|
238
|
-
final.forEach(id => allCompleted.add(id));
|
|
239
|
-
}
|
|
235
|
+
});
|
|
240
236
|
} catch (err) {
|
|
241
237
|
this.log.error(`Error thrown when requesting completed job notifications from the broker`, err);
|
|
242
238
|
}
|
|
@@ -352,12 +348,8 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
352
348
|
.map(id => this.jobs.get(id)!)
|
|
353
349
|
.filter(x => x !== undefined);
|
|
354
350
|
const totalJobsToRetrieve = toBeRetrieved.length;
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
const slice = toBeRetrieved.splice(0, MAX_CONCURRENT_JOB_SETTLED_REQUESTS);
|
|
358
|
-
const results = await Promise.all(slice.map(job => processJob(job!)));
|
|
359
|
-
totalJobsRetrieved += results.filter(x => x).length;
|
|
360
|
-
}
|
|
351
|
+
const results = await asyncPool(MAX_CONCURRENT_JOB_SETTLED_REQUESTS, toBeRetrieved, job => processJob(job));
|
|
352
|
+
const totalJobsRetrieved = results.filter(x => x).length;
|
|
361
353
|
if (totalJobsToRetrieve > 0) {
|
|
362
354
|
this.log.verbose(
|
|
363
355
|
`Successfully retrieved ${totalJobsRetrieved} of ${totalJobsToRetrieve} jobs that should be ready, total ready jobs is now: ${this.jobsToRetrieve.size}`,
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
booleanConfigHelper,
|
|
5
5
|
getDefaultConfig,
|
|
6
6
|
numberConfigHelper,
|
|
7
|
+
optionalNumberConfigHelper,
|
|
7
8
|
} from '@aztec/foundation/config';
|
|
8
9
|
import { pickConfigMappings } from '@aztec/foundation/config';
|
|
9
10
|
import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
|
|
@@ -73,7 +74,7 @@ export const proverBrokerConfigMappings: ConfigMappingsType<ProverBrokerConfig>
|
|
|
73
74
|
},
|
|
74
75
|
proverBrokerStoreMapSizeKb: {
|
|
75
76
|
env: 'PROVER_BROKER_STORE_MAP_SIZE_KB',
|
|
76
|
-
|
|
77
|
+
...optionalNumberConfigHelper(),
|
|
77
78
|
description: "The size of the prover broker's database. Will override the dataStoreMapSizeKb if set.",
|
|
78
79
|
},
|
|
79
80
|
proverBrokerDebugReplayEnabled: {
|
|
@@ -319,14 +319,20 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Pr
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
private cleanUpProvingJobState(ids: ProvingJobId[]) {
|
|
322
|
+
const idsToClean = new Set(ids);
|
|
322
323
|
for (const id of ids) {
|
|
323
324
|
this.jobsCache.delete(id);
|
|
325
|
+
const deferred = this.promises.get(id);
|
|
326
|
+
if (deferred) {
|
|
327
|
+
deferred.resolve({ status: 'rejected', reason: 'Proving job cleaned up' });
|
|
328
|
+
}
|
|
324
329
|
this.promises.delete(id);
|
|
325
330
|
this.resultsCache.delete(id);
|
|
326
331
|
this.inProgress.delete(id);
|
|
327
332
|
this.retries.delete(id);
|
|
328
333
|
this.enqueuedAt.delete(id);
|
|
329
334
|
}
|
|
335
|
+
this.completedJobNotifications = this.completedJobNotifications.filter(id => !idsToClean.has(id));
|
|
330
336
|
}
|
|
331
337
|
|
|
332
338
|
#getProvingJobStatus(id: ProvingJobId): ProvingJobStatus {
|
|
@@ -594,21 +600,21 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Pr
|
|
|
594
600
|
}
|
|
595
601
|
|
|
596
602
|
private async cleanupPass() {
|
|
597
|
-
this.cleanupStaleJobs();
|
|
598
603
|
this.reEnqueueExpiredJobs();
|
|
599
604
|
const oldestEpochToKeep = this.oldestEpochToKeep();
|
|
600
605
|
if (oldestEpochToKeep > 0) {
|
|
606
|
+
this.cleanupJobsOlderThanEpoch(EpochNumber(oldestEpochToKeep));
|
|
601
607
|
await this.database.deleteAllProvingJobsOlderThanEpoch(EpochNumber(oldestEpochToKeep));
|
|
602
608
|
this.logger.trace(`Deleted all epochs older than ${oldestEpochToKeep}`);
|
|
603
609
|
}
|
|
604
610
|
}
|
|
605
611
|
|
|
606
|
-
private
|
|
612
|
+
private cleanupJobsOlderThanEpoch(epochNumber: EpochNumber) {
|
|
607
613
|
const jobIds = Array.from(this.jobsCache.keys());
|
|
608
614
|
const jobsToClean: ProvingJobId[] = [];
|
|
609
615
|
for (const id of jobIds) {
|
|
610
616
|
const job = this.jobsCache.get(id)!;
|
|
611
|
-
if (
|
|
617
|
+
if (job.epochNumber < epochNumber) {
|
|
612
618
|
jobsToClean.push(id);
|
|
613
619
|
}
|
|
614
620
|
}
|
|
@@ -632,10 +638,26 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Pr
|
|
|
632
638
|
const now = this.msTimeSource();
|
|
633
639
|
const msSinceLastUpdate = now - metadata.lastUpdatedAt;
|
|
634
640
|
if (msSinceLastUpdate >= this.jobTimeoutMs) {
|
|
635
|
-
this.logger.warn(`Proving job id=${id} timed out. Adding it back to the queue.`, { provingJobId: id });
|
|
636
641
|
this.inProgress.delete(id);
|
|
637
|
-
this.enqueueJobInternal(item);
|
|
638
642
|
this.instrumentation.incTimedOutJobs(item.type);
|
|
643
|
+
|
|
644
|
+
const retries = this.retries.get(id) ?? 0;
|
|
645
|
+
if (retries + 1 < this.maxRetries && !this.isJobStale(item)) {
|
|
646
|
+
this.logger.warn(`Proving job id=${id} timed out. Re-enqueueing (retry ${retries + 1}/${this.maxRetries}).`, {
|
|
647
|
+
provingJobId: id,
|
|
648
|
+
});
|
|
649
|
+
this.retries.set(id, retries + 1);
|
|
650
|
+
this.enqueueJobInternal(item);
|
|
651
|
+
} else {
|
|
652
|
+
this.logger.error(`Proving job id=${id} timed out after ${retries + 1} attempts. Marking as failed.`, {
|
|
653
|
+
provingJobId: id,
|
|
654
|
+
});
|
|
655
|
+
const result: ProvingJobSettledResult = { status: 'rejected', reason: 'Timed out' };
|
|
656
|
+
this.resultsCache.set(id, result);
|
|
657
|
+
this.promises.get(id)?.resolve(result);
|
|
658
|
+
this.completedJobNotifications.push(id);
|
|
659
|
+
this.instrumentation.incRejectedJobs(item.type);
|
|
660
|
+
}
|
|
639
661
|
}
|
|
640
662
|
}
|
|
641
663
|
}
|
|
@@ -154,7 +154,7 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
154
154
|
const db = await openVersionedStoreAt(
|
|
155
155
|
fullDirectory,
|
|
156
156
|
SingleEpochDatabase.SCHEMA_VERSION,
|
|
157
|
-
config.
|
|
157
|
+
config.rollupAddress,
|
|
158
158
|
config.dataStoreMapSizeKb,
|
|
159
159
|
);
|
|
160
160
|
const epochDb = new SingleEpochDatabase(db);
|
|
@@ -222,7 +222,7 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
222
222
|
const db = await openVersionedStoreAt(
|
|
223
223
|
newEpochDirectory,
|
|
224
224
|
SingleEpochDatabase.SCHEMA_VERSION,
|
|
225
|
-
this.config.
|
|
225
|
+
this.config.rollupAddress,
|
|
226
226
|
this.config.dataStoreMapSizeKb,
|
|
227
227
|
);
|
|
228
228
|
epochDb = new SingleEpochDatabase(db);
|
|
@@ -18,6 +18,15 @@ import { makeTracedFetch } from '@aztec/telemetry-client';
|
|
|
18
18
|
|
|
19
19
|
import { z } from 'zod';
|
|
20
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
|
+
|
|
21
30
|
const ProvingJobFilterSchema = z.object({
|
|
22
31
|
allowList: z.array(z.nativeEnum(ProvingRequestType)),
|
|
23
32
|
});
|
|
@@ -28,26 +37,29 @@ const GetProvingJobResponse = z.object({
|
|
|
28
37
|
});
|
|
29
38
|
|
|
30
39
|
export const ProvingJobProducerSchema: ApiSchemaFor<ProvingJobProducer> = {
|
|
31
|
-
enqueueProvingJob: z.function(
|
|
32
|
-
getProvingJobStatus: z.function(
|
|
33
|
-
cancelProvingJob: z.function(
|
|
34
|
-
getCompletedJobs: z.function(
|
|
40
|
+
enqueueProvingJob: z.function({ input: z.tuple([ProvingJob]), output: ProvingJobStatus }),
|
|
41
|
+
getProvingJobStatus: z.function({ input: z.tuple([ProvingJobId]), output: ProvingJobStatus }),
|
|
42
|
+
cancelProvingJob: z.function({ input: z.tuple([ProvingJobId]), output: z.void() }),
|
|
43
|
+
getCompletedJobs: z.function({ input: z.tuple([z.array(ProvingJobId)]), output: z.array(ProvingJobId) }),
|
|
35
44
|
};
|
|
36
45
|
|
|
37
46
|
export const ProvingJobConsumerSchema: ApiSchemaFor<ProvingJobConsumer> = {
|
|
38
|
-
getProvingJob: z.function(
|
|
39
|
-
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
.
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
getProvingJob: z.function({
|
|
48
|
+
input: z.tuple([optional(ProvingJobFilterSchema)]),
|
|
49
|
+
output: GetProvingJobResponse.optional(),
|
|
50
|
+
}),
|
|
51
|
+
reportProvingJobError: z.function({
|
|
52
|
+
input: z.tuple([ProvingJobId, z.string(), optional(z.boolean()), optional(ProvingJobFilterSchema)]),
|
|
53
|
+
output: GetProvingJobResponse.optional(),
|
|
54
|
+
}),
|
|
55
|
+
reportProvingJobProgress: z.function({
|
|
56
|
+
input: z.tuple([ProvingJobId, z.number(), optional(ProvingJobFilterSchema)]),
|
|
57
|
+
output: GetProvingJobResponse.optional(),
|
|
58
|
+
}),
|
|
59
|
+
reportProvingJobSuccess: z.function({
|
|
60
|
+
input: z.tuple([ProvingJobId, ProofUri, optional(ProvingJobFilterSchema)]),
|
|
61
|
+
output: GetProvingJobResponse.optional(),
|
|
62
|
+
}),
|
|
51
63
|
};
|
|
52
64
|
|
|
53
65
|
export const ProvingJobBrokerSchema: ApiSchemaFor<ProvingJobBroker> = {
|
|
@@ -56,10 +68,10 @@ export const ProvingJobBrokerSchema: ApiSchemaFor<ProvingJobBroker> = {
|
|
|
56
68
|
};
|
|
57
69
|
|
|
58
70
|
export const ProvingJobBrokerDebugSchema: ApiSchemaFor<ProvingJobBrokerDebug> = {
|
|
59
|
-
replayProvingJob: z
|
|
60
|
-
.
|
|
61
|
-
|
|
62
|
-
|
|
71
|
+
replayProvingJob: z.function({
|
|
72
|
+
input: z.tuple([ProvingJobId, z.nativeEnum(ProvingRequestType), EpochNumberSchema, ProofUri]),
|
|
73
|
+
output: ProvingJobStatus,
|
|
74
|
+
}),
|
|
63
75
|
};
|
|
64
76
|
|
|
65
77
|
export const ProvingJobBrokerSchemaWithDebug: ApiSchemaFor<ProvingJobBroker & ProvingJobBrokerDebug> = {
|
|
@@ -70,7 +82,7 @@ export const ProvingJobBrokerSchemaWithDebug: ApiSchemaFor<ProvingJobBroker & Pr
|
|
|
70
82
|
export function createProvingJobBrokerClient(
|
|
71
83
|
url: string,
|
|
72
84
|
versions: Partial<ComponentsVersions>,
|
|
73
|
-
fetch = makeTracedFetch(
|
|
85
|
+
fetch = makeTracedFetch(proverBrokerBackoff, false),
|
|
74
86
|
): ProvingJobBroker {
|
|
75
87
|
return createSafeJsonRpcClient(url, ProvingJobBrokerSchema, {
|
|
76
88
|
namespaceMethods: 'proverBroker',
|
|
@@ -82,7 +94,7 @@ export function createProvingJobBrokerClient(
|
|
|
82
94
|
export function createProvingJobProducerClient(
|
|
83
95
|
url: string,
|
|
84
96
|
versions: Partial<ComponentsVersions>,
|
|
85
|
-
fetch = makeTracedFetch(
|
|
97
|
+
fetch = makeTracedFetch(proverBrokerBackoff, false),
|
|
86
98
|
): ProvingJobProducer {
|
|
87
99
|
return createSafeJsonRpcClient(url, ProvingJobProducerSchema, {
|
|
88
100
|
namespaceMethods: 'provingJobProducer',
|
|
@@ -94,7 +106,7 @@ export function createProvingJobProducerClient(
|
|
|
94
106
|
export function createProvingJobConsumerClient(
|
|
95
107
|
url: string,
|
|
96
108
|
versions: Partial<ComponentsVersions>,
|
|
97
|
-
fetch = makeTracedFetch(
|
|
109
|
+
fetch = makeTracedFetch(proverBrokerBackoff, false),
|
|
98
110
|
): ProvingJobConsumer {
|
|
99
111
|
return createSafeJsonRpcClient(url, ProvingJobConsumerSchema, {
|
|
100
112
|
namespaceMethods: 'provingJobConsumer',
|