@aztec/prover-node 3.0.3-rc.3 → 3.9.9-nightly.20260312
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 +15 -18
- package/dest/factory.d.ts +19 -15
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +23 -60
- 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 +427 -29
- package/dest/metrics.d.ts +11 -1
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +51 -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 +410 -29
- 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 +24 -23
- package/src/actions/rerun-epoch-proving-job.ts +5 -3
- package/src/bin/run-failed-epoch.ts +4 -1
- package/src/config.ts +22 -30
- package/src/factory.ts +58 -102
- package/src/index.ts +1 -0
- package/src/job/epoch-proving-job.ts +62 -24
- package/src/metrics.ts +54 -83
- package/src/monitors/epoch-monitor.ts +1 -8
- package/src/prover-node-publisher.ts +13 -10
- package/src/prover-node.ts +15 -9
- package/src/prover-publisher-factory.ts +13 -7
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createArchiverStore } from '@aztec/archiver';
|
|
2
|
+
import type { L1ContractsConfig } from '@aztec/ethereum/config';
|
|
2
3
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
4
|
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
4
5
|
import { type ProverClientConfig, createProverClient } from '@aztec/prover-client';
|
|
@@ -21,7 +22,7 @@ import { ProverNodeJobMetrics } from '../metrics.js';
|
|
|
21
22
|
export async function rerunEpochProvingJob(
|
|
22
23
|
localPath: string,
|
|
23
24
|
log: Logger,
|
|
24
|
-
config: DataStoreConfig & ProverBrokerConfig & ProverClientConfig,
|
|
25
|
+
config: DataStoreConfig & ProverBrokerConfig & ProverClientConfig & Pick<L1ContractsConfig, 'aztecEpochDuration'>,
|
|
25
26
|
) {
|
|
26
27
|
const jobData = deserializeEpochProvingJobData(readFileSync(localPath));
|
|
27
28
|
log.info(`Loaded proving job data for epoch ${jobData.epochNumber}`);
|
|
@@ -29,8 +30,8 @@ export async function rerunEpochProvingJob(
|
|
|
29
30
|
const telemetry = getTelemetryClient();
|
|
30
31
|
const metrics = new ProverNodeJobMetrics(telemetry.getMeter('prover-job'), telemetry.getTracer('prover-job'));
|
|
31
32
|
const worldState = await createWorldState(config);
|
|
32
|
-
const archiver = await createArchiverStore(config);
|
|
33
|
-
const publicProcessorFactory = new PublicProcessorFactory(archiver);
|
|
33
|
+
const archiver = await createArchiverStore(config, { epochDuration: config.aztecEpochDuration });
|
|
34
|
+
const publicProcessorFactory = new PublicProcessorFactory(archiver, undefined, undefined, log.getBindings());
|
|
34
35
|
|
|
35
36
|
const publisher = { submitEpochProof: () => Promise.resolve(true) };
|
|
36
37
|
const l2BlockSourceForReorgDetection = undefined;
|
|
@@ -52,6 +53,7 @@ export async function rerunEpochProvingJob(
|
|
|
52
53
|
metrics,
|
|
53
54
|
deadline,
|
|
54
55
|
{ skipEpochCheck: true },
|
|
56
|
+
log.getBindings(),
|
|
55
57
|
);
|
|
56
58
|
|
|
57
59
|
log.info(`Rerunning epoch proving job for epoch ${jobData.epochNumber}`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
2
3
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
3
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
5
|
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
@@ -22,8 +23,10 @@ async function rerunFailedEpoch(provingJobUrl: string, baseLocalDir: string) {
|
|
|
22
23
|
const dataDir = join(localDir, 'state');
|
|
23
24
|
|
|
24
25
|
const env = getProverNodeConfigFromEnv();
|
|
26
|
+
const l1Config = getL1ContractsConfigEnvVars();
|
|
25
27
|
const config = {
|
|
26
|
-
...
|
|
28
|
+
...env,
|
|
29
|
+
...l1Config,
|
|
27
30
|
dataDirectory: dataDir,
|
|
28
31
|
dataStoreMapSizeKb: env.dataStoreMapSizeKb ?? 1024 * 1024,
|
|
29
32
|
proverId: env.proverId ?? EthAddress.random(),
|
package/src/config.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver/config';
|
|
2
1
|
import type { ACVMConfig, BBConfig } from '@aztec/bb-prover/config';
|
|
3
|
-
import { type GenesisStateConfig, genesisStateConfigMappings } from '@aztec/ethereum/config';
|
|
4
2
|
import {
|
|
5
3
|
type ConfigMappingsType,
|
|
6
4
|
booleanConfigHelper,
|
|
7
5
|
getConfigFromMappings,
|
|
8
6
|
numberConfigHelper,
|
|
7
|
+
pickConfigMappings,
|
|
9
8
|
} from '@aztec/foundation/config';
|
|
10
9
|
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
11
10
|
import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore/config';
|
|
12
11
|
import { ethPrivateKeySchema } from '@aztec/node-keystore/schemas';
|
|
13
12
|
import type { KeyStore } from '@aztec/node-keystore/types';
|
|
14
13
|
import { type SharedNodeConfig, sharedNodeConfigMappings } from '@aztec/node-lib/config';
|
|
15
|
-
import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
|
|
16
14
|
import {
|
|
17
15
|
type ProverAgentConfig,
|
|
18
16
|
type ProverBrokerConfig,
|
|
@@ -21,24 +19,19 @@ import {
|
|
|
21
19
|
} from '@aztec/prover-client/broker/config';
|
|
22
20
|
import { type ProverClientUserConfig, bbConfigMappings, proverClientConfigMappings } from '@aztec/prover-client/config';
|
|
23
21
|
import {
|
|
24
|
-
type
|
|
25
|
-
type
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
type ProverPublisherConfig,
|
|
23
|
+
type ProverTxSenderConfig,
|
|
24
|
+
proverPublisherConfigMappings,
|
|
25
|
+
proverTxSenderConfigMappings,
|
|
28
26
|
} from '@aztec/sequencer-client/config';
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
P2PConfig &
|
|
34
|
-
WorldStateConfig &
|
|
35
|
-
PublisherConfig &
|
|
36
|
-
TxSenderConfig &
|
|
27
|
+
|
|
28
|
+
export type ProverNodeConfig = ProverClientUserConfig &
|
|
29
|
+
ProverPublisherConfig &
|
|
30
|
+
ProverTxSenderConfig &
|
|
37
31
|
DataStoreConfig &
|
|
38
32
|
KeyStoreConfig &
|
|
39
|
-
SharedNodeConfig &
|
|
40
33
|
SpecificProverNodeConfig &
|
|
41
|
-
|
|
34
|
+
Pick<SharedNodeConfig, 'web3SignerUrl'>;
|
|
42
35
|
|
|
43
36
|
export type SpecificProverNodeConfig = {
|
|
44
37
|
proverNodeMaxPendingJobs: number;
|
|
@@ -53,7 +46,7 @@ export type SpecificProverNodeConfig = {
|
|
|
53
46
|
txGatheringMaxParallelRequestsPerNode: number;
|
|
54
47
|
};
|
|
55
48
|
|
|
56
|
-
const specificProverNodeConfigMappings: ConfigMappingsType<SpecificProverNodeConfig> = {
|
|
49
|
+
export const specificProverNodeConfigMappings: ConfigMappingsType<SpecificProverNodeConfig> = {
|
|
57
50
|
proverNodeMaxPendingJobs: {
|
|
58
51
|
env: 'PROVER_NODE_MAX_PENDING_JOBS',
|
|
59
52
|
description: 'The maximum number of pending jobs for the prover node',
|
|
@@ -67,7 +60,7 @@ const specificProverNodeConfigMappings: ConfigMappingsType<SpecificProverNodeCon
|
|
|
67
60
|
proverNodeMaxParallelBlocksPerEpoch: {
|
|
68
61
|
env: 'PROVER_NODE_MAX_PARALLEL_BLOCKS_PER_EPOCH',
|
|
69
62
|
description: 'The Maximum number of blocks to process in parallel while proving an epoch',
|
|
70
|
-
...numberConfigHelper(
|
|
63
|
+
...numberConfigHelper(0),
|
|
71
64
|
},
|
|
72
65
|
proverNodeFailedEpochStore: {
|
|
73
66
|
env: 'PROVER_NODE_FAILED_EPOCH_STORE',
|
|
@@ -108,15 +101,11 @@ const specificProverNodeConfigMappings: ConfigMappingsType<SpecificProverNodeCon
|
|
|
108
101
|
export const proverNodeConfigMappings: ConfigMappingsType<ProverNodeConfig> = {
|
|
109
102
|
...dataConfigMappings,
|
|
110
103
|
...keyStoreConfigMappings,
|
|
111
|
-
...archiverConfigMappings,
|
|
112
104
|
...proverClientConfigMappings,
|
|
113
|
-
...
|
|
114
|
-
...
|
|
115
|
-
...getPublisherConfigMappings('PROVER'),
|
|
116
|
-
...getTxSenderConfigMappings('PROVER'),
|
|
105
|
+
...proverPublisherConfigMappings,
|
|
106
|
+
...proverTxSenderConfigMappings,
|
|
117
107
|
...specificProverNodeConfigMappings,
|
|
118
|
-
...
|
|
119
|
-
...sharedNodeConfigMappings,
|
|
108
|
+
...pickConfigMappings(sharedNodeConfigMappings, ['web3SignerUrl']),
|
|
120
109
|
};
|
|
121
110
|
|
|
122
111
|
export function getProverNodeConfigFromEnv(): ProverNodeConfig {
|
|
@@ -143,7 +132,7 @@ function createKeyStoreFromWeb3Signer(config: ProverNodeConfig): KeyStore | unde
|
|
|
143
132
|
}
|
|
144
133
|
|
|
145
134
|
// Also, we need at least one publisher address.
|
|
146
|
-
const publishers = config.
|
|
135
|
+
const publishers = config.proverPublisherAddresses ?? [];
|
|
147
136
|
|
|
148
137
|
if (publishers.length === 0) {
|
|
149
138
|
return undefined;
|
|
@@ -164,8 +153,8 @@ function createKeyStoreFromWeb3Signer(config: ProverNodeConfig): KeyStore | unde
|
|
|
164
153
|
|
|
165
154
|
function createKeyStoreFromPublisherKeys(config: ProverNodeConfig): KeyStore | undefined {
|
|
166
155
|
// Extract the publisher keys from the provided config.
|
|
167
|
-
const publisherKeys = config.
|
|
168
|
-
? config.
|
|
156
|
+
const publisherKeys = config.proverPublisherPrivateKeys
|
|
157
|
+
? config.proverPublisherPrivateKeys.map((k: { getValue: () => string }) => ethPrivateKeySchema.parse(k.getValue()))
|
|
169
158
|
: [];
|
|
170
159
|
|
|
171
160
|
// There must be at least 1.
|
|
@@ -194,7 +183,10 @@ function createKeyStoreFromPublisherKeys(config: ProverNodeConfig): KeyStore | u
|
|
|
194
183
|
|
|
195
184
|
export function createKeyStoreForProver(config: ProverNodeConfig): KeyStore | undefined {
|
|
196
185
|
if (config.web3SignerUrl !== undefined && config.web3SignerUrl.length > 0) {
|
|
197
|
-
|
|
186
|
+
const keyStore = createKeyStoreFromWeb3Signer(config);
|
|
187
|
+
if (keyStore) {
|
|
188
|
+
return keyStore;
|
|
189
|
+
}
|
|
198
190
|
}
|
|
199
191
|
|
|
200
192
|
return createKeyStoreFromPublisherKeys(config);
|
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,23 +9,27 @@ 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 { createL1TxUtilsFromEthSignerWithStore } from '@aztec/node-lib/factories';
|
|
16
|
-
import { NodeRpcTxSource, createP2PClient } from '@aztec/p2p';
|
|
17
|
-
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';
|
|
18
15
|
import { createAndStartProvingBroker } from '@aztec/prover-client/broker';
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
import {
|
|
17
|
+
type ProverPublisherConfig,
|
|
18
|
+
type ProverTxSenderConfig,
|
|
19
|
+
getPublisherConfigFromProverConfig,
|
|
20
|
+
} from '@aztec/sequencer-client';
|
|
21
|
+
import type {
|
|
22
|
+
ITxProvider,
|
|
23
|
+
ProverConfig,
|
|
24
|
+
ProvingJobBroker,
|
|
25
|
+
Service,
|
|
26
|
+
WorldStateSynchronizer,
|
|
27
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
23
28
|
import { L1Metrics, type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
24
|
-
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
25
29
|
|
|
26
30
|
import { createPublicClient, fallback, http } from 'viem';
|
|
27
31
|
|
|
28
|
-
import
|
|
32
|
+
import type { SpecificProverNodeConfig } from './config.js';
|
|
29
33
|
import { EpochMonitor } from './monitors/epoch-monitor.js';
|
|
30
34
|
import { ProverNode } from './prover-node.js';
|
|
31
35
|
import { ProverPublisherFactory } from './prover-publisher-factory.js';
|
|
@@ -33,56 +37,42 @@ import { ProverPublisherFactory } from './prover-publisher-factory.js';
|
|
|
33
37
|
export type ProverNodeDeps = {
|
|
34
38
|
telemetry?: TelemetryClient;
|
|
35
39
|
log?: Logger;
|
|
36
|
-
|
|
37
|
-
archiver?: Archiver;
|
|
40
|
+
archiver: Archiver;
|
|
38
41
|
publisherFactory?: ProverPublisherFactory;
|
|
39
|
-
blobSinkClient?: BlobSinkClientInterface;
|
|
40
42
|
broker?: ProvingJobBroker;
|
|
41
43
|
l1TxUtils?: L1TxUtils;
|
|
42
44
|
dateProvider?: DateProvider;
|
|
45
|
+
worldStateSynchronizer: WorldStateSynchronizer;
|
|
46
|
+
p2pClient: { getTxProvider(): ITxProvider } & Partial<Service>;
|
|
47
|
+
epochCache: EpochCacheInterface;
|
|
48
|
+
blobClient: BlobClientInterface;
|
|
49
|
+
keyStoreManager?: KeystoreManager;
|
|
43
50
|
};
|
|
44
51
|
|
|
45
|
-
/** Creates a new prover node given a config
|
|
52
|
+
/** Creates a new prover node subsystem given a config and dependencies */
|
|
46
53
|
export async function createProverNode(
|
|
47
|
-
userConfig:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
userConfig: SpecificProverNodeConfig &
|
|
55
|
+
ProverConfig &
|
|
56
|
+
ProverClientUserConfig &
|
|
57
|
+
ProverPublisherConfig &
|
|
58
|
+
ProverTxSenderConfig,
|
|
59
|
+
deps: ProverNodeDeps,
|
|
52
60
|
) {
|
|
53
61
|
const config = { ...userConfig };
|
|
54
62
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
55
63
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
56
|
-
const
|
|
57
|
-
deps.blobSinkClient ?? createBlobSinkClient(config, { logger: createLogger('prover-node:blob-sink:client') });
|
|
58
|
-
const log = deps.log ?? createLogger('prover-node');
|
|
59
|
-
|
|
60
|
-
// Build a key store from file if given or from environment otherwise
|
|
61
|
-
let keyStoreManager: KeystoreManager | undefined;
|
|
62
|
-
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
63
|
-
if (keyStoreProvided) {
|
|
64
|
-
const keyStores = loadKeystores(config.keyStoreDirectory!);
|
|
65
|
-
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
66
|
-
} else {
|
|
67
|
-
const keyStore = createKeyStoreForProver(config);
|
|
68
|
-
if (keyStore) {
|
|
69
|
-
keyStoreManager = new KeystoreManager(keyStore);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
64
|
+
const log = deps.log ?? createLogger('prover');
|
|
72
65
|
|
|
73
|
-
|
|
66
|
+
const { p2pClient, archiver, keyStoreManager, worldStateSynchronizer } = deps;
|
|
74
67
|
|
|
75
68
|
// Extract the prover signers from the key store and verify that we have one.
|
|
69
|
+
await keyStoreManager?.validateSigners();
|
|
76
70
|
const proverSigners = keyStoreManager?.createProverSigners();
|
|
77
71
|
|
|
78
72
|
if (proverSigners === undefined) {
|
|
79
73
|
throw new Error('Failed to create prover key store configuration');
|
|
80
74
|
} else if (proverSigners.signers.length === 0) {
|
|
81
75
|
throw new Error('No prover signers found in the key store');
|
|
82
|
-
} else if (!keyStoreProvided) {
|
|
83
|
-
log.warn(
|
|
84
|
-
'KEY STORE CREATED FROM ENVIRONMENT, IT IS RECOMMENDED TO USE A FILE-BASED KEY STORE IN PRODUCTION ENVIRONMENTS',
|
|
85
|
-
);
|
|
86
76
|
}
|
|
87
77
|
|
|
88
78
|
log.info(`Creating prover with publishers ${proverSigners.signers.map(signer => signer.address.toString()).join()}`);
|
|
@@ -94,28 +84,7 @@ export async function createProverNode(
|
|
|
94
84
|
const proverId = proverSigners.id ?? proverIdInUserConfig ?? proverSigners.signers[0].address;
|
|
95
85
|
|
|
96
86
|
// Now create the prover client configuration from this.
|
|
97
|
-
const proverClientConfig: ProverClientConfig = {
|
|
98
|
-
...config,
|
|
99
|
-
proverId,
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
await trySnapshotSync(config, log);
|
|
103
|
-
|
|
104
|
-
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config);
|
|
105
|
-
|
|
106
|
-
const archiver =
|
|
107
|
-
deps.archiver ??
|
|
108
|
-
(await createArchiver(config, { blobSinkClient, epochCache, telemetry, dateProvider }, { blockUntilSync: true }));
|
|
109
|
-
log.verbose(`Created archiver and synced to block ${await archiver.getBlockNumber()}`);
|
|
110
|
-
|
|
111
|
-
const worldStateConfig = { ...config, worldStateProvenBlocksOnly: false };
|
|
112
|
-
const worldStateSynchronizer = await createWorldStateSynchronizer(
|
|
113
|
-
worldStateConfig,
|
|
114
|
-
archiver,
|
|
115
|
-
options.prefilledPublicData,
|
|
116
|
-
telemetry,
|
|
117
|
-
);
|
|
118
|
-
await worldStateSynchronizer.start();
|
|
87
|
+
const proverClientConfig: ProverClientConfig = { ...config, proverId };
|
|
119
88
|
|
|
120
89
|
const broker = deps.broker ?? (await createAndStartProvingBroker(config, telemetry));
|
|
121
90
|
|
|
@@ -126,7 +95,7 @@ export async function createProverNode(
|
|
|
126
95
|
|
|
127
96
|
const publicClient = createPublicClient({
|
|
128
97
|
chain: chain.chainInfo,
|
|
129
|
-
transport: fallback(config.l1RpcUrls.map((url: string) => http(url))),
|
|
98
|
+
transport: fallback(config.l1RpcUrls.map((url: string) => http(url, { batch: false }))),
|
|
130
99
|
pollingInterval: config.viemPollingIntervalMS,
|
|
131
100
|
});
|
|
132
101
|
|
|
@@ -134,47 +103,29 @@ export async function createProverNode(
|
|
|
134
103
|
|
|
135
104
|
const l1TxUtils = deps.l1TxUtils
|
|
136
105
|
? [deps.l1TxUtils]
|
|
137
|
-
:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
106
|
+
: config.proverPublisherForwarderAddress
|
|
107
|
+
? await createForwarderL1TxUtilsFromSigners(
|
|
108
|
+
publicClient,
|
|
109
|
+
proverSigners.signers,
|
|
110
|
+
config.proverPublisherForwarderAddress,
|
|
111
|
+
{ ...config, scope: 'prover' },
|
|
112
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
113
|
+
)
|
|
114
|
+
: await createL1TxUtilsFromSigners(
|
|
115
|
+
publicClient,
|
|
116
|
+
proverSigners.signers,
|
|
117
|
+
{ ...config, scope: 'prover' },
|
|
118
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
119
|
+
);
|
|
143
120
|
|
|
144
121
|
const publisherFactory =
|
|
145
122
|
deps.publisherFactory ??
|
|
146
123
|
new ProverPublisherFactory(config, {
|
|
147
124
|
rollupContract,
|
|
148
|
-
publisherManager: new PublisherManager(l1TxUtils, config),
|
|
125
|
+
publisherManager: new PublisherManager(l1TxUtils, getPublisherConfigFromProverConfig(config), log.getBindings()),
|
|
149
126
|
telemetry,
|
|
150
127
|
});
|
|
151
128
|
|
|
152
|
-
const proofVerifier = new QueuedIVCVerifier(
|
|
153
|
-
config,
|
|
154
|
-
config.realProofs || config.debugForceTxProofVerification
|
|
155
|
-
? await BBCircuitVerifier.new(config)
|
|
156
|
-
: new TestCircuitVerifier(config.proverTestVerificationDelayMs),
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
const p2pClient = await createP2PClient(
|
|
160
|
-
P2PClientType.Prover,
|
|
161
|
-
config,
|
|
162
|
-
archiver,
|
|
163
|
-
proofVerifier,
|
|
164
|
-
worldStateSynchronizer,
|
|
165
|
-
epochCache,
|
|
166
|
-
getPackageVersion() ?? '',
|
|
167
|
-
dateProvider,
|
|
168
|
-
telemetry,
|
|
169
|
-
{
|
|
170
|
-
txCollectionNodeSources: deps.aztecNodeTxProvider
|
|
171
|
-
? [new NodeRpcTxSource(deps.aztecNodeTxProvider, 'TestNode')]
|
|
172
|
-
: [],
|
|
173
|
-
},
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
await p2pClient.start();
|
|
177
|
-
|
|
178
129
|
const proverNodeConfig = {
|
|
179
130
|
...pick(
|
|
180
131
|
config,
|
|
@@ -205,6 +156,9 @@ export async function createProverNode(
|
|
|
205
156
|
l1TxUtils.map(utils => utils.getSenderAddress()),
|
|
206
157
|
);
|
|
207
158
|
|
|
159
|
+
// Extract the shared delayer from the first L1TxUtils instance (all instances share the same delayer)
|
|
160
|
+
const delayer = l1TxUtils[0]?.delayer;
|
|
161
|
+
|
|
208
162
|
return new ProverNode(
|
|
209
163
|
prover,
|
|
210
164
|
publisherFactory,
|
|
@@ -218,5 +172,7 @@ export async function createProverNode(
|
|
|
218
172
|
l1Metrics,
|
|
219
173
|
proverNodeConfig,
|
|
220
174
|
telemetry,
|
|
175
|
+
delayer,
|
|
176
|
+
dateProvider,
|
|
221
177
|
);
|
|
222
178
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,15 +3,16 @@ 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
|
+
import { AVM_MAX_CONCURRENT_SIMULATIONS } from '@aztec/native';
|
|
9
10
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
10
11
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
11
12
|
import { buildFinalBlobChallenges } from '@aztec/prover-client/helpers';
|
|
12
13
|
import type { PublicProcessor, PublicProcessorFactory } from '@aztec/simulator/server';
|
|
13
14
|
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
14
|
-
import type {
|
|
15
|
+
import type { L2Block, L2BlockSource } from '@aztec/stdlib/block';
|
|
15
16
|
import type { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
16
17
|
import {
|
|
17
18
|
type EpochProver,
|
|
@@ -43,7 +44,7 @@ export type EpochProvingJobOptions = {
|
|
|
43
44
|
*/
|
|
44
45
|
export class EpochProvingJob implements Traceable {
|
|
45
46
|
private state: EpochProvingJobState = 'initialized';
|
|
46
|
-
private log
|
|
47
|
+
private log: Logger;
|
|
47
48
|
private uuid: string;
|
|
48
49
|
|
|
49
50
|
private runPromise: Promise<void> | undefined;
|
|
@@ -62,9 +63,14 @@ export class EpochProvingJob implements Traceable {
|
|
|
62
63
|
private metrics: ProverNodeJobMetrics,
|
|
63
64
|
private deadline: Date | undefined,
|
|
64
65
|
private config: EpochProvingJobOptions,
|
|
66
|
+
bindings?: LoggerBindings,
|
|
65
67
|
) {
|
|
66
68
|
validateEpochProvingJobData(data);
|
|
67
69
|
this.uuid = crypto.randomUUID();
|
|
70
|
+
this.log = createLogger('prover-node:epoch-proving-job', {
|
|
71
|
+
...bindings,
|
|
72
|
+
instanceId: `epoch-${data.epochNumber}`,
|
|
73
|
+
});
|
|
68
74
|
this.tracer = metrics.tracer;
|
|
69
75
|
}
|
|
70
76
|
|
|
@@ -143,19 +149,32 @@ export class EpochProvingJob implements Traceable {
|
|
|
143
149
|
this.runPromise = promise;
|
|
144
150
|
|
|
145
151
|
try {
|
|
152
|
+
const blobTimer = new Timer();
|
|
146
153
|
const blobFieldsPerCheckpoint = this.checkpoints.map(checkpoint => checkpoint.toBlobFields());
|
|
147
154
|
const finalBlobBatchingChallenges = await buildFinalBlobChallenges(blobFieldsPerCheckpoint);
|
|
155
|
+
this.metrics.recordBlobProcessing(blobTimer.ms());
|
|
148
156
|
|
|
149
157
|
this.prover.startNewEpoch(epochNumber, epochSizeCheckpoints, finalBlobBatchingChallenges);
|
|
158
|
+
const chonkTimer = new Timer();
|
|
150
159
|
await this.prover.startChonkVerifierCircuits(Array.from(this.txs.values()));
|
|
160
|
+
this.metrics.recordChonkVerifier(chonkTimer.ms());
|
|
151
161
|
|
|
152
162
|
// Everything in the epoch should have the same chainId and version.
|
|
153
163
|
const { chainId, version } = this.checkpoints[0].blocks[0].header.globalVariables;
|
|
154
164
|
|
|
155
165
|
const previousBlockHeaders = this.gatherPreviousBlockHeaders();
|
|
156
166
|
|
|
157
|
-
|
|
167
|
+
const allCheckpointsTimer = new Timer();
|
|
168
|
+
|
|
169
|
+
const parallelism = this.config.parallelBlockLimit
|
|
170
|
+
? this.config.parallelBlockLimit
|
|
171
|
+
: AVM_MAX_CONCURRENT_SIMULATIONS > 0
|
|
172
|
+
? AVM_MAX_CONCURRENT_SIMULATIONS
|
|
173
|
+
: this.checkpoints.length;
|
|
174
|
+
|
|
175
|
+
await asyncPool(parallelism, this.checkpoints, async checkpoint => {
|
|
158
176
|
this.checkState();
|
|
177
|
+
const checkpointTimer = new Timer();
|
|
159
178
|
|
|
160
179
|
const checkpointIndex = checkpoint.number - fromCheckpoint;
|
|
161
180
|
const checkpointConstants = CheckpointConstantData.from({
|
|
@@ -188,7 +207,9 @@ export class EpochProvingJob implements Traceable {
|
|
|
188
207
|
previousHeader,
|
|
189
208
|
);
|
|
190
209
|
|
|
191
|
-
for (
|
|
210
|
+
for (let blockIndex = 0; blockIndex < checkpoint.blocks.length; blockIndex++) {
|
|
211
|
+
const blockTimer = new Timer();
|
|
212
|
+
const block = checkpoint.blocks[blockIndex];
|
|
192
213
|
const globalVariables = block.header.globalVariables;
|
|
193
214
|
const txs = this.getTxs(block);
|
|
194
215
|
|
|
@@ -206,8 +227,12 @@ export class EpochProvingJob implements Traceable {
|
|
|
206
227
|
// Start block proving
|
|
207
228
|
await this.prover.startNewBlock(block.number, globalVariables.timestamp, txs.length);
|
|
208
229
|
|
|
209
|
-
// Process public fns
|
|
210
|
-
|
|
230
|
+
// Process public fns. L1 to L2 messages are only inserted for the first block of a checkpoint,
|
|
231
|
+
// as the fork for subsequent blocks already includes them from the previous block's synced state.
|
|
232
|
+
const db = await this.createFork(
|
|
233
|
+
BlockNumber(block.number - 1),
|
|
234
|
+
blockIndex === 0 ? l1ToL2Messages : undefined,
|
|
235
|
+
);
|
|
211
236
|
const config = PublicSimulatorConfig.from({
|
|
212
237
|
proverId: this.prover.getProverId().toField(),
|
|
213
238
|
skipFeeEnforcement: false,
|
|
@@ -229,8 +254,11 @@ export class EpochProvingJob implements Traceable {
|
|
|
229
254
|
// Mark block as completed to pad it
|
|
230
255
|
const expectedBlockHeader = block.header;
|
|
231
256
|
await this.prover.setBlockCompleted(block.number, expectedBlockHeader);
|
|
257
|
+
this.metrics.recordBlockProcessing(blockTimer.ms());
|
|
232
258
|
}
|
|
259
|
+
this.metrics.recordCheckpointProcessing(checkpointTimer.ms());
|
|
233
260
|
});
|
|
261
|
+
this.metrics.recordAllCheckpointsProcessing(allCheckpointsTimer.ms());
|
|
234
262
|
|
|
235
263
|
const executionTime = timer.ms();
|
|
236
264
|
|
|
@@ -290,22 +318,29 @@ export class EpochProvingJob implements Traceable {
|
|
|
290
318
|
}
|
|
291
319
|
|
|
292
320
|
/**
|
|
293
|
-
* Create a new db fork for tx processing, inserting
|
|
321
|
+
* Create a new db fork for tx processing, optionally inserting L1 to L2 messages.
|
|
322
|
+
* L1 to L2 messages should only be inserted for the first block in a checkpoint,
|
|
323
|
+
* as subsequent blocks' synced state already includes them.
|
|
294
324
|
* 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
325
|
*/
|
|
296
|
-
private async createFork(blockNumber: BlockNumber, l1ToL2Messages: Fr[]) {
|
|
326
|
+
private async createFork(blockNumber: BlockNumber, l1ToL2Messages: Fr[] | undefined) {
|
|
327
|
+
this.log.verbose(`Creating fork at ${blockNumber}`, { blockNumber });
|
|
297
328
|
const db = await this.dbProvider.fork(blockNumber);
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
329
|
+
|
|
330
|
+
if (l1ToL2Messages !== undefined) {
|
|
331
|
+
this.log.verbose(`Inserting ${l1ToL2Messages.length} L1 to L2 messages in fork`, {
|
|
332
|
+
blockNumber,
|
|
333
|
+
l1ToL2Messages: l1ToL2Messages.map(m => m.toString()),
|
|
334
|
+
});
|
|
335
|
+
const l1ToL2MessagesPadded = padArrayEnd<Fr, number>(
|
|
336
|
+
l1ToL2Messages,
|
|
337
|
+
Fr.ZERO,
|
|
338
|
+
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
339
|
+
'Too many L1 to L2 messages',
|
|
340
|
+
);
|
|
341
|
+
await db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, l1ToL2MessagesPadded);
|
|
342
|
+
}
|
|
343
|
+
|
|
309
344
|
return db;
|
|
310
345
|
}
|
|
311
346
|
|
|
@@ -362,11 +397,14 @@ export class EpochProvingJob implements Traceable {
|
|
|
362
397
|
const intervalMs = Math.ceil((await l2BlockSource.getL1Constants()).ethereumSlotDuration / 2) * 1000;
|
|
363
398
|
this.epochCheckPromise = new RunningPromise(
|
|
364
399
|
async () => {
|
|
365
|
-
const
|
|
366
|
-
const blockHashes = await Promise.all(
|
|
400
|
+
const blockHeaders = await l2BlockSource.getCheckpointedBlockHeadersForEpoch(this.epochNumber);
|
|
401
|
+
const blockHashes = await Promise.all(blockHeaders.map(header => header.hash()));
|
|
367
402
|
const thisBlocks = this.checkpoints.flatMap(checkpoint => checkpoint.blocks);
|
|
368
403
|
const thisBlockHashes = await Promise.all(thisBlocks.map(block => block.hash()));
|
|
369
|
-
if (
|
|
404
|
+
if (
|
|
405
|
+
blockHeaders.length !== thisBlocks.length ||
|
|
406
|
+
!blockHashes.every((block, i) => block.equals(thisBlockHashes[i]))
|
|
407
|
+
) {
|
|
370
408
|
this.log.warn('Epoch blocks changed underfoot', {
|
|
371
409
|
uuid: this.uuid,
|
|
372
410
|
epochNumber: this.epochNumber,
|
|
@@ -388,7 +426,7 @@ export class EpochProvingJob implements Traceable {
|
|
|
388
426
|
return [this.data.previousBlockHeader, ...lastBlocks.map(block => block.header).slice(0, -1)];
|
|
389
427
|
}
|
|
390
428
|
|
|
391
|
-
private getTxs(block:
|
|
429
|
+
private getTxs(block: L2Block): Tx[] {
|
|
392
430
|
return block.body.txEffects.map(txEffect => this.txs.get(txEffect.txHash.toString())!);
|
|
393
431
|
}
|
|
394
432
|
|