@aztec/aztec-node 0.0.1-commit.d6f2b3f94 → 0.0.1-commit.dbf9cec
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/aztec-node/config.d.ts +7 -4
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +10 -2
- package/dest/aztec-node/server.d.ts +19 -6
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +229 -78
- package/dest/sentinel/sentinel.d.ts +2 -2
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +53 -27
- package/dest/sentinel/store.d.ts +2 -2
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +11 -7
- package/package.json +27 -25
- package/src/aztec-node/config.ts +24 -8
- package/src/aztec-node/server.ts +295 -95
- package/src/sentinel/sentinel.ts +56 -23
- package/src/sentinel/store.ts +12 -12
package/src/aztec-node/server.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Archiver, createArchiver } from '@aztec/archiver';
|
|
2
2
|
import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
|
|
3
3
|
import { type BlobClientInterface, createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
4
|
+
import { Blob } from '@aztec/blob-lib';
|
|
4
5
|
import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
5
6
|
import { EpochCache, type EpochCacheInterface } from '@aztec/epoch-cache';
|
|
6
7
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
@@ -8,7 +9,7 @@ import { getPublicClient } from '@aztec/ethereum/client';
|
|
|
8
9
|
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
9
10
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
10
11
|
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
11
|
-
import { compactArray, pick } from '@aztec/foundation/collection';
|
|
12
|
+
import { compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
12
13
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
14
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
14
15
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
@@ -16,14 +17,19 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
|
16
17
|
import { count } from '@aztec/foundation/string';
|
|
17
18
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
18
19
|
import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
|
|
19
|
-
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
20
|
+
import { type KeyStore, KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
20
21
|
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
22
|
+
import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
|
|
21
23
|
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
type P2P,
|
|
25
|
+
type P2PClientDeps,
|
|
26
|
+
createP2PClient,
|
|
27
|
+
createTxValidatorForAcceptingTxsOverRPC,
|
|
28
|
+
getDefaultAllowedSetupFunctions,
|
|
29
|
+
} from '@aztec/p2p';
|
|
26
30
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
31
|
+
import { type ProverNode, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
|
|
32
|
+
import { createKeyStoreForProver } from '@aztec/prover-node/config';
|
|
27
33
|
import { GlobalVariableBuilder, SequencerClient, type SequencerPublisher } from '@aztec/sequencer-client';
|
|
28
34
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
29
35
|
import {
|
|
@@ -35,7 +41,14 @@ import {
|
|
|
35
41
|
} from '@aztec/slasher';
|
|
36
42
|
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
37
43
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
38
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
type BlockData,
|
|
46
|
+
BlockHash,
|
|
47
|
+
type BlockParameter,
|
|
48
|
+
type DataInBlock,
|
|
49
|
+
L2Block,
|
|
50
|
+
type L2BlockSource,
|
|
51
|
+
} from '@aztec/stdlib/block';
|
|
39
52
|
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
40
53
|
import type {
|
|
41
54
|
ContractClassPublic,
|
|
@@ -63,9 +76,9 @@ import {
|
|
|
63
76
|
type WorldStateSynchronizer,
|
|
64
77
|
tryStop,
|
|
65
78
|
} from '@aztec/stdlib/interfaces/server';
|
|
66
|
-
import type { LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
79
|
+
import type { DebugLogStore, LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
80
|
+
import { InMemoryDebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
67
81
|
import { InboxLeaf, type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
68
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
69
82
|
import type { Offense, SlashPayloadRound } from '@aztec/stdlib/slashing';
|
|
70
83
|
import type { NullifierLeafPreimage, PublicDataTreeLeaf, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
71
84
|
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
@@ -97,7 +110,6 @@ import {
|
|
|
97
110
|
ValidatorClient,
|
|
98
111
|
createBlockProposalHandler,
|
|
99
112
|
createValidatorClient,
|
|
100
|
-
createValidatorForAcceptingTxs,
|
|
101
113
|
} from '@aztec/validator-client';
|
|
102
114
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
103
115
|
|
|
@@ -129,6 +141,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
129
141
|
protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
|
|
130
142
|
protected readonly worldStateSynchronizer: WorldStateSynchronizer,
|
|
131
143
|
protected readonly sequencer: SequencerClient | undefined,
|
|
144
|
+
protected readonly proverNode: ProverNode | undefined,
|
|
132
145
|
protected readonly slasherClient: SlasherClientInterface | undefined,
|
|
133
146
|
protected readonly validatorsSentinel: Sentinel | undefined,
|
|
134
147
|
protected readonly epochPruneWatcher: EpochPruneWatcher | undefined,
|
|
@@ -141,12 +154,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
141
154
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
142
155
|
private log = createLogger('node'),
|
|
143
156
|
private blobClient?: BlobClientInterface,
|
|
157
|
+
private validatorClient?: ValidatorClient,
|
|
158
|
+
private keyStoreManager?: KeystoreManager,
|
|
159
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
144
160
|
) {
|
|
145
161
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
146
162
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
147
163
|
|
|
148
164
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
149
165
|
this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config.l1Contracts);
|
|
166
|
+
|
|
167
|
+
// A defensive check that protects us against introducing a bug in the complex `createAndSync` function. We must
|
|
168
|
+
// never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
|
|
169
|
+
// memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
|
|
170
|
+
if (debugLogStore.isEnabled && config.realProofs) {
|
|
171
|
+
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
172
|
+
}
|
|
150
173
|
}
|
|
151
174
|
|
|
152
175
|
public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
|
|
@@ -170,11 +193,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
170
193
|
logger?: Logger;
|
|
171
194
|
publisher?: SequencerPublisher;
|
|
172
195
|
dateProvider?: DateProvider;
|
|
173
|
-
p2pClientDeps?: P2PClientDeps
|
|
196
|
+
p2pClientDeps?: P2PClientDeps;
|
|
197
|
+
proverNodeDeps?: Partial<ProverNodeDeps>;
|
|
174
198
|
} = {},
|
|
175
199
|
options: {
|
|
176
200
|
prefilledPublicData?: PublicDataTreeLeaf[];
|
|
177
201
|
dontStartSequencer?: boolean;
|
|
202
|
+
dontStartProverNode?: boolean;
|
|
178
203
|
} = {},
|
|
179
204
|
): Promise<AztecNodeService> {
|
|
180
205
|
const config = { ...inputConfig }; // Copy the config so we dont mutate the input object
|
|
@@ -184,16 +209,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
184
209
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
185
210
|
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
186
211
|
|
|
187
|
-
// Build a key store from file if given or from environment otherwise
|
|
212
|
+
// Build a key store from file if given or from environment otherwise.
|
|
213
|
+
// We keep the raw KeyStore available so we can merge with prover keys if enableProverNode is set.
|
|
188
214
|
let keyStoreManager: KeystoreManager | undefined;
|
|
189
215
|
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
190
216
|
if (keyStoreProvided) {
|
|
191
217
|
const keyStores = loadKeystores(config.keyStoreDirectory!);
|
|
192
218
|
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
193
219
|
} else {
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
220
|
+
const rawKeyStores: KeyStore[] = [];
|
|
221
|
+
const validatorKeyStore = createKeyStoreForValidator(config);
|
|
222
|
+
if (validatorKeyStore) {
|
|
223
|
+
rawKeyStores.push(validatorKeyStore);
|
|
224
|
+
}
|
|
225
|
+
if (config.enableProverNode) {
|
|
226
|
+
const proverKeyStore = createKeyStoreForProver(config);
|
|
227
|
+
if (proverKeyStore) {
|
|
228
|
+
rawKeyStores.push(proverKeyStore);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (rawKeyStores.length > 0) {
|
|
232
|
+
keyStoreManager = new KeystoreManager(
|
|
233
|
+
rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores),
|
|
234
|
+
);
|
|
197
235
|
}
|
|
198
236
|
}
|
|
199
237
|
|
|
@@ -204,10 +242,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
204
242
|
if (keyStoreManager === undefined) {
|
|
205
243
|
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
206
244
|
}
|
|
207
|
-
if (!keyStoreProvided) {
|
|
208
|
-
log.warn(
|
|
209
|
-
'KEY STORE CREATED FROM ENVIRONMENT, IT IS RECOMMENDED TO USE A FILE-BASED KEY STORE IN PRODUCTION ENVIRONMENTS',
|
|
210
|
-
);
|
|
245
|
+
if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
|
|
246
|
+
log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
|
|
211
247
|
}
|
|
212
248
|
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
213
249
|
}
|
|
@@ -249,7 +285,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
249
285
|
);
|
|
250
286
|
}
|
|
251
287
|
|
|
252
|
-
const blobClient = await createBlobClientWithFileStores(config,
|
|
288
|
+
const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
|
|
253
289
|
|
|
254
290
|
// attempt snapshot sync if possible
|
|
255
291
|
await trySnapshotSync(config, log);
|
|
@@ -273,14 +309,28 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
273
309
|
config.realProofs || config.debugForceTxProofVerification
|
|
274
310
|
? await BBCircuitVerifier.new(config)
|
|
275
311
|
: new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
312
|
+
|
|
313
|
+
let debugLogStore: DebugLogStore;
|
|
276
314
|
if (!config.realProofs) {
|
|
277
315
|
log.warn(`Aztec node is accepting fake proofs`);
|
|
316
|
+
|
|
317
|
+
debugLogStore = new InMemoryDebugLogStore();
|
|
318
|
+
log.info(
|
|
319
|
+
'Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served',
|
|
320
|
+
);
|
|
321
|
+
} else {
|
|
322
|
+
debugLogStore = new NullDebugLogStore();
|
|
278
323
|
}
|
|
324
|
+
|
|
279
325
|
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
280
326
|
|
|
327
|
+
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
328
|
+
if (proverOnly) {
|
|
329
|
+
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
330
|
+
}
|
|
331
|
+
|
|
281
332
|
// create the tx pool and the p2p client, which will need the l2 block source
|
|
282
333
|
const p2pClient = await createP2PClient(
|
|
283
|
-
P2PClientType.Full,
|
|
284
334
|
config,
|
|
285
335
|
archiver,
|
|
286
336
|
proofVerifier,
|
|
@@ -295,7 +345,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
295
345
|
// We should really not be modifying the config object
|
|
296
346
|
config.txPublicSetupAllowList = config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions());
|
|
297
347
|
|
|
298
|
-
//
|
|
348
|
+
// We'll accumulate sentinel watchers here
|
|
349
|
+
const watchers: Watcher[] = [];
|
|
350
|
+
|
|
351
|
+
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation
|
|
299
352
|
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder(
|
|
300
353
|
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
|
|
301
354
|
worldStateSynchronizer,
|
|
@@ -304,47 +357,48 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
304
357
|
telemetry,
|
|
305
358
|
);
|
|
306
359
|
|
|
307
|
-
|
|
308
|
-
const watchers: Watcher[] = [];
|
|
309
|
-
|
|
310
|
-
// Create validator client if required
|
|
311
|
-
const validatorClient = await createValidatorClient(config, {
|
|
312
|
-
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
313
|
-
worldState: worldStateSynchronizer,
|
|
314
|
-
p2pClient,
|
|
315
|
-
telemetry,
|
|
316
|
-
dateProvider,
|
|
317
|
-
epochCache,
|
|
318
|
-
blockSource: archiver,
|
|
319
|
-
l1ToL2MessageSource: archiver,
|
|
320
|
-
keyStoreManager,
|
|
321
|
-
blobClient,
|
|
322
|
-
});
|
|
360
|
+
let validatorClient: ValidatorClient | undefined;
|
|
323
361
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
if (validatorClient) {
|
|
328
|
-
watchers.push(validatorClient);
|
|
329
|
-
if (!options.dontStartSequencer) {
|
|
330
|
-
await validatorClient.registerHandlers();
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// If there's no validator client but alwaysReexecuteBlockProposals is enabled,
|
|
335
|
-
// create a BlockProposalHandler to reexecute block proposals for monitoring
|
|
336
|
-
if (!validatorClient && config.alwaysReexecuteBlockProposals) {
|
|
337
|
-
log.info('Setting up block proposal reexecution for monitoring');
|
|
338
|
-
createBlockProposalHandler(config, {
|
|
362
|
+
if (!proverOnly) {
|
|
363
|
+
// Create validator client if required
|
|
364
|
+
validatorClient = await createValidatorClient(config, {
|
|
339
365
|
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
340
366
|
worldState: worldStateSynchronizer,
|
|
367
|
+
p2pClient,
|
|
368
|
+
telemetry,
|
|
369
|
+
dateProvider,
|
|
341
370
|
epochCache,
|
|
342
371
|
blockSource: archiver,
|
|
343
372
|
l1ToL2MessageSource: archiver,
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
373
|
+
keyStoreManager,
|
|
374
|
+
blobClient,
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
378
|
+
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
379
|
+
// like attestations or auths will fail.
|
|
380
|
+
if (validatorClient) {
|
|
381
|
+
watchers.push(validatorClient);
|
|
382
|
+
if (!options.dontStartSequencer) {
|
|
383
|
+
await validatorClient.registerHandlers();
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// If there's no validator client but alwaysReexecuteBlockProposals is enabled,
|
|
388
|
+
// create a BlockProposalHandler to reexecute block proposals for monitoring
|
|
389
|
+
if (!validatorClient && config.alwaysReexecuteBlockProposals) {
|
|
390
|
+
log.info('Setting up block proposal reexecution for monitoring');
|
|
391
|
+
createBlockProposalHandler(config, {
|
|
392
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
393
|
+
worldState: worldStateSynchronizer,
|
|
394
|
+
epochCache,
|
|
395
|
+
blockSource: archiver,
|
|
396
|
+
l1ToL2MessageSource: archiver,
|
|
397
|
+
p2pClient,
|
|
398
|
+
dateProvider,
|
|
399
|
+
telemetry,
|
|
400
|
+
}).registerForReexecution(p2pClient);
|
|
401
|
+
}
|
|
348
402
|
}
|
|
349
403
|
|
|
350
404
|
// Start world state and wait for it to sync to the archiver.
|
|
@@ -353,29 +407,33 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
353
407
|
// Start p2p. Note that it depends on world state to be running.
|
|
354
408
|
await p2pClient.start();
|
|
355
409
|
|
|
356
|
-
|
|
357
|
-
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
358
|
-
watchers.push(validatorsSentinel);
|
|
359
|
-
}
|
|
360
|
-
|
|
410
|
+
let validatorsSentinel: Awaited<ReturnType<typeof createSentinel>> | undefined;
|
|
361
411
|
let epochPruneWatcher: EpochPruneWatcher | undefined;
|
|
362
|
-
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
363
|
-
epochPruneWatcher = new EpochPruneWatcher(
|
|
364
|
-
archiver,
|
|
365
|
-
archiver,
|
|
366
|
-
epochCache,
|
|
367
|
-
p2pClient.getTxProvider(),
|
|
368
|
-
validatorCheckpointsBuilder,
|
|
369
|
-
config,
|
|
370
|
-
);
|
|
371
|
-
watchers.push(epochPruneWatcher);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
375
412
|
let attestationsBlockWatcher: AttestationsBlockWatcher | undefined;
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
413
|
+
|
|
414
|
+
if (!proverOnly) {
|
|
415
|
+
validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
416
|
+
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
417
|
+
watchers.push(validatorsSentinel);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
421
|
+
epochPruneWatcher = new EpochPruneWatcher(
|
|
422
|
+
archiver,
|
|
423
|
+
archiver,
|
|
424
|
+
epochCache,
|
|
425
|
+
p2pClient.getTxProvider(),
|
|
426
|
+
validatorCheckpointsBuilder,
|
|
427
|
+
config,
|
|
428
|
+
);
|
|
429
|
+
watchers.push(epochPruneWatcher);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
433
|
+
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
434
|
+
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
435
|
+
watchers.push(attestationsBlockWatcher);
|
|
436
|
+
}
|
|
379
437
|
}
|
|
380
438
|
|
|
381
439
|
// Start p2p-related services once the archiver has completed sync
|
|
@@ -412,19 +470,19 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
412
470
|
);
|
|
413
471
|
await slasherClient.start();
|
|
414
472
|
|
|
415
|
-
const l1TxUtils = config.
|
|
416
|
-
? await
|
|
473
|
+
const l1TxUtils = config.sequencerPublisherForwarderAddress
|
|
474
|
+
? await createForwarderL1TxUtilsFromSigners(
|
|
417
475
|
publicClient,
|
|
418
476
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
419
|
-
config.
|
|
477
|
+
config.sequencerPublisherForwarderAddress,
|
|
420
478
|
{ ...config, scope: 'sequencer' },
|
|
421
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
479
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
422
480
|
)
|
|
423
|
-
: await
|
|
481
|
+
: await createL1TxUtilsFromSigners(
|
|
424
482
|
publicClient,
|
|
425
483
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
426
484
|
{ ...config, scope: 'sequencer' },
|
|
427
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
485
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
428
486
|
);
|
|
429
487
|
|
|
430
488
|
// Create and start the sequencer client
|
|
@@ -434,6 +492,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
434
492
|
archiver,
|
|
435
493
|
dateProvider,
|
|
436
494
|
telemetry,
|
|
495
|
+
debugLogStore,
|
|
437
496
|
);
|
|
438
497
|
|
|
439
498
|
sequencer = await SequencerClient.new(config, {
|
|
@@ -461,6 +520,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
461
520
|
log.warn(`Sequencer created but not started`);
|
|
462
521
|
}
|
|
463
522
|
|
|
523
|
+
// Create prover node subsystem if enabled
|
|
524
|
+
let proverNode: ProverNode | undefined;
|
|
525
|
+
if (config.enableProverNode) {
|
|
526
|
+
proverNode = await createProverNode(config, {
|
|
527
|
+
...deps.proverNodeDeps,
|
|
528
|
+
telemetry,
|
|
529
|
+
dateProvider,
|
|
530
|
+
archiver,
|
|
531
|
+
worldStateSynchronizer,
|
|
532
|
+
p2pClient,
|
|
533
|
+
epochCache,
|
|
534
|
+
blobClient,
|
|
535
|
+
keyStoreManager,
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
if (!options.dontStartProverNode) {
|
|
539
|
+
await proverNode.start();
|
|
540
|
+
log.info(`Prover node subsystem started`);
|
|
541
|
+
} else {
|
|
542
|
+
log.info(`Prover node subsystem created but not started`);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
464
546
|
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
465
547
|
...config,
|
|
466
548
|
rollupVersion: BigInt(config.rollupVersion),
|
|
@@ -468,7 +550,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
468
550
|
slotDuration: Number(slotDuration),
|
|
469
551
|
});
|
|
470
552
|
|
|
471
|
-
|
|
553
|
+
const node = new AztecNodeService(
|
|
472
554
|
config,
|
|
473
555
|
p2pClient,
|
|
474
556
|
archiver,
|
|
@@ -477,6 +559,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
477
559
|
archiver,
|
|
478
560
|
worldStateSynchronizer,
|
|
479
561
|
sequencer,
|
|
562
|
+
proverNode,
|
|
480
563
|
slasherClient,
|
|
481
564
|
validatorsSentinel,
|
|
482
565
|
epochPruneWatcher,
|
|
@@ -489,7 +572,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
489
572
|
telemetry,
|
|
490
573
|
log,
|
|
491
574
|
blobClient,
|
|
575
|
+
validatorClient,
|
|
576
|
+
keyStoreManager,
|
|
577
|
+
debugLogStore,
|
|
492
578
|
);
|
|
579
|
+
|
|
580
|
+
return node;
|
|
493
581
|
}
|
|
494
582
|
|
|
495
583
|
/**
|
|
@@ -500,6 +588,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
500
588
|
return this.sequencer;
|
|
501
589
|
}
|
|
502
590
|
|
|
591
|
+
/** Returns the prover node subsystem, if enabled. */
|
|
592
|
+
public getProverNode(): ProverNode | undefined {
|
|
593
|
+
return this.proverNode;
|
|
594
|
+
}
|
|
595
|
+
|
|
503
596
|
public getBlockSource(): L2BlockSource {
|
|
504
597
|
return this.blockSource;
|
|
505
598
|
}
|
|
@@ -553,6 +646,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
553
646
|
enr,
|
|
554
647
|
l1ContractAddresses: contractAddresses,
|
|
555
648
|
protocolContractAddresses: protocolContractAddresses,
|
|
649
|
+
realProofs: !!this.config.realProofs,
|
|
556
650
|
};
|
|
557
651
|
|
|
558
652
|
return nodeInfo;
|
|
@@ -761,8 +855,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
761
855
|
}
|
|
762
856
|
|
|
763
857
|
await this.p2pClient!.sendTx(tx);
|
|
764
|
-
|
|
765
|
-
this.
|
|
858
|
+
const duration = timer.ms();
|
|
859
|
+
this.metrics.receivedTx(duration, true);
|
|
860
|
+
this.log.info(`Received tx ${txHash} in ${duration}ms`, { txHash });
|
|
766
861
|
}
|
|
767
862
|
|
|
768
863
|
public async getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
@@ -774,18 +869,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
774
869
|
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
775
870
|
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
776
871
|
|
|
872
|
+
let receipt: TxReceipt;
|
|
777
873
|
if (settledTxReceipt) {
|
|
778
|
-
|
|
779
|
-
return settledTxReceipt;
|
|
874
|
+
receipt = settledTxReceipt;
|
|
780
875
|
} else if (isKnownToPool) {
|
|
781
876
|
// If the tx is in the pool but not in the archiver, it's pending.
|
|
782
877
|
// This handles race conditions between archiver and p2p, where the archiver
|
|
783
878
|
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
784
|
-
|
|
879
|
+
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
785
880
|
} else {
|
|
786
881
|
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
787
|
-
|
|
882
|
+
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
788
883
|
}
|
|
884
|
+
|
|
885
|
+
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
886
|
+
|
|
887
|
+
return receipt;
|
|
789
888
|
}
|
|
790
889
|
|
|
791
890
|
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
@@ -802,6 +901,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
802
901
|
await tryStop(this.slasherClient);
|
|
803
902
|
await tryStop(this.proofVerifier);
|
|
804
903
|
await tryStop(this.sequencer);
|
|
904
|
+
await tryStop(this.proverNode);
|
|
805
905
|
await tryStop(this.p2pClient);
|
|
806
906
|
await tryStop(this.worldStateSynchronizer);
|
|
807
907
|
await tryStop(this.blockSource);
|
|
@@ -1105,6 +1205,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1105
1205
|
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
1106
1206
|
}
|
|
1107
1207
|
|
|
1208
|
+
public getBlockData(number: BlockNumber): Promise<BlockData | undefined> {
|
|
1209
|
+
return this.blockSource.getBlockData(number);
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
public getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
|
|
1213
|
+
return this.blockSource.getBlockDataByArchive(archive);
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1108
1216
|
/**
|
|
1109
1217
|
* Simulates the public part of a transaction with the current state.
|
|
1110
1218
|
* @param tx - The transaction to simulate.
|
|
@@ -1128,7 +1236,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1128
1236
|
}
|
|
1129
1237
|
|
|
1130
1238
|
const txHash = tx.getTxHash();
|
|
1131
|
-
const
|
|
1239
|
+
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1240
|
+
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
1132
1241
|
|
|
1133
1242
|
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1134
1243
|
const coinbase = EthAddress.ZERO;
|
|
@@ -1152,6 +1261,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1152
1261
|
blockNumber,
|
|
1153
1262
|
});
|
|
1154
1263
|
|
|
1264
|
+
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1265
|
+
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1155
1266
|
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1156
1267
|
try {
|
|
1157
1268
|
const config = PublicSimulatorConfig.from({
|
|
@@ -1167,7 +1278,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1167
1278
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1168
1279
|
|
|
1169
1280
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1170
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([tx]);
|
|
1281
|
+
const [processedTxs, failedTxs, _usedTxs, returns, _blobFields, debugLogs] = await processor.process([tx]);
|
|
1171
1282
|
// REFACTOR: Consider returning the error rather than throwing
|
|
1172
1283
|
if (failedTxs.length) {
|
|
1173
1284
|
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
|
|
@@ -1181,6 +1292,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1181
1292
|
processedTx.txEffect,
|
|
1182
1293
|
returns,
|
|
1183
1294
|
processedTx.gasUsed,
|
|
1295
|
+
debugLogs,
|
|
1184
1296
|
);
|
|
1185
1297
|
} finally {
|
|
1186
1298
|
await merkleTreeFork.close();
|
|
@@ -1194,10 +1306,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1194
1306
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1195
1307
|
const verifier = isSimulation ? undefined : this.proofVerifier;
|
|
1196
1308
|
|
|
1197
|
-
// We accept transactions if they are not expired by the next slot (checked based on the
|
|
1309
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1198
1310
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1199
1311
|
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
1200
|
-
const validator =
|
|
1312
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(
|
|
1201
1313
|
db,
|
|
1202
1314
|
this.contractDataSource,
|
|
1203
1315
|
verifier,
|
|
@@ -1376,6 +1488,94 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1376
1488
|
}
|
|
1377
1489
|
}
|
|
1378
1490
|
|
|
1491
|
+
public async reloadKeystore(): Promise<void> {
|
|
1492
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
1493
|
+
throw new BadRequestError(
|
|
1494
|
+
'Cannot reload keystore: node is not using a file-based keystore. ' +
|
|
1495
|
+
'Set KEY_STORE_DIRECTORY to use file-based keystores.',
|
|
1496
|
+
);
|
|
1497
|
+
}
|
|
1498
|
+
if (!this.validatorClient) {
|
|
1499
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
this.log.info('Reloading keystore from disk');
|
|
1503
|
+
|
|
1504
|
+
// Re-read and validate keystore files
|
|
1505
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1506
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1507
|
+
await newManager.validateSigners();
|
|
1508
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1509
|
+
|
|
1510
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1511
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1512
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1513
|
+
// would silently fail on every proposer slot.
|
|
1514
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1515
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1516
|
+
const availablePublishers = new Set(
|
|
1517
|
+
oldAdapter
|
|
1518
|
+
.getAttesterAddresses()
|
|
1519
|
+
.flatMap(a => oldAdapter.getPublisherAddresses(a).map(p => p.toString().toLowerCase())),
|
|
1520
|
+
);
|
|
1521
|
+
|
|
1522
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1523
|
+
for (const attester of newAdapter.getAttesterAddresses()) {
|
|
1524
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1525
|
+
if (pubs.length > 0 && !pubs.some(p => availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1526
|
+
throw new BadRequestError(
|
|
1527
|
+
`Cannot reload keystore: validator ${attester} has publisher keys ` +
|
|
1528
|
+
`[${pubs.map(p => p.toString()).join(', ')}] but none match the L1 signers initialized at startup ` +
|
|
1529
|
+
`[${[...availablePublishers].join(', ')}]. Publishers cannot be hot-reloaded — ` +
|
|
1530
|
+
`use an existing publisher key or restart the node.`,
|
|
1531
|
+
);
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
// Build adapters for old and new keystores to compute diff
|
|
1537
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1538
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1539
|
+
const oldAddresses = this.keyStoreManager
|
|
1540
|
+
? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses()
|
|
1541
|
+
: [];
|
|
1542
|
+
|
|
1543
|
+
const oldSet = new Set(oldAddresses.map(a => a.toString()));
|
|
1544
|
+
const newSet = new Set(newAddresses.map(a => a.toString()));
|
|
1545
|
+
const added = newAddresses.filter(a => !oldSet.has(a.toString()));
|
|
1546
|
+
const removed = oldAddresses.filter(a => !newSet.has(a.toString()));
|
|
1547
|
+
|
|
1548
|
+
if (added.length > 0) {
|
|
1549
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map(a => a.toString()).join(', ')}`);
|
|
1550
|
+
}
|
|
1551
|
+
if (removed.length > 0) {
|
|
1552
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map(a => a.toString()).join(', ')}`);
|
|
1553
|
+
}
|
|
1554
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1555
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1559
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1560
|
+
|
|
1561
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1562
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1563
|
+
if (this.sequencer) {
|
|
1564
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1568
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1569
|
+
const slashValidatorsNever = unique(
|
|
1570
|
+
[...(this.config.slashValidatorsNever ?? []), ...newAddresses].map(a => a.toString()),
|
|
1571
|
+
).map(EthAddress.fromString);
|
|
1572
|
+
this.slasherClient.updateConfig({ slashValidatorsNever });
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
this.keyStoreManager = newManager;
|
|
1576
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1379
1579
|
#getInitialHeaderHash(): Promise<BlockHash> {
|
|
1380
1580
|
if (!this.initialHeaderHashPromise) {
|
|
1381
1581
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|