@aztec/aztec-node 0.0.1-commit.2ed92850 → 0.0.1-commit.358457c
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/node_metrics.d.ts +1 -1
- package/dest/aztec-node/node_metrics.d.ts.map +1 -1
- package/dest/aztec-node/node_metrics.js +8 -4
- package/dest/aztec-node/server.d.ts +32 -21
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +201 -79
- package/dest/sentinel/factory.d.ts +1 -1
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/factory.js +1 -1
- 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/node_metrics.ts +12 -5
- package/src/aztec-node/server.ts +274 -120
- package/src/sentinel/factory.ts +1 -6
- package/src/sentinel/sentinel.ts +56 -23
- package/src/sentinel/store.ts +12 -12
package/src/aztec-node/server.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
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 {
|
|
5
|
-
|
|
6
|
-
type L1_TO_L2_MSG_TREE_HEIGHT,
|
|
7
|
-
type NOTE_HASH_TREE_HEIGHT,
|
|
8
|
-
type NULLIFIER_TREE_HEIGHT,
|
|
9
|
-
type PUBLIC_DATA_TREE_HEIGHT,
|
|
10
|
-
} from '@aztec/constants';
|
|
4
|
+
import { Blob } from '@aztec/blob-lib';
|
|
5
|
+
import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
11
6
|
import { EpochCache, type EpochCacheInterface } from '@aztec/epoch-cache';
|
|
12
7
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
13
8
|
import { getPublicClient } from '@aztec/ethereum/client';
|
|
14
9
|
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
15
10
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
16
11
|
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
17
|
-
import { compactArray, pick } from '@aztec/foundation/collection';
|
|
12
|
+
import { compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
18
13
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
19
14
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
20
15
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
@@ -22,14 +17,19 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
|
22
17
|
import { count } from '@aztec/foundation/string';
|
|
23
18
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
24
19
|
import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
|
|
25
|
-
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
20
|
+
import { type KeyStore, KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
26
21
|
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
22
|
+
import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
|
|
27
23
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
type P2P,
|
|
25
|
+
type P2PClientDeps,
|
|
26
|
+
createP2PClient,
|
|
27
|
+
createTxValidatorForAcceptingTxsOverRPC,
|
|
28
|
+
getDefaultAllowedSetupFunctions,
|
|
29
|
+
} from '@aztec/p2p';
|
|
32
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';
|
|
33
33
|
import { GlobalVariableBuilder, SequencerClient, type SequencerPublisher } from '@aztec/sequencer-client';
|
|
34
34
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
35
35
|
import {
|
|
@@ -41,7 +41,14 @@ import {
|
|
|
41
41
|
} from '@aztec/slasher';
|
|
42
42
|
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
43
43
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
44
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
type BlockData,
|
|
46
|
+
BlockHash,
|
|
47
|
+
type BlockParameter,
|
|
48
|
+
type DataInBlock,
|
|
49
|
+
L2Block,
|
|
50
|
+
type L2BlockSource,
|
|
51
|
+
} from '@aztec/stdlib/block';
|
|
45
52
|
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
46
53
|
import type {
|
|
47
54
|
ContractClassPublic,
|
|
@@ -69,7 +76,8 @@ import {
|
|
|
69
76
|
type WorldStateSynchronizer,
|
|
70
77
|
tryStop,
|
|
71
78
|
} from '@aztec/stdlib/interfaces/server';
|
|
72
|
-
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';
|
|
73
81
|
import { InboxLeaf, type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
74
82
|
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
75
83
|
import type { Offense, SlashPayloadRound } from '@aztec/stdlib/slashing';
|
|
@@ -103,7 +111,6 @@ import {
|
|
|
103
111
|
ValidatorClient,
|
|
104
112
|
createBlockProposalHandler,
|
|
105
113
|
createValidatorClient,
|
|
106
|
-
createValidatorForAcceptingTxs,
|
|
107
114
|
} from '@aztec/validator-client';
|
|
108
115
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
109
116
|
|
|
@@ -119,7 +126,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
119
126
|
*/
|
|
120
127
|
export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
121
128
|
private metrics: NodeMetrics;
|
|
122
|
-
private initialHeaderHashPromise: Promise<
|
|
129
|
+
private initialHeaderHashPromise: Promise<BlockHash> | undefined = undefined;
|
|
123
130
|
|
|
124
131
|
// Prevent two snapshot operations to happen simultaneously
|
|
125
132
|
private isUploadingSnapshot = false;
|
|
@@ -135,6 +142,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
135
142
|
protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
|
|
136
143
|
protected readonly worldStateSynchronizer: WorldStateSynchronizer,
|
|
137
144
|
protected readonly sequencer: SequencerClient | undefined,
|
|
145
|
+
protected readonly proverNode: ProverNode | undefined,
|
|
138
146
|
protected readonly slasherClient: SlasherClientInterface | undefined,
|
|
139
147
|
protected readonly validatorsSentinel: Sentinel | undefined,
|
|
140
148
|
protected readonly epochPruneWatcher: EpochPruneWatcher | undefined,
|
|
@@ -147,12 +155,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
147
155
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
148
156
|
private log = createLogger('node'),
|
|
149
157
|
private blobClient?: BlobClientInterface,
|
|
158
|
+
private validatorClient?: ValidatorClient,
|
|
159
|
+
private keyStoreManager?: KeystoreManager,
|
|
160
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
150
161
|
) {
|
|
151
162
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
152
163
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
153
164
|
|
|
154
165
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
155
166
|
this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config.l1Contracts);
|
|
167
|
+
|
|
168
|
+
// A defensive check that protects us against introducing a bug in the complex `createAndSync` function. We must
|
|
169
|
+
// never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
|
|
170
|
+
// memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
|
|
171
|
+
if (debugLogStore.isEnabled && config.realProofs) {
|
|
172
|
+
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
173
|
+
}
|
|
156
174
|
}
|
|
157
175
|
|
|
158
176
|
public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
|
|
@@ -177,10 +195,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
177
195
|
publisher?: SequencerPublisher;
|
|
178
196
|
dateProvider?: DateProvider;
|
|
179
197
|
p2pClientDeps?: P2PClientDeps<P2PClientType.Full>;
|
|
198
|
+
proverNodeDeps?: Partial<ProverNodeDeps>;
|
|
180
199
|
} = {},
|
|
181
200
|
options: {
|
|
182
201
|
prefilledPublicData?: PublicDataTreeLeaf[];
|
|
183
202
|
dontStartSequencer?: boolean;
|
|
203
|
+
dontStartProverNode?: boolean;
|
|
184
204
|
} = {},
|
|
185
205
|
): Promise<AztecNodeService> {
|
|
186
206
|
const config = { ...inputConfig }; // Copy the config so we dont mutate the input object
|
|
@@ -190,16 +210,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
190
210
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
191
211
|
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
192
212
|
|
|
193
|
-
// Build a key store from file if given or from environment otherwise
|
|
213
|
+
// Build a key store from file if given or from environment otherwise.
|
|
214
|
+
// We keep the raw KeyStore available so we can merge with prover keys if enableProverNode is set.
|
|
194
215
|
let keyStoreManager: KeystoreManager | undefined;
|
|
195
216
|
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
196
217
|
if (keyStoreProvided) {
|
|
197
218
|
const keyStores = loadKeystores(config.keyStoreDirectory!);
|
|
198
219
|
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
199
220
|
} else {
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
221
|
+
const rawKeyStores: KeyStore[] = [];
|
|
222
|
+
const validatorKeyStore = createKeyStoreForValidator(config);
|
|
223
|
+
if (validatorKeyStore) {
|
|
224
|
+
rawKeyStores.push(validatorKeyStore);
|
|
225
|
+
}
|
|
226
|
+
if (config.enableProverNode) {
|
|
227
|
+
const proverKeyStore = createKeyStoreForProver(config);
|
|
228
|
+
if (proverKeyStore) {
|
|
229
|
+
rawKeyStores.push(proverKeyStore);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (rawKeyStores.length > 0) {
|
|
233
|
+
keyStoreManager = new KeystoreManager(
|
|
234
|
+
rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores),
|
|
235
|
+
);
|
|
203
236
|
}
|
|
204
237
|
}
|
|
205
238
|
|
|
@@ -210,10 +243,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
210
243
|
if (keyStoreManager === undefined) {
|
|
211
244
|
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
212
245
|
}
|
|
213
|
-
if (!keyStoreProvided) {
|
|
214
|
-
log.warn(
|
|
215
|
-
'KEY STORE CREATED FROM ENVIRONMENT, IT IS RECOMMENDED TO USE A FILE-BASED KEY STORE IN PRODUCTION ENVIRONMENTS',
|
|
216
|
-
);
|
|
246
|
+
if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
|
|
247
|
+
log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
|
|
217
248
|
}
|
|
218
249
|
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
219
250
|
}
|
|
@@ -255,7 +286,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
255
286
|
);
|
|
256
287
|
}
|
|
257
288
|
|
|
258
|
-
const blobClient = await createBlobClientWithFileStores(config,
|
|
289
|
+
const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
|
|
259
290
|
|
|
260
291
|
// attempt snapshot sync if possible
|
|
261
292
|
await trySnapshotSync(config, log);
|
|
@@ -279,9 +310,19 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
279
310
|
config.realProofs || config.debugForceTxProofVerification
|
|
280
311
|
? await BBCircuitVerifier.new(config)
|
|
281
312
|
: new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
313
|
+
|
|
314
|
+
let debugLogStore: DebugLogStore;
|
|
282
315
|
if (!config.realProofs) {
|
|
283
316
|
log.warn(`Aztec node is accepting fake proofs`);
|
|
317
|
+
|
|
318
|
+
debugLogStore = new InMemoryDebugLogStore();
|
|
319
|
+
log.info(
|
|
320
|
+
'Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served',
|
|
321
|
+
);
|
|
322
|
+
} else {
|
|
323
|
+
debugLogStore = new NullDebugLogStore();
|
|
284
324
|
}
|
|
325
|
+
|
|
285
326
|
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
286
327
|
|
|
287
328
|
// create the tx pool and the p2p client, which will need the l2 block source
|
|
@@ -418,19 +459,19 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
418
459
|
);
|
|
419
460
|
await slasherClient.start();
|
|
420
461
|
|
|
421
|
-
const l1TxUtils = config.
|
|
422
|
-
? await
|
|
462
|
+
const l1TxUtils = config.sequencerPublisherForwarderAddress
|
|
463
|
+
? await createForwarderL1TxUtilsFromSigners(
|
|
423
464
|
publicClient,
|
|
424
465
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
425
|
-
config.
|
|
466
|
+
config.sequencerPublisherForwarderAddress,
|
|
426
467
|
{ ...config, scope: 'sequencer' },
|
|
427
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
468
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
428
469
|
)
|
|
429
|
-
: await
|
|
470
|
+
: await createL1TxUtilsFromSigners(
|
|
430
471
|
publicClient,
|
|
431
472
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
432
473
|
{ ...config, scope: 'sequencer' },
|
|
433
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
474
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
434
475
|
);
|
|
435
476
|
|
|
436
477
|
// Create and start the sequencer client
|
|
@@ -440,6 +481,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
440
481
|
archiver,
|
|
441
482
|
dateProvider,
|
|
442
483
|
telemetry,
|
|
484
|
+
debugLogStore,
|
|
443
485
|
);
|
|
444
486
|
|
|
445
487
|
sequencer = await SequencerClient.new(config, {
|
|
@@ -467,6 +509,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
467
509
|
log.warn(`Sequencer created but not started`);
|
|
468
510
|
}
|
|
469
511
|
|
|
512
|
+
// Create prover node subsystem if enabled
|
|
513
|
+
let proverNode: ProverNode | undefined;
|
|
514
|
+
if (config.enableProverNode) {
|
|
515
|
+
proverNode = await createProverNode(config, {
|
|
516
|
+
...deps.proverNodeDeps,
|
|
517
|
+
telemetry,
|
|
518
|
+
dateProvider,
|
|
519
|
+
archiver,
|
|
520
|
+
worldStateSynchronizer,
|
|
521
|
+
p2pClient,
|
|
522
|
+
epochCache,
|
|
523
|
+
blobClient,
|
|
524
|
+
keyStoreManager,
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
if (!options.dontStartProverNode) {
|
|
528
|
+
await proverNode.start();
|
|
529
|
+
log.info(`Prover node subsystem started`);
|
|
530
|
+
} else {
|
|
531
|
+
log.info(`Prover node subsystem created but not started`);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
470
535
|
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
471
536
|
...config,
|
|
472
537
|
rollupVersion: BigInt(config.rollupVersion),
|
|
@@ -474,7 +539,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
474
539
|
slotDuration: Number(slotDuration),
|
|
475
540
|
});
|
|
476
541
|
|
|
477
|
-
|
|
542
|
+
const node = new AztecNodeService(
|
|
478
543
|
config,
|
|
479
544
|
p2pClient,
|
|
480
545
|
archiver,
|
|
@@ -483,6 +548,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
483
548
|
archiver,
|
|
484
549
|
worldStateSynchronizer,
|
|
485
550
|
sequencer,
|
|
551
|
+
proverNode,
|
|
486
552
|
slasherClient,
|
|
487
553
|
validatorsSentinel,
|
|
488
554
|
epochPruneWatcher,
|
|
@@ -495,7 +561,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
495
561
|
telemetry,
|
|
496
562
|
log,
|
|
497
563
|
blobClient,
|
|
564
|
+
validatorClient,
|
|
565
|
+
keyStoreManager,
|
|
566
|
+
debugLogStore,
|
|
498
567
|
);
|
|
568
|
+
|
|
569
|
+
return node;
|
|
499
570
|
}
|
|
500
571
|
|
|
501
572
|
/**
|
|
@@ -506,6 +577,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
506
577
|
return this.sequencer;
|
|
507
578
|
}
|
|
508
579
|
|
|
580
|
+
/** Returns the prover node subsystem, if enabled. */
|
|
581
|
+
public getProverNode(): ProverNode | undefined {
|
|
582
|
+
return this.proverNode;
|
|
583
|
+
}
|
|
584
|
+
|
|
509
585
|
public getBlockSource(): L2BlockSource {
|
|
510
586
|
return this.blockSource;
|
|
511
587
|
}
|
|
@@ -559,6 +635,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
559
635
|
enr,
|
|
560
636
|
l1ContractAddresses: contractAddresses,
|
|
561
637
|
protocolContractAddresses: protocolContractAddresses,
|
|
638
|
+
realProofs: !!this.config.realProofs,
|
|
562
639
|
};
|
|
563
640
|
|
|
564
641
|
return nodeInfo;
|
|
@@ -570,8 +647,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
570
647
|
* @returns The requested block.
|
|
571
648
|
*/
|
|
572
649
|
public async getBlock(block: BlockParameter): Promise<L2Block | undefined> {
|
|
573
|
-
if (
|
|
574
|
-
return this.getBlockByHash(
|
|
650
|
+
if (BlockHash.isBlockHash(block)) {
|
|
651
|
+
return this.getBlockByHash(block);
|
|
575
652
|
}
|
|
576
653
|
const blockNumber = block === 'latest' ? await this.getBlockNumber() : (block as BlockNumber);
|
|
577
654
|
if (blockNumber === BlockNumber.ZERO) {
|
|
@@ -585,9 +662,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
585
662
|
* @param blockHash - The block hash being requested.
|
|
586
663
|
* @returns The requested block.
|
|
587
664
|
*/
|
|
588
|
-
public async getBlockByHash(blockHash:
|
|
665
|
+
public async getBlockByHash(blockHash: BlockHash): Promise<L2Block | undefined> {
|
|
589
666
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
590
|
-
if (blockHash.equals(
|
|
667
|
+
if (blockHash.equals(initialBlockHash)) {
|
|
591
668
|
return this.buildInitialBlock();
|
|
592
669
|
}
|
|
593
670
|
return await this.blockSource.getL2BlockByHash(blockHash);
|
|
@@ -692,13 +769,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
692
769
|
public async getPrivateLogsByTags(
|
|
693
770
|
tags: SiloedTag[],
|
|
694
771
|
page?: number,
|
|
695
|
-
referenceBlock?:
|
|
772
|
+
referenceBlock?: BlockHash,
|
|
696
773
|
): Promise<TxScopedL2Log[][]> {
|
|
697
774
|
if (referenceBlock) {
|
|
698
775
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
699
776
|
if (!referenceBlock.equals(initialBlockHash)) {
|
|
700
|
-
const
|
|
701
|
-
const header = await this.blockSource.getBlockHeaderByHash(blockHashFr);
|
|
777
|
+
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
702
778
|
if (!header) {
|
|
703
779
|
throw new Error(
|
|
704
780
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
@@ -713,13 +789,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
713
789
|
contractAddress: AztecAddress,
|
|
714
790
|
tags: Tag[],
|
|
715
791
|
page?: number,
|
|
716
|
-
referenceBlock?:
|
|
792
|
+
referenceBlock?: BlockHash,
|
|
717
793
|
): Promise<TxScopedL2Log[][]> {
|
|
718
794
|
if (referenceBlock) {
|
|
719
795
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
720
796
|
if (!referenceBlock.equals(initialBlockHash)) {
|
|
721
|
-
const
|
|
722
|
-
const header = await this.blockSource.getBlockHeaderByHash(blockHashFr);
|
|
797
|
+
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
723
798
|
if (!header) {
|
|
724
799
|
throw new Error(
|
|
725
800
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
@@ -782,18 +857,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
782
857
|
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
783
858
|
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
784
859
|
|
|
860
|
+
let receipt: TxReceipt;
|
|
785
861
|
if (settledTxReceipt) {
|
|
786
|
-
|
|
787
|
-
return settledTxReceipt;
|
|
862
|
+
receipt = settledTxReceipt;
|
|
788
863
|
} else if (isKnownToPool) {
|
|
789
864
|
// If the tx is in the pool but not in the archiver, it's pending.
|
|
790
865
|
// This handles race conditions between archiver and p2p, where the archiver
|
|
791
866
|
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
792
|
-
|
|
867
|
+
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
793
868
|
} else {
|
|
794
869
|
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
795
|
-
|
|
870
|
+
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
796
871
|
}
|
|
872
|
+
|
|
873
|
+
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
874
|
+
|
|
875
|
+
return receipt;
|
|
797
876
|
}
|
|
798
877
|
|
|
799
878
|
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
@@ -810,6 +889,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
810
889
|
await tryStop(this.slasherClient);
|
|
811
890
|
await tryStop(this.proofVerifier);
|
|
812
891
|
await tryStop(this.sequencer);
|
|
892
|
+
await tryStop(this.proverNode);
|
|
813
893
|
await tryStop(this.p2pClient);
|
|
814
894
|
await tryStop(this.worldStateSynchronizer);
|
|
815
895
|
await tryStop(this.blockSource);
|
|
@@ -859,11 +939,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
859
939
|
}
|
|
860
940
|
|
|
861
941
|
public async findLeavesIndexes(
|
|
862
|
-
|
|
942
|
+
referenceBlock: BlockParameter,
|
|
863
943
|
treeId: MerkleTreeId,
|
|
864
944
|
leafValues: Fr[],
|
|
865
945
|
): Promise<(DataInBlock<bigint> | undefined)[]> {
|
|
866
|
-
const committedDb = await this.#getWorldState(
|
|
946
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
867
947
|
const maybeIndices = await committedDb.findLeafIndices(
|
|
868
948
|
treeId,
|
|
869
949
|
leafValues.map(x => x.toBuffer()),
|
|
@@ -915,44 +995,28 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
915
995
|
}
|
|
916
996
|
return {
|
|
917
997
|
l2BlockNumber: BlockNumber(Number(blockNumber)),
|
|
918
|
-
l2BlockHash:
|
|
998
|
+
l2BlockHash: new BlockHash(blockHash),
|
|
919
999
|
data: index,
|
|
920
1000
|
};
|
|
921
1001
|
});
|
|
922
1002
|
}
|
|
923
1003
|
|
|
924
|
-
public async
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
): Promise<SiblingPath<typeof NULLIFIER_TREE_HEIGHT>> {
|
|
928
|
-
const committedDb = await this.#getWorldState(block);
|
|
929
|
-
return committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, leafIndex);
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
public async getNoteHashSiblingPath(
|
|
933
|
-
block: BlockParameter,
|
|
934
|
-
leafIndex: bigint,
|
|
935
|
-
): Promise<SiblingPath<typeof NOTE_HASH_TREE_HEIGHT>> {
|
|
936
|
-
const committedDb = await this.#getWorldState(block);
|
|
937
|
-
return committedDb.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
public async getArchiveMembershipWitness(
|
|
941
|
-
block: BlockParameter,
|
|
942
|
-
archive: Fr,
|
|
1004
|
+
public async getBlockHashMembershipWitness(
|
|
1005
|
+
referenceBlock: BlockParameter,
|
|
1006
|
+
blockHash: BlockHash,
|
|
943
1007
|
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
|
|
944
|
-
const committedDb = await this.#getWorldState(
|
|
945
|
-
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [
|
|
1008
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1009
|
+
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
|
|
946
1010
|
return pathAndIndex === undefined
|
|
947
1011
|
? undefined
|
|
948
1012
|
: MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
949
1013
|
}
|
|
950
1014
|
|
|
951
1015
|
public async getNoteHashMembershipWitness(
|
|
952
|
-
|
|
1016
|
+
referenceBlock: BlockParameter,
|
|
953
1017
|
noteHash: Fr,
|
|
954
1018
|
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
|
|
955
|
-
const committedDb = await this.#getWorldState(
|
|
1019
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
956
1020
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.NOTE_HASH_TREE>(
|
|
957
1021
|
MerkleTreeId.NOTE_HASH_TREE,
|
|
958
1022
|
[noteHash],
|
|
@@ -963,10 +1027,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
963
1027
|
}
|
|
964
1028
|
|
|
965
1029
|
public async getL1ToL2MessageMembershipWitness(
|
|
966
|
-
|
|
1030
|
+
referenceBlock: BlockParameter,
|
|
967
1031
|
l1ToL2Message: Fr,
|
|
968
1032
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
|
|
969
|
-
const db = await this.#getWorldState(
|
|
1033
|
+
const db = await this.#getWorldState(referenceBlock);
|
|
970
1034
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [l1ToL2Message]);
|
|
971
1035
|
if (!witness) {
|
|
972
1036
|
return undefined;
|
|
@@ -1019,27 +1083,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1019
1083
|
);
|
|
1020
1084
|
}
|
|
1021
1085
|
|
|
1022
|
-
public async getArchiveSiblingPath(
|
|
1023
|
-
block: BlockParameter,
|
|
1024
|
-
leafIndex: bigint,
|
|
1025
|
-
): Promise<SiblingPath<typeof ARCHIVE_HEIGHT>> {
|
|
1026
|
-
const committedDb = await this.#getWorldState(block);
|
|
1027
|
-
return committedDb.getSiblingPath(MerkleTreeId.ARCHIVE, leafIndex);
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
public async getPublicDataSiblingPath(
|
|
1031
|
-
block: BlockParameter,
|
|
1032
|
-
leafIndex: bigint,
|
|
1033
|
-
): Promise<SiblingPath<typeof PUBLIC_DATA_TREE_HEIGHT>> {
|
|
1034
|
-
const committedDb = await this.#getWorldState(block);
|
|
1035
|
-
return committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, leafIndex);
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
1086
|
public async getNullifierMembershipWitness(
|
|
1039
|
-
|
|
1087
|
+
referenceBlock: BlockParameter,
|
|
1040
1088
|
nullifier: Fr,
|
|
1041
1089
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1042
|
-
const db = await this.#getWorldState(
|
|
1090
|
+
const db = await this.#getWorldState(referenceBlock);
|
|
1043
1091
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]);
|
|
1044
1092
|
if (!witness) {
|
|
1045
1093
|
return undefined;
|
|
@@ -1056,7 +1104,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1056
1104
|
|
|
1057
1105
|
/**
|
|
1058
1106
|
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
1059
|
-
* @param
|
|
1107
|
+
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
|
|
1108
|
+
* (which contains the root of the nullifier tree in which we are searching for the nullifier).
|
|
1060
1109
|
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
1061
1110
|
* @returns The low nullifier membership witness (if found).
|
|
1062
1111
|
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
@@ -1069,10 +1118,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1069
1118
|
* TODO: This is a confusing behavior and we should eventually address that.
|
|
1070
1119
|
*/
|
|
1071
1120
|
public async getLowNullifierMembershipWitness(
|
|
1072
|
-
|
|
1121
|
+
referenceBlock: BlockParameter,
|
|
1073
1122
|
nullifier: Fr,
|
|
1074
1123
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1075
|
-
const committedDb = await this.#getWorldState(
|
|
1124
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1076
1125
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1077
1126
|
if (!findResult) {
|
|
1078
1127
|
return undefined;
|
|
@@ -1087,8 +1136,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1087
1136
|
return new NullifierMembershipWitness(BigInt(index), preimageData as NullifierLeafPreimage, siblingPath);
|
|
1088
1137
|
}
|
|
1089
1138
|
|
|
1090
|
-
async getPublicDataWitness(
|
|
1091
|
-
const committedDb = await this.#getWorldState(
|
|
1139
|
+
async getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
1140
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1092
1141
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1093
1142
|
if (!lowLeafResult) {
|
|
1094
1143
|
return undefined;
|
|
@@ -1102,8 +1151,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1102
1151
|
}
|
|
1103
1152
|
}
|
|
1104
1153
|
|
|
1105
|
-
public async getPublicStorageAt(
|
|
1106
|
-
const committedDb = await this.#getWorldState(
|
|
1154
|
+
public async getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
1155
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1107
1156
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1108
1157
|
|
|
1109
1158
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
@@ -1118,14 +1167,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1118
1167
|
}
|
|
1119
1168
|
|
|
1120
1169
|
public async getBlockHeader(block: BlockParameter = 'latest'): Promise<BlockHeader | undefined> {
|
|
1121
|
-
if (
|
|
1170
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1122
1171
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1123
1172
|
if (block.equals(initialBlockHash)) {
|
|
1124
1173
|
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1125
1174
|
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1126
1175
|
}
|
|
1127
|
-
|
|
1128
|
-
return this.blockSource.getBlockHeaderByHash(blockHashFr);
|
|
1176
|
+
return this.blockSource.getBlockHeaderByHash(block);
|
|
1129
1177
|
} else {
|
|
1130
1178
|
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1131
1179
|
const blockNumber = block === 'latest' ? await this.getBlockNumber() : (block as BlockNumber);
|
|
@@ -1145,6 +1193,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1145
1193
|
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
1146
1194
|
}
|
|
1147
1195
|
|
|
1196
|
+
public getBlockData(number: BlockNumber): Promise<BlockData | undefined> {
|
|
1197
|
+
return this.blockSource.getBlockData(number);
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
public getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
|
|
1201
|
+
return this.blockSource.getBlockDataByArchive(archive);
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1148
1204
|
/**
|
|
1149
1205
|
* Simulates the public part of a transaction with the current state.
|
|
1150
1206
|
* @param tx - The transaction to simulate.
|
|
@@ -1168,7 +1224,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1168
1224
|
}
|
|
1169
1225
|
|
|
1170
1226
|
const txHash = tx.getTxHash();
|
|
1171
|
-
const
|
|
1227
|
+
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1228
|
+
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
1172
1229
|
|
|
1173
1230
|
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1174
1231
|
const coinbase = EthAddress.ZERO;
|
|
@@ -1183,6 +1240,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1183
1240
|
this.contractDataSource,
|
|
1184
1241
|
new DateProvider(),
|
|
1185
1242
|
this.telemetry,
|
|
1243
|
+
this.log.getBindings(),
|
|
1186
1244
|
);
|
|
1187
1245
|
|
|
1188
1246
|
this.log.verbose(`Simulating public calls for tx ${txHash}`, {
|
|
@@ -1191,6 +1249,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1191
1249
|
blockNumber,
|
|
1192
1250
|
});
|
|
1193
1251
|
|
|
1252
|
+
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1253
|
+
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1194
1254
|
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1195
1255
|
try {
|
|
1196
1256
|
const config = PublicSimulatorConfig.from({
|
|
@@ -1206,7 +1266,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1206
1266
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1207
1267
|
|
|
1208
1268
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1209
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([tx]);
|
|
1269
|
+
const [processedTxs, failedTxs, _usedTxs, returns, _blobFields, debugLogs] = await processor.process([tx]);
|
|
1210
1270
|
// REFACTOR: Consider returning the error rather than throwing
|
|
1211
1271
|
if (failedTxs.length) {
|
|
1212
1272
|
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
|
|
@@ -1220,6 +1280,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1220
1280
|
processedTx.txEffect,
|
|
1221
1281
|
returns,
|
|
1222
1282
|
processedTx.gasUsed,
|
|
1283
|
+
debugLogs,
|
|
1223
1284
|
);
|
|
1224
1285
|
} finally {
|
|
1225
1286
|
await merkleTreeFork.close();
|
|
@@ -1233,19 +1294,25 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1233
1294
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1234
1295
|
const verifier = isSimulation ? undefined : this.proofVerifier;
|
|
1235
1296
|
|
|
1236
|
-
// We accept transactions if they are not expired by the next slot (checked based on the
|
|
1297
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1237
1298
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1238
1299
|
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
1239
|
-
const validator =
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1300
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(
|
|
1301
|
+
db,
|
|
1302
|
+
this.contractDataSource,
|
|
1303
|
+
verifier,
|
|
1304
|
+
{
|
|
1305
|
+
timestamp: nextSlotTimestamp,
|
|
1306
|
+
blockNumber,
|
|
1307
|
+
l1ChainId: this.l1ChainId,
|
|
1308
|
+
rollupVersion: this.version,
|
|
1309
|
+
setupAllowList: this.config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions()),
|
|
1310
|
+
gasFees: await this.getCurrentMinFees(),
|
|
1311
|
+
skipFeeEnforcement,
|
|
1312
|
+
txsPermitted: !this.config.disableTransactions,
|
|
1313
|
+
},
|
|
1314
|
+
this.log.getBindings(),
|
|
1315
|
+
);
|
|
1249
1316
|
|
|
1250
1317
|
return await validator.validateTx(tx);
|
|
1251
1318
|
}
|
|
@@ -1409,7 +1476,95 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1409
1476
|
}
|
|
1410
1477
|
}
|
|
1411
1478
|
|
|
1412
|
-
|
|
1479
|
+
public async reloadKeystore(): Promise<void> {
|
|
1480
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
1481
|
+
throw new BadRequestError(
|
|
1482
|
+
'Cannot reload keystore: node is not using a file-based keystore. ' +
|
|
1483
|
+
'Set KEY_STORE_DIRECTORY to use file-based keystores.',
|
|
1484
|
+
);
|
|
1485
|
+
}
|
|
1486
|
+
if (!this.validatorClient) {
|
|
1487
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
this.log.info('Reloading keystore from disk');
|
|
1491
|
+
|
|
1492
|
+
// Re-read and validate keystore files
|
|
1493
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1494
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1495
|
+
await newManager.validateSigners();
|
|
1496
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1497
|
+
|
|
1498
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1499
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1500
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1501
|
+
// would silently fail on every proposer slot.
|
|
1502
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1503
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1504
|
+
const availablePublishers = new Set(
|
|
1505
|
+
oldAdapter
|
|
1506
|
+
.getAttesterAddresses()
|
|
1507
|
+
.flatMap(a => oldAdapter.getPublisherAddresses(a).map(p => p.toString().toLowerCase())),
|
|
1508
|
+
);
|
|
1509
|
+
|
|
1510
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1511
|
+
for (const attester of newAdapter.getAttesterAddresses()) {
|
|
1512
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1513
|
+
if (pubs.length > 0 && !pubs.some(p => availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1514
|
+
throw new BadRequestError(
|
|
1515
|
+
`Cannot reload keystore: validator ${attester} has publisher keys ` +
|
|
1516
|
+
`[${pubs.map(p => p.toString()).join(', ')}] but none match the L1 signers initialized at startup ` +
|
|
1517
|
+
`[${[...availablePublishers].join(', ')}]. Publishers cannot be hot-reloaded — ` +
|
|
1518
|
+
`use an existing publisher key or restart the node.`,
|
|
1519
|
+
);
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
// Build adapters for old and new keystores to compute diff
|
|
1525
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1526
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1527
|
+
const oldAddresses = this.keyStoreManager
|
|
1528
|
+
? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses()
|
|
1529
|
+
: [];
|
|
1530
|
+
|
|
1531
|
+
const oldSet = new Set(oldAddresses.map(a => a.toString()));
|
|
1532
|
+
const newSet = new Set(newAddresses.map(a => a.toString()));
|
|
1533
|
+
const added = newAddresses.filter(a => !oldSet.has(a.toString()));
|
|
1534
|
+
const removed = oldAddresses.filter(a => !newSet.has(a.toString()));
|
|
1535
|
+
|
|
1536
|
+
if (added.length > 0) {
|
|
1537
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map(a => a.toString()).join(', ')}`);
|
|
1538
|
+
}
|
|
1539
|
+
if (removed.length > 0) {
|
|
1540
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map(a => a.toString()).join(', ')}`);
|
|
1541
|
+
}
|
|
1542
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1543
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1547
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1548
|
+
|
|
1549
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1550
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1551
|
+
if (this.sequencer) {
|
|
1552
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1556
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1557
|
+
const slashValidatorsNever = unique(
|
|
1558
|
+
[...(this.config.slashValidatorsNever ?? []), ...newAddresses].map(a => a.toString()),
|
|
1559
|
+
).map(EthAddress.fromString);
|
|
1560
|
+
this.slasherClient.updateConfig({ slashValidatorsNever });
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
this.keyStoreManager = newManager;
|
|
1564
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
#getInitialHeaderHash(): Promise<BlockHash> {
|
|
1413
1568
|
if (!this.initialHeaderHashPromise) {
|
|
1414
1569
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
1415
1570
|
}
|
|
@@ -1435,15 +1590,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1435
1590
|
return this.worldStateSynchronizer.getCommitted();
|
|
1436
1591
|
}
|
|
1437
1592
|
|
|
1438
|
-
if (
|
|
1593
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1439
1594
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1440
1595
|
if (block.equals(initialBlockHash)) {
|
|
1441
1596
|
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1442
1597
|
return this.worldStateSynchronizer.getSnapshot(BlockNumber.ZERO);
|
|
1443
1598
|
}
|
|
1444
1599
|
|
|
1445
|
-
const
|
|
1446
|
-
const header = await this.blockSource.getBlockHeaderByHash(blockHashFr);
|
|
1600
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1447
1601
|
if (!header) {
|
|
1448
1602
|
throw new Error(
|
|
1449
1603
|
`Block hash ${block.toString()} not found when querying world state. If the node API has been queried with anchor block hash possibly a reorg has occurred.`,
|