@aztec/aztec-node 0.0.1-commit.8afd444 → 0.0.1-commit.934299a21
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 +18 -4
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +169 -28
- 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 +221 -33
- 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,7 +76,8 @@ 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
82
|
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
69
83
|
import type { Offense, SlashPayloadRound } from '@aztec/stdlib/slashing';
|
|
@@ -97,7 +111,6 @@ import {
|
|
|
97
111
|
ValidatorClient,
|
|
98
112
|
createBlockProposalHandler,
|
|
99
113
|
createValidatorClient,
|
|
100
|
-
createValidatorForAcceptingTxs,
|
|
101
114
|
} from '@aztec/validator-client';
|
|
102
115
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
103
116
|
|
|
@@ -129,6 +142,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
129
142
|
protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
|
|
130
143
|
protected readonly worldStateSynchronizer: WorldStateSynchronizer,
|
|
131
144
|
protected readonly sequencer: SequencerClient | undefined,
|
|
145
|
+
protected readonly proverNode: ProverNode | undefined,
|
|
132
146
|
protected readonly slasherClient: SlasherClientInterface | undefined,
|
|
133
147
|
protected readonly validatorsSentinel: Sentinel | undefined,
|
|
134
148
|
protected readonly epochPruneWatcher: EpochPruneWatcher | undefined,
|
|
@@ -141,12 +155,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
141
155
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
142
156
|
private log = createLogger('node'),
|
|
143
157
|
private blobClient?: BlobClientInterface,
|
|
158
|
+
private validatorClient?: ValidatorClient,
|
|
159
|
+
private keyStoreManager?: KeystoreManager,
|
|
160
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
144
161
|
) {
|
|
145
162
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
146
163
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
147
164
|
|
|
148
165
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
149
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
|
+
}
|
|
150
174
|
}
|
|
151
175
|
|
|
152
176
|
public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
|
|
@@ -171,10 +195,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
171
195
|
publisher?: SequencerPublisher;
|
|
172
196
|
dateProvider?: DateProvider;
|
|
173
197
|
p2pClientDeps?: P2PClientDeps<P2PClientType.Full>;
|
|
198
|
+
proverNodeDeps?: Partial<ProverNodeDeps>;
|
|
174
199
|
} = {},
|
|
175
200
|
options: {
|
|
176
201
|
prefilledPublicData?: PublicDataTreeLeaf[];
|
|
177
202
|
dontStartSequencer?: boolean;
|
|
203
|
+
dontStartProverNode?: boolean;
|
|
178
204
|
} = {},
|
|
179
205
|
): Promise<AztecNodeService> {
|
|
180
206
|
const config = { ...inputConfig }; // Copy the config so we dont mutate the input object
|
|
@@ -184,16 +210,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
184
210
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
185
211
|
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
186
212
|
|
|
187
|
-
// 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.
|
|
188
215
|
let keyStoreManager: KeystoreManager | undefined;
|
|
189
216
|
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
190
217
|
if (keyStoreProvided) {
|
|
191
218
|
const keyStores = loadKeystores(config.keyStoreDirectory!);
|
|
192
219
|
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
193
220
|
} else {
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
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
|
+
);
|
|
197
236
|
}
|
|
198
237
|
}
|
|
199
238
|
|
|
@@ -204,10 +243,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
204
243
|
if (keyStoreManager === undefined) {
|
|
205
244
|
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
206
245
|
}
|
|
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
|
-
);
|
|
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");
|
|
211
248
|
}
|
|
212
249
|
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
213
250
|
}
|
|
@@ -249,7 +286,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
249
286
|
);
|
|
250
287
|
}
|
|
251
288
|
|
|
252
|
-
const blobClient = await createBlobClientWithFileStores(config,
|
|
289
|
+
const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
|
|
253
290
|
|
|
254
291
|
// attempt snapshot sync if possible
|
|
255
292
|
await trySnapshotSync(config, log);
|
|
@@ -273,9 +310,19 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
273
310
|
config.realProofs || config.debugForceTxProofVerification
|
|
274
311
|
? await BBCircuitVerifier.new(config)
|
|
275
312
|
: new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
313
|
+
|
|
314
|
+
let debugLogStore: DebugLogStore;
|
|
276
315
|
if (!config.realProofs) {
|
|
277
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();
|
|
278
324
|
}
|
|
325
|
+
|
|
279
326
|
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
280
327
|
|
|
281
328
|
// create the tx pool and the p2p client, which will need the l2 block source
|
|
@@ -412,19 +459,19 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
412
459
|
);
|
|
413
460
|
await slasherClient.start();
|
|
414
461
|
|
|
415
|
-
const l1TxUtils = config.
|
|
416
|
-
? await
|
|
462
|
+
const l1TxUtils = config.sequencerPublisherForwarderAddress
|
|
463
|
+
? await createForwarderL1TxUtilsFromSigners(
|
|
417
464
|
publicClient,
|
|
418
465
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
419
|
-
config.
|
|
466
|
+
config.sequencerPublisherForwarderAddress,
|
|
420
467
|
{ ...config, scope: 'sequencer' },
|
|
421
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
468
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
422
469
|
)
|
|
423
|
-
: await
|
|
470
|
+
: await createL1TxUtilsFromSigners(
|
|
424
471
|
publicClient,
|
|
425
472
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
426
473
|
{ ...config, scope: 'sequencer' },
|
|
427
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
474
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
428
475
|
);
|
|
429
476
|
|
|
430
477
|
// Create and start the sequencer client
|
|
@@ -434,6 +481,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
434
481
|
archiver,
|
|
435
482
|
dateProvider,
|
|
436
483
|
telemetry,
|
|
484
|
+
debugLogStore,
|
|
437
485
|
);
|
|
438
486
|
|
|
439
487
|
sequencer = await SequencerClient.new(config, {
|
|
@@ -461,6 +509,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
461
509
|
log.warn(`Sequencer created but not started`);
|
|
462
510
|
}
|
|
463
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
|
+
|
|
464
535
|
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
465
536
|
...config,
|
|
466
537
|
rollupVersion: BigInt(config.rollupVersion),
|
|
@@ -468,7 +539,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
468
539
|
slotDuration: Number(slotDuration),
|
|
469
540
|
});
|
|
470
541
|
|
|
471
|
-
|
|
542
|
+
const node = new AztecNodeService(
|
|
472
543
|
config,
|
|
473
544
|
p2pClient,
|
|
474
545
|
archiver,
|
|
@@ -477,6 +548,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
477
548
|
archiver,
|
|
478
549
|
worldStateSynchronizer,
|
|
479
550
|
sequencer,
|
|
551
|
+
proverNode,
|
|
480
552
|
slasherClient,
|
|
481
553
|
validatorsSentinel,
|
|
482
554
|
epochPruneWatcher,
|
|
@@ -489,7 +561,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
489
561
|
telemetry,
|
|
490
562
|
log,
|
|
491
563
|
blobClient,
|
|
564
|
+
validatorClient,
|
|
565
|
+
keyStoreManager,
|
|
566
|
+
debugLogStore,
|
|
492
567
|
);
|
|
568
|
+
|
|
569
|
+
return node;
|
|
493
570
|
}
|
|
494
571
|
|
|
495
572
|
/**
|
|
@@ -500,6 +577,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
500
577
|
return this.sequencer;
|
|
501
578
|
}
|
|
502
579
|
|
|
580
|
+
/** Returns the prover node subsystem, if enabled. */
|
|
581
|
+
public getProverNode(): ProverNode | undefined {
|
|
582
|
+
return this.proverNode;
|
|
583
|
+
}
|
|
584
|
+
|
|
503
585
|
public getBlockSource(): L2BlockSource {
|
|
504
586
|
return this.blockSource;
|
|
505
587
|
}
|
|
@@ -553,6 +635,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
553
635
|
enr,
|
|
554
636
|
l1ContractAddresses: contractAddresses,
|
|
555
637
|
protocolContractAddresses: protocolContractAddresses,
|
|
638
|
+
realProofs: !!this.config.realProofs,
|
|
556
639
|
};
|
|
557
640
|
|
|
558
641
|
return nodeInfo;
|
|
@@ -774,18 +857,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
774
857
|
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
775
858
|
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
776
859
|
|
|
860
|
+
let receipt: TxReceipt;
|
|
777
861
|
if (settledTxReceipt) {
|
|
778
|
-
|
|
779
|
-
return settledTxReceipt;
|
|
862
|
+
receipt = settledTxReceipt;
|
|
780
863
|
} else if (isKnownToPool) {
|
|
781
864
|
// If the tx is in the pool but not in the archiver, it's pending.
|
|
782
865
|
// This handles race conditions between archiver and p2p, where the archiver
|
|
783
866
|
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
784
|
-
|
|
867
|
+
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
785
868
|
} else {
|
|
786
869
|
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
787
|
-
|
|
870
|
+
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
788
871
|
}
|
|
872
|
+
|
|
873
|
+
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
874
|
+
|
|
875
|
+
return receipt;
|
|
789
876
|
}
|
|
790
877
|
|
|
791
878
|
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
@@ -802,6 +889,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
802
889
|
await tryStop(this.slasherClient);
|
|
803
890
|
await tryStop(this.proofVerifier);
|
|
804
891
|
await tryStop(this.sequencer);
|
|
892
|
+
await tryStop(this.proverNode);
|
|
805
893
|
await tryStop(this.p2pClient);
|
|
806
894
|
await tryStop(this.worldStateSynchronizer);
|
|
807
895
|
await tryStop(this.blockSource);
|
|
@@ -1105,6 +1193,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1105
1193
|
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
1106
1194
|
}
|
|
1107
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
|
+
|
|
1108
1204
|
/**
|
|
1109
1205
|
* Simulates the public part of a transaction with the current state.
|
|
1110
1206
|
* @param tx - The transaction to simulate.
|
|
@@ -1128,7 +1224,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1128
1224
|
}
|
|
1129
1225
|
|
|
1130
1226
|
const txHash = tx.getTxHash();
|
|
1131
|
-
const
|
|
1227
|
+
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1228
|
+
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
1132
1229
|
|
|
1133
1230
|
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1134
1231
|
const coinbase = EthAddress.ZERO;
|
|
@@ -1152,6 +1249,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1152
1249
|
blockNumber,
|
|
1153
1250
|
});
|
|
1154
1251
|
|
|
1252
|
+
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1253
|
+
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1155
1254
|
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1156
1255
|
try {
|
|
1157
1256
|
const config = PublicSimulatorConfig.from({
|
|
@@ -1167,7 +1266,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1167
1266
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1168
1267
|
|
|
1169
1268
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1170
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([tx]);
|
|
1269
|
+
const [processedTxs, failedTxs, _usedTxs, returns, _blobFields, debugLogs] = await processor.process([tx]);
|
|
1171
1270
|
// REFACTOR: Consider returning the error rather than throwing
|
|
1172
1271
|
if (failedTxs.length) {
|
|
1173
1272
|
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
|
|
@@ -1181,6 +1280,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1181
1280
|
processedTx.txEffect,
|
|
1182
1281
|
returns,
|
|
1183
1282
|
processedTx.gasUsed,
|
|
1283
|
+
debugLogs,
|
|
1184
1284
|
);
|
|
1185
1285
|
} finally {
|
|
1186
1286
|
await merkleTreeFork.close();
|
|
@@ -1194,10 +1294,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1194
1294
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1195
1295
|
const verifier = isSimulation ? undefined : this.proofVerifier;
|
|
1196
1296
|
|
|
1197
|
-
// 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)
|
|
1198
1298
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1199
1299
|
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
1200
|
-
const validator =
|
|
1300
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(
|
|
1201
1301
|
db,
|
|
1202
1302
|
this.contractDataSource,
|
|
1203
1303
|
verifier,
|
|
@@ -1376,6 +1476,94 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1376
1476
|
}
|
|
1377
1477
|
}
|
|
1378
1478
|
|
|
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
|
+
|
|
1379
1567
|
#getInitialHeaderHash(): Promise<BlockHash> {
|
|
1380
1568
|
if (!this.initialHeaderHashPromise) {
|
|
1381
1569
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
package/src/sentinel/sentinel.ts
CHANGED
|
@@ -36,6 +36,17 @@ import EventEmitter from 'node:events';
|
|
|
36
36
|
|
|
37
37
|
import { SentinelStore } from './store.js';
|
|
38
38
|
|
|
39
|
+
/** Maps a validator status to its category: proposer or attestation. */
|
|
40
|
+
function statusToCategory(status: ValidatorStatusInSlot): ValidatorStatusType {
|
|
41
|
+
switch (status) {
|
|
42
|
+
case 'attestation-sent':
|
|
43
|
+
case 'attestation-missed':
|
|
44
|
+
return 'attestation';
|
|
45
|
+
default:
|
|
46
|
+
return 'proposer';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
39
50
|
export class Sentinel extends (EventEmitter as new () => WatcherEmitter) implements L2BlockStreamEventHandler, Watcher {
|
|
40
51
|
protected runningPromise: RunningPromise;
|
|
41
52
|
protected blockStream!: L2BlockStream;
|
|
@@ -128,15 +139,15 @@ export class Sentinel extends (EventEmitter as new () => WatcherEmitter) impleme
|
|
|
128
139
|
return;
|
|
129
140
|
}
|
|
130
141
|
const blockNumber = event.block.number;
|
|
131
|
-
const
|
|
132
|
-
if (!
|
|
133
|
-
this.logger.error(`Failed to get block ${blockNumber}
|
|
142
|
+
const header = await this.archiver.getBlockHeader(blockNumber);
|
|
143
|
+
if (!header) {
|
|
144
|
+
this.logger.error(`Failed to get block header ${blockNumber}`);
|
|
134
145
|
return;
|
|
135
146
|
}
|
|
136
147
|
|
|
137
148
|
// TODO(palla/slash): We should only be computing proven performance if this is
|
|
138
149
|
// a full proof epoch and not a partial one, otherwise we'll end up with skewed stats.
|
|
139
|
-
const epoch = getEpochAtSlot(
|
|
150
|
+
const epoch = getEpochAtSlot(header.getSlot(), this.epochCache.getL1Constants());
|
|
140
151
|
this.logger.debug(`Computing proven performance for epoch ${epoch}`);
|
|
141
152
|
const performance = await this.computeProvenPerformance(epoch);
|
|
142
153
|
this.logger.info(`Computed proven performance for epoch ${epoch}`, performance);
|
|
@@ -147,7 +158,11 @@ export class Sentinel extends (EventEmitter as new () => WatcherEmitter) impleme
|
|
|
147
158
|
|
|
148
159
|
protected async computeProvenPerformance(epoch: EpochNumber): Promise<ValidatorsEpochPerformance> {
|
|
149
160
|
const [fromSlot, toSlot] = getSlotRangeForEpoch(epoch, this.epochCache.getL1Constants());
|
|
150
|
-
const { committee } = await this.epochCache.getCommittee(fromSlot);
|
|
161
|
+
const { committee, isEscapeHatchOpen } = await this.epochCache.getCommittee(fromSlot);
|
|
162
|
+
if (isEscapeHatchOpen) {
|
|
163
|
+
this.logger.info(`Skipping proven performance for epoch ${epoch} - escape hatch is open`);
|
|
164
|
+
return {};
|
|
165
|
+
}
|
|
151
166
|
if (!committee) {
|
|
152
167
|
this.logger.trace(`No committee found for slot ${fromSlot}`);
|
|
153
168
|
return {};
|
|
@@ -316,7 +331,12 @@ export class Sentinel extends (EventEmitter as new () => WatcherEmitter) impleme
|
|
|
316
331
|
* and updates overall stats.
|
|
317
332
|
*/
|
|
318
333
|
protected async processSlot(slot: SlotNumber) {
|
|
319
|
-
const { epoch, seed, committee } = await this.epochCache.getCommittee(slot);
|
|
334
|
+
const { epoch, seed, committee, isEscapeHatchOpen } = await this.epochCache.getCommittee(slot);
|
|
335
|
+
if (isEscapeHatchOpen) {
|
|
336
|
+
this.logger.info(`Skipping slot ${slot} at epoch ${epoch} - escape hatch is open`);
|
|
337
|
+
this.lastProcessedSlot = slot;
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
320
340
|
if (!committee || committee.length === 0) {
|
|
321
341
|
this.logger.trace(`No committee found for slot ${slot} at epoch ${epoch}`);
|
|
322
342
|
this.lastProcessedSlot = slot;
|
|
@@ -336,16 +356,16 @@ export class Sentinel extends (EventEmitter as new () => WatcherEmitter) impleme
|
|
|
336
356
|
|
|
337
357
|
// Check if there is an L2 block in L1 for this L2 slot
|
|
338
358
|
|
|
339
|
-
// Here we get all attestations for the
|
|
340
|
-
// or all attestations for all proposals in the slot if no
|
|
359
|
+
// Here we get all checkpoint attestations for the checkpoint at the given slot,
|
|
360
|
+
// or all checkpoint attestations for all proposals in the slot if no checkpoint was mined.
|
|
341
361
|
// We gather from both p2p (contains the ones seen on the p2p layer) and archiver
|
|
342
|
-
// (contains the ones synced from mined
|
|
343
|
-
const
|
|
344
|
-
const p2pAttested = await this.p2p.getCheckpointAttestationsForSlot(slot,
|
|
362
|
+
// (contains the ones synced from mined checkpoints, which we may have missed from p2p).
|
|
363
|
+
const checkpoint = this.slotNumberToCheckpoint.get(slot);
|
|
364
|
+
const p2pAttested = await this.p2p.getCheckpointAttestationsForSlot(slot, checkpoint?.archive);
|
|
345
365
|
// Filter out attestations with invalid signatures
|
|
346
366
|
const p2pAttestors = p2pAttested.map(a => a.getSender()).filter((s): s is EthAddress => s !== undefined);
|
|
347
367
|
const attestors = new Set(
|
|
348
|
-
[...p2pAttestors.map(a => a.toString()), ...(
|
|
368
|
+
[...p2pAttestors.map(a => a.toString()), ...(checkpoint?.attestors.map(a => a.toString()) ?? [])].filter(
|
|
349
369
|
addr => proposer.toString() !== addr, // Exclude the proposer from the attestors
|
|
350
370
|
),
|
|
351
371
|
);
|
|
@@ -356,20 +376,29 @@ export class Sentinel extends (EventEmitter as new () => WatcherEmitter) impleme
|
|
|
356
376
|
// But we'll leave that corner case out to reduce pressure on the node.
|
|
357
377
|
// TODO(palla/slash): This breaks if a given node has more than one validator in the current committee,
|
|
358
378
|
// since they will attest to their own proposal it even if it's not re-executable.
|
|
359
|
-
|
|
360
|
-
|
|
379
|
+
let status: 'checkpoint-mined' | 'checkpoint-proposed' | 'checkpoint-missed' | 'blocks-missed';
|
|
380
|
+
if (checkpoint) {
|
|
381
|
+
status = 'checkpoint-mined';
|
|
382
|
+
} else if (attestors.size > 0) {
|
|
383
|
+
status = 'checkpoint-proposed';
|
|
384
|
+
} else {
|
|
385
|
+
// No checkpoint on L1 and no checkpoint attestations seen. Check if block proposals were sent for this slot.
|
|
386
|
+
const hasBlockProposals = await this.p2p.hasBlockProposalsForSlot(slot);
|
|
387
|
+
status = hasBlockProposals ? 'checkpoint-missed' : 'blocks-missed';
|
|
388
|
+
}
|
|
389
|
+
this.logger.debug(`Checkpoint status for slot ${slot}: ${status}`, { ...checkpoint, slot });
|
|
361
390
|
|
|
362
|
-
// Get attestors that failed their
|
|
391
|
+
// Get attestors that failed their checkpoint attestation duties, but only if there was a checkpoint proposed or mined
|
|
363
392
|
const missedAttestors = new Set(
|
|
364
|
-
|
|
393
|
+
status === 'blocks-missed' || status === 'checkpoint-missed'
|
|
365
394
|
? []
|
|
366
395
|
: committee.filter(v => !attestors.has(v.toString()) && !proposer.equals(v)).map(v => v.toString()),
|
|
367
396
|
);
|
|
368
397
|
|
|
369
398
|
this.logger.debug(`Retrieved ${attestors.size} attestors out of ${committee.length} for slot ${slot}`, {
|
|
370
|
-
|
|
399
|
+
status,
|
|
371
400
|
proposer: proposer.toString(),
|
|
372
|
-
...
|
|
401
|
+
...checkpoint,
|
|
373
402
|
slot,
|
|
374
403
|
attestors: [...attestors],
|
|
375
404
|
missedAttestors: [...missedAttestors],
|
|
@@ -379,7 +408,7 @@ export class Sentinel extends (EventEmitter as new () => WatcherEmitter) impleme
|
|
|
379
408
|
// Compute the status for each validator in the committee
|
|
380
409
|
const statusFor = (who: `0x${string}`): ValidatorStatusInSlot | undefined => {
|
|
381
410
|
if (who === proposer.toString()) {
|
|
382
|
-
return
|
|
411
|
+
return status;
|
|
383
412
|
} else if (attestors.has(who)) {
|
|
384
413
|
return 'attestation-sent';
|
|
385
414
|
} else if (missedAttestors.has(who)) {
|
|
@@ -472,14 +501,16 @@ export class Sentinel extends (EventEmitter as new () => WatcherEmitter) impleme
|
|
|
472
501
|
): ValidatorStats {
|
|
473
502
|
let history = fromSlot ? allHistory.filter(h => BigInt(h.slot) >= fromSlot) : allHistory;
|
|
474
503
|
history = toSlot ? history.filter(h => BigInt(h.slot) <= toSlot) : history;
|
|
475
|
-
const lastProposal = history
|
|
504
|
+
const lastProposal = history
|
|
505
|
+
.filter(h => h.status === 'checkpoint-proposed' || h.status === 'checkpoint-mined')
|
|
506
|
+
.at(-1);
|
|
476
507
|
const lastAttestation = history.filter(h => h.status === 'attestation-sent').at(-1);
|
|
477
508
|
return {
|
|
478
509
|
address: EthAddress.fromString(address),
|
|
479
510
|
lastProposal: this.computeFromSlot(lastProposal?.slot),
|
|
480
511
|
lastAttestation: this.computeFromSlot(lastAttestation?.slot),
|
|
481
512
|
totalSlots: history.length,
|
|
482
|
-
missedProposals: this.computeMissed(history, '
|
|
513
|
+
missedProposals: this.computeMissed(history, 'proposer', ['checkpoint-missed', 'blocks-missed']),
|
|
483
514
|
missedAttestations: this.computeMissed(history, 'attestation', ['attestation-missed']),
|
|
484
515
|
history,
|
|
485
516
|
};
|
|
@@ -487,10 +518,12 @@ export class Sentinel extends (EventEmitter as new () => WatcherEmitter) impleme
|
|
|
487
518
|
|
|
488
519
|
protected computeMissed(
|
|
489
520
|
history: ValidatorStatusHistory,
|
|
490
|
-
|
|
521
|
+
computeOverCategory: ValidatorStatusType | undefined,
|
|
491
522
|
filter: ValidatorStatusInSlot[],
|
|
492
523
|
) {
|
|
493
|
-
const relevantHistory = history.filter(
|
|
524
|
+
const relevantHistory = history.filter(
|
|
525
|
+
h => !computeOverCategory || statusToCategory(h.status) === computeOverCategory,
|
|
526
|
+
);
|
|
494
527
|
const filteredHistory = relevantHistory.filter(h => filter.includes(h.status));
|
|
495
528
|
return {
|
|
496
529
|
currentStreak: countWhile([...relevantHistory].reverse(), h => filter.includes(h.status)),
|