@aztec/aztec-node 0.0.1-commit.6a729f7 → 0.0.1-commit.6b113946b
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 +32 -22
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +350 -163
- 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 +60 -34
- 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 +422 -174
- package/src/sentinel/factory.ts +1 -1
- package/src/sentinel/sentinel.ts +63 -30
- package/src/sentinel/store.ts +12 -12
package/src/aztec-node/server.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Archiver, createArchiver } from '@aztec/archiver';
|
|
2
2
|
import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
|
|
3
3
|
import { type BlobClientInterface, createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
4
|
+
import { 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';
|
|
7
|
-
import { getPublicClient } from '@aztec/ethereum/client';
|
|
8
|
+
import { getPublicClient, makeL1HttpTransport } 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 { chunkBy, compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
12
13
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
14
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
14
15
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
@@ -16,14 +17,19 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
|
16
17
|
import { count } from '@aztec/foundation/string';
|
|
17
18
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
18
19
|
import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
|
|
19
|
-
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
20
|
+
import { type KeyStore, KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
20
21
|
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
22
|
+
import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
|
|
21
23
|
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
type P2P,
|
|
25
|
+
type P2PClientDeps,
|
|
26
|
+
createP2PClient,
|
|
27
|
+
createTxValidatorForAcceptingTxsOverRPC,
|
|
28
|
+
getDefaultAllowedSetupFunctions,
|
|
29
|
+
} from '@aztec/p2p';
|
|
26
30
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
31
|
+
import { type ProverNode, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
|
|
32
|
+
import { createKeyStoreForProver } from '@aztec/prover-node/config';
|
|
27
33
|
import { GlobalVariableBuilder, SequencerClient, type SequencerPublisher } from '@aztec/sequencer-client';
|
|
28
34
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
29
35
|
import {
|
|
@@ -35,7 +41,14 @@ import {
|
|
|
35
41
|
} from '@aztec/slasher';
|
|
36
42
|
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
37
43
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
38
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
type BlockData,
|
|
46
|
+
BlockHash,
|
|
47
|
+
type BlockParameter,
|
|
48
|
+
type DataInBlock,
|
|
49
|
+
L2Block,
|
|
50
|
+
type L2BlockSource,
|
|
51
|
+
} from '@aztec/stdlib/block';
|
|
39
52
|
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
40
53
|
import type {
|
|
41
54
|
ContractClassPublic,
|
|
@@ -63,9 +76,9 @@ import {
|
|
|
63
76
|
type WorldStateSynchronizer,
|
|
64
77
|
tryStop,
|
|
65
78
|
} from '@aztec/stdlib/interfaces/server';
|
|
66
|
-
import type { LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
79
|
+
import type { DebugLogStore, LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
80
|
+
import { InMemoryDebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
67
81
|
import { InboxLeaf, type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
68
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
69
82
|
import type { Offense, SlashPayloadRound } from '@aztec/stdlib/slashing';
|
|
70
83
|
import type { NullifierLeafPreimage, PublicDataTreeLeaf, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
71
84
|
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
@@ -97,11 +110,11 @@ import {
|
|
|
97
110
|
ValidatorClient,
|
|
98
111
|
createBlockProposalHandler,
|
|
99
112
|
createValidatorClient,
|
|
100
|
-
createValidatorForAcceptingTxs,
|
|
101
113
|
} from '@aztec/validator-client';
|
|
114
|
+
import type { SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
|
|
102
115
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
103
116
|
|
|
104
|
-
import { createPublicClient
|
|
117
|
+
import { createPublicClient } from 'viem';
|
|
105
118
|
|
|
106
119
|
import { createSentinel } from '../sentinel/factory.js';
|
|
107
120
|
import { Sentinel } from '../sentinel/sentinel.js';
|
|
@@ -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> {
|
|
@@ -170,11 +194,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
170
194
|
logger?: Logger;
|
|
171
195
|
publisher?: SequencerPublisher;
|
|
172
196
|
dateProvider?: DateProvider;
|
|
173
|
-
p2pClientDeps?: P2PClientDeps
|
|
197
|
+
p2pClientDeps?: P2PClientDeps;
|
|
198
|
+
proverNodeDeps?: Partial<ProverNodeDeps>;
|
|
199
|
+
slashingProtectionDb?: SlashingProtectionDatabase;
|
|
174
200
|
} = {},
|
|
175
201
|
options: {
|
|
176
202
|
prefilledPublicData?: PublicDataTreeLeaf[];
|
|
177
203
|
dontStartSequencer?: boolean;
|
|
204
|
+
dontStartProverNode?: boolean;
|
|
178
205
|
} = {},
|
|
179
206
|
): Promise<AztecNodeService> {
|
|
180
207
|
const config = { ...inputConfig }; // Copy the config so we dont mutate the input object
|
|
@@ -184,16 +211,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
184
211
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
185
212
|
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
186
213
|
|
|
187
|
-
// Build a key store from file if given or from environment otherwise
|
|
214
|
+
// Build a key store from file if given or from environment otherwise.
|
|
215
|
+
// We keep the raw KeyStore available so we can merge with prover keys if enableProverNode is set.
|
|
188
216
|
let keyStoreManager: KeystoreManager | undefined;
|
|
189
217
|
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
190
218
|
if (keyStoreProvided) {
|
|
191
219
|
const keyStores = loadKeystores(config.keyStoreDirectory!);
|
|
192
220
|
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
193
221
|
} else {
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
222
|
+
const rawKeyStores: KeyStore[] = [];
|
|
223
|
+
const validatorKeyStore = createKeyStoreForValidator(config);
|
|
224
|
+
if (validatorKeyStore) {
|
|
225
|
+
rawKeyStores.push(validatorKeyStore);
|
|
226
|
+
}
|
|
227
|
+
if (config.enableProverNode) {
|
|
228
|
+
const proverKeyStore = createKeyStoreForProver(config);
|
|
229
|
+
if (proverKeyStore) {
|
|
230
|
+
rawKeyStores.push(proverKeyStore);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (rawKeyStores.length > 0) {
|
|
234
|
+
keyStoreManager = new KeystoreManager(
|
|
235
|
+
rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores),
|
|
236
|
+
);
|
|
197
237
|
}
|
|
198
238
|
}
|
|
199
239
|
|
|
@@ -204,10 +244,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
204
244
|
if (keyStoreManager === undefined) {
|
|
205
245
|
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
206
246
|
}
|
|
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
|
-
);
|
|
247
|
+
if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
|
|
248
|
+
log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
|
|
211
249
|
}
|
|
212
250
|
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
213
251
|
}
|
|
@@ -221,7 +259,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
221
259
|
|
|
222
260
|
const publicClient = createPublicClient({
|
|
223
261
|
chain: ethereumChain.chainInfo,
|
|
224
|
-
transport:
|
|
262
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, { timeout: config.l1HttpTimeoutMS }),
|
|
225
263
|
pollingInterval: config.viemPollingIntervalMS,
|
|
226
264
|
});
|
|
227
265
|
|
|
@@ -235,10 +273,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
235
273
|
config.l1Contracts = { ...config.l1Contracts, ...l1ContractsAddresses };
|
|
236
274
|
|
|
237
275
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
238
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
276
|
+
const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
|
|
239
277
|
rollupContract.getL1GenesisTime(),
|
|
240
278
|
rollupContract.getSlotDuration(),
|
|
241
279
|
rollupContract.getVersion(),
|
|
280
|
+
rollupContract.getManaLimit().then(Number),
|
|
242
281
|
] as const);
|
|
243
282
|
|
|
244
283
|
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
@@ -249,7 +288,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
249
288
|
);
|
|
250
289
|
}
|
|
251
290
|
|
|
252
|
-
const blobClient = await createBlobClientWithFileStores(config,
|
|
291
|
+
const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
|
|
253
292
|
|
|
254
293
|
// attempt snapshot sync if possible
|
|
255
294
|
await trySnapshotSync(config, log);
|
|
@@ -273,14 +312,28 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
273
312
|
config.realProofs || config.debugForceTxProofVerification
|
|
274
313
|
? await BBCircuitVerifier.new(config)
|
|
275
314
|
: new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
315
|
+
|
|
316
|
+
let debugLogStore: DebugLogStore;
|
|
276
317
|
if (!config.realProofs) {
|
|
277
318
|
log.warn(`Aztec node is accepting fake proofs`);
|
|
319
|
+
|
|
320
|
+
debugLogStore = new InMemoryDebugLogStore();
|
|
321
|
+
log.info(
|
|
322
|
+
'Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served',
|
|
323
|
+
);
|
|
324
|
+
} else {
|
|
325
|
+
debugLogStore = new NullDebugLogStore();
|
|
278
326
|
}
|
|
327
|
+
|
|
279
328
|
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
280
329
|
|
|
330
|
+
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
331
|
+
if (proverOnly) {
|
|
332
|
+
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
333
|
+
}
|
|
334
|
+
|
|
281
335
|
// create the tx pool and the p2p client, which will need the l2 block source
|
|
282
336
|
const p2pClient = await createP2PClient(
|
|
283
|
-
P2PClientType.Full,
|
|
284
337
|
config,
|
|
285
338
|
archiver,
|
|
286
339
|
proofVerifier,
|
|
@@ -292,49 +345,60 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
292
345
|
deps.p2pClientDeps,
|
|
293
346
|
);
|
|
294
347
|
|
|
295
|
-
// We
|
|
296
|
-
|
|
348
|
+
// We'll accumulate sentinel watchers here
|
|
349
|
+
const watchers: Watcher[] = [];
|
|
297
350
|
|
|
298
|
-
// Create FullNodeCheckpointsBuilder for
|
|
351
|
+
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
352
|
+
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
299
353
|
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder(
|
|
300
|
-
{
|
|
354
|
+
{
|
|
355
|
+
...config,
|
|
356
|
+
l1GenesisTime,
|
|
357
|
+
slotDuration: Number(slotDuration),
|
|
358
|
+
rollupManaLimit,
|
|
359
|
+
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint,
|
|
360
|
+
},
|
|
301
361
|
worldStateSynchronizer,
|
|
302
362
|
archiver,
|
|
303
363
|
dateProvider,
|
|
304
364
|
telemetry,
|
|
305
365
|
);
|
|
306
366
|
|
|
307
|
-
|
|
308
|
-
const watchers: Watcher[] = [];
|
|
367
|
+
let validatorClient: ValidatorClient | undefined;
|
|
309
368
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
369
|
+
if (!proverOnly) {
|
|
370
|
+
// Create validator client if required
|
|
371
|
+
validatorClient = await createValidatorClient(config, {
|
|
372
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
373
|
+
worldState: worldStateSynchronizer,
|
|
374
|
+
p2pClient,
|
|
375
|
+
telemetry,
|
|
376
|
+
dateProvider,
|
|
377
|
+
epochCache,
|
|
378
|
+
blockSource: archiver,
|
|
379
|
+
l1ToL2MessageSource: archiver,
|
|
380
|
+
keyStoreManager,
|
|
381
|
+
blobClient,
|
|
382
|
+
slashingProtectionDb: deps.slashingProtectionDb,
|
|
383
|
+
});
|
|
323
384
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
385
|
+
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
386
|
+
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
387
|
+
// like attestations or auths will fail.
|
|
388
|
+
if (validatorClient) {
|
|
389
|
+
watchers.push(validatorClient);
|
|
390
|
+
if (!options.dontStartSequencer) {
|
|
391
|
+
await validatorClient.registerHandlers();
|
|
392
|
+
}
|
|
331
393
|
}
|
|
332
394
|
}
|
|
333
395
|
|
|
334
|
-
// If there's no validator client
|
|
335
|
-
//
|
|
336
|
-
|
|
337
|
-
|
|
396
|
+
// If there's no validator client, create a BlockProposalHandler to handle block proposals
|
|
397
|
+
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
398
|
+
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
399
|
+
if (!validatorClient) {
|
|
400
|
+
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
401
|
+
log.info(`Setting up block proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
338
402
|
createBlockProposalHandler(config, {
|
|
339
403
|
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
340
404
|
worldState: worldStateSynchronizer,
|
|
@@ -344,7 +408,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
344
408
|
p2pClient,
|
|
345
409
|
dateProvider,
|
|
346
410
|
telemetry,
|
|
347
|
-
}).
|
|
411
|
+
}).register(p2pClient, reexecute);
|
|
348
412
|
}
|
|
349
413
|
|
|
350
414
|
// Start world state and wait for it to sync to the archiver.
|
|
@@ -353,29 +417,33 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
353
417
|
// Start p2p. Note that it depends on world state to be running.
|
|
354
418
|
await p2pClient.start();
|
|
355
419
|
|
|
356
|
-
|
|
357
|
-
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
358
|
-
watchers.push(validatorsSentinel);
|
|
359
|
-
}
|
|
360
|
-
|
|
420
|
+
let validatorsSentinel: Awaited<ReturnType<typeof createSentinel>> | undefined;
|
|
361
421
|
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
422
|
let attestationsBlockWatcher: AttestationsBlockWatcher | undefined;
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
423
|
+
|
|
424
|
+
if (!proverOnly) {
|
|
425
|
+
validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
426
|
+
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
427
|
+
watchers.push(validatorsSentinel);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
431
|
+
epochPruneWatcher = new EpochPruneWatcher(
|
|
432
|
+
archiver,
|
|
433
|
+
archiver,
|
|
434
|
+
epochCache,
|
|
435
|
+
p2pClient.getTxProvider(),
|
|
436
|
+
validatorCheckpointsBuilder,
|
|
437
|
+
config,
|
|
438
|
+
);
|
|
439
|
+
watchers.push(epochPruneWatcher);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
443
|
+
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
444
|
+
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
445
|
+
watchers.push(attestationsBlockWatcher);
|
|
446
|
+
}
|
|
379
447
|
}
|
|
380
448
|
|
|
381
449
|
// Start p2p-related services once the archiver has completed sync
|
|
@@ -412,28 +480,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
412
480
|
);
|
|
413
481
|
await slasherClient.start();
|
|
414
482
|
|
|
415
|
-
const l1TxUtils = config.
|
|
416
|
-
? await
|
|
483
|
+
const l1TxUtils = config.sequencerPublisherForwarderAddress
|
|
484
|
+
? await createForwarderL1TxUtilsFromSigners(
|
|
417
485
|
publicClient,
|
|
418
486
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
419
|
-
config.
|
|
487
|
+
config.sequencerPublisherForwarderAddress,
|
|
420
488
|
{ ...config, scope: 'sequencer' },
|
|
421
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
489
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
422
490
|
)
|
|
423
|
-
: await
|
|
491
|
+
: await createL1TxUtilsFromSigners(
|
|
424
492
|
publicClient,
|
|
425
493
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
426
494
|
{ ...config, scope: 'sequencer' },
|
|
427
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
495
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
428
496
|
);
|
|
429
497
|
|
|
430
498
|
// Create and start the sequencer client
|
|
431
499
|
const checkpointsBuilder = new CheckpointsBuilder(
|
|
432
|
-
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
|
|
500
|
+
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration), rollupManaLimit },
|
|
433
501
|
worldStateSynchronizer,
|
|
434
502
|
archiver,
|
|
435
503
|
dateProvider,
|
|
436
504
|
telemetry,
|
|
505
|
+
debugLogStore,
|
|
437
506
|
);
|
|
438
507
|
|
|
439
508
|
sequencer = await SequencerClient.new(config, {
|
|
@@ -461,6 +530,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
461
530
|
log.warn(`Sequencer created but not started`);
|
|
462
531
|
}
|
|
463
532
|
|
|
533
|
+
// Create prover node subsystem if enabled
|
|
534
|
+
let proverNode: ProverNode | undefined;
|
|
535
|
+
if (config.enableProverNode) {
|
|
536
|
+
proverNode = await createProverNode(config, {
|
|
537
|
+
...deps.proverNodeDeps,
|
|
538
|
+
telemetry,
|
|
539
|
+
dateProvider,
|
|
540
|
+
archiver,
|
|
541
|
+
worldStateSynchronizer,
|
|
542
|
+
p2pClient,
|
|
543
|
+
epochCache,
|
|
544
|
+
blobClient,
|
|
545
|
+
keyStoreManager,
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
if (!options.dontStartProverNode) {
|
|
549
|
+
await proverNode.start();
|
|
550
|
+
log.info(`Prover node subsystem started`);
|
|
551
|
+
} else {
|
|
552
|
+
log.info(`Prover node subsystem created but not started`);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
464
556
|
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
465
557
|
...config,
|
|
466
558
|
rollupVersion: BigInt(config.rollupVersion),
|
|
@@ -468,7 +560,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
468
560
|
slotDuration: Number(slotDuration),
|
|
469
561
|
});
|
|
470
562
|
|
|
471
|
-
|
|
563
|
+
const node = new AztecNodeService(
|
|
472
564
|
config,
|
|
473
565
|
p2pClient,
|
|
474
566
|
archiver,
|
|
@@ -477,6 +569,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
477
569
|
archiver,
|
|
478
570
|
worldStateSynchronizer,
|
|
479
571
|
sequencer,
|
|
572
|
+
proverNode,
|
|
480
573
|
slasherClient,
|
|
481
574
|
validatorsSentinel,
|
|
482
575
|
epochPruneWatcher,
|
|
@@ -489,7 +582,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
489
582
|
telemetry,
|
|
490
583
|
log,
|
|
491
584
|
blobClient,
|
|
585
|
+
validatorClient,
|
|
586
|
+
keyStoreManager,
|
|
587
|
+
debugLogStore,
|
|
492
588
|
);
|
|
589
|
+
|
|
590
|
+
return node;
|
|
493
591
|
}
|
|
494
592
|
|
|
495
593
|
/**
|
|
@@ -500,6 +598,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
500
598
|
return this.sequencer;
|
|
501
599
|
}
|
|
502
600
|
|
|
601
|
+
/** Returns the prover node subsystem, if enabled. */
|
|
602
|
+
public getProverNode(): ProverNode | undefined {
|
|
603
|
+
return this.proverNode;
|
|
604
|
+
}
|
|
605
|
+
|
|
503
606
|
public getBlockSource(): L2BlockSource {
|
|
504
607
|
return this.blockSource;
|
|
505
608
|
}
|
|
@@ -525,7 +628,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
525
628
|
}
|
|
526
629
|
|
|
527
630
|
public async getAllowedPublicSetup(): Promise<AllowedElement[]> {
|
|
528
|
-
return this.config.
|
|
631
|
+
return [...(await getDefaultAllowedSetupFunctions()), ...(this.config.txPublicSetupAllowListExtend ?? [])];
|
|
529
632
|
}
|
|
530
633
|
|
|
531
634
|
/**
|
|
@@ -553,6 +656,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
553
656
|
enr,
|
|
554
657
|
l1ContractAddresses: contractAddresses,
|
|
555
658
|
protocolContractAddresses: protocolContractAddresses,
|
|
659
|
+
realProofs: !!this.config.realProofs,
|
|
556
660
|
};
|
|
557
661
|
|
|
558
662
|
return nodeInfo;
|
|
@@ -619,6 +723,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
619
723
|
return (await this.blockSource.getCheckpointedBlocks(from, limit)) ?? [];
|
|
620
724
|
}
|
|
621
725
|
|
|
726
|
+
public getCheckpointsDataForEpoch(epochNumber: EpochNumber) {
|
|
727
|
+
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
728
|
+
}
|
|
729
|
+
|
|
622
730
|
/**
|
|
623
731
|
* Method to fetch the current min L2 fees.
|
|
624
732
|
* @returns The current min L2 fees.
|
|
@@ -651,6 +759,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
651
759
|
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
652
760
|
}
|
|
653
761
|
|
|
762
|
+
public getCheckpointNumber(): Promise<CheckpointNumber> {
|
|
763
|
+
return this.blockSource.getCheckpointNumber();
|
|
764
|
+
}
|
|
765
|
+
|
|
654
766
|
/**
|
|
655
767
|
* Method to fetch the version of the package.
|
|
656
768
|
* @returns The node package version
|
|
@@ -688,18 +800,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
688
800
|
page?: number,
|
|
689
801
|
referenceBlock?: BlockHash,
|
|
690
802
|
): Promise<TxScopedL2Log[][]> {
|
|
803
|
+
let upToBlockNumber: BlockNumber | undefined;
|
|
691
804
|
if (referenceBlock) {
|
|
692
805
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
693
|
-
if (
|
|
806
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
807
|
+
upToBlockNumber = BlockNumber(0);
|
|
808
|
+
} else {
|
|
694
809
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
695
810
|
if (!header) {
|
|
696
811
|
throw new Error(
|
|
697
812
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
698
813
|
);
|
|
699
814
|
}
|
|
815
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
700
816
|
}
|
|
701
817
|
}
|
|
702
|
-
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
818
|
+
return this.logsSource.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
703
819
|
}
|
|
704
820
|
|
|
705
821
|
public async getPublicLogsByTagsFromContract(
|
|
@@ -708,18 +824,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
708
824
|
page?: number,
|
|
709
825
|
referenceBlock?: BlockHash,
|
|
710
826
|
): Promise<TxScopedL2Log[][]> {
|
|
827
|
+
let upToBlockNumber: BlockNumber | undefined;
|
|
711
828
|
if (referenceBlock) {
|
|
712
829
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
713
|
-
if (
|
|
830
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
831
|
+
upToBlockNumber = BlockNumber(0);
|
|
832
|
+
} else {
|
|
714
833
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
715
834
|
if (!header) {
|
|
716
835
|
throw new Error(
|
|
717
836
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
718
837
|
);
|
|
719
838
|
}
|
|
839
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
720
840
|
}
|
|
721
841
|
}
|
|
722
|
-
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
|
|
842
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
723
843
|
}
|
|
724
844
|
|
|
725
845
|
/**
|
|
@@ -761,8 +881,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
761
881
|
}
|
|
762
882
|
|
|
763
883
|
await this.p2pClient!.sendTx(tx);
|
|
764
|
-
|
|
765
|
-
this.
|
|
884
|
+
const duration = timer.ms();
|
|
885
|
+
this.metrics.receivedTx(duration, true);
|
|
886
|
+
this.log.info(`Received tx ${txHash} in ${duration}ms`, { txHash });
|
|
766
887
|
}
|
|
767
888
|
|
|
768
889
|
public async getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
@@ -774,18 +895,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
774
895
|
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
775
896
|
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
776
897
|
|
|
898
|
+
let receipt: TxReceipt;
|
|
777
899
|
if (settledTxReceipt) {
|
|
778
|
-
|
|
779
|
-
return settledTxReceipt;
|
|
900
|
+
receipt = settledTxReceipt;
|
|
780
901
|
} else if (isKnownToPool) {
|
|
781
902
|
// If the tx is in the pool but not in the archiver, it's pending.
|
|
782
903
|
// This handles race conditions between archiver and p2p, where the archiver
|
|
783
904
|
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
784
|
-
|
|
905
|
+
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
785
906
|
} else {
|
|
786
907
|
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
787
|
-
|
|
908
|
+
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
788
909
|
}
|
|
910
|
+
|
|
911
|
+
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
912
|
+
|
|
913
|
+
return receipt;
|
|
789
914
|
}
|
|
790
915
|
|
|
791
916
|
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
@@ -802,6 +927,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
802
927
|
await tryStop(this.slasherClient);
|
|
803
928
|
await tryStop(this.proofVerifier);
|
|
804
929
|
await tryStop(this.sequencer);
|
|
930
|
+
await tryStop(this.proverNode);
|
|
805
931
|
await tryStop(this.p2pClient);
|
|
806
932
|
await tryStop(this.worldStateSynchronizer);
|
|
807
933
|
await tryStop(this.blockSource);
|
|
@@ -855,58 +981,64 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
855
981
|
treeId: MerkleTreeId,
|
|
856
982
|
leafValues: Fr[],
|
|
857
983
|
): Promise<(DataInBlock<bigint> | undefined)[]> {
|
|
858
|
-
const committedDb = await this
|
|
984
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
859
985
|
const maybeIndices = await committedDb.findLeafIndices(
|
|
860
986
|
treeId,
|
|
861
987
|
leafValues.map(x => x.toBuffer()),
|
|
862
988
|
);
|
|
863
|
-
//
|
|
864
|
-
const
|
|
989
|
+
// Filter out undefined values to query block numbers only for found leaves
|
|
990
|
+
const definedIndices = maybeIndices.filter(x => x !== undefined);
|
|
865
991
|
|
|
866
|
-
// Now we find the block numbers for the indices
|
|
867
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId,
|
|
992
|
+
// Now we find the block numbers for the defined indices
|
|
993
|
+
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
868
994
|
|
|
869
|
-
//
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
995
|
+
// Build a map from leaf index to block number
|
|
996
|
+
const indexToBlockNumber = new Map<bigint, BlockNumber>();
|
|
997
|
+
for (let i = 0; i < definedIndices.length; i++) {
|
|
998
|
+
const blockNumber = blockNumbers[i];
|
|
999
|
+
if (blockNumber === undefined) {
|
|
1000
|
+
throw new Error(
|
|
1001
|
+
`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`,
|
|
1002
|
+
);
|
|
873
1003
|
}
|
|
1004
|
+
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
874
1005
|
}
|
|
875
1006
|
|
|
876
1007
|
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
877
|
-
const uniqueBlockNumbers = [...new Set(
|
|
1008
|
+
const uniqueBlockNumbers = [...new Set(indexToBlockNumber.values())];
|
|
878
1009
|
|
|
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).
|
|
1010
|
+
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
881
1011
|
const blockHashes = await Promise.all(
|
|
882
1012
|
uniqueBlockNumbers.map(blockNumber => {
|
|
883
1013
|
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
884
1014
|
}),
|
|
885
1015
|
);
|
|
886
1016
|
|
|
887
|
-
//
|
|
1017
|
+
// Build a map from block number to block hash
|
|
1018
|
+
const blockNumberToHash = new Map<BlockNumber, Fr>();
|
|
888
1019
|
for (let i = 0; i < uniqueBlockNumbers.length; i++) {
|
|
889
|
-
|
|
1020
|
+
const blockHash = blockHashes[i];
|
|
1021
|
+
if (blockHash === undefined) {
|
|
890
1022
|
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
891
1023
|
}
|
|
1024
|
+
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
892
1025
|
}
|
|
893
1026
|
|
|
894
1027
|
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
895
|
-
return maybeIndices.map(
|
|
1028
|
+
return maybeIndices.map(index => {
|
|
896
1029
|
if (index === undefined) {
|
|
897
1030
|
return undefined;
|
|
898
1031
|
}
|
|
899
|
-
const blockNumber =
|
|
1032
|
+
const blockNumber = indexToBlockNumber.get(index);
|
|
900
1033
|
if (blockNumber === undefined) {
|
|
901
|
-
|
|
1034
|
+
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
902
1035
|
}
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
return undefined;
|
|
1036
|
+
const blockHash = blockNumberToHash.get(blockNumber);
|
|
1037
|
+
if (blockHash === undefined) {
|
|
1038
|
+
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
907
1039
|
}
|
|
908
1040
|
return {
|
|
909
|
-
l2BlockNumber:
|
|
1041
|
+
l2BlockNumber: blockNumber,
|
|
910
1042
|
l2BlockHash: new BlockHash(blockHash),
|
|
911
1043
|
data: index,
|
|
912
1044
|
};
|
|
@@ -917,7 +1049,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
917
1049
|
referenceBlock: BlockParameter,
|
|
918
1050
|
blockHash: BlockHash,
|
|
919
1051
|
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
|
|
920
|
-
|
|
1052
|
+
// The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
|
|
1053
|
+
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
|
|
1054
|
+
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
|
|
1055
|
+
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
|
|
1056
|
+
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
|
|
921
1057
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
|
|
922
1058
|
return pathAndIndex === undefined
|
|
923
1059
|
? undefined
|
|
@@ -928,7 +1064,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
928
1064
|
referenceBlock: BlockParameter,
|
|
929
1065
|
noteHash: Fr,
|
|
930
1066
|
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
|
|
931
|
-
const committedDb = await this
|
|
1067
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
932
1068
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.NOTE_HASH_TREE>(
|
|
933
1069
|
MerkleTreeId.NOTE_HASH_TREE,
|
|
934
1070
|
[noteHash],
|
|
@@ -942,7 +1078,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
942
1078
|
referenceBlock: BlockParameter,
|
|
943
1079
|
l1ToL2Message: Fr,
|
|
944
1080
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
|
|
945
|
-
const db = await this
|
|
1081
|
+
const db = await this.getWorldState(referenceBlock);
|
|
946
1082
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [l1ToL2Message]);
|
|
947
1083
|
if (!witness) {
|
|
948
1084
|
return undefined;
|
|
@@ -952,11 +1088,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
952
1088
|
return [witness.index, witness.path];
|
|
953
1089
|
}
|
|
954
1090
|
|
|
955
|
-
public async
|
|
1091
|
+
public async getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined> {
|
|
956
1092
|
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
957
|
-
return messageIndex
|
|
958
|
-
? BlockNumber.fromCheckpointNumber(InboxLeaf.checkpointNumberFromIndex(messageIndex))
|
|
959
|
-
: undefined;
|
|
1093
|
+
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
960
1094
|
}
|
|
961
1095
|
|
|
962
1096
|
/**
|
|
@@ -977,19 +1111,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
977
1111
|
public async getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
|
|
978
1112
|
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
979
1113
|
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
|
-
}
|
|
1114
|
+
const blocksInCheckpoints = chunkBy(checkpointedBlocks, cb => cb.block.header.globalVariables.slotNumber).map(
|
|
1115
|
+
group => group.map(cb => cb.block),
|
|
1116
|
+
);
|
|
993
1117
|
return blocksInCheckpoints.map(blocks =>
|
|
994
1118
|
blocks.map(block => block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs)),
|
|
995
1119
|
);
|
|
@@ -999,7 +1123,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
999
1123
|
referenceBlock: BlockParameter,
|
|
1000
1124
|
nullifier: Fr,
|
|
1001
1125
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1002
|
-
const db = await this
|
|
1126
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1003
1127
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]);
|
|
1004
1128
|
if (!witness) {
|
|
1005
1129
|
return undefined;
|
|
@@ -1014,33 +1138,20 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1014
1138
|
return new NullifierMembershipWitness(index, leafPreimage as NullifierLeafPreimage, path);
|
|
1015
1139
|
}
|
|
1016
1140
|
|
|
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
1141
|
public async getLowNullifierMembershipWitness(
|
|
1033
1142
|
referenceBlock: BlockParameter,
|
|
1034
1143
|
nullifier: Fr,
|
|
1035
1144
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1036
|
-
const committedDb = await this
|
|
1145
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1037
1146
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1038
1147
|
if (!findResult) {
|
|
1039
1148
|
return undefined;
|
|
1040
1149
|
}
|
|
1041
1150
|
const { index, alreadyPresent } = findResult;
|
|
1042
1151
|
if (alreadyPresent) {
|
|
1043
|
-
|
|
1152
|
+
throw new Error(
|
|
1153
|
+
`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`,
|
|
1154
|
+
);
|
|
1044
1155
|
}
|
|
1045
1156
|
const preimageData = (await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index))!;
|
|
1046
1157
|
|
|
@@ -1049,7 +1160,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1049
1160
|
}
|
|
1050
1161
|
|
|
1051
1162
|
async getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
1052
|
-
const committedDb = await this
|
|
1163
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1053
1164
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1054
1165
|
if (!lowLeafResult) {
|
|
1055
1166
|
return undefined;
|
|
@@ -1064,7 +1175,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1064
1175
|
}
|
|
1065
1176
|
|
|
1066
1177
|
public async getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
1067
|
-
const committedDb = await this
|
|
1178
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1068
1179
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1069
1180
|
|
|
1070
1181
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
@@ -1105,6 +1216,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1105
1216
|
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
1106
1217
|
}
|
|
1107
1218
|
|
|
1219
|
+
public getBlockData(number: BlockNumber): Promise<BlockData | undefined> {
|
|
1220
|
+
return this.blockSource.getBlockData(number);
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
public getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
|
|
1224
|
+
return this.blockSource.getBlockDataByArchive(archive);
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1108
1227
|
/**
|
|
1109
1228
|
* Simulates the public part of a transaction with the current state.
|
|
1110
1229
|
* @param tx - The transaction to simulate.
|
|
@@ -1128,7 +1247,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1128
1247
|
}
|
|
1129
1248
|
|
|
1130
1249
|
const txHash = tx.getTxHash();
|
|
1131
|
-
const
|
|
1250
|
+
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1251
|
+
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
1132
1252
|
|
|
1133
1253
|
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1134
1254
|
const coinbase = EthAddress.ZERO;
|
|
@@ -1152,6 +1272,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1152
1272
|
blockNumber,
|
|
1153
1273
|
});
|
|
1154
1274
|
|
|
1275
|
+
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1276
|
+
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1155
1277
|
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1156
1278
|
try {
|
|
1157
1279
|
const config = PublicSimulatorConfig.from({
|
|
@@ -1167,7 +1289,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1167
1289
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1168
1290
|
|
|
1169
1291
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1170
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([tx]);
|
|
1292
|
+
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([tx]);
|
|
1171
1293
|
// REFACTOR: Consider returning the error rather than throwing
|
|
1172
1294
|
if (failedTxs.length) {
|
|
1173
1295
|
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
|
|
@@ -1181,6 +1303,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1181
1303
|
processedTx.txEffect,
|
|
1182
1304
|
returns,
|
|
1183
1305
|
processedTx.gasUsed,
|
|
1306
|
+
debugLogs,
|
|
1184
1307
|
);
|
|
1185
1308
|
} finally {
|
|
1186
1309
|
await merkleTreeFork.close();
|
|
@@ -1194,10 +1317,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1194
1317
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1195
1318
|
const verifier = isSimulation ? undefined : this.proofVerifier;
|
|
1196
1319
|
|
|
1197
|
-
// We accept transactions if they are not expired by the next slot (checked based on the
|
|
1320
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1198
1321
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1199
1322
|
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
1200
|
-
const
|
|
1323
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
1324
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(
|
|
1201
1325
|
db,
|
|
1202
1326
|
this.contractDataSource,
|
|
1203
1327
|
verifier,
|
|
@@ -1206,10 +1330,16 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1206
1330
|
blockNumber,
|
|
1207
1331
|
l1ChainId: this.l1ChainId,
|
|
1208
1332
|
rollupVersion: this.version,
|
|
1209
|
-
setupAllowList:
|
|
1333
|
+
setupAllowList: [
|
|
1334
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
1335
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
1336
|
+
],
|
|
1210
1337
|
gasFees: await this.getCurrentMinFees(),
|
|
1211
1338
|
skipFeeEnforcement,
|
|
1212
1339
|
txsPermitted: !this.config.disableTransactions,
|
|
1340
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1341
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1342
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas,
|
|
1213
1343
|
},
|
|
1214
1344
|
this.log.getBindings(),
|
|
1215
1345
|
);
|
|
@@ -1376,6 +1506,94 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1376
1506
|
}
|
|
1377
1507
|
}
|
|
1378
1508
|
|
|
1509
|
+
public async reloadKeystore(): Promise<void> {
|
|
1510
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
1511
|
+
throw new BadRequestError(
|
|
1512
|
+
'Cannot reload keystore: node is not using a file-based keystore. ' +
|
|
1513
|
+
'Set KEY_STORE_DIRECTORY to use file-based keystores.',
|
|
1514
|
+
);
|
|
1515
|
+
}
|
|
1516
|
+
if (!this.validatorClient) {
|
|
1517
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
this.log.info('Reloading keystore from disk');
|
|
1521
|
+
|
|
1522
|
+
// Re-read and validate keystore files
|
|
1523
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1524
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1525
|
+
await newManager.validateSigners();
|
|
1526
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1527
|
+
|
|
1528
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1529
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1530
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1531
|
+
// would silently fail on every proposer slot.
|
|
1532
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1533
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1534
|
+
const availablePublishers = new Set(
|
|
1535
|
+
oldAdapter
|
|
1536
|
+
.getAttesterAddresses()
|
|
1537
|
+
.flatMap(a => oldAdapter.getPublisherAddresses(a).map(p => p.toString().toLowerCase())),
|
|
1538
|
+
);
|
|
1539
|
+
|
|
1540
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1541
|
+
for (const attester of newAdapter.getAttesterAddresses()) {
|
|
1542
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1543
|
+
if (pubs.length > 0 && !pubs.some(p => availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1544
|
+
throw new BadRequestError(
|
|
1545
|
+
`Cannot reload keystore: validator ${attester} has publisher keys ` +
|
|
1546
|
+
`[${pubs.map(p => p.toString()).join(', ')}] but none match the L1 signers initialized at startup ` +
|
|
1547
|
+
`[${[...availablePublishers].join(', ')}]. Publishers cannot be hot-reloaded — ` +
|
|
1548
|
+
`use an existing publisher key or restart the node.`,
|
|
1549
|
+
);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
// Build adapters for old and new keystores to compute diff
|
|
1555
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1556
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1557
|
+
const oldAddresses = this.keyStoreManager
|
|
1558
|
+
? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses()
|
|
1559
|
+
: [];
|
|
1560
|
+
|
|
1561
|
+
const oldSet = new Set(oldAddresses.map(a => a.toString()));
|
|
1562
|
+
const newSet = new Set(newAddresses.map(a => a.toString()));
|
|
1563
|
+
const added = newAddresses.filter(a => !oldSet.has(a.toString()));
|
|
1564
|
+
const removed = oldAddresses.filter(a => !newSet.has(a.toString()));
|
|
1565
|
+
|
|
1566
|
+
if (added.length > 0) {
|
|
1567
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map(a => a.toString()).join(', ')}`);
|
|
1568
|
+
}
|
|
1569
|
+
if (removed.length > 0) {
|
|
1570
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map(a => a.toString()).join(', ')}`);
|
|
1571
|
+
}
|
|
1572
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1573
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1577
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1578
|
+
|
|
1579
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1580
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1581
|
+
if (this.sequencer) {
|
|
1582
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1586
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1587
|
+
const slashValidatorsNever = unique(
|
|
1588
|
+
[...(this.config.slashValidatorsNever ?? []), ...newAddresses].map(a => a.toString()),
|
|
1589
|
+
).map(EthAddress.fromString);
|
|
1590
|
+
this.slasherClient.updateConfig({ slashValidatorsNever });
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
this.keyStoreManager = newManager;
|
|
1594
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1379
1597
|
#getInitialHeaderHash(): Promise<BlockHash> {
|
|
1380
1598
|
if (!this.initialHeaderHashPromise) {
|
|
1381
1599
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
@@ -1388,7 +1606,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1388
1606
|
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1389
1607
|
* @returns An instance of a committed MerkleTreeOperations
|
|
1390
1608
|
*/
|
|
1391
|
-
async
|
|
1609
|
+
protected async getWorldState(block: BlockParameter) {
|
|
1392
1610
|
let blockSyncedTo: BlockNumber = BlockNumber.ZERO;
|
|
1393
1611
|
try {
|
|
1394
1612
|
// Attempt to sync the world state if necessary
|
|
@@ -1402,6 +1620,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1402
1620
|
return this.worldStateSynchronizer.getCommitted();
|
|
1403
1621
|
}
|
|
1404
1622
|
|
|
1623
|
+
// Get the block number, either directly from the parameter or by quering the archiver with the block hash
|
|
1624
|
+
let blockNumber: BlockNumber;
|
|
1405
1625
|
if (BlockHash.isBlockHash(block)) {
|
|
1406
1626
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1407
1627
|
if (block.equals(initialBlockHash)) {
|
|
@@ -1415,22 +1635,50 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1415
1635
|
`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
1636
|
);
|
|
1417
1637
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1638
|
+
|
|
1639
|
+
blockNumber = header.getBlockNumber();
|
|
1640
|
+
} else {
|
|
1641
|
+
blockNumber = block as BlockNumber;
|
|
1421
1642
|
}
|
|
1422
1643
|
|
|
1423
|
-
//
|
|
1424
|
-
{
|
|
1425
|
-
|
|
1644
|
+
// Check it's within world state sync range
|
|
1645
|
+
if (blockNumber > blockSyncedTo) {
|
|
1646
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1647
|
+
}
|
|
1648
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1649
|
+
|
|
1650
|
+
const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1426
1651
|
|
|
1427
|
-
|
|
1428
|
-
|
|
1652
|
+
// Double-check world-state synced to the same block hash as was requested
|
|
1653
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1654
|
+
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1655
|
+
if (!blockHash || !new BlockHash(blockHash).equals(block)) {
|
|
1656
|
+
throw new Error(
|
|
1657
|
+
`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.`,
|
|
1658
|
+
);
|
|
1429
1659
|
}
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
return snapshot;
|
|
1663
|
+
}
|
|
1430
1664
|
|
|
1431
|
-
|
|
1432
|
-
|
|
1665
|
+
/** Resolves a block parameter to a block number. */
|
|
1666
|
+
protected async resolveBlockNumber(block: BlockParameter): Promise<BlockNumber> {
|
|
1667
|
+
if (block === 'latest') {
|
|
1668
|
+
return BlockNumber(await this.blockSource.getBlockNumber());
|
|
1669
|
+
}
|
|
1670
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1671
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1672
|
+
if (block.equals(initialBlockHash)) {
|
|
1673
|
+
return BlockNumber.ZERO;
|
|
1674
|
+
}
|
|
1675
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1676
|
+
if (!header) {
|
|
1677
|
+
throw new Error(`Block hash ${block.toString()} not found.`);
|
|
1678
|
+
}
|
|
1679
|
+
return header.getBlockNumber();
|
|
1433
1680
|
}
|
|
1681
|
+
return block as BlockNumber;
|
|
1434
1682
|
}
|
|
1435
1683
|
|
|
1436
1684
|
/**
|