@aztec/prover-node 0.69.1 → 0.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +2 -2
- package/dest/factory.d.ts +2 -0
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +10 -8
- package/dest/job/epoch-proving-job.d.ts +8 -3
- package/dest/job/epoch-proving-job.d.ts.map +1 -1
- package/dest/job/epoch-proving-job.js +65 -11
- package/dest/metrics.d.ts +2 -2
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +9 -4
- package/dest/monitors/claims-monitor.d.ts +2 -2
- package/dest/monitors/claims-monitor.d.ts.map +1 -1
- package/dest/monitors/claims-monitor.js +3 -3
- package/dest/monitors/epoch-monitor.d.ts +2 -2
- package/dest/monitors/epoch-monitor.d.ts.map +1 -1
- package/dest/monitors/epoch-monitor.js +3 -3
- package/dest/prover-node.d.ts +17 -16
- package/dest/prover-node.d.ts.map +1 -1
- package/dest/prover-node.js +30 -10
- package/dest/test/index.d.ts +10 -0
- package/dest/test/index.d.ts.map +1 -0
- package/dest/test/index.js +4 -0
- package/package.json +20 -18
- package/src/config.ts +6 -6
- package/src/factory.ts +10 -8
- package/src/job/epoch-proving-job.ts +78 -13
- package/src/metrics.ts +9 -4
- package/src/monitors/claims-monitor.ts +8 -2
- package/src/monitors/epoch-monitor.ts +8 -2
- package/src/prover-node.ts +48 -18
- package/src/test/index.ts +11 -0
|
@@ -3,7 +3,13 @@ import { type EthAddress } from '@aztec/circuits.js';
|
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
5
5
|
import { type L1Publisher } from '@aztec/sequencer-client';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
type TelemetryClient,
|
|
8
|
+
type Traceable,
|
|
9
|
+
type Tracer,
|
|
10
|
+
getTelemetryClient,
|
|
11
|
+
trackSpan,
|
|
12
|
+
} from '@aztec/telemetry-client';
|
|
7
13
|
|
|
8
14
|
export interface ClaimsMonitorHandler {
|
|
9
15
|
handleClaim(proofClaim: EpochProofClaim): Promise<void>;
|
|
@@ -20,8 +26,8 @@ export class ClaimsMonitor implements Traceable {
|
|
|
20
26
|
|
|
21
27
|
constructor(
|
|
22
28
|
private readonly l1Publisher: L1Publisher,
|
|
23
|
-
telemetry: TelemetryClient,
|
|
24
29
|
private options: { pollingIntervalMs: number },
|
|
30
|
+
telemetry: TelemetryClient = getTelemetryClient(),
|
|
25
31
|
) {
|
|
26
32
|
this.tracer = telemetry.getTracer('ClaimsMonitor');
|
|
27
33
|
this.runningPromise = new RunningPromise(this.work.bind(this), this.log, this.options.pollingIntervalMs);
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { type L2BlockSource } from '@aztec/circuit-types';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
type TelemetryClient,
|
|
6
|
+
type Traceable,
|
|
7
|
+
type Tracer,
|
|
8
|
+
getTelemetryClient,
|
|
9
|
+
trackSpan,
|
|
10
|
+
} from '@aztec/telemetry-client';
|
|
5
11
|
|
|
6
12
|
export interface EpochMonitorHandler {
|
|
7
13
|
handleInitialEpochSync(epochNumber: bigint): Promise<void>;
|
|
@@ -19,8 +25,8 @@ export class EpochMonitor implements Traceable {
|
|
|
19
25
|
|
|
20
26
|
constructor(
|
|
21
27
|
private readonly l2BlockSource: L2BlockSource,
|
|
22
|
-
telemetry: TelemetryClient,
|
|
23
28
|
private options: { pollingIntervalMs: number },
|
|
29
|
+
telemetry: TelemetryClient = getTelemetryClient(),
|
|
24
30
|
) {
|
|
25
31
|
this.tracer = telemetry.getTracer('EpochMonitor');
|
|
26
32
|
this.runningPromise = new RunningPromise(this.work.bind(this), this.log, this.options.pollingIntervalMs);
|
package/src/prover-node.ts
CHANGED
|
@@ -13,11 +13,13 @@ import {
|
|
|
13
13
|
type Tx,
|
|
14
14
|
type TxHash,
|
|
15
15
|
type WorldStateSynchronizer,
|
|
16
|
+
getTimestampRangeForEpoch,
|
|
16
17
|
tryStop,
|
|
17
18
|
} from '@aztec/circuit-types';
|
|
18
19
|
import { type ContractDataSource } from '@aztec/circuits.js';
|
|
19
20
|
import { asyncPool } from '@aztec/foundation/async-pool';
|
|
20
21
|
import { compact } from '@aztec/foundation/collection';
|
|
22
|
+
import { memoize } from '@aztec/foundation/decorators';
|
|
21
23
|
import { TimeoutError } from '@aztec/foundation/error';
|
|
22
24
|
import { createLogger } from '@aztec/foundation/log';
|
|
23
25
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
@@ -25,8 +27,15 @@ import { DateProvider } from '@aztec/foundation/timer';
|
|
|
25
27
|
import { type Maybe } from '@aztec/foundation/types';
|
|
26
28
|
import { type P2P } from '@aztec/p2p';
|
|
27
29
|
import { type L1Publisher } from '@aztec/sequencer-client';
|
|
28
|
-
import { PublicProcessorFactory } from '@aztec/simulator';
|
|
29
|
-
import {
|
|
30
|
+
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
31
|
+
import {
|
|
32
|
+
Attributes,
|
|
33
|
+
type TelemetryClient,
|
|
34
|
+
type Traceable,
|
|
35
|
+
type Tracer,
|
|
36
|
+
getTelemetryClient,
|
|
37
|
+
trackSpan,
|
|
38
|
+
} from '@aztec/telemetry-client';
|
|
30
39
|
|
|
31
40
|
import { type BondManager } from './bond/bond-manager.js';
|
|
32
41
|
import { EpochProvingJob, type EpochProvingJobState } from './job/epoch-proving-job.js';
|
|
@@ -64,20 +73,20 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler, Pr
|
|
|
64
73
|
public readonly tracer: Tracer;
|
|
65
74
|
|
|
66
75
|
constructor(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
private readonly telemetryClient: TelemetryClient,
|
|
76
|
+
protected readonly prover: EpochProverManager,
|
|
77
|
+
protected readonly publisher: L1Publisher,
|
|
78
|
+
protected readonly l2BlockSource: L2BlockSource & Maybe<Service>,
|
|
79
|
+
protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
|
|
80
|
+
protected readonly contractDataSource: ContractDataSource,
|
|
81
|
+
protected readonly worldState: WorldStateSynchronizer,
|
|
82
|
+
protected readonly coordination: ProverCoordination & Maybe<Service>,
|
|
83
|
+
protected readonly quoteProvider: QuoteProvider,
|
|
84
|
+
protected readonly quoteSigner: QuoteSigner,
|
|
85
|
+
protected readonly claimsMonitor: ClaimsMonitor,
|
|
86
|
+
protected readonly epochsMonitor: EpochMonitor,
|
|
87
|
+
protected readonly bondManager: BondManager,
|
|
80
88
|
options: Partial<ProverNodeOptions> = {},
|
|
89
|
+
protected readonly telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
81
90
|
) {
|
|
82
91
|
this.options = {
|
|
83
92
|
pollingIntervalMs: 1_000,
|
|
@@ -182,7 +191,11 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler, Pr
|
|
|
182
191
|
);
|
|
183
192
|
await this.doSendEpochProofQuote(signed);
|
|
184
193
|
} catch (err) {
|
|
185
|
-
|
|
194
|
+
if (err instanceof EmptyEpochError) {
|
|
195
|
+
this.log.info(`Not producing quote for ${epochNumber} since no blocks were found`);
|
|
196
|
+
} else {
|
|
197
|
+
this.log.error(`Error handling epoch completed`, err);
|
|
198
|
+
}
|
|
186
199
|
}
|
|
187
200
|
}
|
|
188
201
|
|
|
@@ -289,11 +302,19 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler, Pr
|
|
|
289
302
|
return Promise.resolve();
|
|
290
303
|
};
|
|
291
304
|
|
|
292
|
-
const
|
|
305
|
+
const [_, endTimestamp] = getTimestampRangeForEpoch(epochNumber + 1n, await this.getL1Constants());
|
|
306
|
+
const deadline = new Date(Number(endTimestamp) * 1000);
|
|
307
|
+
|
|
308
|
+
const job = this.doCreateEpochProvingJob(epochNumber, deadline, blocks, txs, publicProcessorFactory, cleanUp);
|
|
293
309
|
this.jobs.set(job.getId(), job);
|
|
294
310
|
return job;
|
|
295
311
|
}
|
|
296
312
|
|
|
313
|
+
@memoize
|
|
314
|
+
private getL1Constants() {
|
|
315
|
+
return this.l2BlockSource.getL1Constants();
|
|
316
|
+
}
|
|
317
|
+
|
|
297
318
|
@trackSpan('ProverNode.gatherEpochData', epochNumber => ({ [Attributes.EPOCH_NUMBER]: Number(epochNumber) }))
|
|
298
319
|
private async gatherEpochData(epochNumber: bigint) {
|
|
299
320
|
// Gather blocks for this epoch and their txs
|
|
@@ -306,7 +327,7 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler, Pr
|
|
|
306
327
|
private async gatherBlocks(epochNumber: bigint) {
|
|
307
328
|
const blocks = await this.l2BlockSource.getBlocksForEpoch(epochNumber);
|
|
308
329
|
if (blocks.length === 0) {
|
|
309
|
-
throw new
|
|
330
|
+
throw new EmptyEpochError(epochNumber);
|
|
310
331
|
}
|
|
311
332
|
return blocks;
|
|
312
333
|
}
|
|
@@ -379,6 +400,7 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler, Pr
|
|
|
379
400
|
/** Extracted for testing purposes. */
|
|
380
401
|
protected doCreateEpochProvingJob(
|
|
381
402
|
epochNumber: bigint,
|
|
403
|
+
deadline: Date | undefined,
|
|
382
404
|
blocks: L2Block[],
|
|
383
405
|
txs: Tx[],
|
|
384
406
|
publicProcessorFactory: PublicProcessorFactory,
|
|
@@ -395,6 +417,7 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler, Pr
|
|
|
395
417
|
this.l2BlockSource,
|
|
396
418
|
this.l1ToL2MessageSource,
|
|
397
419
|
this.metrics,
|
|
420
|
+
deadline,
|
|
398
421
|
{ parallelBlockLimit: this.options.maxParallelBlocksPerEpoch },
|
|
399
422
|
cleanUp,
|
|
400
423
|
);
|
|
@@ -406,3 +429,10 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler, Pr
|
|
|
406
429
|
await this.claimsMonitor.work();
|
|
407
430
|
}
|
|
408
431
|
}
|
|
432
|
+
|
|
433
|
+
class EmptyEpochError extends Error {
|
|
434
|
+
constructor(epochNumber: bigint) {
|
|
435
|
+
super(`No blocks found for epoch ${epochNumber}`);
|
|
436
|
+
this.name = 'EmptyEpochError';
|
|
437
|
+
}
|
|
438
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type EpochProverManager } from '@aztec/circuit-types';
|
|
2
|
+
import { type L1Publisher } from '@aztec/sequencer-client';
|
|
3
|
+
|
|
4
|
+
import { ProverNode } from '../prover-node.js';
|
|
5
|
+
|
|
6
|
+
class TestProverNode_ extends ProverNode {
|
|
7
|
+
public override prover!: EpochProverManager;
|
|
8
|
+
public override publisher!: L1Publisher;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type TestProverNode = TestProverNode_;
|