@aztec/prover-node 0.0.1-commit.fcb71a6 → 0.0.1-commit.ff7989d6c
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/actions/download-epoch-proving-job.d.ts +1 -1
- package/dest/actions/rerun-epoch-proving-job.d.ts +3 -2
- package/dest/actions/rerun-epoch-proving-job.d.ts.map +1 -1
- package/dest/actions/rerun-epoch-proving-job.js +5 -3
- package/dest/bin/run-failed-epoch.js +5 -2
- package/dest/config.d.ts +4 -7
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +14 -17
- package/dest/factory.d.ts +19 -14
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +22 -59
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/job/epoch-proving-job.d.ts +3 -2
- package/dest/job/epoch-proving-job.d.ts.map +1 -1
- package/dest/job/epoch-proving-job.js +416 -28
- package/dest/metrics.d.ts +1 -1
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +26 -100
- package/dest/monitors/epoch-monitor.d.ts +1 -1
- package/dest/monitors/epoch-monitor.d.ts.map +1 -1
- package/dest/monitors/epoch-monitor.js +1 -10
- package/dest/prover-node-publisher.d.ts +6 -5
- package/dest/prover-node-publisher.d.ts.map +1 -1
- package/dest/prover-node-publisher.js +11 -10
- package/dest/prover-node.d.ts +19 -9
- package/dest/prover-node.d.ts.map +1 -1
- package/dest/prover-node.js +409 -28
- package/dest/prover-publisher-factory.d.ts +6 -4
- package/dest/prover-publisher-factory.d.ts.map +1 -1
- package/dest/prover-publisher-factory.js +4 -2
- package/package.json +23 -23
- package/src/actions/rerun-epoch-proving-job.ts +5 -3
- package/src/bin/run-failed-epoch.ts +4 -1
- package/src/config.ts +21 -29
- package/src/factory.ts +60 -99
- package/src/index.ts +1 -0
- package/src/job/epoch-proving-job.ts +45 -23
- package/src/metrics.ts +20 -83
- package/src/monitors/epoch-monitor.ts +1 -8
- package/src/prover-node-publisher.ts +13 -10
- package/src/prover-node.ts +14 -8
- package/src/prover-publisher-factory.ts +13 -7
|
@@ -4,13 +4,7 @@ import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
|
4
4
|
import { sleep } from '@aztec/foundation/sleep';
|
|
5
5
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
6
6
|
import { type L1RollupConstants, getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
7
|
-
import {
|
|
8
|
-
type TelemetryClient,
|
|
9
|
-
type Traceable,
|
|
10
|
-
type Tracer,
|
|
11
|
-
getTelemetryClient,
|
|
12
|
-
trackSpan,
|
|
13
|
-
} from '@aztec/telemetry-client';
|
|
7
|
+
import { type TelemetryClient, type Traceable, type Tracer, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
8
|
|
|
15
9
|
export interface EpochMonitorHandler {
|
|
16
10
|
handleEpochReadyToProve(epochNumber: EpochNumber): Promise<boolean>;
|
|
@@ -73,7 +67,6 @@ export class EpochMonitor implements Traceable {
|
|
|
73
67
|
this.log.info('Stopped EpochMonitor');
|
|
74
68
|
}
|
|
75
69
|
|
|
76
|
-
@trackSpan('EpochMonitor.work')
|
|
77
70
|
public async work() {
|
|
78
71
|
const { epochToProve, blockNumber, slotNumber } = await this.getEpochNumberToProve();
|
|
79
72
|
this.log.debug(`Epoch to prove: ${epochToProve}`, { blockNumber, slotNumber });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BatchedBlob, getEthBlobEvaluationInputs } from '@aztec/blob-lib';
|
|
2
|
-
import {
|
|
2
|
+
import { MAX_CHECKPOINTS_PER_EPOCH } from '@aztec/constants';
|
|
3
3
|
import type { RollupContract, ViemCommitteeAttestation } from '@aztec/ethereum/contracts';
|
|
4
4
|
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
5
5
|
import { makeTuple } from '@aztec/foundation/array';
|
|
@@ -7,7 +7,7 @@ import { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
|
7
7
|
import { areArraysEqual } from '@aztec/foundation/collection';
|
|
8
8
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
9
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
10
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
10
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
11
11
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
12
12
|
import { Timer } from '@aztec/foundation/timer';
|
|
13
13
|
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
@@ -31,7 +31,7 @@ export type L1SubmitEpochProofArgs = {
|
|
|
31
31
|
endTimestamp: Fr;
|
|
32
32
|
outHash: Fr;
|
|
33
33
|
proverId: Fr;
|
|
34
|
-
fees: Tuple<FeeRecipient, typeof
|
|
34
|
+
fees: Tuple<FeeRecipient, typeof MAX_CHECKPOINTS_PER_EPOCH>;
|
|
35
35
|
proof: Proof;
|
|
36
36
|
};
|
|
37
37
|
|
|
@@ -39,7 +39,7 @@ export class ProverNodePublisher {
|
|
|
39
39
|
private interrupted = false;
|
|
40
40
|
private metrics: ProverNodePublisherMetrics;
|
|
41
41
|
|
|
42
|
-
protected log
|
|
42
|
+
protected log: Logger;
|
|
43
43
|
|
|
44
44
|
protected rollupContract: RollupContract;
|
|
45
45
|
|
|
@@ -52,10 +52,12 @@ export class ProverNodePublisher {
|
|
|
52
52
|
l1TxUtils: L1TxUtils;
|
|
53
53
|
telemetry?: TelemetryClient;
|
|
54
54
|
},
|
|
55
|
+
bindings?: LoggerBindings,
|
|
55
56
|
) {
|
|
56
57
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
57
58
|
|
|
58
59
|
this.metrics = new ProverNodePublisherMetrics(telemetry, 'ProverNode');
|
|
60
|
+
this.log = createLogger('prover-node:l1-tx-publisher', bindings);
|
|
59
61
|
|
|
60
62
|
this.rollupContract = deps.rollupContract;
|
|
61
63
|
this.l1TxUtils = deps.l1TxUtils;
|
|
@@ -172,17 +174,17 @@ export class ProverNodePublisher {
|
|
|
172
174
|
|
|
173
175
|
// Check the archive for the immediate checkpoint before the epoch
|
|
174
176
|
const checkpointLog = await this.rollupContract.getCheckpoint(CheckpointNumber(fromCheckpoint - 1));
|
|
175
|
-
if (publicInputs.previousArchiveRoot.
|
|
177
|
+
if (!publicInputs.previousArchiveRoot.equals(checkpointLog.archive)) {
|
|
176
178
|
throw new Error(
|
|
177
|
-
`Previous archive root mismatch: ${publicInputs.previousArchiveRoot.toString()} !== ${checkpointLog.archive}`,
|
|
179
|
+
`Previous archive root mismatch: ${publicInputs.previousArchiveRoot.toString()} !== ${checkpointLog.archive.toString()}`,
|
|
178
180
|
);
|
|
179
181
|
}
|
|
180
182
|
|
|
181
183
|
// Check the archive for the last checkpoint in the epoch
|
|
182
184
|
const endCheckpointLog = await this.rollupContract.getCheckpoint(toCheckpoint);
|
|
183
|
-
if (publicInputs.endArchiveRoot.
|
|
185
|
+
if (!publicInputs.endArchiveRoot.equals(endCheckpointLog.archive)) {
|
|
184
186
|
throw new Error(
|
|
185
|
-
`End archive root mismatch: ${publicInputs.endArchiveRoot.toString()} !== ${endCheckpointLog.archive}`,
|
|
187
|
+
`End archive root mismatch: ${publicInputs.endArchiveRoot.toString()} !== ${endCheckpointLog.archive.toString()}`,
|
|
186
188
|
);
|
|
187
189
|
}
|
|
188
190
|
|
|
@@ -200,7 +202,7 @@ export class ProverNodePublisher {
|
|
|
200
202
|
);
|
|
201
203
|
const argsPublicInputs = [...publicInputs.toFields()];
|
|
202
204
|
|
|
203
|
-
if (!areArraysEqual(rollupPublicInputs
|
|
205
|
+
if (!areArraysEqual(rollupPublicInputs, argsPublicInputs, (a, b) => a.equals(b))) {
|
|
204
206
|
const fmt = (inputs: Fr[] | readonly string[]) => inputs.map(x => x.toString()).join(', ');
|
|
205
207
|
throw new Error(
|
|
206
208
|
`Root rollup public inputs mismatch:\nRollup: ${fmt(rollupPublicInputs)}\nComputed:${fmt(argsPublicInputs)}`,
|
|
@@ -266,9 +268,10 @@ export class ProverNodePublisher {
|
|
|
266
268
|
{
|
|
267
269
|
previousArchive: args.publicInputs.previousArchiveRoot.toString(),
|
|
268
270
|
endArchive: args.publicInputs.endArchiveRoot.toString(),
|
|
271
|
+
outHash: args.publicInputs.outHash.toString(),
|
|
269
272
|
proverId: EthAddress.fromField(args.publicInputs.constants.proverId).toString(),
|
|
270
273
|
} /*_args*/,
|
|
271
|
-
makeTuple(
|
|
274
|
+
makeTuple(MAX_CHECKPOINTS_PER_EPOCH * 2, i =>
|
|
272
275
|
i % 2 === 0
|
|
273
276
|
? args.publicInputs.fees[i / 2].recipient.toField().toString()
|
|
274
277
|
: args.publicInputs.fees[(i - 1) / 2].value.toString(),
|
package/src/prover-node.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Archiver } from '@aztec/archiver';
|
|
2
2
|
import type { RollupContract } from '@aztec/ethereum/contracts';
|
|
3
|
+
import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
|
|
3
4
|
import { BlockNumber, CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
4
5
|
import { assertRequired, compact, pick, sum } from '@aztec/foundation/collection';
|
|
5
6
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -7,7 +8,6 @@ import { memoize } from '@aztec/foundation/decorators';
|
|
|
7
8
|
import { createLogger } from '@aztec/foundation/log';
|
|
8
9
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
9
10
|
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
10
|
-
import type { P2PClient } from '@aztec/p2p';
|
|
11
11
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
12
12
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
13
13
|
import type { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
@@ -17,6 +17,7 @@ import { getProofSubmissionDeadlineTimestamp } from '@aztec/stdlib/epoch-helpers
|
|
|
17
17
|
import {
|
|
18
18
|
type EpochProverManager,
|
|
19
19
|
EpochProvingJobTerminalState,
|
|
20
|
+
type ITxProvider,
|
|
20
21
|
type ProverNodeApi,
|
|
21
22
|
type Service,
|
|
22
23
|
type WorldStateSyncStatus,
|
|
@@ -24,7 +25,6 @@ import {
|
|
|
24
25
|
tryStop,
|
|
25
26
|
} from '@aztec/stdlib/interfaces/server';
|
|
26
27
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
27
|
-
import type { P2PClientType } from '@aztec/stdlib/p2p';
|
|
28
28
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
29
29
|
import {
|
|
30
30
|
Attributes,
|
|
@@ -55,7 +55,6 @@ type DataStoreOptions = Pick<DataStoreConfig, 'dataDirectory'> & Pick<ChainConfi
|
|
|
55
55
|
*/
|
|
56
56
|
export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable {
|
|
57
57
|
private log = createLogger('prover-node');
|
|
58
|
-
private dateProvider = new DateProvider();
|
|
59
58
|
|
|
60
59
|
private jobs: Map<string, EpochProvingJob> = new Map();
|
|
61
60
|
private config: ProverNodeOptions;
|
|
@@ -73,12 +72,14 @@ export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable
|
|
|
73
72
|
protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
|
|
74
73
|
protected readonly contractDataSource: ContractDataSource,
|
|
75
74
|
protected readonly worldState: WorldStateSynchronizer,
|
|
76
|
-
protected readonly p2pClient:
|
|
75
|
+
protected readonly p2pClient: { getTxProvider(): ITxProvider } & Partial<Service>,
|
|
77
76
|
protected readonly epochsMonitor: EpochMonitor,
|
|
78
77
|
protected readonly rollupContract: RollupContract,
|
|
79
78
|
protected readonly l1Metrics: L1Metrics,
|
|
80
79
|
config: Partial<ProverNodeOptions> = {},
|
|
81
80
|
protected readonly telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
81
|
+
private delayer?: Delayer,
|
|
82
|
+
private readonly dateProvider: DateProvider = new DateProvider(),
|
|
82
83
|
) {
|
|
83
84
|
this.config = {
|
|
84
85
|
proverNodePollingIntervalMs: 1_000,
|
|
@@ -111,6 +112,11 @@ export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable
|
|
|
111
112
|
return this.p2pClient;
|
|
112
113
|
}
|
|
113
114
|
|
|
115
|
+
/** Returns the shared tx delayer for prover L1 txs, if enabled. Test-only. */
|
|
116
|
+
public getDelayer(): Delayer | undefined {
|
|
117
|
+
return this.delayer;
|
|
118
|
+
}
|
|
119
|
+
|
|
114
120
|
/**
|
|
115
121
|
* Handles an epoch being completed by starting a proof for it if there are no active jobs for it.
|
|
116
122
|
* @param epochNumber - The epoch number that was just completed.
|
|
@@ -155,17 +161,15 @@ export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable
|
|
|
155
161
|
|
|
156
162
|
/**
|
|
157
163
|
* Stops the prover node and all its dependencies.
|
|
164
|
+
* Resources not owned by this node (shared with the parent aztec-node) are skipped.
|
|
158
165
|
*/
|
|
159
166
|
async stop() {
|
|
160
167
|
this.log.info('Stopping ProverNode');
|
|
161
168
|
await this.epochsMonitor.stop();
|
|
162
169
|
await this.prover.stop();
|
|
163
|
-
await tryStop(this.p2pClient);
|
|
164
|
-
await tryStop(this.l2BlockSource);
|
|
165
170
|
await tryStop(this.publisherFactory);
|
|
166
171
|
this.publisher?.interrupt();
|
|
167
172
|
await Promise.all(Array.from(this.jobs.values()).map(job => job.stop()));
|
|
168
|
-
await this.worldState.stop();
|
|
169
173
|
this.rewardsMetrics.stop();
|
|
170
174
|
this.l1Metrics.stop();
|
|
171
175
|
await this.telemetryClient.stop();
|
|
@@ -288,6 +292,7 @@ export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable
|
|
|
288
292
|
this.contractDataSource,
|
|
289
293
|
this.dateProvider,
|
|
290
294
|
this.telemetryClient,
|
|
295
|
+
this.log.getBindings(),
|
|
291
296
|
);
|
|
292
297
|
|
|
293
298
|
// Set deadline for this job to run. It will abort if it takes too long.
|
|
@@ -311,7 +316,7 @@ export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable
|
|
|
311
316
|
const l1ToL2Messages = await this.gatherMessages(epochNumber, checkpoints);
|
|
312
317
|
const [firstBlock] = checkpoints[0].blocks;
|
|
313
318
|
const previousBlockHeader = await this.gatherPreviousBlockHeader(epochNumber, firstBlock.number - 1);
|
|
314
|
-
const [lastPublishedCheckpoint] = await this.l2BlockSource.
|
|
319
|
+
const [lastPublishedCheckpoint] = await this.l2BlockSource.getCheckpoints(checkpoints.at(-1)!.number, 1);
|
|
315
320
|
const attestations = lastPublishedCheckpoint?.attestations ?? [];
|
|
316
321
|
|
|
317
322
|
return { checkpoints, txs, l1ToL2Messages, epochNumber, previousBlockHeader, attestations };
|
|
@@ -384,6 +389,7 @@ export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable
|
|
|
384
389
|
this.jobMetrics,
|
|
385
390
|
deadline,
|
|
386
391
|
{ parallelBlockLimit, skipSubmitProof: proverNodeDisableProofPublish, ...opts },
|
|
392
|
+
this.log.getBindings(),
|
|
387
393
|
);
|
|
388
394
|
}
|
|
389
395
|
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import type { RollupContract } from '@aztec/ethereum/contracts';
|
|
2
2
|
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
3
3
|
import type { PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
4
|
-
import type {
|
|
4
|
+
import type { LoggerBindings } from '@aztec/foundation/log';
|
|
5
|
+
import type { ProverPublisherConfig, ProverTxSenderConfig } from '@aztec/sequencer-client';
|
|
5
6
|
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
6
7
|
|
|
7
8
|
import { ProverNodePublisher } from './prover-node-publisher.js';
|
|
8
9
|
|
|
9
10
|
export class ProverPublisherFactory {
|
|
10
11
|
constructor(
|
|
11
|
-
private config:
|
|
12
|
+
private config: ProverTxSenderConfig & ProverPublisherConfig,
|
|
12
13
|
private deps: {
|
|
13
14
|
rollupContract: RollupContract;
|
|
14
15
|
publisherManager: PublisherManager<L1TxUtils>;
|
|
15
16
|
telemetry?: TelemetryClient;
|
|
16
17
|
},
|
|
18
|
+
private bindings?: LoggerBindings,
|
|
17
19
|
) {}
|
|
18
20
|
|
|
19
21
|
public async start() {
|
|
@@ -30,10 +32,14 @@ export class ProverPublisherFactory {
|
|
|
30
32
|
*/
|
|
31
33
|
public async create(): Promise<ProverNodePublisher> {
|
|
32
34
|
const l1Publisher = await this.deps.publisherManager.getAvailablePublisher();
|
|
33
|
-
return new ProverNodePublisher(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
return new ProverNodePublisher(
|
|
36
|
+
this.config,
|
|
37
|
+
{
|
|
38
|
+
rollupContract: this.deps.rollupContract,
|
|
39
|
+
l1TxUtils: l1Publisher,
|
|
40
|
+
telemetry: this.deps.telemetry,
|
|
41
|
+
},
|
|
42
|
+
this.bindings,
|
|
43
|
+
);
|
|
38
44
|
}
|
|
39
45
|
}
|