@aztec/prover-client 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0
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 +2 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +17 -3
- 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 +38 -15
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +162 -36
- package/dest/mocks/fixtures.d.ts +1 -1
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +4 -3
- package/dest/mocks/test_context.d.ts +15 -13
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +50 -36
- package/dest/orchestrator/block-building-helpers.d.ts +6 -6
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +5 -5
- package/dest/orchestrator/block-proving-state.d.ts +5 -2
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +8 -1
- package/dest/orchestrator/checkpoint-proving-state.d.ts +20 -23
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +23 -87
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts +161 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.js +1066 -0
- package/dest/orchestrator/chonk-cache.d.ts +39 -0
- package/dest/orchestrator/chonk-cache.d.ts.map +1 -0
- package/dest/orchestrator/chonk-cache.js +80 -0
- package/dest/orchestrator/index.d.ts +4 -2
- package/dest/orchestrator/index.d.ts.map +1 -1
- package/dest/orchestrator/index.js +3 -1
- package/dest/orchestrator/orchestrator_metrics.d.ts +1 -3
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +2 -15
- package/dest/orchestrator/proving-scheduler.d.ts +81 -0
- package/dest/orchestrator/proving-scheduler.d.ts.map +1 -0
- package/dest/orchestrator/proving-scheduler.js +120 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts +88 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-orchestrator.js +232 -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 +7 -6
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +8 -8
- package/dest/prover-client/factory.d.ts +3 -3
- package/dest/prover-client/factory.d.ts.map +1 -1
- package/dest/prover-client/prover-client.d.ts +65 -8
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +66 -14
- package/dest/proving_broker/broker_prover_facade.d.ts +8 -6
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +18 -31
- package/dest/proving_broker/config.d.ts +13 -65
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +23 -6
- package/dest/proving_broker/fixtures.js +1 -1
- 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 -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 +5 -9
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +4 -19
- package/dest/proving_broker/proving_broker.d.ts +8 -5
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +72 -21
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +391 -3
- 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 +4 -3
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +8 -6
- package/dest/proving_broker/rpc.d.ts +6 -2
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +87 -23
- package/dest/test/epoch_settlement.d.ts +36 -0
- package/dest/test/epoch_settlement.d.ts.map +1 -0
- package/dest/test/epoch_settlement.js +52 -0
- package/dest/test/index.d.ts +2 -0
- package/dest/test/index.d.ts.map +1 -0
- package/dest/test/index.js +1 -0
- package/dest/test/mock_proof_store.d.ts +3 -3
- package/dest/test/mock_proof_store.d.ts.map +1 -1
- package/dest/test/mock_prover.d.ts +5 -5
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +4 -4
- package/package.json +23 -22
- package/src/config.ts +19 -3
- package/src/light/index.ts +1 -0
- package/src/light/lightweight_checkpoint_builder.ts +229 -50
- package/src/mocks/fixtures.ts +4 -3
- package/src/mocks/test_context.ts +44 -48
- package/src/orchestrator/block-building-helpers.ts +5 -5
- package/src/orchestrator/block-proving-state.ts +10 -1
- package/src/orchestrator/checkpoint-proving-state.ts +22 -116
- package/src/orchestrator/checkpoint-sub-tree-orchestrator.ts +1044 -0
- package/src/orchestrator/chonk-cache.ts +99 -0
- package/src/orchestrator/index.ts +8 -1
- package/src/orchestrator/orchestrator_metrics.ts +2 -25
- package/src/orchestrator/proving-scheduler.ts +160 -0
- package/src/orchestrator/top-tree-orchestrator.ts +384 -0
- package/src/orchestrator/top-tree-proving-state.ts +219 -0
- package/src/orchestrator/tx-proving-state.ts +11 -15
- package/src/prover-client/factory.ts +6 -2
- package/src/prover-client/prover-client.ts +148 -29
- package/src/proving_broker/broker_prover_facade.ts +27 -37
- package/src/proving_broker/config.ts +26 -3
- package/src/proving_broker/fixtures.ts +1 -1
- 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 -1
- package/src/proving_broker/proving_agent.ts +6 -19
- package/src/proving_broker/proving_broker.ts +68 -16
- package/src/proving_broker/proving_broker_database/persisted.ts +17 -3
- package/src/proving_broker/proving_broker_instrumentation.ts +23 -35
- package/src/proving_broker/proving_job_controller.ts +11 -6
- package/src/proving_broker/rpc.ts +46 -20
- package/src/test/epoch_settlement.ts +82 -0
- package/src/test/index.ts +1 -0
- package/src/test/mock_prover.ts +3 -15
- package/dest/block-factory/index.d.ts +0 -2
- package/dest/block-factory/index.d.ts.map +0 -1
- package/dest/block-factory/index.js +0 -1
- package/dest/block-factory/light.d.ts +0 -38
- package/dest/block-factory/light.d.ts.map +0 -1
- package/dest/block-factory/light.js +0 -108
- package/dest/orchestrator/epoch-proving-state.d.ts +0 -74
- package/dest/orchestrator/epoch-proving-state.d.ts.map +0 -1
- package/dest/orchestrator/epoch-proving-state.js +0 -233
- package/dest/orchestrator/orchestrator.d.ts +0 -113
- package/dest/orchestrator/orchestrator.d.ts.map +0 -1
- package/dest/orchestrator/orchestrator.js +0 -842
- package/dest/prover-client/server-epoch-prover.d.ts +0 -32
- package/dest/prover-client/server-epoch-prover.d.ts.map +0 -1
- package/dest/prover-client/server-epoch-prover.js +0 -40
- 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/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/block-factory/index.ts +0 -1
- package/src/block-factory/light.ts +0 -137
- package/src/orchestrator/epoch-proving-state.ts +0 -330
- package/src/orchestrator/orchestrator.ts +0 -1265
- package/src/prover-client/server-epoch-prover.ts +0 -69
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
- package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
}
|
|
7
1
|
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
8
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
9
3
|
import { RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
@@ -11,7 +5,7 @@ import { PriorityMemoryQueue } from '@aztec/foundation/queue';
|
|
|
11
5
|
import { Timer } from '@aztec/foundation/timer';
|
|
12
6
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
13
7
|
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
14
|
-
import { getTelemetryClient
|
|
8
|
+
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
15
9
|
import assert from 'assert';
|
|
16
10
|
import { defaultProverBrokerConfig } from './config.js';
|
|
17
11
|
import { ProvingBrokerInstrumentation } from './proving_broker_instrumentation.js';
|
|
@@ -57,7 +51,8 @@ import { ProvingBrokerInstrumentation } from './proving_broker_instrumentation.j
|
|
|
57
51
|
*/ epochHeight;
|
|
58
52
|
maxEpochsToKeepResultsFor;
|
|
59
53
|
started;
|
|
60
|
-
|
|
54
|
+
debugReplayEnabled;
|
|
55
|
+
constructor(database, { proverBrokerJobTimeoutMs, proverBrokerPollIntervalMs, proverBrokerJobMaxRetries, proverBrokerMaxEpochsToKeepResultsFor, proverBrokerDebugReplayEnabled } = defaultProverBrokerConfig, client = getTelemetryClient(), logger = createLogger('prover-client:proving-broker')){
|
|
61
56
|
this.database = database;
|
|
62
57
|
this.logger = logger;
|
|
63
58
|
this.queues = {
|
|
@@ -110,6 +105,7 @@ import { ProvingBrokerInstrumentation } from './proving_broker_instrumentation.j
|
|
|
110
105
|
this.jobTimeoutMs = proverBrokerJobTimeoutMs;
|
|
111
106
|
this.maxRetries = proverBrokerJobMaxRetries;
|
|
112
107
|
this.maxEpochsToKeepResultsFor = proverBrokerMaxEpochsToKeepResultsFor;
|
|
108
|
+
this.debugReplayEnabled = proverBrokerDebugReplayEnabled ?? false;
|
|
113
109
|
}
|
|
114
110
|
measureQueueDepth;
|
|
115
111
|
countActiveJobs;
|
|
@@ -169,6 +165,32 @@ import { ProvingBrokerInstrumentation } from './proving_broker_instrumentation.j
|
|
|
169
165
|
reportProvingJobProgress(id, startedAt, filter) {
|
|
170
166
|
return Promise.resolve(this.#reportProvingJobProgress(id, startedAt, filter));
|
|
171
167
|
}
|
|
168
|
+
async replayProvingJob(jobId, type, epochNumber, inputsUri) {
|
|
169
|
+
if (!this.debugReplayEnabled) {
|
|
170
|
+
throw new Error('Debug replay not enabled. Set PROVER_BROKER_DEBUG_REPLAY_ENABLED=true');
|
|
171
|
+
}
|
|
172
|
+
this.logger.info(`Replaying proving job`, {
|
|
173
|
+
provingJobId: jobId,
|
|
174
|
+
epochNumber,
|
|
175
|
+
inputsUri
|
|
176
|
+
});
|
|
177
|
+
// Clear existing state and enqueue
|
|
178
|
+
this.cleanUpProvingJobState([
|
|
179
|
+
jobId
|
|
180
|
+
]);
|
|
181
|
+
const job = {
|
|
182
|
+
id: jobId,
|
|
183
|
+
type,
|
|
184
|
+
epochNumber,
|
|
185
|
+
inputsUri
|
|
186
|
+
};
|
|
187
|
+
this.jobsCache.set(jobId, job);
|
|
188
|
+
await this.database.addProvingJob(job);
|
|
189
|
+
this.enqueueJobInternal(job);
|
|
190
|
+
return {
|
|
191
|
+
status: 'in-queue'
|
|
192
|
+
};
|
|
193
|
+
}
|
|
172
194
|
async #enqueueProvingJob(job) {
|
|
173
195
|
// We return the job status at the start of this call
|
|
174
196
|
const jobStatus = this.#getProvingJobStatus(job.id);
|
|
@@ -217,17 +239,27 @@ import { ProvingBrokerInstrumentation } from './proving_broker_instrumentation.j
|
|
|
217
239
|
this.logger.info(`Cancelling job id=${id}`, {
|
|
218
240
|
provingJobId: id
|
|
219
241
|
});
|
|
220
|
-
await this.#reportProvingJobError(id, 'Aborted', false);
|
|
242
|
+
await this.#reportProvingJobError(id, 'Aborted', false, undefined, true);
|
|
221
243
|
}
|
|
222
244
|
}
|
|
223
245
|
cleanUpProvingJobState(ids) {
|
|
246
|
+
const idsToClean = new Set(ids);
|
|
224
247
|
for (const id of ids){
|
|
225
248
|
this.jobsCache.delete(id);
|
|
249
|
+
const deferred = this.promises.get(id);
|
|
250
|
+
if (deferred) {
|
|
251
|
+
deferred.resolve({
|
|
252
|
+
status: 'rejected',
|
|
253
|
+
reason: 'Proving job cleaned up'
|
|
254
|
+
});
|
|
255
|
+
}
|
|
226
256
|
this.promises.delete(id);
|
|
227
257
|
this.resultsCache.delete(id);
|
|
228
258
|
this.inProgress.delete(id);
|
|
229
259
|
this.retries.delete(id);
|
|
260
|
+
this.enqueuedAt.delete(id);
|
|
230
261
|
}
|
|
262
|
+
this.completedJobNotifications = this.completedJobNotifications.filter((id)=>!idsToClean.has(id));
|
|
231
263
|
}
|
|
232
264
|
#getProvingJobStatus(id) {
|
|
233
265
|
const result = this.resultsCache.get(id);
|
|
@@ -278,6 +310,8 @@ import { ProvingBrokerInstrumentation } from './proving_broker_instrumentation.j
|
|
|
278
310
|
const enqueuedAt = this.enqueuedAt.get(job.id);
|
|
279
311
|
if (enqueuedAt) {
|
|
280
312
|
this.instrumentation.recordJobWait(job.type, enqueuedAt);
|
|
313
|
+
// we can clear this flag now.
|
|
314
|
+
this.enqueuedAt.delete(job.id);
|
|
281
315
|
}
|
|
282
316
|
return {
|
|
283
317
|
job,
|
|
@@ -288,7 +322,7 @@ import { ProvingBrokerInstrumentation } from './proving_broker_instrumentation.j
|
|
|
288
322
|
}
|
|
289
323
|
return undefined;
|
|
290
324
|
}
|
|
291
|
-
async #reportProvingJobError(id, err, retry = false, filter) {
|
|
325
|
+
async #reportProvingJobError(id, err, retry = false, filter, aborted = false) {
|
|
292
326
|
const info = this.inProgress.get(id);
|
|
293
327
|
const item = this.jobsCache.get(id);
|
|
294
328
|
const retries = this.retries.get(id) ?? 0;
|
|
@@ -335,7 +369,11 @@ import { ProvingBrokerInstrumentation } from './proving_broker_instrumentation.j
|
|
|
335
369
|
this.resultsCache.set(id, result);
|
|
336
370
|
this.promises.get(id).resolve(result);
|
|
337
371
|
this.completedJobNotifications.push(id);
|
|
338
|
-
|
|
372
|
+
if (aborted) {
|
|
373
|
+
this.instrumentation.incAbortedJobs(item.type);
|
|
374
|
+
} else {
|
|
375
|
+
this.instrumentation.incRejectedJobs(item.type);
|
|
376
|
+
}
|
|
339
377
|
if (info) {
|
|
340
378
|
const duration = this.msTimeSource() - info.startedAt;
|
|
341
379
|
this.instrumentation.recordJobDuration(item.type, duration);
|
|
@@ -450,20 +488,20 @@ import { ProvingBrokerInstrumentation } from './proving_broker_instrumentation.j
|
|
|
450
488
|
return this.#getProvingJob(filter);
|
|
451
489
|
}
|
|
452
490
|
async cleanupPass() {
|
|
453
|
-
this.cleanupStaleJobs();
|
|
454
491
|
this.reEnqueueExpiredJobs();
|
|
455
492
|
const oldestEpochToKeep = this.oldestEpochToKeep();
|
|
456
493
|
if (oldestEpochToKeep > 0) {
|
|
494
|
+
this.cleanupJobsOlderThanEpoch(EpochNumber(oldestEpochToKeep));
|
|
457
495
|
await this.database.deleteAllProvingJobsOlderThanEpoch(EpochNumber(oldestEpochToKeep));
|
|
458
496
|
this.logger.trace(`Deleted all epochs older than ${oldestEpochToKeep}`);
|
|
459
497
|
}
|
|
460
498
|
}
|
|
461
|
-
|
|
499
|
+
cleanupJobsOlderThanEpoch(epochNumber) {
|
|
462
500
|
const jobIds = Array.from(this.jobsCache.keys());
|
|
463
501
|
const jobsToClean = [];
|
|
464
502
|
for (const id of jobIds){
|
|
465
503
|
const job = this.jobsCache.get(id);
|
|
466
|
-
if (
|
|
504
|
+
if (job.epochNumber < epochNumber) {
|
|
467
505
|
jobsToClean.push(id);
|
|
468
506
|
}
|
|
469
507
|
}
|
|
@@ -486,12 +524,28 @@ import { ProvingBrokerInstrumentation } from './proving_broker_instrumentation.j
|
|
|
486
524
|
const now = this.msTimeSource();
|
|
487
525
|
const msSinceLastUpdate = now - metadata.lastUpdatedAt;
|
|
488
526
|
if (msSinceLastUpdate >= this.jobTimeoutMs) {
|
|
489
|
-
this.logger.warn(`Proving job id=${id} timed out. Adding it back to the queue.`, {
|
|
490
|
-
provingJobId: id
|
|
491
|
-
});
|
|
492
527
|
this.inProgress.delete(id);
|
|
493
|
-
this.enqueueJobInternal(item);
|
|
494
528
|
this.instrumentation.incTimedOutJobs(item.type);
|
|
529
|
+
const retries = this.retries.get(id) ?? 0;
|
|
530
|
+
if (retries + 1 < this.maxRetries && !this.isJobStale(item)) {
|
|
531
|
+
this.logger.warn(`Proving job id=${id} timed out. Re-enqueueing (retry ${retries + 1}/${this.maxRetries}).`, {
|
|
532
|
+
provingJobId: id
|
|
533
|
+
});
|
|
534
|
+
this.retries.set(id, retries + 1);
|
|
535
|
+
this.enqueueJobInternal(item);
|
|
536
|
+
} else {
|
|
537
|
+
this.logger.error(`Proving job id=${id} timed out after ${retries + 1} attempts. Marking as failed.`, {
|
|
538
|
+
provingJobId: id
|
|
539
|
+
});
|
|
540
|
+
const result = {
|
|
541
|
+
status: 'rejected',
|
|
542
|
+
reason: 'Timed out'
|
|
543
|
+
};
|
|
544
|
+
this.resultsCache.set(id, result);
|
|
545
|
+
this.promises.get(id)?.resolve(result);
|
|
546
|
+
this.completedJobNotifications.push(id);
|
|
547
|
+
this.instrumentation.incRejectedJobs(item.type);
|
|
548
|
+
}
|
|
495
549
|
}
|
|
496
550
|
}
|
|
497
551
|
}
|
|
@@ -513,9 +567,6 @@ import { ProvingBrokerInstrumentation } from './proving_broker_instrumentation.j
|
|
|
513
567
|
return this.epochHeight - this.maxEpochsToKeepResultsFor;
|
|
514
568
|
}
|
|
515
569
|
}
|
|
516
|
-
_ts_decorate([
|
|
517
|
-
trackSpan('ProvingBroker.cleanupPass')
|
|
518
|
-
], ProvingBroker.prototype, "cleanupPass", null);
|
|
519
570
|
/**
|
|
520
571
|
* Compares two proving jobs and selects which one's more important
|
|
521
572
|
* @param a - A proving job
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { type Logger } from '@aztec/foundation/log';
|
|
3
3
|
import { type ProofUri, ProvingJob, type ProvingJobId, ProvingJobSettledResult } from '@aztec/stdlib/interfaces/server';
|
|
4
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
+
import { type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
|
|
5
5
|
import type { ProverBrokerConfig } from '../config.js';
|
|
6
6
|
import type { ProvingBrokerDatabase } from '../proving_broker_database.js';
|
|
7
7
|
export declare class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
@@ -10,6 +10,7 @@ export declare class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
10
10
|
private logger;
|
|
11
11
|
private metrics;
|
|
12
12
|
private batchQueue;
|
|
13
|
+
readonly tracer: Tracer;
|
|
13
14
|
private constructor();
|
|
14
15
|
commitWrites(items: Array<ProvingJob | [ProvingJobId, ProvingJobSettledResult]>, epochNumber: number): Promise<void>;
|
|
15
16
|
private estimateSize;
|
|
@@ -23,4 +24,4 @@ export declare class KVBrokerDatabase implements ProvingBrokerDatabase {
|
|
|
23
24
|
setProvingJobResult(id: ProvingJobId, value: ProofUri): Promise<void>;
|
|
24
25
|
private getEpochDatabase;
|
|
25
26
|
}
|
|
26
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGVyc2lzdGVkLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcHJvdmluZ19icm9rZXIvcHJvdmluZ19icm9rZXJfZGF0YWJhc2UvcGVyc2lzdGVkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU5RCxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFJbEUsT0FBTyxFQUNMLEtBQUssUUFBUSxFQUNiLFVBQVUsRUFDVixLQUFLLFlBQVksRUFDakIsdUJBQXVCLEVBRXhCLE1BQU0saUNBQWlDLENBQUM7QUFDekMsT0FBTyxFQUdMLEtBQUssZUFBZSxFQUNwQixLQUFLLE1BQU0sRUFHWixNQUFNLHlCQUF5QixDQUFDO0FBS2pDLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sY0FBYyxDQUFDO0FBQ3ZELE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sK0JBQStCLENBQUM7QUF3RDNFLHFCQUFhLGdCQUFpQixZQUFXLHFCQUFxQjtJQVExRCxPQUFPLENBQUMsTUFBTTtJQUNkLE9BQU8sQ0FBQyxNQUFNO0lBRWQsT0FBTyxDQUFDLE1BQU07SUFWaEIsT0FBTyxDQUFDLE9BQU8sQ0FBYztJQUU3QixPQUFPLENBQUMsVUFBVSxDQUEyRTtJQUU3RixTQUFnQixNQUFNLEVBQUUsTUFBTSxDQUFDO0lBRS9CLE9BQU8sZUFzQk47SUFHWSxZQUFZLENBQUMsS0FBSyxFQUFFLEtBQUssQ0FBQyxVQUFVLEdBQUcsQ0FBQyxZQUFZLEVBQUUsdUJBQXVCLENBQUMsQ0FBQyxFQUFFLFdBQVcsRUFBRSxNQUFNLGlCQU1oSDtZQUVhLFlBQVk7SUFVMUIsT0FBb0IsR0FBRyxDQUNyQixNQUFNLEVBQUUsa0JBQWtCLEVBQzFCLE1BQU0sR0FBRSxlQUFzQyxFQUM5QyxNQUFNLFNBQXdELDZCQThCL0Q7SUFFRCxPQUFPLENBQUMsS0FBSztJQUlQLEtBQUssSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLENBSzNCO0lBS0ssa0NBQWtDLENBQUMsV0FBVyxFQUFFLFdBQVcsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBV2hGO0lBRUQsYUFBYSxDQUFDLEdBQUcsRUFBRSxVQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUU1QztJQUVNLGNBQWMsSUFBSSxxQkFBcUIsQ0FBQyxDQUFDLFVBQVUsRUFBRSx1QkFBdUIsR0FBRyxTQUFTLENBQUMsQ0FBQyxDQUtoRztJQUVELGtCQUFrQixDQUFDLEVBQUUsRUFBRSxZQUFZLEVBQUUsTUFBTSxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBRWxFO0lBRUQsbUJBQW1CLENBQUMsRUFBRSxFQUFFLFlBQVksRUFBRSxLQUFLLEVBQUUsUUFBUSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFcEU7WUFFYSxnQkFBZ0I7Q0FvQi9CIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persisted.d.ts","sourceRoot":"","sources":["../../../src/proving_broker/proving_broker_database/persisted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAIlE,OAAO,EACL,KAAK,QAAQ,EACb,UAAU,EACV,KAAK,YAAY,EACjB,uBAAuB,EAExB,MAAM,iCAAiC,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"persisted.d.ts","sourceRoot":"","sources":["../../../src/proving_broker/proving_broker_database/persisted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAIlE,OAAO,EACL,KAAK,QAAQ,EACb,UAAU,EACV,KAAK,YAAY,EACjB,uBAAuB,EAExB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAKjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAwD3E,qBAAa,gBAAiB,YAAW,qBAAqB;IAQ1D,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IAEd,OAAO,CAAC,MAAM;IAVhB,OAAO,CAAC,OAAO,CAAc;IAE7B,OAAO,CAAC,UAAU,CAA2E;IAE7F,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,eAsBN;IAGY,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,GAAG,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,iBAMhH;YAEa,YAAY;IAU1B,OAAoB,GAAG,CACrB,MAAM,EAAE,kBAAkB,EAC1B,MAAM,GAAE,eAAsC,EAC9C,MAAM,SAAwD,6BA8B/D;IAED,OAAO,CAAC,KAAK;IAIP,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAK3B;IAKK,kCAAkC,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAWhF;IAED,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5C;IAEM,cAAc,IAAI,qBAAqB,CAAC,CAAC,UAAU,EAAE,uBAAuB,GAAG,SAAS,CAAC,CAAC,CAKhG;IAED,kBAAkB,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAElE;IAED,mBAAmB,CAAC,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE;YAEa,gBAAgB;CAoB/B"}
|
|
@@ -1,10 +1,383 @@
|
|
|
1
|
+
function applyDecs2203RFactory() {
|
|
2
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
3
|
+
return function addInitializer(initializer) {
|
|
4
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
5
|
+
assertCallable(initializer, "An initializer");
|
|
6
|
+
initializers.push(initializer);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
10
|
+
var kindStr;
|
|
11
|
+
switch(kind){
|
|
12
|
+
case 1:
|
|
13
|
+
kindStr = "accessor";
|
|
14
|
+
break;
|
|
15
|
+
case 2:
|
|
16
|
+
kindStr = "method";
|
|
17
|
+
break;
|
|
18
|
+
case 3:
|
|
19
|
+
kindStr = "getter";
|
|
20
|
+
break;
|
|
21
|
+
case 4:
|
|
22
|
+
kindStr = "setter";
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
kindStr = "field";
|
|
26
|
+
}
|
|
27
|
+
var ctx = {
|
|
28
|
+
kind: kindStr,
|
|
29
|
+
name: isPrivate ? "#" + name : name,
|
|
30
|
+
static: isStatic,
|
|
31
|
+
private: isPrivate,
|
|
32
|
+
metadata: metadata
|
|
33
|
+
};
|
|
34
|
+
var decoratorFinishedRef = {
|
|
35
|
+
v: false
|
|
36
|
+
};
|
|
37
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
38
|
+
var get, set;
|
|
39
|
+
if (kind === 0) {
|
|
40
|
+
if (isPrivate) {
|
|
41
|
+
get = desc.get;
|
|
42
|
+
set = desc.set;
|
|
43
|
+
} else {
|
|
44
|
+
get = function() {
|
|
45
|
+
return this[name];
|
|
46
|
+
};
|
|
47
|
+
set = function(v) {
|
|
48
|
+
this[name] = v;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
} else if (kind === 2) {
|
|
52
|
+
get = function() {
|
|
53
|
+
return desc.value;
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
if (kind === 1 || kind === 3) {
|
|
57
|
+
get = function() {
|
|
58
|
+
return desc.get.call(this);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (kind === 1 || kind === 4) {
|
|
62
|
+
set = function(v) {
|
|
63
|
+
desc.set.call(this, v);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
ctx.access = get && set ? {
|
|
68
|
+
get: get,
|
|
69
|
+
set: set
|
|
70
|
+
} : get ? {
|
|
71
|
+
get: get
|
|
72
|
+
} : {
|
|
73
|
+
set: set
|
|
74
|
+
};
|
|
75
|
+
try {
|
|
76
|
+
return dec(value, ctx);
|
|
77
|
+
} finally{
|
|
78
|
+
decoratorFinishedRef.v = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
82
|
+
if (decoratorFinishedRef.v) {
|
|
83
|
+
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function assertCallable(fn, hint) {
|
|
87
|
+
if (typeof fn !== "function") {
|
|
88
|
+
throw new TypeError(hint + " must be a function");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function assertValidReturnValue(kind, value) {
|
|
92
|
+
var type = typeof value;
|
|
93
|
+
if (kind === 1) {
|
|
94
|
+
if (type !== "object" || value === null) {
|
|
95
|
+
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
96
|
+
}
|
|
97
|
+
if (value.get !== undefined) {
|
|
98
|
+
assertCallable(value.get, "accessor.get");
|
|
99
|
+
}
|
|
100
|
+
if (value.set !== undefined) {
|
|
101
|
+
assertCallable(value.set, "accessor.set");
|
|
102
|
+
}
|
|
103
|
+
if (value.init !== undefined) {
|
|
104
|
+
assertCallable(value.init, "accessor.init");
|
|
105
|
+
}
|
|
106
|
+
} else if (type !== "function") {
|
|
107
|
+
var hint;
|
|
108
|
+
if (kind === 0) {
|
|
109
|
+
hint = "field";
|
|
110
|
+
} else if (kind === 10) {
|
|
111
|
+
hint = "class";
|
|
112
|
+
} else {
|
|
113
|
+
hint = "method";
|
|
114
|
+
}
|
|
115
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
119
|
+
var decs = decInfo[0];
|
|
120
|
+
var desc, init, value;
|
|
121
|
+
if (isPrivate) {
|
|
122
|
+
if (kind === 0 || kind === 1) {
|
|
123
|
+
desc = {
|
|
124
|
+
get: decInfo[3],
|
|
125
|
+
set: decInfo[4]
|
|
126
|
+
};
|
|
127
|
+
} else if (kind === 3) {
|
|
128
|
+
desc = {
|
|
129
|
+
get: decInfo[3]
|
|
130
|
+
};
|
|
131
|
+
} else if (kind === 4) {
|
|
132
|
+
desc = {
|
|
133
|
+
set: decInfo[3]
|
|
134
|
+
};
|
|
135
|
+
} else {
|
|
136
|
+
desc = {
|
|
137
|
+
value: decInfo[3]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
} else if (kind !== 0) {
|
|
141
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
142
|
+
}
|
|
143
|
+
if (kind === 1) {
|
|
144
|
+
value = {
|
|
145
|
+
get: desc.get,
|
|
146
|
+
set: desc.set
|
|
147
|
+
};
|
|
148
|
+
} else if (kind === 2) {
|
|
149
|
+
value = desc.value;
|
|
150
|
+
} else if (kind === 3) {
|
|
151
|
+
value = desc.get;
|
|
152
|
+
} else if (kind === 4) {
|
|
153
|
+
value = desc.set;
|
|
154
|
+
}
|
|
155
|
+
var newValue, get, set;
|
|
156
|
+
if (typeof decs === "function") {
|
|
157
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
158
|
+
if (newValue !== void 0) {
|
|
159
|
+
assertValidReturnValue(kind, newValue);
|
|
160
|
+
if (kind === 0) {
|
|
161
|
+
init = newValue;
|
|
162
|
+
} else if (kind === 1) {
|
|
163
|
+
init = newValue.init;
|
|
164
|
+
get = newValue.get || value.get;
|
|
165
|
+
set = newValue.set || value.set;
|
|
166
|
+
value = {
|
|
167
|
+
get: get,
|
|
168
|
+
set: set
|
|
169
|
+
};
|
|
170
|
+
} else {
|
|
171
|
+
value = newValue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
for(var i = decs.length - 1; i >= 0; i--){
|
|
176
|
+
var dec = decs[i];
|
|
177
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
178
|
+
if (newValue !== void 0) {
|
|
179
|
+
assertValidReturnValue(kind, newValue);
|
|
180
|
+
var newInit;
|
|
181
|
+
if (kind === 0) {
|
|
182
|
+
newInit = newValue;
|
|
183
|
+
} else if (kind === 1) {
|
|
184
|
+
newInit = newValue.init;
|
|
185
|
+
get = newValue.get || value.get;
|
|
186
|
+
set = newValue.set || value.set;
|
|
187
|
+
value = {
|
|
188
|
+
get: get,
|
|
189
|
+
set: set
|
|
190
|
+
};
|
|
191
|
+
} else {
|
|
192
|
+
value = newValue;
|
|
193
|
+
}
|
|
194
|
+
if (newInit !== void 0) {
|
|
195
|
+
if (init === void 0) {
|
|
196
|
+
init = newInit;
|
|
197
|
+
} else if (typeof init === "function") {
|
|
198
|
+
init = [
|
|
199
|
+
init,
|
|
200
|
+
newInit
|
|
201
|
+
];
|
|
202
|
+
} else {
|
|
203
|
+
init.push(newInit);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (kind === 0 || kind === 1) {
|
|
210
|
+
if (init === void 0) {
|
|
211
|
+
init = function(instance, init) {
|
|
212
|
+
return init;
|
|
213
|
+
};
|
|
214
|
+
} else if (typeof init !== "function") {
|
|
215
|
+
var ownInitializers = init;
|
|
216
|
+
init = function(instance, init) {
|
|
217
|
+
var value = init;
|
|
218
|
+
for(var i = 0; i < ownInitializers.length; i++){
|
|
219
|
+
value = ownInitializers[i].call(instance, value);
|
|
220
|
+
}
|
|
221
|
+
return value;
|
|
222
|
+
};
|
|
223
|
+
} else {
|
|
224
|
+
var originalInitializer = init;
|
|
225
|
+
init = function(instance, init) {
|
|
226
|
+
return originalInitializer.call(instance, init);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
ret.push(init);
|
|
230
|
+
}
|
|
231
|
+
if (kind !== 0) {
|
|
232
|
+
if (kind === 1) {
|
|
233
|
+
desc.get = value.get;
|
|
234
|
+
desc.set = value.set;
|
|
235
|
+
} else if (kind === 2) {
|
|
236
|
+
desc.value = value;
|
|
237
|
+
} else if (kind === 3) {
|
|
238
|
+
desc.get = value;
|
|
239
|
+
} else if (kind === 4) {
|
|
240
|
+
desc.set = value;
|
|
241
|
+
}
|
|
242
|
+
if (isPrivate) {
|
|
243
|
+
if (kind === 1) {
|
|
244
|
+
ret.push(function(instance, args) {
|
|
245
|
+
return value.get.call(instance, args);
|
|
246
|
+
});
|
|
247
|
+
ret.push(function(instance, args) {
|
|
248
|
+
return value.set.call(instance, args);
|
|
249
|
+
});
|
|
250
|
+
} else if (kind === 2) {
|
|
251
|
+
ret.push(value);
|
|
252
|
+
} else {
|
|
253
|
+
ret.push(function(instance, args) {
|
|
254
|
+
return value.call(instance, args);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
Object.defineProperty(base, name, desc);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
263
|
+
var ret = [];
|
|
264
|
+
var protoInitializers;
|
|
265
|
+
var staticInitializers;
|
|
266
|
+
var existingProtoNonFields = new Map();
|
|
267
|
+
var existingStaticNonFields = new Map();
|
|
268
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
269
|
+
var decInfo = decInfos[i];
|
|
270
|
+
if (!Array.isArray(decInfo)) continue;
|
|
271
|
+
var kind = decInfo[1];
|
|
272
|
+
var name = decInfo[2];
|
|
273
|
+
var isPrivate = decInfo.length > 3;
|
|
274
|
+
var isStatic = kind >= 5;
|
|
275
|
+
var base;
|
|
276
|
+
var initializers;
|
|
277
|
+
if (isStatic) {
|
|
278
|
+
base = Class;
|
|
279
|
+
kind = kind - 5;
|
|
280
|
+
staticInitializers = staticInitializers || [];
|
|
281
|
+
initializers = staticInitializers;
|
|
282
|
+
} else {
|
|
283
|
+
base = Class.prototype;
|
|
284
|
+
protoInitializers = protoInitializers || [];
|
|
285
|
+
initializers = protoInitializers;
|
|
286
|
+
}
|
|
287
|
+
if (kind !== 0 && !isPrivate) {
|
|
288
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
289
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
290
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
|
291
|
+
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
292
|
+
} else if (!existingKind && kind > 2) {
|
|
293
|
+
existingNonFields.set(name, kind);
|
|
294
|
+
} else {
|
|
295
|
+
existingNonFields.set(name, true);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
299
|
+
}
|
|
300
|
+
pushInitializers(ret, protoInitializers);
|
|
301
|
+
pushInitializers(ret, staticInitializers);
|
|
302
|
+
return ret;
|
|
303
|
+
}
|
|
304
|
+
function pushInitializers(ret, initializers) {
|
|
305
|
+
if (initializers) {
|
|
306
|
+
ret.push(function(instance) {
|
|
307
|
+
for(var i = 0; i < initializers.length; i++){
|
|
308
|
+
initializers[i].call(instance);
|
|
309
|
+
}
|
|
310
|
+
return instance;
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
315
|
+
if (classDecs.length > 0) {
|
|
316
|
+
var initializers = [];
|
|
317
|
+
var newClass = targetClass;
|
|
318
|
+
var name = targetClass.name;
|
|
319
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
320
|
+
var decoratorFinishedRef = {
|
|
321
|
+
v: false
|
|
322
|
+
};
|
|
323
|
+
try {
|
|
324
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
325
|
+
kind: "class",
|
|
326
|
+
name: name,
|
|
327
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
328
|
+
metadata
|
|
329
|
+
});
|
|
330
|
+
} finally{
|
|
331
|
+
decoratorFinishedRef.v = true;
|
|
332
|
+
}
|
|
333
|
+
if (nextNewClass !== undefined) {
|
|
334
|
+
assertValidReturnValue(10, nextNewClass);
|
|
335
|
+
newClass = nextNewClass;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return [
|
|
339
|
+
defineMetadata(newClass, metadata),
|
|
340
|
+
function() {
|
|
341
|
+
for(var i = 0; i < initializers.length; i++){
|
|
342
|
+
initializers[i].call(newClass);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function defineMetadata(Class, metadata) {
|
|
349
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
350
|
+
configurable: true,
|
|
351
|
+
enumerable: true,
|
|
352
|
+
value: metadata
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
356
|
+
if (parentClass !== void 0) {
|
|
357
|
+
var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
358
|
+
}
|
|
359
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
360
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
361
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
362
|
+
return {
|
|
363
|
+
e: e,
|
|
364
|
+
get c () {
|
|
365
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
371
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
372
|
+
}
|
|
373
|
+
var _dec, _initProto;
|
|
1
374
|
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
375
|
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
376
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
377
|
import { BatchQueue } from '@aztec/foundation/queue';
|
|
5
378
|
import { openVersionedStoreAt } from '@aztec/kv-store/lmdb-v2';
|
|
6
379
|
import { ProvingJob, ProvingJobSettledResult, getEpochFromProvingJobId } from '@aztec/stdlib/interfaces/server';
|
|
7
|
-
import { Attributes, LmdbMetrics, getTelemetryClient } from '@aztec/telemetry-client';
|
|
380
|
+
import { Attributes, LmdbMetrics, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
8
381
|
import { mkdir, readdir } from 'fs/promises';
|
|
9
382
|
import { join } from 'path';
|
|
10
383
|
class SingleEpochDatabase {
|
|
@@ -62,19 +435,34 @@ class SingleEpochDatabase {
|
|
|
62
435
|
return this.store.close();
|
|
63
436
|
}
|
|
64
437
|
}
|
|
438
|
+
_dec = trackSpan('KVBrokerDatabase.deleteAllProvingJobsOlderThanEpoch', (epochNumber)=>({
|
|
439
|
+
[Attributes.EPOCH_NUMBER]: epochNumber
|
|
440
|
+
}));
|
|
65
441
|
export class KVBrokerDatabase {
|
|
66
442
|
epochs;
|
|
67
443
|
config;
|
|
68
444
|
logger;
|
|
445
|
+
static{
|
|
446
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
447
|
+
[
|
|
448
|
+
_dec,
|
|
449
|
+
2,
|
|
450
|
+
"deleteAllProvingJobsOlderThanEpoch"
|
|
451
|
+
]
|
|
452
|
+
], []));
|
|
453
|
+
}
|
|
69
454
|
metrics;
|
|
70
455
|
batchQueue;
|
|
456
|
+
tracer;
|
|
71
457
|
constructor(epochs, config, client = getTelemetryClient(), logger){
|
|
72
458
|
this.epochs = epochs;
|
|
73
459
|
this.config = config;
|
|
74
460
|
this.logger = logger;
|
|
461
|
+
_initProto(this);
|
|
75
462
|
this.metrics = new LmdbMetrics(client.getMeter('KVBrokerDatabase'), {
|
|
76
463
|
[Attributes.DB_DATA_TYPE]: 'prover-broker'
|
|
77
464
|
}, ()=>this.estimateSize());
|
|
465
|
+
this.tracer = client.getTracer('KVBrokerDatabase');
|
|
78
466
|
this.batchQueue = new BatchQueue((items, key)=>this.commitWrites(items, key), config.proverBrokerBatchSize, config.proverBrokerBatchIntervalMs, createLogger('proving-client:proving-broker-database:batch-queue'));
|
|
79
467
|
}
|
|
80
468
|
// exposed for testing
|
|
@@ -111,7 +499,7 @@ export class KVBrokerDatabase {
|
|
|
111
499
|
continue;
|
|
112
500
|
}
|
|
113
501
|
logger.info(`Loading broker database for epoch ${epochNumber} from ${fullDirectory} with map size ${config.dataStoreMapSizeKb}KB`);
|
|
114
|
-
const db = await openVersionedStoreAt(fullDirectory, SingleEpochDatabase.SCHEMA_VERSION, config.
|
|
502
|
+
const db = await openVersionedStoreAt(fullDirectory, SingleEpochDatabase.SCHEMA_VERSION, config.rollupAddress, config.dataStoreMapSizeKb);
|
|
115
503
|
const epochDb = new SingleEpochDatabase(db);
|
|
116
504
|
epochs.set(epochNumber, epochDb);
|
|
117
505
|
}
|
|
@@ -175,7 +563,7 @@ export class KVBrokerDatabase {
|
|
|
175
563
|
recursive: true
|
|
176
564
|
});
|
|
177
565
|
this.logger.info(`Creating broker database for epoch ${epochNumber} at ${newEpochDirectory} with map size ${this.config.dataStoreMapSizeKb}`);
|
|
178
|
-
const db = await openVersionedStoreAt(newEpochDirectory, SingleEpochDatabase.SCHEMA_VERSION, this.config.
|
|
566
|
+
const db = await openVersionedStoreAt(newEpochDirectory, SingleEpochDatabase.SCHEMA_VERSION, this.config.rollupAddress, this.config.dataStoreMapSizeKb);
|
|
179
567
|
epochDb = new SingleEpochDatabase(db);
|
|
180
568
|
this.epochs.set(epochNumber, epochDb);
|
|
181
569
|
}
|