@aztec/prover-node 0.0.1-commit.e61ad554 → 0.0.1-commit.ec5f612
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/rerun-epoch-proving-job.d.ts +1 -1
- package/dest/actions/rerun-epoch-proving-job.d.ts.map +1 -1
- package/dest/actions/rerun-epoch-proving-job.js +2 -2
- 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 -12
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +17 -55
- 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 +27 -13
- package/dest/metrics.d.ts +1 -1
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +11 -3
- 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 +5 -4
- package/dest/prover-node.d.ts +18 -8
- package/dest/prover-node.d.ts.map +1 -1
- package/dest/prover-node.js +11 -8
- 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 +22 -22
- package/src/actions/rerun-epoch-proving-job.ts +2 -1
- package/src/bin/run-failed-epoch.ts +4 -1
- package/src/config.ts +21 -29
- package/src/factory.ts +51 -98
- package/src/job/epoch-proving-job.ts +38 -19
- package/src/metrics.ts +6 -2
- package/src/prover-node-publisher.ts +7 -5
- package/src/prover-node.ts +13 -7
- package/src/prover-publisher-factory.ts +13 -7
package/src/factory.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { Archiver } from '@aztec/archiver';
|
|
2
|
+
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
3
|
+
import { Blob } from '@aztec/blob-lib';
|
|
4
|
+
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
5
5
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
6
6
|
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
7
7
|
import { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
@@ -9,26 +9,28 @@ import { PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
|
9
9
|
import { pick } from '@aztec/foundation/collection';
|
|
10
10
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
11
11
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
createForwarderL1TxUtilsFromEthSigner,
|
|
17
|
-
createL1TxUtilsFromEthSignerWithStore,
|
|
18
|
-
} from '@aztec/node-lib/factories';
|
|
19
|
-
import { NodeRpcTxSource, createP2PClient } from '@aztec/p2p';
|
|
20
|
-
import { type ProverClientConfig, createProverClient } from '@aztec/prover-client';
|
|
12
|
+
import { KeystoreManager } from '@aztec/node-keystore';
|
|
13
|
+
import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
|
|
14
|
+
import { type ProverClientConfig, type ProverClientUserConfig, createProverClient } from '@aztec/prover-client';
|
|
21
15
|
import { createAndStartProvingBroker } from '@aztec/prover-client/broker';
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
import {
|
|
17
|
+
type ProverPublisherConfig,
|
|
18
|
+
type ProverTxSenderConfig,
|
|
19
|
+
getPublisherConfigFromProverConfig,
|
|
20
|
+
} from '@aztec/sequencer-client';
|
|
21
|
+
import type {
|
|
22
|
+
AztecNode,
|
|
23
|
+
ITxProvider,
|
|
24
|
+
ProverConfig,
|
|
25
|
+
ProvingJobBroker,
|
|
26
|
+
Service,
|
|
27
|
+
WorldStateSynchronizer,
|
|
28
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
26
29
|
import { L1Metrics, type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
27
|
-
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
28
30
|
|
|
29
31
|
import { createPublicClient, fallback, http } from 'viem';
|
|
30
32
|
|
|
31
|
-
import
|
|
33
|
+
import type { SpecificProverNodeConfig } from './config.js';
|
|
32
34
|
import { EpochMonitor } from './monitors/epoch-monitor.js';
|
|
33
35
|
import { ProverNode } from './prover-node.js';
|
|
34
36
|
import { ProverPublisherFactory } from './prover-publisher-factory.js';
|
|
@@ -37,53 +39,42 @@ export type ProverNodeDeps = {
|
|
|
37
39
|
telemetry?: TelemetryClient;
|
|
38
40
|
log?: Logger;
|
|
39
41
|
aztecNodeTxProvider?: Pick<AztecNode, 'getTxsByHash'>;
|
|
40
|
-
archiver
|
|
42
|
+
archiver: Archiver;
|
|
41
43
|
publisherFactory?: ProverPublisherFactory;
|
|
42
44
|
broker?: ProvingJobBroker;
|
|
43
45
|
l1TxUtils?: L1TxUtils;
|
|
44
46
|
dateProvider?: DateProvider;
|
|
47
|
+
worldStateSynchronizer: WorldStateSynchronizer;
|
|
48
|
+
p2pClient: { getTxProvider(): ITxProvider } & Partial<Service>;
|
|
49
|
+
epochCache: EpochCacheInterface;
|
|
50
|
+
blobClient: BlobClientInterface;
|
|
51
|
+
keyStoreManager?: KeystoreManager;
|
|
45
52
|
};
|
|
46
53
|
|
|
47
|
-
/** Creates a new prover node given a config
|
|
54
|
+
/** Creates a new prover node subsystem given a config and dependencies */
|
|
48
55
|
export async function createProverNode(
|
|
49
|
-
userConfig:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
userConfig: SpecificProverNodeConfig &
|
|
57
|
+
ProverConfig &
|
|
58
|
+
ProverClientUserConfig &
|
|
59
|
+
ProverPublisherConfig &
|
|
60
|
+
ProverTxSenderConfig,
|
|
61
|
+
deps: ProverNodeDeps,
|
|
54
62
|
) {
|
|
55
63
|
const config = { ...userConfig };
|
|
56
64
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
57
65
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
58
|
-
const
|
|
59
|
-
const log = deps.log ?? createLogger('prover-node');
|
|
60
|
-
|
|
61
|
-
// Build a key store from file if given or from environment otherwise
|
|
62
|
-
let keyStoreManager: KeystoreManager | undefined;
|
|
63
|
-
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
64
|
-
if (keyStoreProvided) {
|
|
65
|
-
const keyStores = loadKeystores(config.keyStoreDirectory!);
|
|
66
|
-
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
67
|
-
} else {
|
|
68
|
-
const keyStore = createKeyStoreForProver(config);
|
|
69
|
-
if (keyStore) {
|
|
70
|
-
keyStoreManager = new KeystoreManager(keyStore);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
66
|
+
const log = deps.log ?? createLogger('prover');
|
|
73
67
|
|
|
74
|
-
|
|
68
|
+
const { p2pClient, archiver, keyStoreManager, worldStateSynchronizer } = deps;
|
|
75
69
|
|
|
76
70
|
// Extract the prover signers from the key store and verify that we have one.
|
|
71
|
+
await keyStoreManager?.validateSigners();
|
|
77
72
|
const proverSigners = keyStoreManager?.createProverSigners();
|
|
78
73
|
|
|
79
74
|
if (proverSigners === undefined) {
|
|
80
75
|
throw new Error('Failed to create prover key store configuration');
|
|
81
76
|
} else if (proverSigners.signers.length === 0) {
|
|
82
77
|
throw new Error('No prover signers found in the key store');
|
|
83
|
-
} else if (!keyStoreProvided) {
|
|
84
|
-
log.warn(
|
|
85
|
-
'KEY STORE CREATED FROM ENVIRONMENT, IT IS RECOMMENDED TO USE A FILE-BASED KEY STORE IN PRODUCTION ENVIRONMENTS',
|
|
86
|
-
);
|
|
87
78
|
}
|
|
88
79
|
|
|
89
80
|
log.info(`Creating prover with publishers ${proverSigners.signers.map(signer => signer.address.toString()).join()}`);
|
|
@@ -95,27 +86,7 @@ export async function createProverNode(
|
|
|
95
86
|
const proverId = proverSigners.id ?? proverIdInUserConfig ?? proverSigners.signers[0].address;
|
|
96
87
|
|
|
97
88
|
// Now create the prover client configuration from this.
|
|
98
|
-
const proverClientConfig: ProverClientConfig = {
|
|
99
|
-
...config,
|
|
100
|
-
proverId,
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
await trySnapshotSync(config, log);
|
|
104
|
-
|
|
105
|
-
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config);
|
|
106
|
-
|
|
107
|
-
const archiver =
|
|
108
|
-
deps.archiver ??
|
|
109
|
-
(await createArchiver(config, { blobClient, epochCache, telemetry, dateProvider }, { blockUntilSync: true }));
|
|
110
|
-
log.verbose(`Created archiver and synced to block ${await archiver.getBlockNumber()}`);
|
|
111
|
-
|
|
112
|
-
const worldStateSynchronizer = await createWorldStateSynchronizer(
|
|
113
|
-
config,
|
|
114
|
-
archiver,
|
|
115
|
-
options.prefilledPublicData,
|
|
116
|
-
telemetry,
|
|
117
|
-
);
|
|
118
|
-
await worldStateSynchronizer.start();
|
|
89
|
+
const proverClientConfig: ProverClientConfig = { ...config, proverId };
|
|
119
90
|
|
|
120
91
|
const broker = deps.broker ?? (await createAndStartProvingBroker(config, telemetry));
|
|
121
92
|
|
|
@@ -134,15 +105,15 @@ export async function createProverNode(
|
|
|
134
105
|
|
|
135
106
|
const l1TxUtils = deps.l1TxUtils
|
|
136
107
|
? [deps.l1TxUtils]
|
|
137
|
-
: config.
|
|
138
|
-
? await
|
|
108
|
+
: config.proverPublisherForwarderAddress
|
|
109
|
+
? await createForwarderL1TxUtilsFromSigners(
|
|
139
110
|
publicClient,
|
|
140
111
|
proverSigners.signers,
|
|
141
|
-
config.
|
|
112
|
+
config.proverPublisherForwarderAddress,
|
|
142
113
|
{ ...config, scope: 'prover' },
|
|
143
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
114
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
144
115
|
)
|
|
145
|
-
: await
|
|
116
|
+
: await createL1TxUtilsFromSigners(
|
|
146
117
|
publicClient,
|
|
147
118
|
proverSigners.signers,
|
|
148
119
|
{ ...config, scope: 'prover' },
|
|
@@ -153,35 +124,12 @@ export async function createProverNode(
|
|
|
153
124
|
deps.publisherFactory ??
|
|
154
125
|
new ProverPublisherFactory(config, {
|
|
155
126
|
rollupContract,
|
|
156
|
-
publisherManager: new PublisherManager(l1TxUtils, config),
|
|
127
|
+
publisherManager: new PublisherManager(l1TxUtils, getPublisherConfigFromProverConfig(config), log.getBindings()),
|
|
157
128
|
telemetry,
|
|
158
129
|
});
|
|
159
130
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
config.realProofs || config.debugForceTxProofVerification
|
|
163
|
-
? await BBCircuitVerifier.new(config)
|
|
164
|
-
: new TestCircuitVerifier(config.proverTestVerificationDelayMs),
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
const p2pClient = await createP2PClient(
|
|
168
|
-
P2PClientType.Prover,
|
|
169
|
-
config,
|
|
170
|
-
archiver,
|
|
171
|
-
proofVerifier,
|
|
172
|
-
worldStateSynchronizer,
|
|
173
|
-
epochCache,
|
|
174
|
-
getPackageVersion() ?? '',
|
|
175
|
-
dateProvider,
|
|
176
|
-
telemetry,
|
|
177
|
-
{
|
|
178
|
-
txCollectionNodeSources: deps.aztecNodeTxProvider
|
|
179
|
-
? [new NodeRpcTxSource(deps.aztecNodeTxProvider, 'TestNode')]
|
|
180
|
-
: [],
|
|
181
|
-
},
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
await p2pClient.start();
|
|
131
|
+
// TODO(#20393): Check that the tx collection node sources are properly injected
|
|
132
|
+
// See aztecNodeTxProvider
|
|
185
133
|
|
|
186
134
|
const proverNodeConfig = {
|
|
187
135
|
...pick(
|
|
@@ -213,6 +161,9 @@ export async function createProverNode(
|
|
|
213
161
|
l1TxUtils.map(utils => utils.getSenderAddress()),
|
|
214
162
|
);
|
|
215
163
|
|
|
164
|
+
// Extract the shared delayer from the first L1TxUtils instance (all instances share the same delayer)
|
|
165
|
+
const delayer = l1TxUtils[0]?.delayer;
|
|
166
|
+
|
|
216
167
|
return new ProverNode(
|
|
217
168
|
prover,
|
|
218
169
|
publisherFactory,
|
|
@@ -226,5 +177,7 @@ export async function createProverNode(
|
|
|
226
177
|
l1Metrics,
|
|
227
178
|
proverNodeConfig,
|
|
228
179
|
telemetry,
|
|
180
|
+
delayer,
|
|
181
|
+
dateProvider,
|
|
229
182
|
);
|
|
230
183
|
}
|
|
@@ -3,7 +3,7 @@ import { asyncPool } from '@aztec/foundation/async-pool';
|
|
|
3
3
|
import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
5
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
7
7
|
import { RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
8
8
|
import { Timer } from '@aztec/foundation/timer';
|
|
9
9
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
@@ -43,7 +43,7 @@ export type EpochProvingJobOptions = {
|
|
|
43
43
|
*/
|
|
44
44
|
export class EpochProvingJob implements Traceable {
|
|
45
45
|
private state: EpochProvingJobState = 'initialized';
|
|
46
|
-
private log
|
|
46
|
+
private log: Logger;
|
|
47
47
|
private uuid: string;
|
|
48
48
|
|
|
49
49
|
private runPromise: Promise<void> | undefined;
|
|
@@ -62,9 +62,14 @@ export class EpochProvingJob implements Traceable {
|
|
|
62
62
|
private metrics: ProverNodeJobMetrics,
|
|
63
63
|
private deadline: Date | undefined,
|
|
64
64
|
private config: EpochProvingJobOptions,
|
|
65
|
+
bindings?: LoggerBindings,
|
|
65
66
|
) {
|
|
66
67
|
validateEpochProvingJobData(data);
|
|
67
68
|
this.uuid = crypto.randomUUID();
|
|
69
|
+
this.log = createLogger('prover-node:epoch-proving-job', {
|
|
70
|
+
...bindings,
|
|
71
|
+
instanceId: `epoch-${data.epochNumber}`,
|
|
72
|
+
});
|
|
68
73
|
this.tracer = metrics.tracer;
|
|
69
74
|
}
|
|
70
75
|
|
|
@@ -144,7 +149,9 @@ export class EpochProvingJob implements Traceable {
|
|
|
144
149
|
|
|
145
150
|
try {
|
|
146
151
|
const blobFieldsPerCheckpoint = this.checkpoints.map(checkpoint => checkpoint.toBlobFields());
|
|
152
|
+
this.log.info(`Blob fields per checkpoint: ${timer.ms()}ms`);
|
|
147
153
|
const finalBlobBatchingChallenges = await buildFinalBlobChallenges(blobFieldsPerCheckpoint);
|
|
154
|
+
this.log.info(`Final blob batching challeneger: ${timer.ms()}ms`);
|
|
148
155
|
|
|
149
156
|
this.prover.startNewEpoch(epochNumber, epochSizeCheckpoints, finalBlobBatchingChallenges);
|
|
150
157
|
await this.prover.startChonkVerifierCircuits(Array.from(this.txs.values()));
|
|
@@ -188,7 +195,8 @@ export class EpochProvingJob implements Traceable {
|
|
|
188
195
|
previousHeader,
|
|
189
196
|
);
|
|
190
197
|
|
|
191
|
-
for (
|
|
198
|
+
for (let blockIndex = 0; blockIndex < checkpoint.blocks.length; blockIndex++) {
|
|
199
|
+
const block = checkpoint.blocks[blockIndex];
|
|
192
200
|
const globalVariables = block.header.globalVariables;
|
|
193
201
|
const txs = this.getTxs(block);
|
|
194
202
|
|
|
@@ -206,8 +214,12 @@ export class EpochProvingJob implements Traceable {
|
|
|
206
214
|
// Start block proving
|
|
207
215
|
await this.prover.startNewBlock(block.number, globalVariables.timestamp, txs.length);
|
|
208
216
|
|
|
209
|
-
// Process public fns
|
|
210
|
-
|
|
217
|
+
// Process public fns. L1 to L2 messages are only inserted for the first block of a checkpoint,
|
|
218
|
+
// as the fork for subsequent blocks already includes them from the previous block's synced state.
|
|
219
|
+
const db = await this.createFork(
|
|
220
|
+
BlockNumber(block.number - 1),
|
|
221
|
+
blockIndex === 0 ? l1ToL2Messages : undefined,
|
|
222
|
+
);
|
|
211
223
|
const config = PublicSimulatorConfig.from({
|
|
212
224
|
proverId: this.prover.getProverId().toField(),
|
|
213
225
|
skipFeeEnforcement: false,
|
|
@@ -290,22 +302,29 @@ export class EpochProvingJob implements Traceable {
|
|
|
290
302
|
}
|
|
291
303
|
|
|
292
304
|
/**
|
|
293
|
-
* Create a new db fork for tx processing, inserting
|
|
305
|
+
* Create a new db fork for tx processing, optionally inserting L1 to L2 messages.
|
|
306
|
+
* L1 to L2 messages should only be inserted for the first block in a checkpoint,
|
|
307
|
+
* as subsequent blocks' synced state already includes them.
|
|
294
308
|
* REFACTOR: The prover already spawns a db fork of its own for each block, so we may be able to do away with just one fork.
|
|
295
309
|
*/
|
|
296
|
-
private async createFork(blockNumber: BlockNumber, l1ToL2Messages: Fr[]) {
|
|
310
|
+
private async createFork(blockNumber: BlockNumber, l1ToL2Messages: Fr[] | undefined) {
|
|
311
|
+
this.log.verbose(`Creating fork at ${blockNumber}`, { blockNumber });
|
|
297
312
|
const db = await this.dbProvider.fork(blockNumber);
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
313
|
+
|
|
314
|
+
if (l1ToL2Messages !== undefined) {
|
|
315
|
+
this.log.verbose(`Inserting ${l1ToL2Messages.length} L1 to L2 messages in fork`, {
|
|
316
|
+
blockNumber,
|
|
317
|
+
l1ToL2Messages: l1ToL2Messages.map(m => m.toString()),
|
|
318
|
+
});
|
|
319
|
+
const l1ToL2MessagesPadded = padArrayEnd<Fr, number>(
|
|
320
|
+
l1ToL2Messages,
|
|
321
|
+
Fr.ZERO,
|
|
322
|
+
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
323
|
+
'Too many L1 to L2 messages',
|
|
324
|
+
);
|
|
325
|
+
await db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, l1ToL2MessagesPadded);
|
|
326
|
+
}
|
|
327
|
+
|
|
309
328
|
return db;
|
|
310
329
|
}
|
|
311
330
|
|
|
@@ -363,7 +382,7 @@ export class EpochProvingJob implements Traceable {
|
|
|
363
382
|
this.epochCheckPromise = new RunningPromise(
|
|
364
383
|
async () => {
|
|
365
384
|
const blockHeaders = await l2BlockSource.getCheckpointedBlockHeadersForEpoch(this.epochNumber);
|
|
366
|
-
const blockHashes = await Promise.all(blockHeaders.map(
|
|
385
|
+
const blockHashes = await Promise.all(blockHeaders.map(header => header.hash()));
|
|
367
386
|
const thisBlocks = this.checkpoints.flatMap(checkpoint => checkpoint.blocks);
|
|
368
387
|
const thisBlockHashes = await Promise.all(thisBlocks.map(block => block.hash()));
|
|
369
388
|
if (
|
package/src/metrics.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
type TelemetryClient,
|
|
14
14
|
type Tracer,
|
|
15
15
|
type UpDownCounter,
|
|
16
|
+
createUpDownCounterWithDefault,
|
|
16
17
|
} from '@aztec/telemetry-client';
|
|
17
18
|
|
|
18
19
|
import { formatEther, formatUnits } from 'viem';
|
|
@@ -65,7 +66,7 @@ export class ProverNodeRewardsMetrics {
|
|
|
65
66
|
) {
|
|
66
67
|
this.rewards = this.meter.createObservableGauge(Metrics.PROVER_NODE_REWARDS_PER_EPOCH);
|
|
67
68
|
|
|
68
|
-
this.accumulatedRewards = this.meter
|
|
69
|
+
this.accumulatedRewards = createUpDownCounterWithDefault(this.meter, Metrics.PROVER_NODE_REWARDS_TOTAL);
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
public async start() {
|
|
@@ -128,7 +129,10 @@ export class ProverNodePublisherMetrics {
|
|
|
128
129
|
|
|
129
130
|
this.gasPrice = this.meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE);
|
|
130
131
|
|
|
131
|
-
this.txCount = this.meter
|
|
132
|
+
this.txCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_PUBLISHER_TX_COUNT, {
|
|
133
|
+
[Attributes.L1_TX_TYPE]: ['submitProof'],
|
|
134
|
+
[Attributes.OK]: [true, false],
|
|
135
|
+
});
|
|
132
136
|
|
|
133
137
|
this.txDuration = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION);
|
|
134
138
|
|
|
@@ -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;
|
|
@@ -269,7 +271,7 @@ export class ProverNodePublisher {
|
|
|
269
271
|
outHash: args.publicInputs.outHash.toString(),
|
|
270
272
|
proverId: EthAddress.fromField(args.publicInputs.constants.proverId).toString(),
|
|
271
273
|
} /*_args*/,
|
|
272
|
-
makeTuple(
|
|
274
|
+
makeTuple(MAX_CHECKPOINTS_PER_EPOCH * 2, i =>
|
|
273
275
|
i % 2 === 0
|
|
274
276
|
? args.publicInputs.fees[i / 2].recipient.toField().toString()
|
|
275
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.
|
|
@@ -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
|
}
|