@aztec/prover-node 0.0.1-commit.9372f48 → 0.0.1-commit.949a33fd8
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.js +1 -1
- package/dest/actions/rerun-epoch-proving-job.d.ts +4 -3
- package/dest/actions/rerun-epoch-proving-job.d.ts.map +1 -1
- package/dest/actions/rerun-epoch-proving-job.js +5 -6
- package/dest/actions/upload-epoch-proof-failure.d.ts +2 -2
- package/dest/actions/upload-epoch-proof-failure.d.ts.map +1 -1
- package/dest/bin/run-failed-epoch.js +5 -2
- package/dest/config.d.ts +5 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +16 -19
- package/dest/factory.d.ts +19 -13
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +39 -59
- package/dest/job/epoch-proving-job.d.ts +2 -2
- package/dest/job/epoch-proving-job.d.ts.map +1 -1
- package/dest/job/epoch-proving-job.js +46 -12
- package/dest/metrics.d.ts +21 -1
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +47 -0
- 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 +5 -7
- package/dest/prover-node-publisher.d.ts +18 -3
- package/dest/prover-node-publisher.d.ts.map +1 -1
- package/dest/prover-node-publisher.js +54 -5
- package/dest/prover-node.d.ts +19 -9
- package/dest/prover-node.d.ts.map +1 -1
- package/dest/prover-node.js +14 -9
- package/dest/prover-publisher-factory.d.ts +4 -4
- package/dest/prover-publisher-factory.d.ts.map +1 -1
- package/dest/prover-publisher-factory.js +3 -3
- package/package.json +23 -22
- package/src/actions/download-epoch-proving-job.ts +1 -1
- package/src/actions/rerun-epoch-proving-job.ts +9 -4
- package/src/actions/upload-epoch-proof-failure.ts +1 -1
- package/src/bin/run-failed-epoch.ts +4 -1
- package/src/config.ts +23 -31
- package/src/factory.ts +67 -102
- package/src/job/epoch-proving-job.ts +62 -19
- package/src/metrics.ts +71 -0
- package/src/monitors/epoch-monitor.ts +3 -4
- package/src/prover-node-publisher.ts +76 -8
- package/src/prover-node.ts +17 -11
- package/src/prover-publisher-factory.ts +5 -5
|
@@ -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';
|
|
@@ -19,9 +19,9 @@ import type { L1PublishProofStats } from '@aztec/stdlib/stats';
|
|
|
19
19
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
20
20
|
|
|
21
21
|
import { inspect } from 'util';
|
|
22
|
-
import { type Hex, type TransactionReceipt, encodeFunctionData } from 'viem';
|
|
22
|
+
import { type Hex, type TransactionReceipt, encodeFunctionData, formatEther, formatGwei } from 'viem';
|
|
23
23
|
|
|
24
|
-
import { ProverNodePublisherMetrics } from './metrics.js';
|
|
24
|
+
import { type EstimatedSubmitProofStats, ProverNodePublisherMetrics } from './metrics.js';
|
|
25
25
|
|
|
26
26
|
/** Arguments to the submitEpochProof method of the rollup contract */
|
|
27
27
|
export type L1SubmitEpochProofArgs = {
|
|
@@ -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
|
|
|
@@ -168,7 +168,7 @@ export class ProverNodePublisher {
|
|
|
168
168
|
// toCheckpoint can't be greater than pending
|
|
169
169
|
if (toCheckpoint > pending) {
|
|
170
170
|
throw new Error(
|
|
171
|
-
`Cannot submit epoch proof for ${fromCheckpoint}-${toCheckpoint} as
|
|
171
|
+
`Cannot submit epoch proof for ${fromCheckpoint}-${toCheckpoint} as proposed checkpoint is ${pending}`,
|
|
172
172
|
);
|
|
173
173
|
}
|
|
174
174
|
|
|
@@ -210,6 +210,74 @@ export class ProverNodePublisher {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Estimates what submitting the epoch proof would have cost on L1 without actually sending it.
|
|
215
|
+
* Runs the same validation as `submitEpochProof`, encodes the calldata, estimates gas, and records metrics.
|
|
216
|
+
* Used when proof publishing is disabled (e.g. PROVER_NODE_DISABLE_PROOF_PUBLISH=true on mainnet).
|
|
217
|
+
*/
|
|
218
|
+
public async analyzeEpochProofSubmission(args: {
|
|
219
|
+
epochNumber: EpochNumber;
|
|
220
|
+
fromCheckpoint: CheckpointNumber;
|
|
221
|
+
toCheckpoint: CheckpointNumber;
|
|
222
|
+
publicInputs: RootRollupPublicInputs;
|
|
223
|
+
proof: Proof;
|
|
224
|
+
batchedBlobInputs: BatchedBlob;
|
|
225
|
+
attestations: ViemCommitteeAttestation[];
|
|
226
|
+
}): Promise<void> {
|
|
227
|
+
const { epochNumber, fromCheckpoint, toCheckpoint } = args;
|
|
228
|
+
|
|
229
|
+
await this.validateEpochProofSubmission(args);
|
|
230
|
+
|
|
231
|
+
const data = this.encodeSubmitEpochProofCalldata(args);
|
|
232
|
+
const senderAddress = this.l1TxUtils.getSenderAddress();
|
|
233
|
+
|
|
234
|
+
const [gasLimit, gasPrice, latestBlock] = await Promise.all([
|
|
235
|
+
this.l1TxUtils.estimateGas(senderAddress.toString() as `0x${string}`, { to: this.rollupContract.address, data }),
|
|
236
|
+
this.l1TxUtils.getGasPrice(),
|
|
237
|
+
this.l1TxUtils.client.getBlock({ blockTag: 'latest' }),
|
|
238
|
+
]);
|
|
239
|
+
|
|
240
|
+
const baseFeePerGas = latestBlock.baseFeePerGas ?? 0n;
|
|
241
|
+
const { maxPriorityFeePerGas } = gasPrice;
|
|
242
|
+
|
|
243
|
+
const effectiveFeePerGas = baseFeePerGas + maxPriorityFeePerGas;
|
|
244
|
+
const estimatedTotalFee = gasLimit * effectiveFeePerGas;
|
|
245
|
+
|
|
246
|
+
const stats: EstimatedSubmitProofStats = {
|
|
247
|
+
gasLimit,
|
|
248
|
+
baseFeePerGas,
|
|
249
|
+
maxPriorityFeePerGas,
|
|
250
|
+
estimatedTotalFee,
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
this.log.info(`Estimated epoch proof submission cost (not submitted)`, {
|
|
254
|
+
epochNumber,
|
|
255
|
+
fromCheckpoint,
|
|
256
|
+
toCheckpoint,
|
|
257
|
+
gasLimit: gasLimit.toString(),
|
|
258
|
+
baseFeePerGas: formatGwei(baseFeePerGas),
|
|
259
|
+
maxPriorityFeePerGas: formatGwei(maxPriorityFeePerGas),
|
|
260
|
+
estimatedTotalFeeEth: formatEther(estimatedTotalFee),
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
this.metrics.recordEstimatedSubmitProof(stats);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
private encodeSubmitEpochProofCalldata(args: {
|
|
267
|
+
fromCheckpoint: CheckpointNumber;
|
|
268
|
+
toCheckpoint: CheckpointNumber;
|
|
269
|
+
publicInputs: RootRollupPublicInputs;
|
|
270
|
+
proof: Proof;
|
|
271
|
+
batchedBlobInputs: BatchedBlob;
|
|
272
|
+
attestations: ViemCommitteeAttestation[];
|
|
273
|
+
}): Hex {
|
|
274
|
+
return encodeFunctionData({
|
|
275
|
+
abi: RollupAbi,
|
|
276
|
+
functionName: 'submitEpochRootProof',
|
|
277
|
+
args: [this.getSubmitEpochProofArgs(args)],
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
213
281
|
private async sendSubmitEpochProofTx(args: {
|
|
214
282
|
fromCheckpoint: CheckpointNumber;
|
|
215
283
|
toCheckpoint: CheckpointNumber;
|
|
@@ -271,7 +339,7 @@ export class ProverNodePublisher {
|
|
|
271
339
|
outHash: args.publicInputs.outHash.toString(),
|
|
272
340
|
proverId: EthAddress.fromField(args.publicInputs.constants.proverId).toString(),
|
|
273
341
|
} /*_args*/,
|
|
274
|
-
makeTuple(
|
|
342
|
+
makeTuple(MAX_CHECKPOINTS_PER_EPOCH * 2, i =>
|
|
275
343
|
i % 2 === 0
|
|
276
344
|
? args.publicInputs.fees[i / 2].recipient.toField().toString()
|
|
277
345
|
: args.publicInputs.fees[(i - 1) / 2].value.toString(),
|
|
@@ -296,9 +364,9 @@ export class ProverNodePublisher {
|
|
|
296
364
|
end: argsArray[1],
|
|
297
365
|
args: argsArray[2],
|
|
298
366
|
fees: argsArray[3],
|
|
299
|
-
attestations:
|
|
367
|
+
attestations: CommitteeAttestationsAndSigners.packAttestations(
|
|
300
368
|
args.attestations.map(a => CommitteeAttestation.fromViem(a)),
|
|
301
|
-
)
|
|
369
|
+
),
|
|
302
370
|
blobInputs: argsArray[4],
|
|
303
371
|
proof: proofHex,
|
|
304
372
|
};
|
package/src/prover-node.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
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';
|
|
6
7
|
import { memoize } from '@aztec/foundation/decorators';
|
|
7
8
|
import { createLogger } from '@aztec/foundation/log';
|
|
8
9
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
9
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
10
|
-
import type { P2PClient } from '@aztec/p2p';
|
|
11
10
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
12
11
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
13
12
|
import type { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
@@ -17,14 +16,15 @@ import { getProofSubmissionDeadlineTimestamp } from '@aztec/stdlib/epoch-helpers
|
|
|
17
16
|
import {
|
|
18
17
|
type EpochProverManager,
|
|
19
18
|
EpochProvingJobTerminalState,
|
|
19
|
+
type ITxProvider,
|
|
20
20
|
type ProverNodeApi,
|
|
21
21
|
type Service,
|
|
22
22
|
type WorldStateSyncStatus,
|
|
23
23
|
type WorldStateSynchronizer,
|
|
24
24
|
tryStop,
|
|
25
25
|
} from '@aztec/stdlib/interfaces/server';
|
|
26
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
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,17 +72,19 @@ 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,
|
|
85
86
|
proverNodeMaxPendingJobs: 100,
|
|
86
|
-
proverNodeMaxParallelBlocksPerEpoch:
|
|
87
|
+
proverNodeMaxParallelBlocksPerEpoch: 0,
|
|
87
88
|
txGatheringIntervalMs: 1_000,
|
|
88
89
|
txGatheringBatchSize: 10,
|
|
89
90
|
txGatheringMaxParallelRequestsPerNode: 100,
|
|
@@ -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();
|
|
@@ -275,13 +279,15 @@ export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable
|
|
|
275
279
|
const fromCheckpoint = epochData.checkpoints[0].number;
|
|
276
280
|
const toCheckpoint = epochData.checkpoints.at(-1)!.number;
|
|
277
281
|
const fromBlock = epochData.checkpoints[0].blocks[0].number;
|
|
278
|
-
const
|
|
282
|
+
const lastBlock = epochData.checkpoints.at(-1)!.blocks.at(-1)!;
|
|
283
|
+
const toBlock = lastBlock.number;
|
|
279
284
|
this.log.verbose(
|
|
280
285
|
`Creating proving job for epoch ${epochNumber} for checkpoint range ${fromCheckpoint} to ${toCheckpoint} and block range ${fromBlock} to ${toBlock}`,
|
|
281
286
|
);
|
|
282
287
|
|
|
283
288
|
// Fast forward world state to right before the target block and get a fork
|
|
284
|
-
await
|
|
289
|
+
const lastBlockHash = await lastBlock.header.hash();
|
|
290
|
+
await this.worldState.syncImmediate(toBlock, lastBlockHash);
|
|
285
291
|
|
|
286
292
|
// Create a processor factory
|
|
287
293
|
const publicProcessorFactory = new PublicProcessorFactory(
|
|
@@ -2,14 +2,14 @@ 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
4
|
import type { LoggerBindings } from '@aztec/foundation/log';
|
|
5
|
-
import type {
|
|
5
|
+
import type { ProverPublisherConfig, ProverTxSenderConfig } from '@aztec/sequencer-client';
|
|
6
6
|
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
7
7
|
|
|
8
8
|
import { ProverNodePublisher } from './prover-node-publisher.js';
|
|
9
9
|
|
|
10
10
|
export class ProverPublisherFactory {
|
|
11
11
|
constructor(
|
|
12
|
-
private config:
|
|
12
|
+
private config: ProverTxSenderConfig & ProverPublisherConfig,
|
|
13
13
|
private deps: {
|
|
14
14
|
rollupContract: RollupContract;
|
|
15
15
|
publisherManager: PublisherManager<L1TxUtils>;
|
|
@@ -19,11 +19,11 @@ export class ProverPublisherFactory {
|
|
|
19
19
|
) {}
|
|
20
20
|
|
|
21
21
|
public async start() {
|
|
22
|
-
await this.deps.publisherManager.
|
|
22
|
+
await this.deps.publisherManager.start();
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
public stop() {
|
|
26
|
-
this.deps.publisherManager.
|
|
25
|
+
public async stop() {
|
|
26
|
+
await this.deps.publisherManager.stop();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|