@aztec/aztec-node 0.0.1-commit.4d79d1f2d → 0.0.1-commit.5358163d3
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 +235 -81
- 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 +298 -99
- 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,
|
|
@@ -292,10 +342,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
292
342
|
deps.p2pClientDeps,
|
|
293
343
|
);
|
|
294
344
|
|
|
295
|
-
// We
|
|
296
|
-
|
|
345
|
+
// We'll accumulate sentinel watchers here
|
|
346
|
+
const watchers: Watcher[] = [];
|
|
297
347
|
|
|
298
|
-
// Create FullNodeCheckpointsBuilder for
|
|
348
|
+
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation
|
|
299
349
|
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder(
|
|
300
350
|
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
|
|
301
351
|
worldStateSynchronizer,
|
|
@@ -304,47 +354,48 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
304
354
|
telemetry,
|
|
305
355
|
);
|
|
306
356
|
|
|
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
|
-
});
|
|
323
|
-
|
|
324
|
-
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
325
|
-
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
326
|
-
// like attestations or auths will fail.
|
|
327
|
-
if (validatorClient) {
|
|
328
|
-
watchers.push(validatorClient);
|
|
329
|
-
if (!options.dontStartSequencer) {
|
|
330
|
-
await validatorClient.registerHandlers();
|
|
331
|
-
}
|
|
332
|
-
}
|
|
357
|
+
let validatorClient: ValidatorClient | undefined;
|
|
333
358
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
log.info('Setting up block proposal reexecution for monitoring');
|
|
338
|
-
createBlockProposalHandler(config, {
|
|
359
|
+
if (!proverOnly) {
|
|
360
|
+
// Create validator client if required
|
|
361
|
+
validatorClient = await createValidatorClient(config, {
|
|
339
362
|
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
340
363
|
worldState: worldStateSynchronizer,
|
|
364
|
+
p2pClient,
|
|
365
|
+
telemetry,
|
|
366
|
+
dateProvider,
|
|
341
367
|
epochCache,
|
|
342
368
|
blockSource: archiver,
|
|
343
369
|
l1ToL2MessageSource: archiver,
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
370
|
+
keyStoreManager,
|
|
371
|
+
blobClient,
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
375
|
+
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
376
|
+
// like attestations or auths will fail.
|
|
377
|
+
if (validatorClient) {
|
|
378
|
+
watchers.push(validatorClient);
|
|
379
|
+
if (!options.dontStartSequencer) {
|
|
380
|
+
await validatorClient.registerHandlers();
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// If there's no validator client but alwaysReexecuteBlockProposals is enabled,
|
|
385
|
+
// create a BlockProposalHandler to reexecute block proposals for monitoring
|
|
386
|
+
if (!validatorClient && config.alwaysReexecuteBlockProposals) {
|
|
387
|
+
log.info('Setting up block proposal reexecution for monitoring');
|
|
388
|
+
createBlockProposalHandler(config, {
|
|
389
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
390
|
+
worldState: worldStateSynchronizer,
|
|
391
|
+
epochCache,
|
|
392
|
+
blockSource: archiver,
|
|
393
|
+
l1ToL2MessageSource: archiver,
|
|
394
|
+
p2pClient,
|
|
395
|
+
dateProvider,
|
|
396
|
+
telemetry,
|
|
397
|
+
}).registerForReexecution(p2pClient);
|
|
398
|
+
}
|
|
348
399
|
}
|
|
349
400
|
|
|
350
401
|
// Start world state and wait for it to sync to the archiver.
|
|
@@ -353,29 +404,33 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
353
404
|
// Start p2p. Note that it depends on world state to be running.
|
|
354
405
|
await p2pClient.start();
|
|
355
406
|
|
|
356
|
-
|
|
357
|
-
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
358
|
-
watchers.push(validatorsSentinel);
|
|
359
|
-
}
|
|
360
|
-
|
|
407
|
+
let validatorsSentinel: Awaited<ReturnType<typeof createSentinel>> | undefined;
|
|
361
408
|
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
409
|
let attestationsBlockWatcher: AttestationsBlockWatcher | undefined;
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
410
|
+
|
|
411
|
+
if (!proverOnly) {
|
|
412
|
+
validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
413
|
+
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
414
|
+
watchers.push(validatorsSentinel);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
418
|
+
epochPruneWatcher = new EpochPruneWatcher(
|
|
419
|
+
archiver,
|
|
420
|
+
archiver,
|
|
421
|
+
epochCache,
|
|
422
|
+
p2pClient.getTxProvider(),
|
|
423
|
+
validatorCheckpointsBuilder,
|
|
424
|
+
config,
|
|
425
|
+
);
|
|
426
|
+
watchers.push(epochPruneWatcher);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
430
|
+
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
431
|
+
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
432
|
+
watchers.push(attestationsBlockWatcher);
|
|
433
|
+
}
|
|
379
434
|
}
|
|
380
435
|
|
|
381
436
|
// Start p2p-related services once the archiver has completed sync
|
|
@@ -412,19 +467,19 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
412
467
|
);
|
|
413
468
|
await slasherClient.start();
|
|
414
469
|
|
|
415
|
-
const l1TxUtils = config.
|
|
416
|
-
? await
|
|
470
|
+
const l1TxUtils = config.sequencerPublisherForwarderAddress
|
|
471
|
+
? await createForwarderL1TxUtilsFromSigners(
|
|
417
472
|
publicClient,
|
|
418
473
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
419
|
-
config.
|
|
474
|
+
config.sequencerPublisherForwarderAddress,
|
|
420
475
|
{ ...config, scope: 'sequencer' },
|
|
421
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
476
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
422
477
|
)
|
|
423
|
-
: await
|
|
478
|
+
: await createL1TxUtilsFromSigners(
|
|
424
479
|
publicClient,
|
|
425
480
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
426
481
|
{ ...config, scope: 'sequencer' },
|
|
427
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
482
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
428
483
|
);
|
|
429
484
|
|
|
430
485
|
// Create and start the sequencer client
|
|
@@ -434,6 +489,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
434
489
|
archiver,
|
|
435
490
|
dateProvider,
|
|
436
491
|
telemetry,
|
|
492
|
+
debugLogStore,
|
|
437
493
|
);
|
|
438
494
|
|
|
439
495
|
sequencer = await SequencerClient.new(config, {
|
|
@@ -461,6 +517,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
461
517
|
log.warn(`Sequencer created but not started`);
|
|
462
518
|
}
|
|
463
519
|
|
|
520
|
+
// Create prover node subsystem if enabled
|
|
521
|
+
let proverNode: ProverNode | undefined;
|
|
522
|
+
if (config.enableProverNode) {
|
|
523
|
+
proverNode = await createProverNode(config, {
|
|
524
|
+
...deps.proverNodeDeps,
|
|
525
|
+
telemetry,
|
|
526
|
+
dateProvider,
|
|
527
|
+
archiver,
|
|
528
|
+
worldStateSynchronizer,
|
|
529
|
+
p2pClient,
|
|
530
|
+
epochCache,
|
|
531
|
+
blobClient,
|
|
532
|
+
keyStoreManager,
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
if (!options.dontStartProverNode) {
|
|
536
|
+
await proverNode.start();
|
|
537
|
+
log.info(`Prover node subsystem started`);
|
|
538
|
+
} else {
|
|
539
|
+
log.info(`Prover node subsystem created but not started`);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
464
543
|
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
465
544
|
...config,
|
|
466
545
|
rollupVersion: BigInt(config.rollupVersion),
|
|
@@ -468,7 +547,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
468
547
|
slotDuration: Number(slotDuration),
|
|
469
548
|
});
|
|
470
549
|
|
|
471
|
-
|
|
550
|
+
const node = new AztecNodeService(
|
|
472
551
|
config,
|
|
473
552
|
p2pClient,
|
|
474
553
|
archiver,
|
|
@@ -477,6 +556,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
477
556
|
archiver,
|
|
478
557
|
worldStateSynchronizer,
|
|
479
558
|
sequencer,
|
|
559
|
+
proverNode,
|
|
480
560
|
slasherClient,
|
|
481
561
|
validatorsSentinel,
|
|
482
562
|
epochPruneWatcher,
|
|
@@ -489,7 +569,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
489
569
|
telemetry,
|
|
490
570
|
log,
|
|
491
571
|
blobClient,
|
|
572
|
+
validatorClient,
|
|
573
|
+
keyStoreManager,
|
|
574
|
+
debugLogStore,
|
|
492
575
|
);
|
|
576
|
+
|
|
577
|
+
return node;
|
|
493
578
|
}
|
|
494
579
|
|
|
495
580
|
/**
|
|
@@ -500,6 +585,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
500
585
|
return this.sequencer;
|
|
501
586
|
}
|
|
502
587
|
|
|
588
|
+
/** Returns the prover node subsystem, if enabled. */
|
|
589
|
+
public getProverNode(): ProverNode | undefined {
|
|
590
|
+
return this.proverNode;
|
|
591
|
+
}
|
|
592
|
+
|
|
503
593
|
public getBlockSource(): L2BlockSource {
|
|
504
594
|
return this.blockSource;
|
|
505
595
|
}
|
|
@@ -525,7 +615,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
525
615
|
}
|
|
526
616
|
|
|
527
617
|
public async getAllowedPublicSetup(): Promise<AllowedElement[]> {
|
|
528
|
-
return this.config.
|
|
618
|
+
return [...(await getDefaultAllowedSetupFunctions()), ...(this.config.txPublicSetupAllowListExtend ?? [])];
|
|
529
619
|
}
|
|
530
620
|
|
|
531
621
|
/**
|
|
@@ -762,8 +852,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
762
852
|
}
|
|
763
853
|
|
|
764
854
|
await this.p2pClient!.sendTx(tx);
|
|
765
|
-
|
|
766
|
-
this.
|
|
855
|
+
const duration = timer.ms();
|
|
856
|
+
this.metrics.receivedTx(duration, true);
|
|
857
|
+
this.log.info(`Received tx ${txHash} in ${duration}ms`, { txHash });
|
|
767
858
|
}
|
|
768
859
|
|
|
769
860
|
public async getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
@@ -775,18 +866,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
775
866
|
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
776
867
|
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
777
868
|
|
|
869
|
+
let receipt: TxReceipt;
|
|
778
870
|
if (settledTxReceipt) {
|
|
779
|
-
|
|
780
|
-
return settledTxReceipt;
|
|
871
|
+
receipt = settledTxReceipt;
|
|
781
872
|
} else if (isKnownToPool) {
|
|
782
873
|
// If the tx is in the pool but not in the archiver, it's pending.
|
|
783
874
|
// This handles race conditions between archiver and p2p, where the archiver
|
|
784
875
|
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
785
|
-
|
|
876
|
+
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
786
877
|
} else {
|
|
787
878
|
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
788
|
-
|
|
879
|
+
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
789
880
|
}
|
|
881
|
+
|
|
882
|
+
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
883
|
+
|
|
884
|
+
return receipt;
|
|
790
885
|
}
|
|
791
886
|
|
|
792
887
|
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
@@ -803,6 +898,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
803
898
|
await tryStop(this.slasherClient);
|
|
804
899
|
await tryStop(this.proofVerifier);
|
|
805
900
|
await tryStop(this.sequencer);
|
|
901
|
+
await tryStop(this.proverNode);
|
|
806
902
|
await tryStop(this.p2pClient);
|
|
807
903
|
await tryStop(this.worldStateSynchronizer);
|
|
808
904
|
await tryStop(this.blockSource);
|
|
@@ -1106,6 +1202,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1106
1202
|
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
1107
1203
|
}
|
|
1108
1204
|
|
|
1205
|
+
public getBlockData(number: BlockNumber): Promise<BlockData | undefined> {
|
|
1206
|
+
return this.blockSource.getBlockData(number);
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
public getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
|
|
1210
|
+
return this.blockSource.getBlockDataByArchive(archive);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1109
1213
|
/**
|
|
1110
1214
|
* Simulates the public part of a transaction with the current state.
|
|
1111
1215
|
* @param tx - The transaction to simulate.
|
|
@@ -1129,7 +1233,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1129
1233
|
}
|
|
1130
1234
|
|
|
1131
1235
|
const txHash = tx.getTxHash();
|
|
1132
|
-
const
|
|
1236
|
+
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1237
|
+
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
1133
1238
|
|
|
1134
1239
|
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1135
1240
|
const coinbase = EthAddress.ZERO;
|
|
@@ -1153,6 +1258,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1153
1258
|
blockNumber,
|
|
1154
1259
|
});
|
|
1155
1260
|
|
|
1261
|
+
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1262
|
+
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1156
1263
|
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1157
1264
|
try {
|
|
1158
1265
|
const config = PublicSimulatorConfig.from({
|
|
@@ -1168,7 +1275,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1168
1275
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1169
1276
|
|
|
1170
1277
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1171
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([tx]);
|
|
1278
|
+
const [processedTxs, failedTxs, _usedTxs, returns, _blobFields, debugLogs] = await processor.process([tx]);
|
|
1172
1279
|
// REFACTOR: Consider returning the error rather than throwing
|
|
1173
1280
|
if (failedTxs.length) {
|
|
1174
1281
|
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
|
|
@@ -1182,6 +1289,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1182
1289
|
processedTx.txEffect,
|
|
1183
1290
|
returns,
|
|
1184
1291
|
processedTx.gasUsed,
|
|
1292
|
+
debugLogs,
|
|
1185
1293
|
);
|
|
1186
1294
|
} finally {
|
|
1187
1295
|
await merkleTreeFork.close();
|
|
@@ -1195,10 +1303,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1195
1303
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1196
1304
|
const verifier = isSimulation ? undefined : this.proofVerifier;
|
|
1197
1305
|
|
|
1198
|
-
// We accept transactions if they are not expired by the next slot (checked based on the
|
|
1306
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1199
1307
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1200
1308
|
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
1201
|
-
const validator =
|
|
1309
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(
|
|
1202
1310
|
db,
|
|
1203
1311
|
this.contractDataSource,
|
|
1204
1312
|
verifier,
|
|
@@ -1207,7 +1315,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1207
1315
|
blockNumber,
|
|
1208
1316
|
l1ChainId: this.l1ChainId,
|
|
1209
1317
|
rollupVersion: this.version,
|
|
1210
|
-
setupAllowList:
|
|
1318
|
+
setupAllowList: [
|
|
1319
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
1320
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
1321
|
+
],
|
|
1211
1322
|
gasFees: await this.getCurrentMinFees(),
|
|
1212
1323
|
skipFeeEnforcement,
|
|
1213
1324
|
txsPermitted: !this.config.disableTransactions,
|
|
@@ -1377,6 +1488,94 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1377
1488
|
}
|
|
1378
1489
|
}
|
|
1379
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
|
+
|
|
1380
1579
|
#getInitialHeaderHash(): Promise<BlockHash> {
|
|
1381
1580
|
if (!this.initialHeaderHashPromise) {
|
|
1382
1581
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|