@aztec/aztec-node 0.0.1-commit.9d2bcf6d → 0.0.1-commit.9ee6fcc6
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 +8 -5
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +11 -3
- package/dest/aztec-node/server.d.ts +36 -23
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +413 -178
- package/dest/sentinel/factory.d.ts +2 -2
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/sentinel.d.ts +2 -2
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +61 -35
- 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 +26 -25
- package/src/aztec-node/config.ts +25 -9
- package/src/aztec-node/server.ts +478 -192
- package/src/sentinel/factory.ts +1 -1
- package/src/sentinel/sentinel.ts +64 -31
- package/src/sentinel/store.ts +12 -12
package/src/aztec-node/server.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Archiver, createArchiver } from '@aztec/archiver';
|
|
2
|
-
import { BBCircuitVerifier,
|
|
2
|
+
import { BBCircuitVerifier, BatchChonkVerifier, QueuedIVCVerifier } from '@aztec/bb-prover';
|
|
3
|
+
import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
3
4
|
import { type BlobClientInterface, createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
5
|
+
import { Blob } from '@aztec/blob-lib';
|
|
4
6
|
import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
5
7
|
import { EpochCache, type EpochCacheInterface } from '@aztec/epoch-cache';
|
|
6
8
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
7
|
-
import { getPublicClient } from '@aztec/ethereum/client';
|
|
9
|
+
import { getPublicClient, makeL1HttpTransport } from '@aztec/ethereum/client';
|
|
8
10
|
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
9
11
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
12
|
+
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
10
13
|
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
11
|
-
import { compactArray, pick } from '@aztec/foundation/collection';
|
|
14
|
+
import { chunkBy, compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
12
15
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
16
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
14
17
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
@@ -16,14 +19,19 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
|
16
19
|
import { count } from '@aztec/foundation/string';
|
|
17
20
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
18
21
|
import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
|
|
19
|
-
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
22
|
+
import { type KeyStore, KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
20
23
|
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
24
|
+
import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
|
|
21
25
|
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
type P2P,
|
|
27
|
+
type P2PClientDeps,
|
|
28
|
+
createP2PClient,
|
|
29
|
+
createTxValidatorForAcceptingTxsOverRPC,
|
|
30
|
+
getDefaultAllowedSetupFunctions,
|
|
31
|
+
} from '@aztec/p2p';
|
|
26
32
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
33
|
+
import { type ProverNode, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
|
|
34
|
+
import { createKeyStoreForProver } from '@aztec/prover-node/config';
|
|
27
35
|
import { GlobalVariableBuilder, SequencerClient, type SequencerPublisher } from '@aztec/sequencer-client';
|
|
28
36
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
29
37
|
import {
|
|
@@ -35,7 +43,14 @@ import {
|
|
|
35
43
|
} from '@aztec/slasher';
|
|
36
44
|
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
37
45
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
38
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
type BlockData,
|
|
48
|
+
BlockHash,
|
|
49
|
+
type BlockParameter,
|
|
50
|
+
type DataInBlock,
|
|
51
|
+
L2Block,
|
|
52
|
+
type L2BlockSource,
|
|
53
|
+
} from '@aztec/stdlib/block';
|
|
39
54
|
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
40
55
|
import type {
|
|
41
56
|
ContractClassPublic,
|
|
@@ -63,9 +78,9 @@ import {
|
|
|
63
78
|
type WorldStateSynchronizer,
|
|
64
79
|
tryStop,
|
|
65
80
|
} from '@aztec/stdlib/interfaces/server';
|
|
66
|
-
import type { LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
81
|
+
import type { DebugLogStore, LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
82
|
+
import { InMemoryDebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
67
83
|
import { InboxLeaf, type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
68
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
69
84
|
import type { Offense, SlashPayloadRound } from '@aztec/stdlib/slashing';
|
|
70
85
|
import type { NullifierLeafPreimage, PublicDataTreeLeaf, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
71
86
|
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
@@ -97,11 +112,11 @@ import {
|
|
|
97
112
|
ValidatorClient,
|
|
98
113
|
createBlockProposalHandler,
|
|
99
114
|
createValidatorClient,
|
|
100
|
-
createValidatorForAcceptingTxs,
|
|
101
115
|
} from '@aztec/validator-client';
|
|
116
|
+
import type { SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
|
|
102
117
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
103
118
|
|
|
104
|
-
import { createPublicClient
|
|
119
|
+
import { createPublicClient } from 'viem';
|
|
105
120
|
|
|
106
121
|
import { createSentinel } from '../sentinel/factory.js';
|
|
107
122
|
import { Sentinel } from '../sentinel/sentinel.js';
|
|
@@ -129,6 +144,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
129
144
|
protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
|
|
130
145
|
protected readonly worldStateSynchronizer: WorldStateSynchronizer,
|
|
131
146
|
protected readonly sequencer: SequencerClient | undefined,
|
|
147
|
+
protected readonly proverNode: ProverNode | undefined,
|
|
132
148
|
protected readonly slasherClient: SlasherClientInterface | undefined,
|
|
133
149
|
protected readonly validatorsSentinel: Sentinel | undefined,
|
|
134
150
|
protected readonly epochPruneWatcher: EpochPruneWatcher | undefined,
|
|
@@ -137,16 +153,32 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
137
153
|
protected readonly globalVariableBuilder: GlobalVariableBuilderInterface,
|
|
138
154
|
protected readonly epochCache: EpochCacheInterface,
|
|
139
155
|
protected readonly packageVersion: string,
|
|
140
|
-
private
|
|
156
|
+
private peerProofVerifier: ClientProtocolCircuitVerifier,
|
|
157
|
+
private rpcProofVerifier: ClientProtocolCircuitVerifier,
|
|
141
158
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
142
159
|
private log = createLogger('node'),
|
|
143
160
|
private blobClient?: BlobClientInterface,
|
|
161
|
+
private validatorClient?: ValidatorClient,
|
|
162
|
+
private keyStoreManager?: KeystoreManager,
|
|
163
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
144
164
|
) {
|
|
145
165
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
146
166
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
147
167
|
|
|
148
168
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
149
169
|
this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config.l1Contracts);
|
|
170
|
+
|
|
171
|
+
// A defensive check that protects us against introducing a bug in the complex `createAndSync` function. We must
|
|
172
|
+
// never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
|
|
173
|
+
// memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
|
|
174
|
+
if (debugLogStore.isEnabled && config.realProofs) {
|
|
175
|
+
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** @internal Exposed for testing — returns the RPC proof verifier. */
|
|
180
|
+
public getProofVerifier(): ClientProtocolCircuitVerifier {
|
|
181
|
+
return this.rpcProofVerifier;
|
|
150
182
|
}
|
|
151
183
|
|
|
152
184
|
public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
|
|
@@ -170,11 +202,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
170
202
|
logger?: Logger;
|
|
171
203
|
publisher?: SequencerPublisher;
|
|
172
204
|
dateProvider?: DateProvider;
|
|
173
|
-
p2pClientDeps?: P2PClientDeps
|
|
205
|
+
p2pClientDeps?: P2PClientDeps;
|
|
206
|
+
proverNodeDeps?: Partial<ProverNodeDeps>;
|
|
207
|
+
slashingProtectionDb?: SlashingProtectionDatabase;
|
|
174
208
|
} = {},
|
|
175
209
|
options: {
|
|
176
210
|
prefilledPublicData?: PublicDataTreeLeaf[];
|
|
177
211
|
dontStartSequencer?: boolean;
|
|
212
|
+
dontStartProverNode?: boolean;
|
|
178
213
|
} = {},
|
|
179
214
|
): Promise<AztecNodeService> {
|
|
180
215
|
const config = { ...inputConfig }; // Copy the config so we dont mutate the input object
|
|
@@ -184,16 +219,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
184
219
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
185
220
|
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
186
221
|
|
|
187
|
-
// Build a key store from file if given or from environment otherwise
|
|
222
|
+
// Build a key store from file if given or from environment otherwise.
|
|
223
|
+
// We keep the raw KeyStore available so we can merge with prover keys if enableProverNode is set.
|
|
188
224
|
let keyStoreManager: KeystoreManager | undefined;
|
|
189
225
|
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
190
226
|
if (keyStoreProvided) {
|
|
191
227
|
const keyStores = loadKeystores(config.keyStoreDirectory!);
|
|
192
228
|
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
193
229
|
} else {
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
230
|
+
const rawKeyStores: KeyStore[] = [];
|
|
231
|
+
const validatorKeyStore = createKeyStoreForValidator(config);
|
|
232
|
+
if (validatorKeyStore) {
|
|
233
|
+
rawKeyStores.push(validatorKeyStore);
|
|
234
|
+
}
|
|
235
|
+
if (config.enableProverNode) {
|
|
236
|
+
const proverKeyStore = createKeyStoreForProver(config);
|
|
237
|
+
if (proverKeyStore) {
|
|
238
|
+
rawKeyStores.push(proverKeyStore);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (rawKeyStores.length > 0) {
|
|
242
|
+
keyStoreManager = new KeystoreManager(
|
|
243
|
+
rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores),
|
|
244
|
+
);
|
|
197
245
|
}
|
|
198
246
|
}
|
|
199
247
|
|
|
@@ -204,10 +252,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
204
252
|
if (keyStoreManager === undefined) {
|
|
205
253
|
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
206
254
|
}
|
|
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
|
-
);
|
|
255
|
+
if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
|
|
256
|
+
log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
|
|
211
257
|
}
|
|
212
258
|
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
213
259
|
}
|
|
@@ -221,7 +267,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
221
267
|
|
|
222
268
|
const publicClient = createPublicClient({
|
|
223
269
|
chain: ethereumChain.chainInfo,
|
|
224
|
-
transport:
|
|
270
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, { timeout: config.l1HttpTimeoutMS }),
|
|
225
271
|
pollingInterval: config.viemPollingIntervalMS,
|
|
226
272
|
});
|
|
227
273
|
|
|
@@ -235,10 +281,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
235
281
|
config.l1Contracts = { ...config.l1Contracts, ...l1ContractsAddresses };
|
|
236
282
|
|
|
237
283
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
238
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
284
|
+
const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
|
|
239
285
|
rollupContract.getL1GenesisTime(),
|
|
240
286
|
rollupContract.getSlotDuration(),
|
|
241
287
|
rollupContract.getVersion(),
|
|
288
|
+
rollupContract.getManaLimit().then(Number),
|
|
242
289
|
] as const);
|
|
243
290
|
|
|
244
291
|
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
@@ -249,7 +296,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
249
296
|
);
|
|
250
297
|
}
|
|
251
298
|
|
|
252
|
-
const blobClient = await createBlobClientWithFileStores(config,
|
|
299
|
+
const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
|
|
253
300
|
|
|
254
301
|
// attempt snapshot sync if possible
|
|
255
302
|
await trySnapshotSync(config, log);
|
|
@@ -269,21 +316,40 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
269
316
|
options.prefilledPublicData,
|
|
270
317
|
telemetry,
|
|
271
318
|
);
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
319
|
+
const useRealVerifiers = config.realProofs || config.debugForceTxProofVerification;
|
|
320
|
+
let peerProofVerifier: ClientProtocolCircuitVerifier;
|
|
321
|
+
let rpcProofVerifier: ClientProtocolCircuitVerifier;
|
|
322
|
+
if (useRealVerifiers) {
|
|
323
|
+
peerProofVerifier = await BatchChonkVerifier.new(config, config.bbChonkVerifyMaxBatch, 'peer');
|
|
324
|
+
const rpcVerifier = await BBCircuitVerifier.new(config);
|
|
325
|
+
rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, config.numConcurrentIVCVerifiers);
|
|
326
|
+
} else {
|
|
327
|
+
peerProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
328
|
+
rpcProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
let debugLogStore: DebugLogStore;
|
|
276
332
|
if (!config.realProofs) {
|
|
277
333
|
log.warn(`Aztec node is accepting fake proofs`);
|
|
334
|
+
|
|
335
|
+
debugLogStore = new InMemoryDebugLogStore();
|
|
336
|
+
log.info(
|
|
337
|
+
'Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served',
|
|
338
|
+
);
|
|
339
|
+
} else {
|
|
340
|
+
debugLogStore = new NullDebugLogStore();
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
344
|
+
if (proverOnly) {
|
|
345
|
+
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
278
346
|
}
|
|
279
|
-
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
280
347
|
|
|
281
348
|
// create the tx pool and the p2p client, which will need the l2 block source
|
|
282
349
|
const p2pClient = await createP2PClient(
|
|
283
|
-
P2PClientType.Full,
|
|
284
350
|
config,
|
|
285
351
|
archiver,
|
|
286
|
-
|
|
352
|
+
peerProofVerifier,
|
|
287
353
|
worldStateSynchronizer,
|
|
288
354
|
epochCache,
|
|
289
355
|
packageVersion,
|
|
@@ -292,49 +358,60 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
292
358
|
deps.p2pClientDeps,
|
|
293
359
|
);
|
|
294
360
|
|
|
295
|
-
// We
|
|
296
|
-
|
|
361
|
+
// We'll accumulate sentinel watchers here
|
|
362
|
+
const watchers: Watcher[] = [];
|
|
297
363
|
|
|
298
|
-
// Create FullNodeCheckpointsBuilder for
|
|
364
|
+
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
365
|
+
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
299
366
|
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder(
|
|
300
|
-
{
|
|
367
|
+
{
|
|
368
|
+
...config,
|
|
369
|
+
l1GenesisTime,
|
|
370
|
+
slotDuration: Number(slotDuration),
|
|
371
|
+
rollupManaLimit,
|
|
372
|
+
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint,
|
|
373
|
+
},
|
|
301
374
|
worldStateSynchronizer,
|
|
302
375
|
archiver,
|
|
303
376
|
dateProvider,
|
|
304
377
|
telemetry,
|
|
305
378
|
);
|
|
306
379
|
|
|
307
|
-
|
|
308
|
-
const watchers: Watcher[] = [];
|
|
380
|
+
let validatorClient: ValidatorClient | undefined;
|
|
309
381
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
382
|
+
if (!proverOnly) {
|
|
383
|
+
// Create validator client if required
|
|
384
|
+
validatorClient = await createValidatorClient(config, {
|
|
385
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
386
|
+
worldState: worldStateSynchronizer,
|
|
387
|
+
p2pClient,
|
|
388
|
+
telemetry,
|
|
389
|
+
dateProvider,
|
|
390
|
+
epochCache,
|
|
391
|
+
blockSource: archiver,
|
|
392
|
+
l1ToL2MessageSource: archiver,
|
|
393
|
+
keyStoreManager,
|
|
394
|
+
blobClient,
|
|
395
|
+
slashingProtectionDb: deps.slashingProtectionDb,
|
|
396
|
+
});
|
|
323
397
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
398
|
+
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
399
|
+
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
400
|
+
// like attestations or auths will fail.
|
|
401
|
+
if (validatorClient) {
|
|
402
|
+
watchers.push(validatorClient);
|
|
403
|
+
if (!options.dontStartSequencer) {
|
|
404
|
+
await validatorClient.registerHandlers();
|
|
405
|
+
}
|
|
331
406
|
}
|
|
332
407
|
}
|
|
333
408
|
|
|
334
|
-
// If there's no validator client
|
|
335
|
-
//
|
|
336
|
-
|
|
337
|
-
|
|
409
|
+
// If there's no validator client, create a BlockProposalHandler to handle block proposals
|
|
410
|
+
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
411
|
+
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
412
|
+
if (!validatorClient) {
|
|
413
|
+
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
414
|
+
log.info(`Setting up block proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
338
415
|
createBlockProposalHandler(config, {
|
|
339
416
|
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
340
417
|
worldState: worldStateSynchronizer,
|
|
@@ -344,7 +421,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
344
421
|
p2pClient,
|
|
345
422
|
dateProvider,
|
|
346
423
|
telemetry,
|
|
347
|
-
}).
|
|
424
|
+
}).register(p2pClient, reexecute);
|
|
348
425
|
}
|
|
349
426
|
|
|
350
427
|
// Start world state and wait for it to sync to the archiver.
|
|
@@ -353,29 +430,33 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
353
430
|
// Start p2p. Note that it depends on world state to be running.
|
|
354
431
|
await p2pClient.start();
|
|
355
432
|
|
|
356
|
-
|
|
357
|
-
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
358
|
-
watchers.push(validatorsSentinel);
|
|
359
|
-
}
|
|
360
|
-
|
|
433
|
+
let validatorsSentinel: Awaited<ReturnType<typeof createSentinel>> | undefined;
|
|
361
434
|
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
435
|
let attestationsBlockWatcher: AttestationsBlockWatcher | undefined;
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
436
|
+
|
|
437
|
+
if (!proverOnly) {
|
|
438
|
+
validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
439
|
+
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
440
|
+
watchers.push(validatorsSentinel);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
444
|
+
epochPruneWatcher = new EpochPruneWatcher(
|
|
445
|
+
archiver,
|
|
446
|
+
archiver,
|
|
447
|
+
epochCache,
|
|
448
|
+
p2pClient.getTxProvider(),
|
|
449
|
+
validatorCheckpointsBuilder,
|
|
450
|
+
config,
|
|
451
|
+
);
|
|
452
|
+
watchers.push(epochPruneWatcher);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
456
|
+
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
457
|
+
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
458
|
+
watchers.push(attestationsBlockWatcher);
|
|
459
|
+
}
|
|
379
460
|
}
|
|
380
461
|
|
|
381
462
|
// Start p2p-related services once the archiver has completed sync
|
|
@@ -390,6 +471,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
390
471
|
})
|
|
391
472
|
.catch(err => log.error('Failed to start p2p services after archiver sync', err));
|
|
392
473
|
|
|
474
|
+
const globalVariableBuilder = new GlobalVariableBuilder(dateProvider, publicClient, {
|
|
475
|
+
l1Contracts: config.l1Contracts,
|
|
476
|
+
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
477
|
+
rollupVersion: BigInt(config.rollupVersion),
|
|
478
|
+
l1GenesisTime,
|
|
479
|
+
slotDuration: Number(slotDuration),
|
|
480
|
+
});
|
|
481
|
+
|
|
393
482
|
// Validator enabled, create/start relevant service
|
|
394
483
|
let sequencer: SequencerClient | undefined;
|
|
395
484
|
let slasherClient: SlasherClientInterface | undefined;
|
|
@@ -412,34 +501,49 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
412
501
|
);
|
|
413
502
|
await slasherClient.start();
|
|
414
503
|
|
|
415
|
-
const l1TxUtils = config.
|
|
416
|
-
? await
|
|
504
|
+
const l1TxUtils = config.sequencerPublisherForwarderAddress
|
|
505
|
+
? await createForwarderL1TxUtilsFromSigners(
|
|
417
506
|
publicClient,
|
|
418
507
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
419
|
-
config.
|
|
508
|
+
config.sequencerPublisherForwarderAddress,
|
|
420
509
|
{ ...config, scope: 'sequencer' },
|
|
421
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
510
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
422
511
|
)
|
|
423
|
-
: await
|
|
512
|
+
: await createL1TxUtilsFromSigners(
|
|
424
513
|
publicClient,
|
|
425
514
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
426
515
|
{ ...config, scope: 'sequencer' },
|
|
427
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
516
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
428
517
|
);
|
|
429
518
|
|
|
519
|
+
// Create a funder L1TxUtils from the keystore funding account (if configured)
|
|
520
|
+
const fundingSigner = keyStoreManager?.createFundingSigner();
|
|
521
|
+
let funderL1TxUtils: L1TxUtils | undefined;
|
|
522
|
+
if (fundingSigner) {
|
|
523
|
+
const [funder] = await createL1TxUtilsFromSigners(
|
|
524
|
+
publicClient,
|
|
525
|
+
[fundingSigner],
|
|
526
|
+
{ ...config, scope: 'sequencer' },
|
|
527
|
+
{ telemetry, logger: log.createChild('l1-tx-utils:funder'), dateProvider },
|
|
528
|
+
);
|
|
529
|
+
funderL1TxUtils = funder;
|
|
530
|
+
}
|
|
531
|
+
|
|
430
532
|
// Create and start the sequencer client
|
|
431
533
|
const checkpointsBuilder = new CheckpointsBuilder(
|
|
432
|
-
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
|
|
534
|
+
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration), rollupManaLimit },
|
|
433
535
|
worldStateSynchronizer,
|
|
434
536
|
archiver,
|
|
435
537
|
dateProvider,
|
|
436
538
|
telemetry,
|
|
539
|
+
debugLogStore,
|
|
437
540
|
);
|
|
438
541
|
|
|
439
542
|
sequencer = await SequencerClient.new(config, {
|
|
440
543
|
...deps,
|
|
441
544
|
epochCache,
|
|
442
545
|
l1TxUtils,
|
|
546
|
+
funderL1TxUtils,
|
|
443
547
|
validatorClient,
|
|
444
548
|
p2pClient,
|
|
445
549
|
worldStateSynchronizer,
|
|
@@ -451,6 +555,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
451
555
|
dateProvider,
|
|
452
556
|
blobClient,
|
|
453
557
|
nodeKeyStore: keyStoreManager!,
|
|
558
|
+
globalVariableBuilder,
|
|
454
559
|
});
|
|
455
560
|
}
|
|
456
561
|
|
|
@@ -461,14 +566,30 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
461
566
|
log.warn(`Sequencer created but not started`);
|
|
462
567
|
}
|
|
463
568
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
569
|
+
// Create prover node subsystem if enabled
|
|
570
|
+
let proverNode: ProverNode | undefined;
|
|
571
|
+
if (config.enableProverNode) {
|
|
572
|
+
proverNode = await createProverNode(config, {
|
|
573
|
+
...deps.proverNodeDeps,
|
|
574
|
+
telemetry,
|
|
575
|
+
dateProvider,
|
|
576
|
+
archiver,
|
|
577
|
+
worldStateSynchronizer,
|
|
578
|
+
p2pClient,
|
|
579
|
+
epochCache,
|
|
580
|
+
blobClient,
|
|
581
|
+
keyStoreManager,
|
|
582
|
+
});
|
|
470
583
|
|
|
471
|
-
|
|
584
|
+
if (!options.dontStartProverNode) {
|
|
585
|
+
await proverNode.start();
|
|
586
|
+
log.info(`Prover node subsystem started`);
|
|
587
|
+
} else {
|
|
588
|
+
log.info(`Prover node subsystem created but not started`);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
const node = new AztecNodeService(
|
|
472
593
|
config,
|
|
473
594
|
p2pClient,
|
|
474
595
|
archiver,
|
|
@@ -477,6 +598,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
477
598
|
archiver,
|
|
478
599
|
worldStateSynchronizer,
|
|
479
600
|
sequencer,
|
|
601
|
+
proverNode,
|
|
480
602
|
slasherClient,
|
|
481
603
|
validatorsSentinel,
|
|
482
604
|
epochPruneWatcher,
|
|
@@ -485,11 +607,17 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
485
607
|
globalVariableBuilder,
|
|
486
608
|
epochCache,
|
|
487
609
|
packageVersion,
|
|
488
|
-
|
|
610
|
+
peerProofVerifier,
|
|
611
|
+
rpcProofVerifier,
|
|
489
612
|
telemetry,
|
|
490
613
|
log,
|
|
491
614
|
blobClient,
|
|
615
|
+
validatorClient,
|
|
616
|
+
keyStoreManager,
|
|
617
|
+
debugLogStore,
|
|
492
618
|
);
|
|
619
|
+
|
|
620
|
+
return node;
|
|
493
621
|
}
|
|
494
622
|
|
|
495
623
|
/**
|
|
@@ -500,6 +628,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
500
628
|
return this.sequencer;
|
|
501
629
|
}
|
|
502
630
|
|
|
631
|
+
/** Returns the prover node subsystem, if enabled. */
|
|
632
|
+
public getProverNode(): ProverNode | undefined {
|
|
633
|
+
return this.proverNode;
|
|
634
|
+
}
|
|
635
|
+
|
|
503
636
|
public getBlockSource(): L2BlockSource {
|
|
504
637
|
return this.blockSource;
|
|
505
638
|
}
|
|
@@ -525,7 +658,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
525
658
|
}
|
|
526
659
|
|
|
527
660
|
public async getAllowedPublicSetup(): Promise<AllowedElement[]> {
|
|
528
|
-
return this.config.
|
|
661
|
+
return [...(await getDefaultAllowedSetupFunctions()), ...(this.config.txPublicSetupAllowListExtend ?? [])];
|
|
529
662
|
}
|
|
530
663
|
|
|
531
664
|
/**
|
|
@@ -553,6 +686,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
553
686
|
enr,
|
|
554
687
|
l1ContractAddresses: contractAddresses,
|
|
555
688
|
protocolContractAddresses: protocolContractAddresses,
|
|
689
|
+
realProofs: !!this.config.realProofs,
|
|
556
690
|
};
|
|
557
691
|
|
|
558
692
|
return nodeInfo;
|
|
@@ -619,6 +753,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
619
753
|
return (await this.blockSource.getCheckpointedBlocks(from, limit)) ?? [];
|
|
620
754
|
}
|
|
621
755
|
|
|
756
|
+
public getCheckpointsDataForEpoch(epochNumber: EpochNumber) {
|
|
757
|
+
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
758
|
+
}
|
|
759
|
+
|
|
622
760
|
/**
|
|
623
761
|
* Method to fetch the current min L2 fees.
|
|
624
762
|
* @returns The current min L2 fees.
|
|
@@ -651,6 +789,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
651
789
|
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
652
790
|
}
|
|
653
791
|
|
|
792
|
+
public getCheckpointNumber(): Promise<CheckpointNumber> {
|
|
793
|
+
return this.blockSource.getCheckpointNumber();
|
|
794
|
+
}
|
|
795
|
+
|
|
654
796
|
/**
|
|
655
797
|
* Method to fetch the version of the package.
|
|
656
798
|
* @returns The node package version
|
|
@@ -688,18 +830,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
688
830
|
page?: number,
|
|
689
831
|
referenceBlock?: BlockHash,
|
|
690
832
|
): Promise<TxScopedL2Log[][]> {
|
|
833
|
+
let upToBlockNumber: BlockNumber | undefined;
|
|
691
834
|
if (referenceBlock) {
|
|
692
835
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
693
|
-
if (
|
|
836
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
837
|
+
upToBlockNumber = BlockNumber(0);
|
|
838
|
+
} else {
|
|
694
839
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
695
840
|
if (!header) {
|
|
696
841
|
throw new Error(
|
|
697
842
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
698
843
|
);
|
|
699
844
|
}
|
|
845
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
700
846
|
}
|
|
701
847
|
}
|
|
702
|
-
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
848
|
+
return this.logsSource.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
703
849
|
}
|
|
704
850
|
|
|
705
851
|
public async getPublicLogsByTagsFromContract(
|
|
@@ -708,18 +854,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
708
854
|
page?: number,
|
|
709
855
|
referenceBlock?: BlockHash,
|
|
710
856
|
): Promise<TxScopedL2Log[][]> {
|
|
857
|
+
let upToBlockNumber: BlockNumber | undefined;
|
|
711
858
|
if (referenceBlock) {
|
|
712
859
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
713
|
-
if (
|
|
860
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
861
|
+
upToBlockNumber = BlockNumber(0);
|
|
862
|
+
} else {
|
|
714
863
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
715
864
|
if (!header) {
|
|
716
865
|
throw new Error(
|
|
717
866
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
718
867
|
);
|
|
719
868
|
}
|
|
869
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
720
870
|
}
|
|
721
871
|
}
|
|
722
|
-
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
|
|
872
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
723
873
|
}
|
|
724
874
|
|
|
725
875
|
/**
|
|
@@ -761,8 +911,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
761
911
|
}
|
|
762
912
|
|
|
763
913
|
await this.p2pClient!.sendTx(tx);
|
|
764
|
-
|
|
765
|
-
this.
|
|
914
|
+
const duration = timer.ms();
|
|
915
|
+
this.metrics.receivedTx(duration, true);
|
|
916
|
+
this.log.info(`Received tx ${txHash} in ${duration}ms`, { txHash });
|
|
766
917
|
}
|
|
767
918
|
|
|
768
919
|
public async getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
@@ -774,18 +925,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
774
925
|
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
775
926
|
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
776
927
|
|
|
928
|
+
let receipt: TxReceipt;
|
|
777
929
|
if (settledTxReceipt) {
|
|
778
|
-
|
|
779
|
-
return settledTxReceipt;
|
|
930
|
+
receipt = settledTxReceipt;
|
|
780
931
|
} else if (isKnownToPool) {
|
|
781
932
|
// If the tx is in the pool but not in the archiver, it's pending.
|
|
782
933
|
// This handles race conditions between archiver and p2p, where the archiver
|
|
783
934
|
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
784
|
-
|
|
935
|
+
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
785
936
|
} else {
|
|
786
937
|
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
787
|
-
|
|
938
|
+
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
788
939
|
}
|
|
940
|
+
|
|
941
|
+
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
942
|
+
|
|
943
|
+
return receipt;
|
|
789
944
|
}
|
|
790
945
|
|
|
791
946
|
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
@@ -800,8 +955,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
800
955
|
await tryStop(this.validatorsSentinel);
|
|
801
956
|
await tryStop(this.epochPruneWatcher);
|
|
802
957
|
await tryStop(this.slasherClient);
|
|
803
|
-
await tryStop(this.
|
|
958
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
804
959
|
await tryStop(this.sequencer);
|
|
960
|
+
await tryStop(this.proverNode);
|
|
805
961
|
await tryStop(this.p2pClient);
|
|
806
962
|
await tryStop(this.worldStateSynchronizer);
|
|
807
963
|
await tryStop(this.blockSource);
|
|
@@ -855,58 +1011,64 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
855
1011
|
treeId: MerkleTreeId,
|
|
856
1012
|
leafValues: Fr[],
|
|
857
1013
|
): Promise<(DataInBlock<bigint> | undefined)[]> {
|
|
858
|
-
const committedDb = await this
|
|
1014
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
859
1015
|
const maybeIndices = await committedDb.findLeafIndices(
|
|
860
1016
|
treeId,
|
|
861
1017
|
leafValues.map(x => x.toBuffer()),
|
|
862
1018
|
);
|
|
863
|
-
//
|
|
864
|
-
const
|
|
1019
|
+
// Filter out undefined values to query block numbers only for found leaves
|
|
1020
|
+
const definedIndices = maybeIndices.filter(x => x !== undefined);
|
|
865
1021
|
|
|
866
|
-
// Now we find the block numbers for the indices
|
|
867
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId,
|
|
1022
|
+
// Now we find the block numbers for the defined indices
|
|
1023
|
+
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
868
1024
|
|
|
869
|
-
//
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
1025
|
+
// Build a map from leaf index to block number
|
|
1026
|
+
const indexToBlockNumber = new Map<bigint, BlockNumber>();
|
|
1027
|
+
for (let i = 0; i < definedIndices.length; i++) {
|
|
1028
|
+
const blockNumber = blockNumbers[i];
|
|
1029
|
+
if (blockNumber === undefined) {
|
|
1030
|
+
throw new Error(
|
|
1031
|
+
`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`,
|
|
1032
|
+
);
|
|
873
1033
|
}
|
|
1034
|
+
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
874
1035
|
}
|
|
875
1036
|
|
|
876
1037
|
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
877
|
-
const uniqueBlockNumbers = [...new Set(
|
|
1038
|
+
const uniqueBlockNumbers = [...new Set(indexToBlockNumber.values())];
|
|
878
1039
|
|
|
879
|
-
// Now we obtain the block hashes from the archive tree
|
|
880
|
-
// (note that block number corresponds to the leaf index in the archive tree).
|
|
1040
|
+
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
881
1041
|
const blockHashes = await Promise.all(
|
|
882
1042
|
uniqueBlockNumbers.map(blockNumber => {
|
|
883
1043
|
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
884
1044
|
}),
|
|
885
1045
|
);
|
|
886
1046
|
|
|
887
|
-
//
|
|
1047
|
+
// Build a map from block number to block hash
|
|
1048
|
+
const blockNumberToHash = new Map<BlockNumber, Fr>();
|
|
888
1049
|
for (let i = 0; i < uniqueBlockNumbers.length; i++) {
|
|
889
|
-
|
|
1050
|
+
const blockHash = blockHashes[i];
|
|
1051
|
+
if (blockHash === undefined) {
|
|
890
1052
|
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
891
1053
|
}
|
|
1054
|
+
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
892
1055
|
}
|
|
893
1056
|
|
|
894
1057
|
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
895
|
-
return maybeIndices.map(
|
|
1058
|
+
return maybeIndices.map(index => {
|
|
896
1059
|
if (index === undefined) {
|
|
897
1060
|
return undefined;
|
|
898
1061
|
}
|
|
899
|
-
const blockNumber =
|
|
1062
|
+
const blockNumber = indexToBlockNumber.get(index);
|
|
900
1063
|
if (blockNumber === undefined) {
|
|
901
|
-
|
|
1064
|
+
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
902
1065
|
}
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
return undefined;
|
|
1066
|
+
const blockHash = blockNumberToHash.get(blockNumber);
|
|
1067
|
+
if (blockHash === undefined) {
|
|
1068
|
+
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
907
1069
|
}
|
|
908
1070
|
return {
|
|
909
|
-
l2BlockNumber:
|
|
1071
|
+
l2BlockNumber: blockNumber,
|
|
910
1072
|
l2BlockHash: new BlockHash(blockHash),
|
|
911
1073
|
data: index,
|
|
912
1074
|
};
|
|
@@ -917,7 +1079,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
917
1079
|
referenceBlock: BlockParameter,
|
|
918
1080
|
blockHash: BlockHash,
|
|
919
1081
|
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
|
|
920
|
-
|
|
1082
|
+
// The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
|
|
1083
|
+
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
|
|
1084
|
+
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
|
|
1085
|
+
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
|
|
1086
|
+
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
|
|
921
1087
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
|
|
922
1088
|
return pathAndIndex === undefined
|
|
923
1089
|
? undefined
|
|
@@ -928,7 +1094,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
928
1094
|
referenceBlock: BlockParameter,
|
|
929
1095
|
noteHash: Fr,
|
|
930
1096
|
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
|
|
931
|
-
const committedDb = await this
|
|
1097
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
932
1098
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.NOTE_HASH_TREE>(
|
|
933
1099
|
MerkleTreeId.NOTE_HASH_TREE,
|
|
934
1100
|
[noteHash],
|
|
@@ -942,7 +1108,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
942
1108
|
referenceBlock: BlockParameter,
|
|
943
1109
|
l1ToL2Message: Fr,
|
|
944
1110
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
|
|
945
|
-
const db = await this
|
|
1111
|
+
const db = await this.getWorldState(referenceBlock);
|
|
946
1112
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [l1ToL2Message]);
|
|
947
1113
|
if (!witness) {
|
|
948
1114
|
return undefined;
|
|
@@ -952,11 +1118,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
952
1118
|
return [witness.index, witness.path];
|
|
953
1119
|
}
|
|
954
1120
|
|
|
955
|
-
public async
|
|
1121
|
+
public async getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined> {
|
|
956
1122
|
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
957
|
-
return messageIndex
|
|
958
|
-
? BlockNumber.fromCheckpointNumber(InboxLeaf.checkpointNumberFromIndex(messageIndex))
|
|
959
|
-
: undefined;
|
|
1123
|
+
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
960
1124
|
}
|
|
961
1125
|
|
|
962
1126
|
/**
|
|
@@ -977,19 +1141,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
977
1141
|
public async getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
|
|
978
1142
|
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
979
1143
|
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
980
|
-
const blocksInCheckpoints
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
for (const checkpointedBlock of checkpointedBlocks) {
|
|
984
|
-
const block = checkpointedBlock.block;
|
|
985
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
986
|
-
if (slotNumber !== previousSlotNumber) {
|
|
987
|
-
checkpointIndex++;
|
|
988
|
-
blocksInCheckpoints.push([]);
|
|
989
|
-
previousSlotNumber = slotNumber;
|
|
990
|
-
}
|
|
991
|
-
blocksInCheckpoints[checkpointIndex].push(block);
|
|
992
|
-
}
|
|
1144
|
+
const blocksInCheckpoints = chunkBy(checkpointedBlocks, cb => cb.block.header.globalVariables.slotNumber).map(
|
|
1145
|
+
group => group.map(cb => cb.block),
|
|
1146
|
+
);
|
|
993
1147
|
return blocksInCheckpoints.map(blocks =>
|
|
994
1148
|
blocks.map(block => block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs)),
|
|
995
1149
|
);
|
|
@@ -999,7 +1153,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
999
1153
|
referenceBlock: BlockParameter,
|
|
1000
1154
|
nullifier: Fr,
|
|
1001
1155
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1002
|
-
const db = await this
|
|
1156
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1003
1157
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]);
|
|
1004
1158
|
if (!witness) {
|
|
1005
1159
|
return undefined;
|
|
@@ -1014,33 +1168,20 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1014
1168
|
return new NullifierMembershipWitness(index, leafPreimage as NullifierLeafPreimage, path);
|
|
1015
1169
|
}
|
|
1016
1170
|
|
|
1017
|
-
/**
|
|
1018
|
-
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
1019
|
-
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
|
|
1020
|
-
* (which contains the root of the nullifier tree in which we are searching for the nullifier).
|
|
1021
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
1022
|
-
* @returns The low nullifier membership witness (if found).
|
|
1023
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
1024
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
1025
|
-
* we are trying to prove non-inclusion for.
|
|
1026
|
-
*
|
|
1027
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
1028
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
1029
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
1030
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
1031
|
-
*/
|
|
1032
1171
|
public async getLowNullifierMembershipWitness(
|
|
1033
1172
|
referenceBlock: BlockParameter,
|
|
1034
1173
|
nullifier: Fr,
|
|
1035
1174
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1036
|
-
const committedDb = await this
|
|
1175
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1037
1176
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1038
1177
|
if (!findResult) {
|
|
1039
1178
|
return undefined;
|
|
1040
1179
|
}
|
|
1041
1180
|
const { index, alreadyPresent } = findResult;
|
|
1042
1181
|
if (alreadyPresent) {
|
|
1043
|
-
|
|
1182
|
+
throw new Error(
|
|
1183
|
+
`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`,
|
|
1184
|
+
);
|
|
1044
1185
|
}
|
|
1045
1186
|
const preimageData = (await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index))!;
|
|
1046
1187
|
|
|
@@ -1049,7 +1190,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1049
1190
|
}
|
|
1050
1191
|
|
|
1051
1192
|
async getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
1052
|
-
const committedDb = await this
|
|
1193
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1053
1194
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1054
1195
|
if (!lowLeafResult) {
|
|
1055
1196
|
return undefined;
|
|
@@ -1064,7 +1205,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1064
1205
|
}
|
|
1065
1206
|
|
|
1066
1207
|
public async getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
1067
|
-
const committedDb = await this
|
|
1208
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1068
1209
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1069
1210
|
|
|
1070
1211
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
@@ -1105,6 +1246,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1105
1246
|
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
1106
1247
|
}
|
|
1107
1248
|
|
|
1249
|
+
public getBlockData(number: BlockNumber): Promise<BlockData | undefined> {
|
|
1250
|
+
return this.blockSource.getBlockData(number);
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
public getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
|
|
1254
|
+
return this.blockSource.getBlockDataByArchive(archive);
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1108
1257
|
/**
|
|
1109
1258
|
* Simulates the public part of a transaction with the current state.
|
|
1110
1259
|
* @param tx - The transaction to simulate.
|
|
@@ -1128,7 +1277,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1128
1277
|
}
|
|
1129
1278
|
|
|
1130
1279
|
const txHash = tx.getTxHash();
|
|
1131
|
-
const
|
|
1280
|
+
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1281
|
+
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
1132
1282
|
|
|
1133
1283
|
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1134
1284
|
const coinbase = EthAddress.ZERO;
|
|
@@ -1152,6 +1302,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1152
1302
|
blockNumber,
|
|
1153
1303
|
});
|
|
1154
1304
|
|
|
1305
|
+
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1306
|
+
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1155
1307
|
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1156
1308
|
try {
|
|
1157
1309
|
const config = PublicSimulatorConfig.from({
|
|
@@ -1167,7 +1319,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1167
1319
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1168
1320
|
|
|
1169
1321
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1170
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([tx]);
|
|
1322
|
+
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([tx]);
|
|
1171
1323
|
// REFACTOR: Consider returning the error rather than throwing
|
|
1172
1324
|
if (failedTxs.length) {
|
|
1173
1325
|
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
|
|
@@ -1181,6 +1333,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1181
1333
|
processedTx.txEffect,
|
|
1182
1334
|
returns,
|
|
1183
1335
|
processedTx.gasUsed,
|
|
1336
|
+
debugLogs,
|
|
1184
1337
|
);
|
|
1185
1338
|
} finally {
|
|
1186
1339
|
await merkleTreeFork.close();
|
|
@@ -1192,12 +1345,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1192
1345
|
{ isSimulation, skipFeeEnforcement }: { isSimulation?: boolean; skipFeeEnforcement?: boolean } = {},
|
|
1193
1346
|
): Promise<TxValidationResult> {
|
|
1194
1347
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1195
|
-
const verifier = isSimulation ? undefined : this.
|
|
1348
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
1196
1349
|
|
|
1197
|
-
// We accept transactions if they are not expired by the next slot (checked based on the
|
|
1350
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1198
1351
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1199
1352
|
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
1200
|
-
const
|
|
1353
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
1354
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(
|
|
1201
1355
|
db,
|
|
1202
1356
|
this.contractDataSource,
|
|
1203
1357
|
verifier,
|
|
@@ -1206,10 +1360,16 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1206
1360
|
blockNumber,
|
|
1207
1361
|
l1ChainId: this.l1ChainId,
|
|
1208
1362
|
rollupVersion: this.version,
|
|
1209
|
-
setupAllowList:
|
|
1363
|
+
setupAllowList: [
|
|
1364
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
1365
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
1366
|
+
],
|
|
1210
1367
|
gasFees: await this.getCurrentMinFees(),
|
|
1211
1368
|
skipFeeEnforcement,
|
|
1212
1369
|
txsPermitted: !this.config.disableTransactions,
|
|
1370
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1371
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1372
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas,
|
|
1213
1373
|
},
|
|
1214
1374
|
this.log.getBindings(),
|
|
1215
1375
|
);
|
|
@@ -1234,7 +1394,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1234
1394
|
archiver.updateConfig(config);
|
|
1235
1395
|
}
|
|
1236
1396
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
1237
|
-
|
|
1397
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
1398
|
+
if (newConfig.realProofs) {
|
|
1399
|
+
this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
|
|
1400
|
+
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
|
|
1401
|
+
this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
|
|
1402
|
+
} else {
|
|
1403
|
+
this.peerProofVerifier = new TestCircuitVerifier();
|
|
1404
|
+
this.rpcProofVerifier = new TestCircuitVerifier();
|
|
1405
|
+
}
|
|
1238
1406
|
}
|
|
1239
1407
|
|
|
1240
1408
|
this.config = newConfig;
|
|
@@ -1376,6 +1544,94 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1376
1544
|
}
|
|
1377
1545
|
}
|
|
1378
1546
|
|
|
1547
|
+
public async reloadKeystore(): Promise<void> {
|
|
1548
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
1549
|
+
throw new BadRequestError(
|
|
1550
|
+
'Cannot reload keystore: node is not using a file-based keystore. ' +
|
|
1551
|
+
'Set KEY_STORE_DIRECTORY to use file-based keystores.',
|
|
1552
|
+
);
|
|
1553
|
+
}
|
|
1554
|
+
if (!this.validatorClient) {
|
|
1555
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
this.log.info('Reloading keystore from disk');
|
|
1559
|
+
|
|
1560
|
+
// Re-read and validate keystore files
|
|
1561
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1562
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1563
|
+
await newManager.validateSigners();
|
|
1564
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1565
|
+
|
|
1566
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1567
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1568
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1569
|
+
// would silently fail on every proposer slot.
|
|
1570
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1571
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1572
|
+
const availablePublishers = new Set(
|
|
1573
|
+
oldAdapter
|
|
1574
|
+
.getAttesterAddresses()
|
|
1575
|
+
.flatMap(a => oldAdapter.getPublisherAddresses(a).map(p => p.toString().toLowerCase())),
|
|
1576
|
+
);
|
|
1577
|
+
|
|
1578
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1579
|
+
for (const attester of newAdapter.getAttesterAddresses()) {
|
|
1580
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1581
|
+
if (pubs.length > 0 && !pubs.some(p => availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1582
|
+
throw new BadRequestError(
|
|
1583
|
+
`Cannot reload keystore: validator ${attester} has publisher keys ` +
|
|
1584
|
+
`[${pubs.map(p => p.toString()).join(', ')}] but none match the L1 signers initialized at startup ` +
|
|
1585
|
+
`[${[...availablePublishers].join(', ')}]. Publishers cannot be hot-reloaded — ` +
|
|
1586
|
+
`use an existing publisher key or restart the node.`,
|
|
1587
|
+
);
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
// Build adapters for old and new keystores to compute diff
|
|
1593
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1594
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1595
|
+
const oldAddresses = this.keyStoreManager
|
|
1596
|
+
? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses()
|
|
1597
|
+
: [];
|
|
1598
|
+
|
|
1599
|
+
const oldSet = new Set(oldAddresses.map(a => a.toString()));
|
|
1600
|
+
const newSet = new Set(newAddresses.map(a => a.toString()));
|
|
1601
|
+
const added = newAddresses.filter(a => !oldSet.has(a.toString()));
|
|
1602
|
+
const removed = oldAddresses.filter(a => !newSet.has(a.toString()));
|
|
1603
|
+
|
|
1604
|
+
if (added.length > 0) {
|
|
1605
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map(a => a.toString()).join(', ')}`);
|
|
1606
|
+
}
|
|
1607
|
+
if (removed.length > 0) {
|
|
1608
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map(a => a.toString()).join(', ')}`);
|
|
1609
|
+
}
|
|
1610
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1611
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1615
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1616
|
+
|
|
1617
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1618
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1619
|
+
if (this.sequencer) {
|
|
1620
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1624
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1625
|
+
const slashValidatorsNever = unique(
|
|
1626
|
+
[...(this.config.slashValidatorsNever ?? []), ...newAddresses].map(a => a.toString()),
|
|
1627
|
+
).map(EthAddress.fromString);
|
|
1628
|
+
this.slasherClient.updateConfig({ slashValidatorsNever });
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
this.keyStoreManager = newManager;
|
|
1632
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1379
1635
|
#getInitialHeaderHash(): Promise<BlockHash> {
|
|
1380
1636
|
if (!this.initialHeaderHashPromise) {
|
|
1381
1637
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
@@ -1388,7 +1644,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1388
1644
|
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1389
1645
|
* @returns An instance of a committed MerkleTreeOperations
|
|
1390
1646
|
*/
|
|
1391
|
-
async
|
|
1647
|
+
protected async getWorldState(block: BlockParameter) {
|
|
1392
1648
|
let blockSyncedTo: BlockNumber = BlockNumber.ZERO;
|
|
1393
1649
|
try {
|
|
1394
1650
|
// Attempt to sync the world state if necessary
|
|
@@ -1402,6 +1658,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1402
1658
|
return this.worldStateSynchronizer.getCommitted();
|
|
1403
1659
|
}
|
|
1404
1660
|
|
|
1661
|
+
// Get the block number, either directly from the parameter or by quering the archiver with the block hash
|
|
1662
|
+
let blockNumber: BlockNumber;
|
|
1405
1663
|
if (BlockHash.isBlockHash(block)) {
|
|
1406
1664
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1407
1665
|
if (block.equals(initialBlockHash)) {
|
|
@@ -1415,22 +1673,50 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1415
1673
|
`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.`,
|
|
1416
1674
|
);
|
|
1417
1675
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1676
|
+
|
|
1677
|
+
blockNumber = header.getBlockNumber();
|
|
1678
|
+
} else {
|
|
1679
|
+
blockNumber = block as BlockNumber;
|
|
1421
1680
|
}
|
|
1422
1681
|
|
|
1423
|
-
//
|
|
1424
|
-
{
|
|
1425
|
-
|
|
1682
|
+
// Check it's within world state sync range
|
|
1683
|
+
if (blockNumber > blockSyncedTo) {
|
|
1684
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1685
|
+
}
|
|
1686
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1426
1687
|
|
|
1427
|
-
|
|
1428
|
-
|
|
1688
|
+
const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1689
|
+
|
|
1690
|
+
// Double-check world-state synced to the same block hash as was requested
|
|
1691
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1692
|
+
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1693
|
+
if (!blockHash || !new BlockHash(blockHash).equals(block)) {
|
|
1694
|
+
throw new Error(
|
|
1695
|
+
`Block hash ${block.toString()} not found in world state at block number ${blockNumber}. If the node API has been queried with anchor block hash possibly a reorg has occurred.`,
|
|
1696
|
+
);
|
|
1429
1697
|
}
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
return snapshot;
|
|
1701
|
+
}
|
|
1430
1702
|
|
|
1431
|
-
|
|
1432
|
-
|
|
1703
|
+
/** Resolves a block parameter to a block number. */
|
|
1704
|
+
protected async resolveBlockNumber(block: BlockParameter): Promise<BlockNumber> {
|
|
1705
|
+
if (block === 'latest') {
|
|
1706
|
+
return BlockNumber(await this.blockSource.getBlockNumber());
|
|
1707
|
+
}
|
|
1708
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1709
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1710
|
+
if (block.equals(initialBlockHash)) {
|
|
1711
|
+
return BlockNumber.ZERO;
|
|
1712
|
+
}
|
|
1713
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1714
|
+
if (!header) {
|
|
1715
|
+
throw new Error(`Block hash ${block.toString()} not found.`);
|
|
1716
|
+
}
|
|
1717
|
+
return header.getBlockNumber();
|
|
1433
1718
|
}
|
|
1719
|
+
return block as BlockNumber;
|
|
1434
1720
|
}
|
|
1435
1721
|
|
|
1436
1722
|
/**
|