@aztec/prover-client 0.0.0-test.1 → 0.0.1-commit.017a351
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 +8 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +26 -2
- package/dest/index.d.ts +1 -1
- package/dest/light/index.d.ts +2 -0
- package/dest/light/index.d.ts.map +1 -0
- package/dest/light/index.js +1 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts +52 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -0
- package/dest/light/lightweight_checkpoint_builder.js +231 -0
- package/dest/mocks/fixtures.d.ts +8 -8
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +36 -17
- package/dest/mocks/test_context.d.ts +45 -32
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +162 -90
- package/dest/orchestrator/block-building-helpers.d.ts +36 -29
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +170 -189
- package/dest/orchestrator/block-proving-state.d.ts +73 -48
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +289 -177
- package/dest/orchestrator/checkpoint-proving-state.d.ts +83 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-proving-state.js +252 -0
- 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 +43 -28
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +179 -73
- 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 +59 -51
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +808 -385
- package/dest/orchestrator/orchestrator_metrics.d.ts +1 -1
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +2 -6
- 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/orchestrator/tx-proving-state.d.ts +15 -12
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +27 -44
- package/dest/prover-client/factory.d.ts +3 -3
- package/dest/prover-client/factory.d.ts.map +1 -1
- package/dest/prover-client/index.d.ts +1 -1
- package/dest/prover-client/prover-client.d.ts +68 -9
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +68 -14
- package/dest/prover-client/server-epoch-prover.d.ts +16 -12
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +11 -11
- package/dest/proving_broker/broker_prover_facade.d.ts +28 -19
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +74 -61
- package/dest/proving_broker/config.d.ts +18 -61
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +43 -9
- package/dest/proving_broker/factory.d.ts +2 -2
- package/dest/proving_broker/factory.d.ts.map +1 -1
- package/dest/proving_broker/factory.js +5 -1
- package/dest/proving_broker/fixtures.d.ts +3 -2
- package/dest/proving_broker/fixtures.d.ts.map +1 -1
- package/dest/proving_broker/fixtures.js +3 -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/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 -1
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -0
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts +1 -1
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/proof_store.d.ts +1 -1
- package/dest/proving_broker/proving_agent.d.ts +8 -12
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +86 -65
- package/dest/proving_broker/proving_broker.d.ts +18 -6
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +108 -44
- 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 +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +5 -3
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +401 -11
- package/dest/proving_broker/proving_broker_database.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
- 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 +22 -35
- package/dest/proving_broker/proving_job_controller.d.ts +11 -10
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +92 -62
- package/dest/proving_broker/rpc.d.ts +9 -7
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +88 -27
- package/dest/test/mock_proof_store.d.ts +9 -0
- package/dest/test/mock_proof_store.d.ts.map +1 -0
- package/dest/test/mock_proof_store.js +10 -0
- package/dest/test/mock_prover.d.ts +23 -17
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +38 -20
- package/package.json +34 -33
- package/src/config.ts +41 -9
- package/src/light/index.ts +1 -0
- package/src/light/lightweight_checkpoint_builder.ts +320 -0
- package/src/mocks/fixtures.ts +46 -40
- package/src/mocks/test_context.ts +231 -120
- package/src/orchestrator/block-building-helpers.ts +258 -334
- package/src/orchestrator/block-proving-state.ts +334 -231
- package/src/orchestrator/checkpoint-proving-state.ts +362 -0
- package/src/orchestrator/checkpoint-sub-tree-orchestrator.ts +271 -0
- package/src/orchestrator/epoch-proving-context.ts +101 -0
- package/src/orchestrator/epoch-proving-state.ts +239 -111
- package/src/orchestrator/index.ts +8 -0
- package/src/orchestrator/orchestrator.ts +591 -451
- package/src/orchestrator/orchestrator_metrics.ts +2 -6
- 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/orchestrator/tx-proving-state.ts +48 -66
- package/src/prover-client/factory.ts +6 -2
- package/src/prover-client/prover-client.ts +173 -38
- package/src/prover-client/server-epoch-prover.ts +40 -22
- package/src/proving_broker/broker_prover_facade.ts +227 -149
- package/src/proving_broker/config.ts +49 -8
- package/src/proving_broker/factory.ts +2 -1
- package/src/proving_broker/fixtures.ts +8 -3
- package/src/proving_broker/index.ts +1 -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 -0
- package/src/proving_broker/proof_store/inline_proof_store.ts +1 -1
- package/src/proving_broker/proving_agent.ts +95 -66
- package/src/proving_broker/proving_broker.ts +121 -49
- package/src/proving_broker/proving_broker_database/memory.ts +3 -2
- package/src/proving_broker/proving_broker_database/persisted.ts +31 -15
- package/src/proving_broker/proving_broker_database.ts +2 -1
- package/src/proving_broker/proving_broker_instrumentation.ts +23 -35
- package/src/proving_broker/proving_job_controller.ts +100 -83
- package/src/proving_broker/rpc.ts +46 -25
- package/src/test/mock_proof_store.ts +14 -0
- package/src/test/mock_prover.ts +156 -64
- package/dest/bin/get-proof-inputs.d.ts +0 -2
- package/dest/bin/get-proof-inputs.d.ts.map +0 -1
- package/dest/bin/get-proof-inputs.js +0 -51
- package/dest/block_builder/index.d.ts +0 -6
- package/dest/block_builder/index.d.ts.map +0 -1
- package/dest/block_builder/index.js +0 -1
- package/dest/block_builder/light.d.ts +0 -33
- package/dest/block_builder/light.d.ts.map +0 -1
- package/dest/block_builder/light.js +0 -82
- 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 -51
- package/dest/proving_broker/proving_agent_instrumentation.d.ts +0 -8
- package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +0 -1
- package/dest/proving_broker/proving_agent_instrumentation.js +0 -16
- package/src/bin/get-proof-inputs.ts +0 -59
- package/src/block_builder/index.ts +0 -6
- package/src/block_builder/light.ts +0 -101
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -72
- package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
|
@@ -1,26 +1,23 @@
|
|
|
1
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import { type PromiseWithResolvers, RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
3
4
|
import { PriorityMemoryQueue } from '@aztec/foundation/queue';
|
|
4
5
|
import { Timer } from '@aztec/foundation/timer';
|
|
5
|
-
import
|
|
6
|
-
GetProvingJobResponse,
|
|
7
|
-
ProofUri,
|
|
8
|
-
ProvingJob,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
import {
|
|
7
|
+
type GetProvingJobResponse,
|
|
8
|
+
type ProofUri,
|
|
9
|
+
type ProvingJob,
|
|
10
|
+
type ProvingJobBrokerDebug,
|
|
11
|
+
type ProvingJobConsumer,
|
|
12
|
+
type ProvingJobFilter,
|
|
13
|
+
type ProvingJobId,
|
|
14
|
+
type ProvingJobProducer,
|
|
15
|
+
type ProvingJobSettledResult,
|
|
16
|
+
type ProvingJobStatus,
|
|
17
|
+
tryStop,
|
|
15
18
|
} from '@aztec/stdlib/interfaces/server';
|
|
16
19
|
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
17
|
-
import {
|
|
18
|
-
type TelemetryClient,
|
|
19
|
-
type Traceable,
|
|
20
|
-
type Tracer,
|
|
21
|
-
getTelemetryClient,
|
|
22
|
-
trackSpan,
|
|
23
|
-
} from '@aztec/telemetry-client';
|
|
20
|
+
import { type TelemetryClient, type Traceable, type Tracer, getTelemetryClient } from '@aztec/telemetry-client';
|
|
24
21
|
|
|
25
22
|
import assert from 'assert';
|
|
26
23
|
|
|
@@ -40,23 +37,36 @@ type EnqueuedProvingJob = Pick<ProvingJob, 'id' | 'epochNumber'>;
|
|
|
40
37
|
* A broker that manages proof requests and distributes them to workers based on their priority.
|
|
41
38
|
* It takes a backend that is responsible for storing and retrieving proof requests and results.
|
|
42
39
|
*/
|
|
43
|
-
export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Traceable {
|
|
40
|
+
export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, ProvingJobBrokerDebug, Traceable {
|
|
44
41
|
private queues: ProvingQueues = {
|
|
45
42
|
[ProvingRequestType.PUBLIC_VM]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
46
|
-
[ProvingRequestType.
|
|
43
|
+
[ProvingRequestType.PUBLIC_CHONK_VERIFIER]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
47
44
|
|
|
48
|
-
[ProvingRequestType.
|
|
49
|
-
[ProvingRequestType.
|
|
50
|
-
[ProvingRequestType.
|
|
45
|
+
[ProvingRequestType.PRIVATE_TX_BASE_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
46
|
+
[ProvingRequestType.PUBLIC_TX_BASE_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
47
|
+
[ProvingRequestType.TX_MERGE_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
51
48
|
[ProvingRequestType.ROOT_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
52
49
|
|
|
53
50
|
[ProvingRequestType.BLOCK_MERGE_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
51
|
+
[ProvingRequestType.BLOCK_ROOT_FIRST_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
52
|
+
[ProvingRequestType.BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(
|
|
53
|
+
provingJobComparator,
|
|
54
|
+
),
|
|
55
|
+
[ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(
|
|
56
|
+
provingJobComparator,
|
|
57
|
+
),
|
|
54
58
|
[ProvingRequestType.BLOCK_ROOT_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
55
|
-
[ProvingRequestType.
|
|
56
|
-
|
|
59
|
+
[ProvingRequestType.BLOCK_ROOT_SINGLE_TX_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
60
|
+
|
|
61
|
+
[ProvingRequestType.CHECKPOINT_ROOT_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
62
|
+
[ProvingRequestType.CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(
|
|
63
|
+
provingJobComparator,
|
|
64
|
+
),
|
|
65
|
+
[ProvingRequestType.CHECKPOINT_MERGE_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
66
|
+
[ProvingRequestType.CHECKPOINT_PADDING_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
57
67
|
|
|
58
|
-
[ProvingRequestType.
|
|
59
|
-
[ProvingRequestType.
|
|
68
|
+
[ProvingRequestType.PARITY_BASE]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
69
|
+
[ProvingRequestType.PARITY_ROOT]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
|
|
60
70
|
};
|
|
61
71
|
|
|
62
72
|
// holds a copy of the database in memory in order to quickly fulfill requests
|
|
@@ -93,7 +103,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
93
103
|
/**
|
|
94
104
|
* The broker keeps track of the highest epoch its seen.
|
|
95
105
|
* This information is used for garbage collection: once it reaches the next epoch, it can start pruning the database of old state.
|
|
96
|
-
* It is important that this value is
|
|
106
|
+
* It is important that this value is initialized to zero. This ensures that we don't delete any old jobs until the current
|
|
97
107
|
* process instance receives a job request informing it of the actual current highest epoch
|
|
98
108
|
* Example:
|
|
99
109
|
* proving epoch 11 - the broker will wipe all jobs for epochs 9 and lower
|
|
@@ -105,6 +115,8 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
105
115
|
|
|
106
116
|
private started = false;
|
|
107
117
|
|
|
118
|
+
private debugReplayEnabled: boolean;
|
|
119
|
+
|
|
108
120
|
public constructor(
|
|
109
121
|
private database: ProvingBrokerDatabase,
|
|
110
122
|
{
|
|
@@ -112,6 +124,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
112
124
|
proverBrokerPollIntervalMs,
|
|
113
125
|
proverBrokerJobMaxRetries,
|
|
114
126
|
proverBrokerMaxEpochsToKeepResultsFor,
|
|
127
|
+
proverBrokerDebugReplayEnabled,
|
|
115
128
|
}: Required<
|
|
116
129
|
Pick<
|
|
117
130
|
ProverBrokerConfig,
|
|
@@ -119,6 +132,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
119
132
|
| 'proverBrokerPollIntervalMs'
|
|
120
133
|
| 'proverBrokerJobMaxRetries'
|
|
121
134
|
| 'proverBrokerMaxEpochsToKeepResultsFor'
|
|
135
|
+
| 'proverBrokerDebugReplayEnabled'
|
|
122
136
|
>
|
|
123
137
|
> = defaultProverBrokerConfig,
|
|
124
138
|
client: TelemetryClient = getTelemetryClient(),
|
|
@@ -130,6 +144,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
130
144
|
this.jobTimeoutMs = proverBrokerJobTimeoutMs!;
|
|
131
145
|
this.maxRetries = proverBrokerJobMaxRetries!;
|
|
132
146
|
this.maxEpochsToKeepResultsFor = proverBrokerMaxEpochsToKeepResultsFor!;
|
|
147
|
+
this.debugReplayEnabled = proverBrokerDebugReplayEnabled ?? false;
|
|
133
148
|
}
|
|
134
149
|
|
|
135
150
|
private measureQueueDepth: MonitorCallback = (type: ProvingRequestType) => {
|
|
@@ -184,7 +199,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
184
199
|
this.logger.warn('ProvingBroker not started');
|
|
185
200
|
return Promise.resolve();
|
|
186
201
|
}
|
|
187
|
-
await this.cleanupPromise
|
|
202
|
+
await tryStop(this.cleanupPromise);
|
|
188
203
|
}
|
|
189
204
|
|
|
190
205
|
public enqueueProvingJob(job: ProvingJob): Promise<ProvingJobStatus> {
|
|
@@ -232,6 +247,29 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
232
247
|
return Promise.resolve(this.#reportProvingJobProgress(id, startedAt, filter));
|
|
233
248
|
}
|
|
234
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
|
+
|
|
235
273
|
async #enqueueProvingJob(job: ProvingJob): Promise<ProvingJobStatus> {
|
|
236
274
|
// We return the job status at the start of this call
|
|
237
275
|
const jobStatus = this.#getProvingJobStatus(job.id);
|
|
@@ -276,18 +314,25 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
276
314
|
// notify listeners of the cancellation
|
|
277
315
|
if (!this.resultsCache.has(id)) {
|
|
278
316
|
this.logger.info(`Cancelling job id=${id}`, { provingJobId: id });
|
|
279
|
-
await this.#reportProvingJobError(id, 'Aborted', false);
|
|
317
|
+
await this.#reportProvingJobError(id, 'Aborted', false, undefined, true);
|
|
280
318
|
}
|
|
281
319
|
}
|
|
282
320
|
|
|
283
321
|
private cleanUpProvingJobState(ids: ProvingJobId[]) {
|
|
322
|
+
const idsToClean = new Set(ids);
|
|
284
323
|
for (const id of ids) {
|
|
285
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
|
+
}
|
|
286
329
|
this.promises.delete(id);
|
|
287
330
|
this.resultsCache.delete(id);
|
|
288
331
|
this.inProgress.delete(id);
|
|
289
332
|
this.retries.delete(id);
|
|
333
|
+
this.enqueuedAt.delete(id);
|
|
290
334
|
}
|
|
335
|
+
this.completedJobNotifications = this.completedJobNotifications.filter(id => !idsToClean.has(id));
|
|
291
336
|
}
|
|
292
337
|
|
|
293
338
|
#getProvingJobStatus(id: ProvingJobId): ProvingJobStatus {
|
|
@@ -313,7 +358,6 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
313
358
|
return Promise.resolve(notifications.concat(completedJobs));
|
|
314
359
|
}
|
|
315
360
|
|
|
316
|
-
// eslint-disable-next-line require-await
|
|
317
361
|
#getProvingJob(filter: ProvingJobFilter = { allowList: [] }): { job: ProvingJob; time: number } | undefined {
|
|
318
362
|
const allowedProofs: ProvingRequestType[] =
|
|
319
363
|
Array.isArray(filter.allowList) && filter.allowList.length > 0
|
|
@@ -340,6 +384,8 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
340
384
|
const enqueuedAt = this.enqueuedAt.get(job.id);
|
|
341
385
|
if (enqueuedAt) {
|
|
342
386
|
this.instrumentation.recordJobWait(job.type, enqueuedAt);
|
|
387
|
+
// we can clear this flag now.
|
|
388
|
+
this.enqueuedAt.delete(job.id);
|
|
343
389
|
}
|
|
344
390
|
|
|
345
391
|
return { job, time };
|
|
@@ -355,6 +401,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
355
401
|
err: string,
|
|
356
402
|
retry = false,
|
|
357
403
|
filter?: ProvingJobFilter,
|
|
404
|
+
aborted = false,
|
|
358
405
|
): Promise<GetProvingJobResponse | undefined> {
|
|
359
406
|
const info = this.inProgress.get(id);
|
|
360
407
|
const item = this.jobsCache.get(id);
|
|
@@ -415,7 +462,11 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
415
462
|
this.promises.get(id)!.resolve(result);
|
|
416
463
|
this.completedJobNotifications.push(id);
|
|
417
464
|
|
|
418
|
-
|
|
465
|
+
if (aborted) {
|
|
466
|
+
this.instrumentation.incAbortedJobs(item.type);
|
|
467
|
+
} else {
|
|
468
|
+
this.instrumentation.incRejectedJobs(item.type);
|
|
469
|
+
}
|
|
419
470
|
if (info) {
|
|
420
471
|
const duration = this.msTimeSource() - info.startedAt;
|
|
421
472
|
this.instrumentation.recordJobDuration(item.type, duration);
|
|
@@ -548,30 +599,29 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
548
599
|
return this.#getProvingJob(filter);
|
|
549
600
|
}
|
|
550
601
|
|
|
551
|
-
@trackSpan('ProvingBroker.cleanupPass')
|
|
552
602
|
private async cleanupPass() {
|
|
553
|
-
this.cleanupStaleJobs();
|
|
554
603
|
this.reEnqueueExpiredJobs();
|
|
555
604
|
const oldestEpochToKeep = this.oldestEpochToKeep();
|
|
556
605
|
if (oldestEpochToKeep > 0) {
|
|
557
|
-
|
|
606
|
+
this.cleanupJobsOlderThanEpoch(EpochNumber(oldestEpochToKeep));
|
|
607
|
+
await this.database.deleteAllProvingJobsOlderThanEpoch(EpochNumber(oldestEpochToKeep));
|
|
558
608
|
this.logger.trace(`Deleted all epochs older than ${oldestEpochToKeep}`);
|
|
559
609
|
}
|
|
560
610
|
}
|
|
561
611
|
|
|
562
|
-
private
|
|
612
|
+
private cleanupJobsOlderThanEpoch(epochNumber: EpochNumber) {
|
|
563
613
|
const jobIds = Array.from(this.jobsCache.keys());
|
|
564
614
|
const jobsToClean: ProvingJobId[] = [];
|
|
565
615
|
for (const id of jobIds) {
|
|
566
616
|
const job = this.jobsCache.get(id)!;
|
|
567
|
-
if (
|
|
617
|
+
if (job.epochNumber < epochNumber) {
|
|
568
618
|
jobsToClean.push(id);
|
|
569
619
|
}
|
|
570
620
|
}
|
|
571
621
|
|
|
572
622
|
if (jobsToClean.length > 0) {
|
|
573
623
|
this.cleanUpProvingJobState(jobsToClean);
|
|
574
|
-
this.logger.
|
|
624
|
+
this.logger.verbose(`Cleaned up proving jobs=${jobsToClean.length}`);
|
|
575
625
|
}
|
|
576
626
|
}
|
|
577
627
|
|
|
@@ -588,10 +638,26 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
588
638
|
const now = this.msTimeSource();
|
|
589
639
|
const msSinceLastUpdate = now - metadata.lastUpdatedAt;
|
|
590
640
|
if (msSinceLastUpdate >= this.jobTimeoutMs) {
|
|
591
|
-
this.logger.warn(`Proving job id=${id} timed out. Adding it back to the queue.`, { provingJobId: id });
|
|
592
641
|
this.inProgress.delete(id);
|
|
593
|
-
this.enqueueJobInternal(item);
|
|
594
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
|
+
}
|
|
595
661
|
}
|
|
596
662
|
}
|
|
597
663
|
}
|
|
@@ -671,17 +737,23 @@ function proofTypeComparator(a: ProvingRequestType, b: ProvingRequestType): -1 |
|
|
|
671
737
|
* The aim is that this will speed up block proving as the closer we get to a block's root proof the more likely it
|
|
672
738
|
* is to get picked up by agents
|
|
673
739
|
*/
|
|
674
|
-
const PROOF_TYPES_IN_PRIORITY_ORDER: ProvingRequestType[] = [
|
|
740
|
+
export const PROOF_TYPES_IN_PRIORITY_ORDER: ProvingRequestType[] = [
|
|
741
|
+
ProvingRequestType.ROOT_ROLLUP,
|
|
742
|
+
ProvingRequestType.BLOCK_ROOT_FIRST_ROLLUP,
|
|
743
|
+
ProvingRequestType.BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP,
|
|
744
|
+
ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP,
|
|
675
745
|
ProvingRequestType.BLOCK_ROOT_ROLLUP,
|
|
676
|
-
ProvingRequestType.
|
|
746
|
+
ProvingRequestType.BLOCK_ROOT_SINGLE_TX_ROLLUP,
|
|
677
747
|
ProvingRequestType.BLOCK_MERGE_ROLLUP,
|
|
678
|
-
ProvingRequestType.
|
|
679
|
-
ProvingRequestType.
|
|
680
|
-
ProvingRequestType.
|
|
681
|
-
ProvingRequestType.
|
|
748
|
+
ProvingRequestType.CHECKPOINT_ROOT_ROLLUP,
|
|
749
|
+
ProvingRequestType.CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP,
|
|
750
|
+
ProvingRequestType.CHECKPOINT_MERGE_ROLLUP,
|
|
751
|
+
ProvingRequestType.CHECKPOINT_PADDING_ROLLUP,
|
|
752
|
+
ProvingRequestType.TX_MERGE_ROLLUP,
|
|
753
|
+
ProvingRequestType.PUBLIC_TX_BASE_ROLLUP,
|
|
754
|
+
ProvingRequestType.PRIVATE_TX_BASE_ROLLUP,
|
|
682
755
|
ProvingRequestType.PUBLIC_VM,
|
|
683
|
-
ProvingRequestType.
|
|
684
|
-
ProvingRequestType.
|
|
685
|
-
ProvingRequestType.
|
|
686
|
-
ProvingRequestType.EMPTY_BLOCK_ROOT_ROLLUP,
|
|
756
|
+
ProvingRequestType.PUBLIC_CHONK_VERIFIER,
|
|
757
|
+
ProvingRequestType.PARITY_ROOT,
|
|
758
|
+
ProvingRequestType.PARITY_BASE,
|
|
687
759
|
];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import {
|
|
2
3
|
type ProofUri,
|
|
3
4
|
type ProvingJob,
|
|
@@ -43,7 +44,7 @@ export class InMemoryBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
43
44
|
return Promise.resolve();
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
deleteAllProvingJobsOlderThanEpoch(epochNumber:
|
|
47
|
+
deleteAllProvingJobsOlderThanEpoch(epochNumber: EpochNumber): Promise<void> {
|
|
47
48
|
const toDelete = [
|
|
48
49
|
...Array.from(this.jobs.keys()).filter(x => getEpochFromProvingJobId(x) < epochNumber),
|
|
49
50
|
...Array.from(this.results.keys()).filter(x => getEpochFromProvingJobId(x) < epochNumber),
|
|
@@ -52,7 +53,7 @@ export class InMemoryBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
async *allProvingJobs(): AsyncIterableIterator<[ProvingJob, ProvingJobSettledResult | undefined]> {
|
|
55
|
-
for
|
|
56
|
+
for (const item of this.jobs.values()) {
|
|
56
57
|
yield [item, this.results.get(item.id)] as const;
|
|
57
58
|
}
|
|
58
59
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { BatchQueue } from '@aztec/foundation/queue';
|
|
@@ -10,7 +11,14 @@ import {
|
|
|
10
11
|
ProvingJobSettledResult,
|
|
11
12
|
getEpochFromProvingJobId,
|
|
12
13
|
} from '@aztec/stdlib/interfaces/server';
|
|
13
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
Attributes,
|
|
16
|
+
LmdbMetrics,
|
|
17
|
+
type TelemetryClient,
|
|
18
|
+
type Tracer,
|
|
19
|
+
getTelemetryClient,
|
|
20
|
+
trackSpan,
|
|
21
|
+
} from '@aztec/telemetry-client';
|
|
14
22
|
|
|
15
23
|
import { mkdir, readdir } from 'fs/promises';
|
|
16
24
|
import { join } from 'path';
|
|
@@ -46,9 +54,9 @@ class SingleEpochDatabase {
|
|
|
46
54
|
|
|
47
55
|
async *allProvingJobs(): AsyncIterableIterator<[ProvingJob, ProvingJobSettledResult | undefined]> {
|
|
48
56
|
for await (const jobStr of this.jobs.valuesAsync()) {
|
|
49
|
-
const job =
|
|
57
|
+
const job = jsonParseWithSchema(jobStr, ProvingJob);
|
|
50
58
|
const resultStr = await this.jobResults.getAsync(job.id);
|
|
51
|
-
const result = resultStr ?
|
|
59
|
+
const result = resultStr ? jsonParseWithSchema(resultStr, ProvingJobSettledResult) : undefined;
|
|
52
60
|
yield [job, result];
|
|
53
61
|
}
|
|
54
62
|
}
|
|
@@ -77,6 +85,8 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
77
85
|
|
|
78
86
|
private batchQueue: BatchQueue<ProvingJob | [ProvingJobId, ProvingJobSettledResult], number>;
|
|
79
87
|
|
|
88
|
+
public readonly tracer: Tracer;
|
|
89
|
+
|
|
80
90
|
private constructor(
|
|
81
91
|
private epochs: Map<number, SingleEpochDatabase>,
|
|
82
92
|
private config: ProverBrokerConfig,
|
|
@@ -91,6 +101,8 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
91
101
|
() => this.estimateSize(),
|
|
92
102
|
);
|
|
93
103
|
|
|
104
|
+
this.tracer = client.getTracer('KVBrokerDatabase');
|
|
105
|
+
|
|
94
106
|
this.batchQueue = new BatchQueue(
|
|
95
107
|
(items, key) => this.commitWrites(items, key),
|
|
96
108
|
config.proverBrokerBatchSize,
|
|
@@ -104,14 +116,15 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
104
116
|
const jobsToAdd = items.filter((item): item is ProvingJob => 'id' in item);
|
|
105
117
|
const resultsToAdd = items.filter((item): item is [ProvingJobId, ProvingJobSettledResult] => Array.isArray(item));
|
|
106
118
|
|
|
107
|
-
const db = await this.getEpochDatabase(epochNumber);
|
|
119
|
+
const db = await this.getEpochDatabase(EpochNumber(epochNumber));
|
|
108
120
|
await db.batchWrite(jobsToAdd, resultsToAdd);
|
|
109
121
|
}
|
|
110
122
|
|
|
111
123
|
private async estimateSize() {
|
|
112
124
|
const sizes = await Promise.all(Array.from(this.epochs.values()).map(x => x.estimateSize()));
|
|
113
125
|
return {
|
|
114
|
-
mappingSize: this.config.
|
|
126
|
+
mappingSize: this.config.dataStoreMapSizeKb,
|
|
127
|
+
physicalFileSize: sizes.reduce((prev, curr) => prev + curr.physicalFileSize, 0),
|
|
115
128
|
numItems: sizes.reduce((prev, curr) => prev + curr.numItems, 0),
|
|
116
129
|
actualSize: sizes.reduce((prev, curr) => prev + curr.actualSize, 0),
|
|
117
130
|
};
|
|
@@ -136,13 +149,13 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
136
149
|
continue;
|
|
137
150
|
}
|
|
138
151
|
logger.info(
|
|
139
|
-
`Loading broker database for epoch ${epochNumber} from ${fullDirectory} with map size ${config.
|
|
152
|
+
`Loading broker database for epoch ${epochNumber} from ${fullDirectory} with map size ${config.dataStoreMapSizeKb}KB`,
|
|
140
153
|
);
|
|
141
154
|
const db = await openVersionedStoreAt(
|
|
142
155
|
fullDirectory,
|
|
143
156
|
SingleEpochDatabase.SCHEMA_VERSION,
|
|
144
|
-
config.
|
|
145
|
-
config.
|
|
157
|
+
config.rollupAddress,
|
|
158
|
+
config.dataStoreMapSizeKb,
|
|
146
159
|
);
|
|
147
160
|
const epochDb = new SingleEpochDatabase(db);
|
|
148
161
|
epochs.set(epochNumber, epochDb);
|
|
@@ -163,14 +176,17 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
163
176
|
}
|
|
164
177
|
}
|
|
165
178
|
|
|
166
|
-
|
|
167
|
-
|
|
179
|
+
@trackSpan('KVBrokerDatabase.deleteAllProvingJobsOlderThanEpoch', epochNumber => ({
|
|
180
|
+
[Attributes.EPOCH_NUMBER]: epochNumber,
|
|
181
|
+
}))
|
|
182
|
+
async deleteAllProvingJobsOlderThanEpoch(epochNumber: EpochNumber): Promise<void> {
|
|
183
|
+
const oldEpochs = Array.from(this.epochs.keys()).filter(e => e < Number(epochNumber));
|
|
168
184
|
for (const old of oldEpochs) {
|
|
169
185
|
const db = this.epochs.get(old);
|
|
170
186
|
if (!db) {
|
|
171
187
|
continue;
|
|
172
188
|
}
|
|
173
|
-
this.logger.
|
|
189
|
+
this.logger.verbose(`Deleting broker database for epoch ${old}`);
|
|
174
190
|
await db.delete();
|
|
175
191
|
this.epochs.delete(old);
|
|
176
192
|
}
|
|
@@ -195,19 +211,19 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
195
211
|
return this.batchQueue.put([id, { status: 'fulfilled', value }], getEpochFromProvingJobId(id));
|
|
196
212
|
}
|
|
197
213
|
|
|
198
|
-
private async getEpochDatabase(epochNumber:
|
|
214
|
+
private async getEpochDatabase(epochNumber: EpochNumber): Promise<SingleEpochDatabase> {
|
|
199
215
|
let epochDb = this.epochs.get(epochNumber);
|
|
200
216
|
if (!epochDb) {
|
|
201
217
|
const newEpochDirectory = join(this.config.dataDirectory!, epochNumber.toString());
|
|
202
218
|
await mkdir(newEpochDirectory, { recursive: true });
|
|
203
219
|
this.logger.info(
|
|
204
|
-
`Creating broker database for epoch ${epochNumber} at ${newEpochDirectory} with map size ${this.config.
|
|
220
|
+
`Creating broker database for epoch ${epochNumber} at ${newEpochDirectory} with map size ${this.config.dataStoreMapSizeKb}`,
|
|
205
221
|
);
|
|
206
222
|
const db = await openVersionedStoreAt(
|
|
207
223
|
newEpochDirectory,
|
|
208
224
|
SingleEpochDatabase.SCHEMA_VERSION,
|
|
209
|
-
this.config.
|
|
210
|
-
this.config.
|
|
225
|
+
this.config.rollupAddress,
|
|
226
|
+
this.config.dataStoreMapSizeKb,
|
|
211
227
|
);
|
|
212
228
|
epochDb = new SingleEpochDatabase(db);
|
|
213
229
|
this.epochs.set(epochNumber, epochDb);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { ProofUri, ProvingJob, ProvingJobId, ProvingJobSettledResult } from '@aztec/stdlib/interfaces/server';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -14,7 +15,7 @@ export interface ProvingBrokerDatabase {
|
|
|
14
15
|
* Deletes all proving jobs belonging to epochs older than the given epoch
|
|
15
16
|
* @param epochNumber - The epoch number beyond which jobs should be deleted
|
|
16
17
|
*/
|
|
17
|
-
deleteAllProvingJobsOlderThanEpoch(epochNumber:
|
|
18
|
+
deleteAllProvingJobsOlderThanEpoch(epochNumber: EpochNumber): Promise<void>;
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Returns an iterator over all saved proving jobs
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
type ObservableResult,
|
|
9
9
|
type TelemetryClient,
|
|
10
10
|
type UpDownCounter,
|
|
11
|
-
|
|
11
|
+
createUpDownCounterWithDefault,
|
|
12
12
|
} from '@aztec/telemetry-client';
|
|
13
13
|
|
|
14
14
|
export type MonitorCallback = (proofType: ProvingRequestType) => number;
|
|
@@ -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;
|
|
@@ -28,49 +29,30 @@ export class ProvingBrokerInstrumentation {
|
|
|
28
29
|
constructor(client: TelemetryClient, name = 'ProvingBroker') {
|
|
29
30
|
const meter = client.getMeter(name);
|
|
30
31
|
|
|
31
|
-
this.queueSize = meter.createObservableGauge(Metrics.PROVING_QUEUE_SIZE
|
|
32
|
-
valueType: ValueType.INT,
|
|
33
|
-
});
|
|
32
|
+
this.queueSize = meter.createObservableGauge(Metrics.PROVING_QUEUE_SIZE);
|
|
34
33
|
|
|
35
|
-
this.activeJobs = meter.createObservableGauge(Metrics.PROVING_QUEUE_ACTIVE_JOBS
|
|
36
|
-
valueType: ValueType.INT,
|
|
37
|
-
});
|
|
34
|
+
this.activeJobs = meter.createObservableGauge(Metrics.PROVING_QUEUE_ACTIVE_JOBS);
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
36
|
+
const provingJobTypes = Object.values(ProvingRequestType).filter(v => typeof v === 'string');
|
|
37
|
+
const provingJobAttrs = { [Attributes.PROVING_JOB_TYPE]: provingJobTypes };
|
|
42
38
|
|
|
43
|
-
this.
|
|
44
|
-
valueType: ValueType.INT,
|
|
45
|
-
});
|
|
39
|
+
this.resolvedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_RESOLVED_JOBS, provingJobAttrs);
|
|
46
40
|
|
|
47
|
-
this.
|
|
48
|
-
valueType: ValueType.INT,
|
|
49
|
-
});
|
|
41
|
+
this.rejectedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_REJECTED_JOBS, provingJobAttrs);
|
|
50
42
|
|
|
51
|
-
this.
|
|
52
|
-
valueType: ValueType.INT,
|
|
53
|
-
});
|
|
43
|
+
this.abortedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_ABORTED_JOBS, provingJobAttrs);
|
|
54
44
|
|
|
55
|
-
this.
|
|
56
|
-
valueType: ValueType.INT,
|
|
57
|
-
});
|
|
45
|
+
this.retriedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_RETRIED_JOBS, provingJobAttrs);
|
|
58
46
|
|
|
59
|
-
this.
|
|
60
|
-
valueType: ValueType.INT,
|
|
61
|
-
});
|
|
47
|
+
this.timedOutJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_TIMED_OUT_JOBS, provingJobAttrs);
|
|
62
48
|
|
|
63
|
-
this.
|
|
64
|
-
description: 'Records how long a job sits in the queue',
|
|
65
|
-
unit: 'ms',
|
|
66
|
-
valueType: ValueType.INT,
|
|
67
|
-
});
|
|
49
|
+
this.cachedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_CACHED_JOBS, provingJobAttrs);
|
|
68
50
|
|
|
69
|
-
this.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
51
|
+
this.totalJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_TOTAL_JOBS, provingJobAttrs);
|
|
52
|
+
|
|
53
|
+
this.jobWait = meter.createHistogram(Metrics.PROVING_QUEUE_JOB_WAIT);
|
|
54
|
+
|
|
55
|
+
this.jobDuration = meter.createHistogram(Metrics.PROVING_QUEUE_JOB_DURATION);
|
|
74
56
|
}
|
|
75
57
|
|
|
76
58
|
monitorQueueDepth(fn: MonitorCallback) {
|
|
@@ -93,6 +75,12 @@ export class ProvingBrokerInstrumentation {
|
|
|
93
75
|
});
|
|
94
76
|
}
|
|
95
77
|
|
|
78
|
+
incAbortedJobs(proofType: ProvingRequestType) {
|
|
79
|
+
this.abortedJobs.add(1, {
|
|
80
|
+
[Attributes.PROVING_JOB_TYPE]: ProvingRequestType[proofType],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
96
84
|
incRetriedJobs(proofType: ProvingRequestType) {
|
|
97
85
|
this.retriedJobs.add(1, {
|
|
98
86
|
[Attributes.PROVING_JOB_TYPE]: ProvingRequestType[proofType],
|