@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
|
@@ -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',
|
|
@@ -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,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 { 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
|
+
AztecNode,
|
|
23
|
+
ITxProvider,
|
|
24
|
+
ProverConfig,
|
|
25
|
+
ProvingJobBroker,
|
|
26
|
+
Service,
|
|
27
|
+
WorldStateSynchronizer,
|
|
28
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
23
29
|
import { L1Metrics, type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
24
|
-
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
25
30
|
|
|
26
31
|
import { createPublicClient, fallback, http } from 'viem';
|
|
27
32
|
|
|
28
|
-
import
|
|
33
|
+
import type { SpecificProverNodeConfig } from './config.js';
|
|
29
34
|
import { EpochMonitor } from './monitors/epoch-monitor.js';
|
|
30
35
|
import { ProverNode } from './prover-node.js';
|
|
31
36
|
import { ProverPublisherFactory } from './prover-publisher-factory.js';
|
|
@@ -34,55 +39,42 @@ export type ProverNodeDeps = {
|
|
|
34
39
|
telemetry?: TelemetryClient;
|
|
35
40
|
log?: Logger;
|
|
36
41
|
aztecNodeTxProvider?: Pick<AztecNode, 'getTxsByHash'>;
|
|
37
|
-
archiver
|
|
42
|
+
archiver: Archiver;
|
|
38
43
|
publisherFactory?: ProverPublisherFactory;
|
|
39
|
-
blobClient?: BlobClientInterface;
|
|
40
44
|
broker?: ProvingJobBroker;
|
|
41
45
|
l1TxUtils?: L1TxUtils;
|
|
42
46
|
dateProvider?: DateProvider;
|
|
47
|
+
worldStateSynchronizer: WorldStateSynchronizer;
|
|
48
|
+
p2pClient: { getTxProvider(): ITxProvider } & Partial<Service>;
|
|
49
|
+
epochCache: EpochCacheInterface;
|
|
50
|
+
blobClient: BlobClientInterface;
|
|
51
|
+
keyStoreManager?: KeystoreManager;
|
|
43
52
|
};
|
|
44
53
|
|
|
45
|
-
/** Creates a new prover node given a config
|
|
54
|
+
/** Creates a new prover node subsystem given a config and dependencies */
|
|
46
55
|
export async function createProverNode(
|
|
47
|
-
userConfig:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
userConfig: SpecificProverNodeConfig &
|
|
57
|
+
ProverConfig &
|
|
58
|
+
ProverClientUserConfig &
|
|
59
|
+
ProverPublisherConfig &
|
|
60
|
+
ProverTxSenderConfig,
|
|
61
|
+
deps: ProverNodeDeps,
|
|
52
62
|
) {
|
|
53
63
|
const config = { ...userConfig };
|
|
54
64
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
55
65
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
56
|
-
const
|
|
57
|
-
deps.blobClient ?? createBlobClient(config, { logger: createLogger('prover-node:blob-client: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
|
-
}
|
|
66
|
+
const log = deps.log ?? createLogger('prover');
|
|
72
67
|
|
|
73
|
-
|
|
68
|
+
const { p2pClient, archiver, keyStoreManager, worldStateSynchronizer } = deps;
|
|
74
69
|
|
|
75
70
|
// Extract the prover signers from the key store and verify that we have one.
|
|
71
|
+
await keyStoreManager?.validateSigners();
|
|
76
72
|
const proverSigners = keyStoreManager?.createProverSigners();
|
|
77
73
|
|
|
78
74
|
if (proverSigners === undefined) {
|
|
79
75
|
throw new Error('Failed to create prover key store configuration');
|
|
80
76
|
} else if (proverSigners.signers.length === 0) {
|
|
81
77
|
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
78
|
}
|
|
87
79
|
|
|
88
80
|
log.info(`Creating prover with publishers ${proverSigners.signers.map(signer => signer.address.toString()).join()}`);
|
|
@@ -94,28 +86,7 @@ export async function createProverNode(
|
|
|
94
86
|
const proverId = proverSigners.id ?? proverIdInUserConfig ?? proverSigners.signers[0].address;
|
|
95
87
|
|
|
96
88
|
// 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, { blobClient, 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();
|
|
89
|
+
const proverClientConfig: ProverClientConfig = { ...config, proverId };
|
|
119
90
|
|
|
120
91
|
const broker = deps.broker ?? (await createAndStartProvingBroker(config, telemetry));
|
|
121
92
|
|
|
@@ -134,46 +105,31 @@ export async function createProverNode(
|
|
|
134
105
|
|
|
135
106
|
const l1TxUtils = deps.l1TxUtils
|
|
136
107
|
? [deps.l1TxUtils]
|
|
137
|
-
:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
108
|
+
: config.proverPublisherForwarderAddress
|
|
109
|
+
? await createForwarderL1TxUtilsFromSigners(
|
|
110
|
+
publicClient,
|
|
111
|
+
proverSigners.signers,
|
|
112
|
+
config.proverPublisherForwarderAddress,
|
|
113
|
+
{ ...config, scope: 'prover' },
|
|
114
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
115
|
+
)
|
|
116
|
+
: await createL1TxUtilsFromSigners(
|
|
117
|
+
publicClient,
|
|
118
|
+
proverSigners.signers,
|
|
119
|
+
{ ...config, scope: 'prover' },
|
|
120
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
121
|
+
);
|
|
143
122
|
|
|
144
123
|
const publisherFactory =
|
|
145
124
|
deps.publisherFactory ??
|
|
146
125
|
new ProverPublisherFactory(config, {
|
|
147
126
|
rollupContract,
|
|
148
|
-
publisherManager: new PublisherManager(l1TxUtils, config),
|
|
127
|
+
publisherManager: new PublisherManager(l1TxUtils, getPublisherConfigFromProverConfig(config), log.getBindings()),
|
|
149
128
|
telemetry,
|
|
150
129
|
});
|
|
151
130
|
|
|
152
|
-
|
|
153
|
-
|
|
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();
|
|
131
|
+
// TODO(#20393): Check that the tx collection node sources are properly injected
|
|
132
|
+
// See aztecNodeTxProvider
|
|
177
133
|
|
|
178
134
|
const proverNodeConfig = {
|
|
179
135
|
...pick(
|
|
@@ -205,6 +161,9 @@ export async function createProverNode(
|
|
|
205
161
|
l1TxUtils.map(utils => utils.getSenderAddress()),
|
|
206
162
|
);
|
|
207
163
|
|
|
164
|
+
// Extract the shared delayer from the first L1TxUtils instance (all instances share the same delayer)
|
|
165
|
+
const delayer = l1TxUtils[0]?.delayer;
|
|
166
|
+
|
|
208
167
|
return new ProverNode(
|
|
209
168
|
prover,
|
|
210
169
|
publisherFactory,
|
|
@@ -218,5 +177,7 @@ export async function createProverNode(
|
|
|
218
177
|
l1Metrics,
|
|
219
178
|
proverNodeConfig,
|
|
220
179
|
telemetry,
|
|
180
|
+
delayer,
|
|
181
|
+
dateProvider,
|
|
221
182
|
);
|
|
222
183
|
}
|
package/src/index.ts
CHANGED
|
@@ -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';
|
|
@@ -11,7 +11,7 @@ import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
|
11
11
|
import { buildFinalBlobChallenges } from '@aztec/prover-client/helpers';
|
|
12
12
|
import type { PublicProcessor, PublicProcessorFactory } from '@aztec/simulator/server';
|
|
13
13
|
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
14
|
-
import type {
|
|
14
|
+
import type { L2Block, L2BlockSource } from '@aztec/stdlib/block';
|
|
15
15
|
import type { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
16
16
|
import {
|
|
17
17
|
type EpochProver,
|
|
@@ -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
|
|
|
@@ -362,11 +381,14 @@ export class EpochProvingJob implements Traceable {
|
|
|
362
381
|
const intervalMs = Math.ceil((await l2BlockSource.getL1Constants()).ethereumSlotDuration / 2) * 1000;
|
|
363
382
|
this.epochCheckPromise = new RunningPromise(
|
|
364
383
|
async () => {
|
|
365
|
-
const
|
|
366
|
-
const blockHashes = await Promise.all(
|
|
384
|
+
const blockHeaders = await l2BlockSource.getCheckpointedBlockHeadersForEpoch(this.epochNumber);
|
|
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
|
-
if (
|
|
388
|
+
if (
|
|
389
|
+
blockHeaders.length !== thisBlocks.length ||
|
|
390
|
+
!blockHashes.every((block, i) => block.equals(thisBlockHashes[i]))
|
|
391
|
+
) {
|
|
370
392
|
this.log.warn('Epoch blocks changed underfoot', {
|
|
371
393
|
uuid: this.uuid,
|
|
372
394
|
epochNumber: this.epochNumber,
|
|
@@ -388,7 +410,7 @@ export class EpochProvingJob implements Traceable {
|
|
|
388
410
|
return [this.data.previousBlockHeader, ...lastBlocks.map(block => block.header).slice(0, -1)];
|
|
389
411
|
}
|
|
390
412
|
|
|
391
|
-
private getTxs(block:
|
|
413
|
+
private getTxs(block: L2Block): Tx[] {
|
|
392
414
|
return block.body.txEffects.map(txEffect => this.txs.get(txEffect.txHash.toString())!);
|
|
393
415
|
}
|
|
394
416
|
|
package/src/metrics.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
type TelemetryClient,
|
|
14
14
|
type Tracer,
|
|
15
15
|
type UpDownCounter,
|
|
16
|
-
|
|
16
|
+
createUpDownCounterWithDefault,
|
|
17
17
|
} from '@aztec/telemetry-client';
|
|
18
18
|
|
|
19
19
|
import { formatEther, formatUnits } from 'viem';
|
|
@@ -30,28 +30,11 @@ export class ProverNodeJobMetrics {
|
|
|
30
30
|
public readonly tracer: Tracer,
|
|
31
31
|
private logger = createLogger('prover-node:publisher:metrics'),
|
|
32
32
|
) {
|
|
33
|
-
this.proverEpochExecutionDuration = this.meter.createHistogram(Metrics.PROVER_NODE_EXECUTION_DURATION
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.provingJobDuration = this.meter.createHistogram(Metrics.PROVER_NODE_JOB_DURATION, {
|
|
39
|
-
description: 'Duration of proving job',
|
|
40
|
-
unit: 's',
|
|
41
|
-
valueType: ValueType.DOUBLE,
|
|
42
|
-
});
|
|
43
|
-
this.provingJobCheckpoints = this.meter.createGauge(Metrics.PROVER_NODE_JOB_CHECKPOINTS, {
|
|
44
|
-
description: 'Number of checkpoints in a proven epoch',
|
|
45
|
-
valueType: ValueType.INT,
|
|
46
|
-
});
|
|
47
|
-
this.provingJobBlocks = this.meter.createGauge(Metrics.PROVER_NODE_JOB_BLOCKS, {
|
|
48
|
-
description: 'Number of blocks in a proven epoch',
|
|
49
|
-
valueType: ValueType.INT,
|
|
50
|
-
});
|
|
51
|
-
this.provingJobTransactions = this.meter.createGauge(Metrics.PROVER_NODE_JOB_TRANSACTIONS, {
|
|
52
|
-
description: 'Number of transactions in a proven epoch',
|
|
53
|
-
valueType: ValueType.INT,
|
|
54
|
-
});
|
|
33
|
+
this.proverEpochExecutionDuration = this.meter.createHistogram(Metrics.PROVER_NODE_EXECUTION_DURATION);
|
|
34
|
+
this.provingJobDuration = this.meter.createHistogram(Metrics.PROVER_NODE_JOB_DURATION);
|
|
35
|
+
this.provingJobCheckpoints = this.meter.createGauge(Metrics.PROVER_NODE_JOB_CHECKPOINTS);
|
|
36
|
+
this.provingJobBlocks = this.meter.createGauge(Metrics.PROVER_NODE_JOB_BLOCKS);
|
|
37
|
+
this.provingJobTransactions = this.meter.createGauge(Metrics.PROVER_NODE_JOB_TRANSACTIONS);
|
|
55
38
|
}
|
|
56
39
|
|
|
57
40
|
public recordProvingJob(
|
|
@@ -81,15 +64,9 @@ export class ProverNodeRewardsMetrics {
|
|
|
81
64
|
private rollup: RollupContract,
|
|
82
65
|
private logger = createLogger('prover-node:publisher:metrics'),
|
|
83
66
|
) {
|
|
84
|
-
this.rewards = this.meter.createObservableGauge(Metrics.PROVER_NODE_REWARDS_PER_EPOCH
|
|
85
|
-
valueType: ValueType.DOUBLE,
|
|
86
|
-
description: 'The rewards earned',
|
|
87
|
-
});
|
|
67
|
+
this.rewards = this.meter.createObservableGauge(Metrics.PROVER_NODE_REWARDS_PER_EPOCH);
|
|
88
68
|
|
|
89
|
-
this.accumulatedRewards = this.meter
|
|
90
|
-
valueType: ValueType.DOUBLE,
|
|
91
|
-
description: 'The rewards earned (total)',
|
|
92
|
-
});
|
|
69
|
+
this.accumulatedRewards = createUpDownCounterWithDefault(this.meter, Metrics.PROVER_NODE_REWARDS_TOTAL);
|
|
93
70
|
}
|
|
94
71
|
|
|
95
72
|
public async start() {
|
|
@@ -150,68 +127,28 @@ export class ProverNodePublisherMetrics {
|
|
|
150
127
|
) {
|
|
151
128
|
this.meter = client.getMeter(name);
|
|
152
129
|
|
|
153
|
-
this.gasPrice = this.meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE
|
|
154
|
-
description: 'The gas price used for transactions',
|
|
155
|
-
unit: 'gwei',
|
|
156
|
-
valueType: ValueType.DOUBLE,
|
|
157
|
-
});
|
|
130
|
+
this.gasPrice = this.meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE);
|
|
158
131
|
|
|
159
|
-
this.txCount = this.meter
|
|
160
|
-
|
|
132
|
+
this.txCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_PUBLISHER_TX_COUNT, {
|
|
133
|
+
[Attributes.L1_TX_TYPE]: ['submitProof'],
|
|
134
|
+
[Attributes.OK]: [true, false],
|
|
161
135
|
});
|
|
162
136
|
|
|
163
|
-
this.txDuration = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION
|
|
164
|
-
description: 'The duration of transaction processing',
|
|
165
|
-
unit: 'ms',
|
|
166
|
-
valueType: ValueType.INT,
|
|
167
|
-
});
|
|
137
|
+
this.txDuration = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION);
|
|
168
138
|
|
|
169
|
-
this.txGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS
|
|
170
|
-
description: 'The gas consumed by transactions',
|
|
171
|
-
unit: 'gas',
|
|
172
|
-
valueType: ValueType.INT,
|
|
173
|
-
});
|
|
139
|
+
this.txGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS);
|
|
174
140
|
|
|
175
|
-
this.txCalldataSize = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE
|
|
176
|
-
description: 'The size of the calldata in transactions',
|
|
177
|
-
unit: 'By',
|
|
178
|
-
valueType: ValueType.INT,
|
|
179
|
-
});
|
|
141
|
+
this.txCalldataSize = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE);
|
|
180
142
|
|
|
181
|
-
this.txCalldataGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS
|
|
182
|
-
description: 'The gas consumed by the calldata in transactions',
|
|
183
|
-
unit: 'gas',
|
|
184
|
-
valueType: ValueType.INT,
|
|
185
|
-
});
|
|
143
|
+
this.txCalldataGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS);
|
|
186
144
|
|
|
187
|
-
this.txBlobDataGasUsed = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED
|
|
188
|
-
description: 'The amount of blob gas used in transactions',
|
|
189
|
-
unit: 'gas',
|
|
190
|
-
valueType: ValueType.INT,
|
|
191
|
-
});
|
|
145
|
+
this.txBlobDataGasUsed = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED);
|
|
192
146
|
|
|
193
|
-
this.txBlobDataGasCost = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST
|
|
194
|
-
description: 'The gas cost of blobs in transactions',
|
|
195
|
-
unit: 'gwei',
|
|
196
|
-
valueType: ValueType.INT,
|
|
197
|
-
});
|
|
147
|
+
this.txBlobDataGasCost = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST);
|
|
198
148
|
|
|
199
|
-
this.txTotalFee = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE
|
|
200
|
-
description: 'How much L1 tx costs',
|
|
201
|
-
unit: 'gwei',
|
|
202
|
-
valueType: ValueType.DOUBLE,
|
|
203
|
-
advice: {
|
|
204
|
-
explicitBucketBoundaries: [
|
|
205
|
-
0.001, 0.002, 0.004, 0.008, 0.01, 0.02, 0.04, 0.08, 0.1, 0.2, 0.4, 0.8, 1, 1.2, 1.4, 1.8, 2,
|
|
206
|
-
],
|
|
207
|
-
},
|
|
208
|
-
});
|
|
149
|
+
this.txTotalFee = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE);
|
|
209
150
|
|
|
210
|
-
this.senderBalance = this.meter.createGauge(Metrics.L1_PUBLISHER_BALANCE
|
|
211
|
-
unit: 'eth',
|
|
212
|
-
description: 'The balance of the sender address',
|
|
213
|
-
valueType: ValueType.DOUBLE,
|
|
214
|
-
});
|
|
151
|
+
this.senderBalance = this.meter.createGauge(Metrics.L1_PUBLISHER_BALANCE);
|
|
215
152
|
}
|
|
216
153
|
|
|
217
154
|
recordFailedTx() {
|