@aztec/aztec-node 0.0.1-commit.29c6b1a3 → 0.0.1-commit.2b2662070
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/node_metrics.d.ts +1 -1
- package/dest/aztec-node/node_metrics.d.ts.map +1 -1
- package/dest/aztec-node/node_metrics.js +8 -4
- package/dest/aztec-node/server.d.ts +58 -49
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +491 -237
- package/dest/sentinel/factory.d.ts +2 -2
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/factory.js +1 -1
- package/dest/sentinel/sentinel.d.ts +2 -2
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +62 -36
- 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/node_metrics.ts +12 -5
- package/src/aztec-node/server.ts +599 -296
- package/src/sentinel/factory.ts +2 -7
- package/src/sentinel/sentinel.ts +65 -32
- package/src/sentinel/store.ts +12 -12
package/src/aztec-node/server.ts
CHANGED
|
@@ -1,36 +1,44 @@
|
|
|
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';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
type L1_TO_L2_MSG_TREE_HEIGHT,
|
|
7
|
-
type NOTE_HASH_TREE_HEIGHT,
|
|
8
|
-
type NULLIFIER_TREE_HEIGHT,
|
|
9
|
-
type PUBLIC_DATA_TREE_HEIGHT,
|
|
10
|
-
} from '@aztec/constants';
|
|
5
|
+
import { Blob } from '@aztec/blob-lib';
|
|
6
|
+
import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
11
7
|
import { EpochCache, type EpochCacheInterface } from '@aztec/epoch-cache';
|
|
12
8
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
13
|
-
import { getPublicClient } from '@aztec/ethereum/client';
|
|
9
|
+
import { getPublicClient, makeL1HttpTransport } from '@aztec/ethereum/client';
|
|
14
10
|
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
15
11
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
12
|
+
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
16
13
|
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
17
|
-
import { compactArray, pick } from '@aztec/foundation/collection';
|
|
14
|
+
import { chunkBy, compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
18
15
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
19
16
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
20
17
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
21
18
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
19
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
22
20
|
import { count } from '@aztec/foundation/string';
|
|
23
21
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
24
22
|
import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
|
|
25
|
-
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
23
|
+
import { type KeyStore, KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
26
24
|
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
25
|
+
import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
|
|
27
26
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
type P2P,
|
|
28
|
+
type P2PClientDeps,
|
|
29
|
+
createP2PClient,
|
|
30
|
+
createTxValidatorForAcceptingTxsOverRPC,
|
|
31
|
+
getDefaultAllowedSetupFunctions,
|
|
32
|
+
} from '@aztec/p2p';
|
|
32
33
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
33
|
-
import {
|
|
34
|
+
import { type ProverNode, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
|
|
35
|
+
import { createKeyStoreForProver } from '@aztec/prover-node/config';
|
|
36
|
+
import {
|
|
37
|
+
FeeProviderImpl,
|
|
38
|
+
GlobalVariableBuilder,
|
|
39
|
+
SequencerClient,
|
|
40
|
+
type SequencerPublisher,
|
|
41
|
+
} from '@aztec/sequencer-client';
|
|
34
42
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
35
43
|
import {
|
|
36
44
|
AttestationsBlockWatcher,
|
|
@@ -41,7 +49,14 @@ import {
|
|
|
41
49
|
} from '@aztec/slasher';
|
|
42
50
|
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
43
51
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
44
|
-
import {
|
|
52
|
+
import {
|
|
53
|
+
type BlockData,
|
|
54
|
+
BlockHash,
|
|
55
|
+
type BlockParameter,
|
|
56
|
+
type DataInBlock,
|
|
57
|
+
L2Block,
|
|
58
|
+
type L2BlockSource,
|
|
59
|
+
} from '@aztec/stdlib/block';
|
|
45
60
|
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
46
61
|
import type {
|
|
47
62
|
ContractClassPublic,
|
|
@@ -50,13 +65,14 @@ import type {
|
|
|
50
65
|
NodeInfo,
|
|
51
66
|
ProtocolContractAddresses,
|
|
52
67
|
} from '@aztec/stdlib/contract';
|
|
53
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
68
|
+
import { GasFees, type ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
54
69
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
55
70
|
import {
|
|
56
71
|
type AztecNode,
|
|
57
72
|
type AztecNodeAdmin,
|
|
58
73
|
type AztecNodeAdminConfig,
|
|
59
74
|
AztecNodeAdminConfigSchema,
|
|
75
|
+
type AztecNodeDebug,
|
|
60
76
|
type GetContractClassLogsResponse,
|
|
61
77
|
type GetPublicLogsResponse,
|
|
62
78
|
} from '@aztec/stdlib/interfaces/client';
|
|
@@ -69,14 +85,15 @@ import {
|
|
|
69
85
|
type WorldStateSynchronizer,
|
|
70
86
|
tryStop,
|
|
71
87
|
} from '@aztec/stdlib/interfaces/server';
|
|
72
|
-
import type { LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
88
|
+
import type { DebugLogStore, LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
89
|
+
import { InMemoryDebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
73
90
|
import { InboxLeaf, type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
74
|
-
import {
|
|
75
|
-
import type {
|
|
76
|
-
import type { NullifierLeafPreimage, PublicDataTreeLeaf, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
91
|
+
import type { Offense } from '@aztec/stdlib/slashing';
|
|
92
|
+
import type { NullifierLeafPreimage, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
77
93
|
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
78
94
|
import {
|
|
79
95
|
type BlockHeader,
|
|
96
|
+
type FeeProvider,
|
|
80
97
|
type GlobalVariableBuilder as GlobalVariableBuilderInterface,
|
|
81
98
|
type IndexedTxEffect,
|
|
82
99
|
PublicSimulationOutput,
|
|
@@ -88,6 +105,7 @@ import {
|
|
|
88
105
|
} from '@aztec/stdlib/tx';
|
|
89
106
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
90
107
|
import type { SingleValidatorStats, ValidatorsStats } from '@aztec/stdlib/validators';
|
|
108
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
91
109
|
import {
|
|
92
110
|
Attributes,
|
|
93
111
|
type TelemetryClient,
|
|
@@ -101,13 +119,13 @@ import {
|
|
|
101
119
|
FullNodeCheckpointsBuilder,
|
|
102
120
|
NodeKeystoreAdapter,
|
|
103
121
|
ValidatorClient,
|
|
104
|
-
|
|
122
|
+
createProposalHandler,
|
|
105
123
|
createValidatorClient,
|
|
106
|
-
createValidatorForAcceptingTxs,
|
|
107
124
|
} from '@aztec/validator-client';
|
|
125
|
+
import type { SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
|
|
108
126
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
109
127
|
|
|
110
|
-
import { createPublicClient
|
|
128
|
+
import { createPublicClient } from 'viem';
|
|
111
129
|
|
|
112
130
|
import { createSentinel } from '../sentinel/factory.js';
|
|
113
131
|
import { Sentinel } from '../sentinel/sentinel.js';
|
|
@@ -117,7 +135,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
117
135
|
/**
|
|
118
136
|
* The aztec node.
|
|
119
137
|
*/
|
|
120
|
-
export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
138
|
+
export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDebug, Traceable {
|
|
121
139
|
private metrics: NodeMetrics;
|
|
122
140
|
private initialHeaderHashPromise: Promise<BlockHash> | undefined = undefined;
|
|
123
141
|
|
|
@@ -135,24 +153,42 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
135
153
|
protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
|
|
136
154
|
protected readonly worldStateSynchronizer: WorldStateSynchronizer,
|
|
137
155
|
protected readonly sequencer: SequencerClient | undefined,
|
|
156
|
+
protected readonly proverNode: ProverNode | undefined,
|
|
138
157
|
protected readonly slasherClient: SlasherClientInterface | undefined,
|
|
139
158
|
protected readonly validatorsSentinel: Sentinel | undefined,
|
|
140
159
|
protected readonly epochPruneWatcher: EpochPruneWatcher | undefined,
|
|
141
160
|
protected readonly l1ChainId: number,
|
|
142
161
|
protected readonly version: number,
|
|
143
162
|
protected readonly globalVariableBuilder: GlobalVariableBuilderInterface,
|
|
163
|
+
protected readonly feeProvider: FeeProvider,
|
|
144
164
|
protected readonly epochCache: EpochCacheInterface,
|
|
145
165
|
protected readonly packageVersion: string,
|
|
146
|
-
private
|
|
166
|
+
private peerProofVerifier: ClientProtocolCircuitVerifier,
|
|
167
|
+
private rpcProofVerifier: ClientProtocolCircuitVerifier,
|
|
147
168
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
148
169
|
private log = createLogger('node'),
|
|
149
170
|
private blobClient?: BlobClientInterface,
|
|
171
|
+
private validatorClient?: ValidatorClient,
|
|
172
|
+
private keyStoreManager?: KeystoreManager,
|
|
173
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
150
174
|
) {
|
|
151
175
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
152
176
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
153
177
|
|
|
154
178
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
155
179
|
this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config.l1Contracts);
|
|
180
|
+
|
|
181
|
+
// A defensive check that protects us against introducing a bug in the complex `createAndSync` function. We must
|
|
182
|
+
// never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
|
|
183
|
+
// memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
|
|
184
|
+
if (debugLogStore.isEnabled && config.realProofs) {
|
|
185
|
+
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** @internal Exposed for testing — returns the RPC proof verifier. */
|
|
190
|
+
public getProofVerifier(): ClientProtocolCircuitVerifier {
|
|
191
|
+
return this.rpcProofVerifier;
|
|
156
192
|
}
|
|
157
193
|
|
|
158
194
|
public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
|
|
@@ -176,11 +212,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
176
212
|
logger?: Logger;
|
|
177
213
|
publisher?: SequencerPublisher;
|
|
178
214
|
dateProvider?: DateProvider;
|
|
179
|
-
p2pClientDeps?: P2PClientDeps
|
|
215
|
+
p2pClientDeps?: P2PClientDeps;
|
|
216
|
+
proverNodeDeps?: Partial<ProverNodeDeps>;
|
|
217
|
+
slashingProtectionDb?: SlashingProtectionDatabase;
|
|
180
218
|
} = {},
|
|
181
219
|
options: {
|
|
182
|
-
|
|
220
|
+
genesis?: GenesisData;
|
|
183
221
|
dontStartSequencer?: boolean;
|
|
222
|
+
dontStartProverNode?: boolean;
|
|
184
223
|
} = {},
|
|
185
224
|
): Promise<AztecNodeService> {
|
|
186
225
|
const config = { ...inputConfig }; // Copy the config so we dont mutate the input object
|
|
@@ -190,16 +229,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
190
229
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
191
230
|
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
192
231
|
|
|
193
|
-
// Build a key store from file if given or from environment otherwise
|
|
232
|
+
// Build a key store from file if given or from environment otherwise.
|
|
233
|
+
// We keep the raw KeyStore available so we can merge with prover keys if enableProverNode is set.
|
|
194
234
|
let keyStoreManager: KeystoreManager | undefined;
|
|
195
235
|
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
196
236
|
if (keyStoreProvided) {
|
|
197
237
|
const keyStores = loadKeystores(config.keyStoreDirectory!);
|
|
198
238
|
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
199
239
|
} else {
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
240
|
+
const rawKeyStores: KeyStore[] = [];
|
|
241
|
+
const validatorKeyStore = createKeyStoreForValidator(config);
|
|
242
|
+
if (validatorKeyStore) {
|
|
243
|
+
rawKeyStores.push(validatorKeyStore);
|
|
244
|
+
}
|
|
245
|
+
if (config.enableProverNode) {
|
|
246
|
+
const proverKeyStore = createKeyStoreForProver(config);
|
|
247
|
+
if (proverKeyStore) {
|
|
248
|
+
rawKeyStores.push(proverKeyStore);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (rawKeyStores.length > 0) {
|
|
252
|
+
keyStoreManager = new KeystoreManager(
|
|
253
|
+
rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores),
|
|
254
|
+
);
|
|
203
255
|
}
|
|
204
256
|
}
|
|
205
257
|
|
|
@@ -210,10 +262,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
210
262
|
if (keyStoreManager === undefined) {
|
|
211
263
|
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
212
264
|
}
|
|
213
|
-
if (!keyStoreProvided) {
|
|
214
|
-
log.warn(
|
|
215
|
-
'KEY STORE CREATED FROM ENVIRONMENT, IT IS RECOMMENDED TO USE A FILE-BASED KEY STORE IN PRODUCTION ENVIRONMENTS',
|
|
216
|
-
);
|
|
265
|
+
if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
|
|
266
|
+
log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
|
|
217
267
|
}
|
|
218
268
|
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
219
269
|
}
|
|
@@ -227,7 +277,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
227
277
|
|
|
228
278
|
const publicClient = createPublicClient({
|
|
229
279
|
chain: ethereumChain.chainInfo,
|
|
230
|
-
transport:
|
|
280
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, { timeout: config.l1HttpTimeoutMS }),
|
|
231
281
|
pollingInterval: config.viemPollingIntervalMS,
|
|
232
282
|
});
|
|
233
283
|
|
|
@@ -241,10 +291,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
241
291
|
config.l1Contracts = { ...config.l1Contracts, ...l1ContractsAddresses };
|
|
242
292
|
|
|
243
293
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
244
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
294
|
+
const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
|
|
245
295
|
rollupContract.getL1GenesisTime(),
|
|
246
296
|
rollupContract.getSlotDuration(),
|
|
247
297
|
rollupContract.getVersion(),
|
|
298
|
+
rollupContract.getManaLimit().then(Number),
|
|
248
299
|
] as const);
|
|
249
300
|
|
|
250
301
|
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
@@ -255,7 +306,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
255
306
|
);
|
|
256
307
|
}
|
|
257
308
|
|
|
258
|
-
const blobClient = await createBlobClientWithFileStores(config,
|
|
309
|
+
const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
|
|
259
310
|
|
|
260
311
|
// attempt snapshot sync if possible
|
|
261
312
|
await trySnapshotSync(config, log);
|
|
@@ -269,27 +320,41 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
269
320
|
);
|
|
270
321
|
|
|
271
322
|
// now create the merkle trees and the world state synchronizer
|
|
272
|
-
const worldStateSynchronizer = await createWorldStateSynchronizer(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
323
|
+
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.genesis, telemetry);
|
|
324
|
+
const useRealVerifiers = config.realProofs || config.debugForceTxProofVerification;
|
|
325
|
+
let peerProofVerifier: ClientProtocolCircuitVerifier;
|
|
326
|
+
let rpcProofVerifier: ClientProtocolCircuitVerifier;
|
|
327
|
+
if (useRealVerifiers) {
|
|
328
|
+
peerProofVerifier = await BatchChonkVerifier.new(config, config.bbChonkVerifyMaxBatch, 'peer');
|
|
329
|
+
const rpcVerifier = await BBCircuitVerifier.new(config);
|
|
330
|
+
rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, config.numConcurrentIVCVerifiers);
|
|
331
|
+
} else {
|
|
332
|
+
peerProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
333
|
+
rpcProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
let debugLogStore: DebugLogStore;
|
|
282
337
|
if (!config.realProofs) {
|
|
283
338
|
log.warn(`Aztec node is accepting fake proofs`);
|
|
339
|
+
|
|
340
|
+
debugLogStore = new InMemoryDebugLogStore();
|
|
341
|
+
log.info(
|
|
342
|
+
'Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served',
|
|
343
|
+
);
|
|
344
|
+
} else {
|
|
345
|
+
debugLogStore = new NullDebugLogStore();
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
349
|
+
if (proverOnly) {
|
|
350
|
+
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
284
351
|
}
|
|
285
|
-
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
286
352
|
|
|
287
353
|
// create the tx pool and the p2p client, which will need the l2 block source
|
|
288
354
|
const p2pClient = await createP2PClient(
|
|
289
|
-
P2PClientType.Full,
|
|
290
355
|
config,
|
|
291
356
|
archiver,
|
|
292
|
-
|
|
357
|
+
peerProofVerifier,
|
|
293
358
|
worldStateSynchronizer,
|
|
294
359
|
epochCache,
|
|
295
360
|
packageVersion,
|
|
@@ -298,59 +363,77 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
298
363
|
deps.p2pClientDeps,
|
|
299
364
|
);
|
|
300
365
|
|
|
301
|
-
// We
|
|
302
|
-
|
|
366
|
+
// We'll accumulate sentinel watchers here
|
|
367
|
+
const watchers: Watcher[] = [];
|
|
303
368
|
|
|
304
|
-
// Create FullNodeCheckpointsBuilder for
|
|
369
|
+
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
370
|
+
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
305
371
|
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder(
|
|
306
|
-
{
|
|
372
|
+
{
|
|
373
|
+
...config,
|
|
374
|
+
l1GenesisTime,
|
|
375
|
+
slotDuration: Number(slotDuration),
|
|
376
|
+
rollupManaLimit,
|
|
377
|
+
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint,
|
|
378
|
+
},
|
|
307
379
|
worldStateSynchronizer,
|
|
308
380
|
archiver,
|
|
309
381
|
dateProvider,
|
|
310
382
|
telemetry,
|
|
311
383
|
);
|
|
312
384
|
|
|
313
|
-
|
|
314
|
-
const watchers: Watcher[] = [];
|
|
385
|
+
let validatorClient: ValidatorClient | undefined;
|
|
315
386
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
387
|
+
if (!proverOnly) {
|
|
388
|
+
// Create validator client if required
|
|
389
|
+
validatorClient = await createValidatorClient(config, {
|
|
390
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
391
|
+
worldState: worldStateSynchronizer,
|
|
392
|
+
p2pClient,
|
|
393
|
+
telemetry,
|
|
394
|
+
dateProvider,
|
|
395
|
+
epochCache,
|
|
396
|
+
blockSource: archiver,
|
|
397
|
+
l1ToL2MessageSource: archiver,
|
|
398
|
+
keyStoreManager,
|
|
399
|
+
blobClient,
|
|
400
|
+
slashingProtectionDb: deps.slashingProtectionDb,
|
|
401
|
+
});
|
|
329
402
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
403
|
+
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
404
|
+
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
405
|
+
// like attestations or auths will fail.
|
|
406
|
+
if (validatorClient) {
|
|
407
|
+
watchers.push(validatorClient);
|
|
408
|
+
|
|
409
|
+
const vc = validatorClient;
|
|
410
|
+
const getValidatorAddresses = () => vc.getValidatorAddresses().map(a => a.toString());
|
|
411
|
+
validatorClient.getProposalHandler().register(p2pClient, true, archiver, getValidatorAddresses);
|
|
412
|
+
|
|
413
|
+
if (!options.dontStartSequencer) {
|
|
414
|
+
await validatorClient.registerHandlers();
|
|
415
|
+
}
|
|
337
416
|
}
|
|
338
417
|
}
|
|
339
418
|
|
|
340
|
-
// If there's no validator client
|
|
341
|
-
//
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
419
|
+
// If there's no validator client, create a ProposalHandler to handle block and checkpoint proposals
|
|
420
|
+
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
421
|
+
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
422
|
+
// Checkpoint proposals rebuild blobs if the blob client can upload blobs.
|
|
423
|
+
if (!validatorClient) {
|
|
424
|
+
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
425
|
+
log.info(`Setting up proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
426
|
+
createProposalHandler(config, {
|
|
345
427
|
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
346
428
|
worldState: worldStateSynchronizer,
|
|
347
429
|
epochCache,
|
|
348
430
|
blockSource: archiver,
|
|
349
431
|
l1ToL2MessageSource: archiver,
|
|
350
432
|
p2pClient,
|
|
433
|
+
blobClient,
|
|
351
434
|
dateProvider,
|
|
352
435
|
telemetry,
|
|
353
|
-
}).
|
|
436
|
+
}).register(p2pClient, reexecute, archiver);
|
|
354
437
|
}
|
|
355
438
|
|
|
356
439
|
// Start world state and wait for it to sync to the archiver.
|
|
@@ -359,36 +442,39 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
359
442
|
// Start p2p. Note that it depends on world state to be running.
|
|
360
443
|
await p2pClient.start();
|
|
361
444
|
|
|
362
|
-
|
|
363
|
-
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
364
|
-
watchers.push(validatorsSentinel);
|
|
365
|
-
}
|
|
366
|
-
|
|
445
|
+
let validatorsSentinel: Awaited<ReturnType<typeof createSentinel>> | undefined;
|
|
367
446
|
let epochPruneWatcher: EpochPruneWatcher | undefined;
|
|
368
|
-
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
369
|
-
epochPruneWatcher = new EpochPruneWatcher(
|
|
370
|
-
archiver,
|
|
371
|
-
archiver,
|
|
372
|
-
epochCache,
|
|
373
|
-
p2pClient.getTxProvider(),
|
|
374
|
-
validatorCheckpointsBuilder,
|
|
375
|
-
config,
|
|
376
|
-
);
|
|
377
|
-
watchers.push(epochPruneWatcher);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
381
447
|
let attestationsBlockWatcher: AttestationsBlockWatcher | undefined;
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
448
|
+
|
|
449
|
+
if (!proverOnly) {
|
|
450
|
+
validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
451
|
+
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
452
|
+
watchers.push(validatorsSentinel);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
456
|
+
epochPruneWatcher = new EpochPruneWatcher(
|
|
457
|
+
archiver,
|
|
458
|
+
archiver,
|
|
459
|
+
epochCache,
|
|
460
|
+
p2pClient.getTxProvider(),
|
|
461
|
+
validatorCheckpointsBuilder,
|
|
462
|
+
config,
|
|
463
|
+
);
|
|
464
|
+
watchers.push(epochPruneWatcher);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
468
|
+
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
469
|
+
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
470
|
+
watchers.push(attestationsBlockWatcher);
|
|
471
|
+
}
|
|
385
472
|
}
|
|
386
473
|
|
|
387
474
|
// Start p2p-related services once the archiver has completed sync
|
|
388
475
|
void archiver
|
|
389
476
|
.waitForInitialSync()
|
|
390
477
|
.then(async () => {
|
|
391
|
-
await p2pClient.start();
|
|
392
478
|
await validatorsSentinel?.start();
|
|
393
479
|
await epochPruneWatcher?.start();
|
|
394
480
|
await attestationsBlockWatcher?.start();
|
|
@@ -396,6 +482,17 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
396
482
|
})
|
|
397
483
|
.catch(err => log.error('Failed to start p2p services after archiver sync', err));
|
|
398
484
|
|
|
485
|
+
const globalVariableBuilderConfig = {
|
|
486
|
+
l1Contracts: config.l1Contracts,
|
|
487
|
+
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
488
|
+
rollupVersion: BigInt(config.rollupVersion),
|
|
489
|
+
l1GenesisTime,
|
|
490
|
+
slotDuration: Number(slotDuration),
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
const globalVariableBuilder = new GlobalVariableBuilder(dateProvider, publicClient, globalVariableBuilderConfig);
|
|
494
|
+
const feeProvider = new FeeProviderImpl(dateProvider, publicClient, globalVariableBuilderConfig);
|
|
495
|
+
|
|
399
496
|
// Validator enabled, create/start relevant service
|
|
400
497
|
let sequencer: SequencerClient | undefined;
|
|
401
498
|
let slasherClient: SlasherClientInterface | undefined;
|
|
@@ -418,34 +515,49 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
418
515
|
);
|
|
419
516
|
await slasherClient.start();
|
|
420
517
|
|
|
421
|
-
const l1TxUtils = config.
|
|
422
|
-
? await
|
|
518
|
+
const l1TxUtils = config.sequencerPublisherForwarderAddress
|
|
519
|
+
? await createForwarderL1TxUtilsFromSigners(
|
|
423
520
|
publicClient,
|
|
424
521
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
425
|
-
config.
|
|
522
|
+
config.sequencerPublisherForwarderAddress,
|
|
426
523
|
{ ...config, scope: 'sequencer' },
|
|
427
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
524
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
428
525
|
)
|
|
429
|
-
: await
|
|
526
|
+
: await createL1TxUtilsFromSigners(
|
|
430
527
|
publicClient,
|
|
431
528
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
432
529
|
{ ...config, scope: 'sequencer' },
|
|
433
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
530
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
434
531
|
);
|
|
435
532
|
|
|
533
|
+
// Create a funder L1TxUtils from the keystore funding account (if configured)
|
|
534
|
+
const fundingSigner = keyStoreManager?.createFundingSigner();
|
|
535
|
+
let funderL1TxUtils: L1TxUtils | undefined;
|
|
536
|
+
if (fundingSigner) {
|
|
537
|
+
const [funder] = await createL1TxUtilsFromSigners(
|
|
538
|
+
publicClient,
|
|
539
|
+
[fundingSigner],
|
|
540
|
+
{ ...config, scope: 'sequencer' },
|
|
541
|
+
{ telemetry, logger: log.createChild('l1-tx-utils:funder'), dateProvider },
|
|
542
|
+
);
|
|
543
|
+
funderL1TxUtils = funder;
|
|
544
|
+
}
|
|
545
|
+
|
|
436
546
|
// Create and start the sequencer client
|
|
437
547
|
const checkpointsBuilder = new CheckpointsBuilder(
|
|
438
|
-
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
|
|
548
|
+
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration), rollupManaLimit },
|
|
439
549
|
worldStateSynchronizer,
|
|
440
550
|
archiver,
|
|
441
551
|
dateProvider,
|
|
442
552
|
telemetry,
|
|
553
|
+
debugLogStore,
|
|
443
554
|
);
|
|
444
555
|
|
|
445
556
|
sequencer = await SequencerClient.new(config, {
|
|
446
557
|
...deps,
|
|
447
558
|
epochCache,
|
|
448
559
|
l1TxUtils,
|
|
560
|
+
funderL1TxUtils,
|
|
449
561
|
validatorClient,
|
|
450
562
|
p2pClient,
|
|
451
563
|
worldStateSynchronizer,
|
|
@@ -457,6 +569,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
457
569
|
dateProvider,
|
|
458
570
|
blobClient,
|
|
459
571
|
nodeKeyStore: keyStoreManager!,
|
|
572
|
+
globalVariableBuilder,
|
|
460
573
|
});
|
|
461
574
|
}
|
|
462
575
|
|
|
@@ -467,14 +580,30 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
467
580
|
log.warn(`Sequencer created but not started`);
|
|
468
581
|
}
|
|
469
582
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
583
|
+
// Create prover node subsystem if enabled
|
|
584
|
+
let proverNode: ProverNode | undefined;
|
|
585
|
+
if (config.enableProverNode) {
|
|
586
|
+
proverNode = await createProverNode(config, {
|
|
587
|
+
...deps.proverNodeDeps,
|
|
588
|
+
telemetry,
|
|
589
|
+
dateProvider,
|
|
590
|
+
archiver,
|
|
591
|
+
worldStateSynchronizer,
|
|
592
|
+
p2pClient,
|
|
593
|
+
epochCache,
|
|
594
|
+
blobClient,
|
|
595
|
+
keyStoreManager,
|
|
596
|
+
});
|
|
476
597
|
|
|
477
|
-
|
|
598
|
+
if (!options.dontStartProverNode) {
|
|
599
|
+
await proverNode.start();
|
|
600
|
+
log.info(`Prover node subsystem started`);
|
|
601
|
+
} else {
|
|
602
|
+
log.info(`Prover node subsystem created but not started`);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
const node = new AztecNodeService(
|
|
478
607
|
config,
|
|
479
608
|
p2pClient,
|
|
480
609
|
archiver,
|
|
@@ -483,19 +612,27 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
483
612
|
archiver,
|
|
484
613
|
worldStateSynchronizer,
|
|
485
614
|
sequencer,
|
|
615
|
+
proverNode,
|
|
486
616
|
slasherClient,
|
|
487
617
|
validatorsSentinel,
|
|
488
618
|
epochPruneWatcher,
|
|
489
619
|
ethereumChain.chainInfo.id,
|
|
490
620
|
config.rollupVersion,
|
|
491
621
|
globalVariableBuilder,
|
|
622
|
+
feeProvider,
|
|
492
623
|
epochCache,
|
|
493
624
|
packageVersion,
|
|
494
|
-
|
|
625
|
+
peerProofVerifier,
|
|
626
|
+
rpcProofVerifier,
|
|
495
627
|
telemetry,
|
|
496
628
|
log,
|
|
497
629
|
blobClient,
|
|
630
|
+
validatorClient,
|
|
631
|
+
keyStoreManager,
|
|
632
|
+
debugLogStore,
|
|
498
633
|
);
|
|
634
|
+
|
|
635
|
+
return node;
|
|
499
636
|
}
|
|
500
637
|
|
|
501
638
|
/**
|
|
@@ -506,6 +643,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
506
643
|
return this.sequencer;
|
|
507
644
|
}
|
|
508
645
|
|
|
646
|
+
/** Returns the prover node subsystem, if enabled. */
|
|
647
|
+
public getProverNode(): ProverNode | undefined {
|
|
648
|
+
return this.proverNode;
|
|
649
|
+
}
|
|
650
|
+
|
|
509
651
|
public getBlockSource(): L2BlockSource {
|
|
510
652
|
return this.blockSource;
|
|
511
653
|
}
|
|
@@ -531,7 +673,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
531
673
|
}
|
|
532
674
|
|
|
533
675
|
public async getAllowedPublicSetup(): Promise<AllowedElement[]> {
|
|
534
|
-
return this.config.
|
|
676
|
+
return [...(await getDefaultAllowedSetupFunctions()), ...(this.config.txPublicSetupAllowListExtend ?? [])];
|
|
535
677
|
}
|
|
536
678
|
|
|
537
679
|
/**
|
|
@@ -559,6 +701,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
559
701
|
enr,
|
|
560
702
|
l1ContractAddresses: contractAddresses,
|
|
561
703
|
protocolContractAddresses: protocolContractAddresses,
|
|
704
|
+
realProofs: !!this.config.realProofs,
|
|
562
705
|
};
|
|
563
706
|
|
|
564
707
|
return nodeInfo;
|
|
@@ -570,8 +713,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
570
713
|
* @returns The requested block.
|
|
571
714
|
*/
|
|
572
715
|
public async getBlock(block: BlockParameter): Promise<L2Block | undefined> {
|
|
573
|
-
if (BlockHash.
|
|
574
|
-
return this.getBlockByHash(
|
|
716
|
+
if (BlockHash.isBlockHash(block)) {
|
|
717
|
+
return this.getBlockByHash(block);
|
|
575
718
|
}
|
|
576
719
|
const blockNumber = block === 'latest' ? await this.getBlockNumber() : (block as BlockNumber);
|
|
577
720
|
if (blockNumber === BlockNumber.ZERO) {
|
|
@@ -585,9 +728,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
585
728
|
* @param blockHash - The block hash being requested.
|
|
586
729
|
* @returns The requested block.
|
|
587
730
|
*/
|
|
588
|
-
public async getBlockByHash(blockHash:
|
|
731
|
+
public async getBlockByHash(blockHash: BlockHash): Promise<L2Block | undefined> {
|
|
589
732
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
590
|
-
if (blockHash.equals(
|
|
733
|
+
if (blockHash.equals(initialBlockHash)) {
|
|
591
734
|
return this.buildInitialBlock();
|
|
592
735
|
}
|
|
593
736
|
return await this.blockSource.getL2BlockByHash(blockHash);
|
|
@@ -625,12 +768,17 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
625
768
|
return (await this.blockSource.getCheckpointedBlocks(from, limit)) ?? [];
|
|
626
769
|
}
|
|
627
770
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
771
|
+
public getCheckpointsDataForEpoch(epochNumber: EpochNumber) {
|
|
772
|
+
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
773
|
+
}
|
|
774
|
+
|
|
632
775
|
public async getCurrentMinFees(): Promise<GasFees> {
|
|
633
|
-
return await this.
|
|
776
|
+
return await this.feeProvider.getCurrentMinFees();
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/** Returns predicted min fees for the current slot and next N slots. */
|
|
780
|
+
public async getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]> {
|
|
781
|
+
return await this.feeProvider.getPredictedMinFees(manaUsage);
|
|
634
782
|
}
|
|
635
783
|
|
|
636
784
|
public async getMaxPriorityFees(): Promise<GasFees> {
|
|
@@ -657,6 +805,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
657
805
|
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
658
806
|
}
|
|
659
807
|
|
|
808
|
+
public getCheckpointNumber(): Promise<CheckpointNumber> {
|
|
809
|
+
return this.blockSource.getCheckpointNumber();
|
|
810
|
+
}
|
|
811
|
+
|
|
660
812
|
/**
|
|
661
813
|
* Method to fetch the version of the package.
|
|
662
814
|
* @returns The node package version
|
|
@@ -694,19 +846,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
694
846
|
page?: number,
|
|
695
847
|
referenceBlock?: BlockHash,
|
|
696
848
|
): Promise<TxScopedL2Log[][]> {
|
|
849
|
+
let upToBlockNumber: BlockNumber | undefined;
|
|
697
850
|
if (referenceBlock) {
|
|
698
851
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
699
|
-
if (
|
|
700
|
-
|
|
701
|
-
|
|
852
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
853
|
+
upToBlockNumber = BlockNumber(0);
|
|
854
|
+
} else {
|
|
855
|
+
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
702
856
|
if (!header) {
|
|
703
857
|
throw new Error(
|
|
704
858
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
705
859
|
);
|
|
706
860
|
}
|
|
861
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
707
862
|
}
|
|
708
863
|
}
|
|
709
|
-
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
864
|
+
return this.logsSource.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
710
865
|
}
|
|
711
866
|
|
|
712
867
|
public async getPublicLogsByTagsFromContract(
|
|
@@ -715,19 +870,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
715
870
|
page?: number,
|
|
716
871
|
referenceBlock?: BlockHash,
|
|
717
872
|
): Promise<TxScopedL2Log[][]> {
|
|
873
|
+
let upToBlockNumber: BlockNumber | undefined;
|
|
718
874
|
if (referenceBlock) {
|
|
719
875
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
720
|
-
if (
|
|
721
|
-
|
|
722
|
-
|
|
876
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
877
|
+
upToBlockNumber = BlockNumber(0);
|
|
878
|
+
} else {
|
|
879
|
+
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
723
880
|
if (!header) {
|
|
724
881
|
throw new Error(
|
|
725
882
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
726
883
|
);
|
|
727
884
|
}
|
|
885
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
728
886
|
}
|
|
729
887
|
}
|
|
730
|
-
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
|
|
888
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
731
889
|
}
|
|
732
890
|
|
|
733
891
|
/**
|
|
@@ -769,8 +927,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
769
927
|
}
|
|
770
928
|
|
|
771
929
|
await this.p2pClient!.sendTx(tx);
|
|
772
|
-
|
|
773
|
-
this.
|
|
930
|
+
const duration = timer.ms();
|
|
931
|
+
this.metrics.receivedTx(duration, true);
|
|
932
|
+
this.log.info(`Received tx ${txHash} in ${duration}ms`, { txHash });
|
|
774
933
|
}
|
|
775
934
|
|
|
776
935
|
public async getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
@@ -782,18 +941,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
782
941
|
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
783
942
|
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
784
943
|
|
|
944
|
+
let receipt: TxReceipt;
|
|
785
945
|
if (settledTxReceipt) {
|
|
786
|
-
|
|
787
|
-
return settledTxReceipt;
|
|
946
|
+
receipt = settledTxReceipt;
|
|
788
947
|
} else if (isKnownToPool) {
|
|
789
948
|
// If the tx is in the pool but not in the archiver, it's pending.
|
|
790
949
|
// This handles race conditions between archiver and p2p, where the archiver
|
|
791
950
|
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
792
|
-
|
|
951
|
+
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
793
952
|
} else {
|
|
794
953
|
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
795
|
-
|
|
954
|
+
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
796
955
|
}
|
|
956
|
+
|
|
957
|
+
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
958
|
+
|
|
959
|
+
return receipt;
|
|
797
960
|
}
|
|
798
961
|
|
|
799
962
|
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
@@ -808,8 +971,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
808
971
|
await tryStop(this.validatorsSentinel);
|
|
809
972
|
await tryStop(this.epochPruneWatcher);
|
|
810
973
|
await tryStop(this.slasherClient);
|
|
811
|
-
await tryStop(this.
|
|
974
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
812
975
|
await tryStop(this.sequencer);
|
|
976
|
+
await tryStop(this.proverNode);
|
|
813
977
|
await tryStop(this.p2pClient);
|
|
814
978
|
await tryStop(this.worldStateSynchronizer);
|
|
815
979
|
await tryStop(this.blockSource);
|
|
@@ -859,100 +1023,98 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
859
1023
|
}
|
|
860
1024
|
|
|
861
1025
|
public async findLeavesIndexes(
|
|
862
|
-
|
|
1026
|
+
referenceBlock: BlockParameter,
|
|
863
1027
|
treeId: MerkleTreeId,
|
|
864
1028
|
leafValues: Fr[],
|
|
865
1029
|
): Promise<(DataInBlock<bigint> | undefined)[]> {
|
|
866
|
-
const committedDb = await this
|
|
1030
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
867
1031
|
const maybeIndices = await committedDb.findLeafIndices(
|
|
868
1032
|
treeId,
|
|
869
1033
|
leafValues.map(x => x.toBuffer()),
|
|
870
1034
|
);
|
|
871
|
-
//
|
|
872
|
-
const
|
|
1035
|
+
// Filter out undefined values to query block numbers only for found leaves
|
|
1036
|
+
const definedIndices = maybeIndices.filter(x => x !== undefined);
|
|
873
1037
|
|
|
874
|
-
// Now we find the block numbers for the indices
|
|
875
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId,
|
|
1038
|
+
// Now we find the block numbers for the defined indices
|
|
1039
|
+
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
876
1040
|
|
|
877
|
-
//
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
1041
|
+
// Build a map from leaf index to block number
|
|
1042
|
+
const indexToBlockNumber = new Map<bigint, BlockNumber>();
|
|
1043
|
+
for (let i = 0; i < definedIndices.length; i++) {
|
|
1044
|
+
const blockNumber = blockNumbers[i];
|
|
1045
|
+
if (blockNumber === undefined) {
|
|
1046
|
+
throw new Error(
|
|
1047
|
+
`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`,
|
|
1048
|
+
);
|
|
881
1049
|
}
|
|
1050
|
+
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
882
1051
|
}
|
|
883
1052
|
|
|
884
1053
|
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
885
|
-
const uniqueBlockNumbers = [...new Set(
|
|
1054
|
+
const uniqueBlockNumbers = [...new Set(indexToBlockNumber.values())];
|
|
886
1055
|
|
|
887
|
-
// Now we obtain the block hashes from the archive tree
|
|
888
|
-
// (note that block number corresponds to the leaf index in the archive tree).
|
|
1056
|
+
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
889
1057
|
const blockHashes = await Promise.all(
|
|
890
1058
|
uniqueBlockNumbers.map(blockNumber => {
|
|
891
1059
|
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
892
1060
|
}),
|
|
893
1061
|
);
|
|
894
1062
|
|
|
895
|
-
//
|
|
1063
|
+
// Build a map from block number to block hash
|
|
1064
|
+
const blockNumberToHash = new Map<BlockNumber, BlockHash>();
|
|
896
1065
|
for (let i = 0; i < uniqueBlockNumbers.length; i++) {
|
|
897
|
-
|
|
1066
|
+
const blockHash = blockHashes[i];
|
|
1067
|
+
if (blockHash === undefined) {
|
|
898
1068
|
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
899
1069
|
}
|
|
1070
|
+
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
900
1071
|
}
|
|
901
1072
|
|
|
902
1073
|
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
903
|
-
return maybeIndices.map(
|
|
1074
|
+
return maybeIndices.map(index => {
|
|
904
1075
|
if (index === undefined) {
|
|
905
1076
|
return undefined;
|
|
906
1077
|
}
|
|
907
|
-
const blockNumber =
|
|
1078
|
+
const blockNumber = indexToBlockNumber.get(index);
|
|
908
1079
|
if (blockNumber === undefined) {
|
|
909
|
-
|
|
1080
|
+
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
910
1081
|
}
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
return undefined;
|
|
1082
|
+
const l2BlockHash = blockNumberToHash.get(blockNumber);
|
|
1083
|
+
if (l2BlockHash === undefined) {
|
|
1084
|
+
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
915
1085
|
}
|
|
916
1086
|
return {
|
|
917
|
-
l2BlockNumber:
|
|
918
|
-
l2BlockHash
|
|
1087
|
+
l2BlockNumber: blockNumber,
|
|
1088
|
+
l2BlockHash,
|
|
919
1089
|
data: index,
|
|
920
1090
|
};
|
|
921
1091
|
});
|
|
922
1092
|
}
|
|
923
1093
|
|
|
924
|
-
public async
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
): Promise<SiblingPath<typeof NULLIFIER_TREE_HEIGHT>> {
|
|
928
|
-
const committedDb = await this.#getWorldState(block);
|
|
929
|
-
return committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, leafIndex);
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
public async getNoteHashSiblingPath(
|
|
933
|
-
block: BlockParameter,
|
|
934
|
-
leafIndex: bigint,
|
|
935
|
-
): Promise<SiblingPath<typeof NOTE_HASH_TREE_HEIGHT>> {
|
|
936
|
-
const committedDb = await this.#getWorldState(block);
|
|
937
|
-
return committedDb.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
public async getArchiveMembershipWitness(
|
|
941
|
-
block: BlockParameter,
|
|
942
|
-
archive: Fr,
|
|
1094
|
+
public async getBlockHashMembershipWitness(
|
|
1095
|
+
referenceBlock: BlockParameter,
|
|
1096
|
+
blockHash: BlockHash,
|
|
943
1097
|
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
|
|
944
|
-
|
|
945
|
-
|
|
1098
|
+
// The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
|
|
1099
|
+
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
|
|
1100
|
+
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
|
|
1101
|
+
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
|
|
1102
|
+
if (referenceBlockNumber === BlockNumber.ZERO) {
|
|
1103
|
+
// Block 0 (the initial block) has an empty archive, so no membership witness can exist.
|
|
1104
|
+
return undefined;
|
|
1105
|
+
}
|
|
1106
|
+
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
|
|
1107
|
+
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
|
|
946
1108
|
return pathAndIndex === undefined
|
|
947
1109
|
? undefined
|
|
948
1110
|
: MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
949
1111
|
}
|
|
950
1112
|
|
|
951
1113
|
public async getNoteHashMembershipWitness(
|
|
952
|
-
|
|
1114
|
+
referenceBlock: BlockParameter,
|
|
953
1115
|
noteHash: Fr,
|
|
954
1116
|
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
|
|
955
|
-
const committedDb = await this
|
|
1117
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
956
1118
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.NOTE_HASH_TREE>(
|
|
957
1119
|
MerkleTreeId.NOTE_HASH_TREE,
|
|
958
1120
|
[noteHash],
|
|
@@ -963,10 +1125,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
963
1125
|
}
|
|
964
1126
|
|
|
965
1127
|
public async getL1ToL2MessageMembershipWitness(
|
|
966
|
-
|
|
1128
|
+
referenceBlock: BlockParameter,
|
|
967
1129
|
l1ToL2Message: Fr,
|
|
968
1130
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
|
|
969
|
-
const db = await this
|
|
1131
|
+
const db = await this.getWorldState(referenceBlock);
|
|
970
1132
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [l1ToL2Message]);
|
|
971
1133
|
if (!witness) {
|
|
972
1134
|
return undefined;
|
|
@@ -976,11 +1138,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
976
1138
|
return [witness.index, witness.path];
|
|
977
1139
|
}
|
|
978
1140
|
|
|
979
|
-
public async
|
|
1141
|
+
public async getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined> {
|
|
980
1142
|
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
981
|
-
return messageIndex
|
|
982
|
-
? BlockNumber.fromCheckpointNumber(InboxLeaf.checkpointNumberFromIndex(messageIndex))
|
|
983
|
-
: undefined;
|
|
1143
|
+
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
984
1144
|
}
|
|
985
1145
|
|
|
986
1146
|
/**
|
|
@@ -1001,45 +1161,19 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1001
1161
|
public async getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
|
|
1002
1162
|
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
1003
1163
|
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1004
|
-
const blocksInCheckpoints
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
for (const checkpointedBlock of checkpointedBlocks) {
|
|
1008
|
-
const block = checkpointedBlock.block;
|
|
1009
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
1010
|
-
if (slotNumber !== previousSlotNumber) {
|
|
1011
|
-
checkpointIndex++;
|
|
1012
|
-
blocksInCheckpoints.push([]);
|
|
1013
|
-
previousSlotNumber = slotNumber;
|
|
1014
|
-
}
|
|
1015
|
-
blocksInCheckpoints[checkpointIndex].push(block);
|
|
1016
|
-
}
|
|
1164
|
+
const blocksInCheckpoints = chunkBy(checkpointedBlocks, cb => cb.block.header.globalVariables.slotNumber).map(
|
|
1165
|
+
group => group.map(cb => cb.block),
|
|
1166
|
+
);
|
|
1017
1167
|
return blocksInCheckpoints.map(blocks =>
|
|
1018
1168
|
blocks.map(block => block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs)),
|
|
1019
1169
|
);
|
|
1020
1170
|
}
|
|
1021
1171
|
|
|
1022
|
-
public async getArchiveSiblingPath(
|
|
1023
|
-
block: BlockParameter,
|
|
1024
|
-
leafIndex: bigint,
|
|
1025
|
-
): Promise<SiblingPath<typeof ARCHIVE_HEIGHT>> {
|
|
1026
|
-
const committedDb = await this.#getWorldState(block);
|
|
1027
|
-
return committedDb.getSiblingPath(MerkleTreeId.ARCHIVE, leafIndex);
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
public async getPublicDataSiblingPath(
|
|
1031
|
-
block: BlockParameter,
|
|
1032
|
-
leafIndex: bigint,
|
|
1033
|
-
): Promise<SiblingPath<typeof PUBLIC_DATA_TREE_HEIGHT>> {
|
|
1034
|
-
const committedDb = await this.#getWorldState(block);
|
|
1035
|
-
return committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, leafIndex);
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
1172
|
public async getNullifierMembershipWitness(
|
|
1039
|
-
|
|
1173
|
+
referenceBlock: BlockParameter,
|
|
1040
1174
|
nullifier: Fr,
|
|
1041
1175
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1042
|
-
const db = await this
|
|
1176
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1043
1177
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]);
|
|
1044
1178
|
if (!witness) {
|
|
1045
1179
|
return undefined;
|
|
@@ -1054,32 +1188,20 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1054
1188
|
return new NullifierMembershipWitness(index, leafPreimage as NullifierLeafPreimage, path);
|
|
1055
1189
|
}
|
|
1056
1190
|
|
|
1057
|
-
/**
|
|
1058
|
-
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
1059
|
-
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1060
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
1061
|
-
* @returns The low nullifier membership witness (if found).
|
|
1062
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
1063
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
1064
|
-
* we are trying to prove non-inclusion for.
|
|
1065
|
-
*
|
|
1066
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
1067
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
1068
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
1069
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
1070
|
-
*/
|
|
1071
1191
|
public async getLowNullifierMembershipWitness(
|
|
1072
|
-
|
|
1192
|
+
referenceBlock: BlockParameter,
|
|
1073
1193
|
nullifier: Fr,
|
|
1074
1194
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1075
|
-
const committedDb = await this
|
|
1195
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1076
1196
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1077
1197
|
if (!findResult) {
|
|
1078
1198
|
return undefined;
|
|
1079
1199
|
}
|
|
1080
1200
|
const { index, alreadyPresent } = findResult;
|
|
1081
1201
|
if (alreadyPresent) {
|
|
1082
|
-
|
|
1202
|
+
throw new Error(
|
|
1203
|
+
`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`,
|
|
1204
|
+
);
|
|
1083
1205
|
}
|
|
1084
1206
|
const preimageData = (await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index))!;
|
|
1085
1207
|
|
|
@@ -1087,8 +1209,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1087
1209
|
return new NullifierMembershipWitness(BigInt(index), preimageData as NullifierLeafPreimage, siblingPath);
|
|
1088
1210
|
}
|
|
1089
1211
|
|
|
1090
|
-
async getPublicDataWitness(
|
|
1091
|
-
const committedDb = await this
|
|
1212
|
+
async getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
1213
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1092
1214
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1093
1215
|
if (!lowLeafResult) {
|
|
1094
1216
|
return undefined;
|
|
@@ -1102,8 +1224,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1102
1224
|
}
|
|
1103
1225
|
}
|
|
1104
1226
|
|
|
1105
|
-
public async getPublicStorageAt(
|
|
1106
|
-
const committedDb = await this
|
|
1227
|
+
public async getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
1228
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1107
1229
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1108
1230
|
|
|
1109
1231
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
@@ -1118,14 +1240,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1118
1240
|
}
|
|
1119
1241
|
|
|
1120
1242
|
public async getBlockHeader(block: BlockParameter = 'latest'): Promise<BlockHeader | undefined> {
|
|
1121
|
-
if (BlockHash.
|
|
1243
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1122
1244
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1123
1245
|
if (block.equals(initialBlockHash)) {
|
|
1124
1246
|
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1125
1247
|
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1126
1248
|
}
|
|
1127
|
-
|
|
1128
|
-
return this.blockSource.getBlockHeaderByHash(blockHashFr);
|
|
1249
|
+
return this.blockSource.getBlockHeaderByHash(block);
|
|
1129
1250
|
} else {
|
|
1130
1251
|
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1131
1252
|
const blockNumber = block === 'latest' ? await this.getBlockNumber() : (block as BlockNumber);
|
|
@@ -1145,6 +1266,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1145
1266
|
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
1146
1267
|
}
|
|
1147
1268
|
|
|
1269
|
+
public getBlockData(number: BlockNumber): Promise<BlockData | undefined> {
|
|
1270
|
+
return this.blockSource.getBlockData(number);
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
public getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
|
|
1274
|
+
return this.blockSource.getBlockDataByArchive(archive);
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1148
1277
|
/**
|
|
1149
1278
|
* Simulates the public part of a transaction with the current state.
|
|
1150
1279
|
* @param tx - The transaction to simulate.
|
|
@@ -1168,7 +1297,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1168
1297
|
}
|
|
1169
1298
|
|
|
1170
1299
|
const txHash = tx.getTxHash();
|
|
1171
|
-
const
|
|
1300
|
+
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1301
|
+
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
1172
1302
|
|
|
1173
1303
|
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1174
1304
|
const coinbase = EthAddress.ZERO;
|
|
@@ -1183,6 +1313,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1183
1313
|
this.contractDataSource,
|
|
1184
1314
|
new DateProvider(),
|
|
1185
1315
|
this.telemetry,
|
|
1316
|
+
this.log.getBindings(),
|
|
1186
1317
|
);
|
|
1187
1318
|
|
|
1188
1319
|
this.log.verbose(`Simulating public calls for tx ${txHash}`, {
|
|
@@ -1191,6 +1322,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1191
1322
|
blockNumber,
|
|
1192
1323
|
});
|
|
1193
1324
|
|
|
1325
|
+
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1326
|
+
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1194
1327
|
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1195
1328
|
try {
|
|
1196
1329
|
const config = PublicSimulatorConfig.from({
|
|
@@ -1206,7 +1339,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1206
1339
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1207
1340
|
|
|
1208
1341
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1209
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([tx]);
|
|
1342
|
+
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([tx]);
|
|
1210
1343
|
// REFACTOR: Consider returning the error rather than throwing
|
|
1211
1344
|
if (failedTxs.length) {
|
|
1212
1345
|
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
|
|
@@ -1220,6 +1353,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1220
1353
|
processedTx.txEffect,
|
|
1221
1354
|
returns,
|
|
1222
1355
|
processedTx.gasUsed,
|
|
1356
|
+
debugLogs,
|
|
1223
1357
|
);
|
|
1224
1358
|
} finally {
|
|
1225
1359
|
await merkleTreeFork.close();
|
|
@@ -1231,21 +1365,34 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1231
1365
|
{ isSimulation, skipFeeEnforcement }: { isSimulation?: boolean; skipFeeEnforcement?: boolean } = {},
|
|
1232
1366
|
): Promise<TxValidationResult> {
|
|
1233
1367
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1234
|
-
const verifier = isSimulation ? undefined : this.
|
|
1368
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
1235
1369
|
|
|
1236
|
-
// We accept transactions if they are not expired by the next slot (checked based on the
|
|
1370
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1237
1371
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1238
1372
|
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
1239
|
-
const
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1373
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
1374
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(
|
|
1375
|
+
db,
|
|
1376
|
+
this.contractDataSource,
|
|
1377
|
+
verifier,
|
|
1378
|
+
{
|
|
1379
|
+
timestamp: nextSlotTimestamp,
|
|
1380
|
+
blockNumber,
|
|
1381
|
+
l1ChainId: this.l1ChainId,
|
|
1382
|
+
rollupVersion: this.version,
|
|
1383
|
+
setupAllowList: [
|
|
1384
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
1385
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
1386
|
+
],
|
|
1387
|
+
gasFees: await this.getCurrentMinFees(),
|
|
1388
|
+
skipFeeEnforcement,
|
|
1389
|
+
txsPermitted: !this.config.disableTransactions,
|
|
1390
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1391
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1392
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas,
|
|
1393
|
+
},
|
|
1394
|
+
this.log.getBindings(),
|
|
1395
|
+
);
|
|
1249
1396
|
|
|
1250
1397
|
return await validator.validateTx(tx);
|
|
1251
1398
|
}
|
|
@@ -1267,7 +1414,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1267
1414
|
archiver.updateConfig(config);
|
|
1268
1415
|
}
|
|
1269
1416
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
1270
|
-
|
|
1417
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
1418
|
+
if (newConfig.realProofs) {
|
|
1419
|
+
this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
|
|
1420
|
+
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
|
|
1421
|
+
this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
|
|
1422
|
+
} else {
|
|
1423
|
+
this.peerProofVerifier = new TestCircuitVerifier();
|
|
1424
|
+
this.rpcProofVerifier = new TestCircuitVerifier();
|
|
1425
|
+
}
|
|
1271
1426
|
}
|
|
1272
1427
|
|
|
1273
1428
|
this.config = newConfig;
|
|
@@ -1342,7 +1497,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1342
1497
|
return Promise.resolve();
|
|
1343
1498
|
}
|
|
1344
1499
|
|
|
1345
|
-
public async rollbackTo(targetBlock: BlockNumber, force?: boolean): Promise<void> {
|
|
1500
|
+
public async rollbackTo(targetBlock: BlockNumber, force?: boolean, resumeSync = true): Promise<void> {
|
|
1346
1501
|
const archiver = this.blockSource as Archiver;
|
|
1347
1502
|
if (!('rollbackTo' in archiver)) {
|
|
1348
1503
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
@@ -1372,9 +1527,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1372
1527
|
this.log.error(`Error during rollback`, err);
|
|
1373
1528
|
throw err;
|
|
1374
1529
|
} finally {
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1530
|
+
if (resumeSync) {
|
|
1531
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
1532
|
+
this.worldStateSynchronizer.resumeSync();
|
|
1533
|
+
archiver.resume();
|
|
1534
|
+
} else {
|
|
1535
|
+
this.log.info(`Sync left paused after rollback (resumeSync=false).`);
|
|
1536
|
+
}
|
|
1378
1537
|
}
|
|
1379
1538
|
}
|
|
1380
1539
|
|
|
@@ -1391,24 +1550,139 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1391
1550
|
return Promise.resolve();
|
|
1392
1551
|
}
|
|
1393
1552
|
|
|
1394
|
-
public getSlashPayloads(): Promise<SlashPayloadRound[]> {
|
|
1395
|
-
if (!this.slasherClient) {
|
|
1396
|
-
throw new Error(`Slasher client not enabled`);
|
|
1397
|
-
}
|
|
1398
|
-
return this.slasherClient.getSlashPayloads();
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
1553
|
public getSlashOffenses(round: bigint | 'all' | 'current'): Promise<Offense[]> {
|
|
1402
1554
|
if (!this.slasherClient) {
|
|
1403
1555
|
throw new Error(`Slasher client not enabled`);
|
|
1404
1556
|
}
|
|
1405
1557
|
if (round === 'all') {
|
|
1406
|
-
return this.slasherClient.
|
|
1558
|
+
return this.slasherClient.getOffenses();
|
|
1407
1559
|
} else {
|
|
1408
1560
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1409
1561
|
}
|
|
1410
1562
|
}
|
|
1411
1563
|
|
|
1564
|
+
public async reloadKeystore(): Promise<void> {
|
|
1565
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
1566
|
+
throw new BadRequestError(
|
|
1567
|
+
'Cannot reload keystore: node is not using a file-based keystore. ' +
|
|
1568
|
+
'Set KEY_STORE_DIRECTORY to use file-based keystores.',
|
|
1569
|
+
);
|
|
1570
|
+
}
|
|
1571
|
+
if (!this.validatorClient) {
|
|
1572
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
this.log.info('Reloading keystore from disk');
|
|
1576
|
+
|
|
1577
|
+
// Re-read and validate keystore files
|
|
1578
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1579
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1580
|
+
await newManager.validateSigners();
|
|
1581
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1582
|
+
|
|
1583
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1584
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1585
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1586
|
+
// would silently fail on every proposer slot.
|
|
1587
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1588
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1589
|
+
const availablePublishers = new Set(
|
|
1590
|
+
oldAdapter
|
|
1591
|
+
.getAttesterAddresses()
|
|
1592
|
+
.flatMap(a => oldAdapter.getPublisherAddresses(a).map(p => p.toString().toLowerCase())),
|
|
1593
|
+
);
|
|
1594
|
+
|
|
1595
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1596
|
+
for (const attester of newAdapter.getAttesterAddresses()) {
|
|
1597
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1598
|
+
if (pubs.length > 0 && !pubs.some(p => availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1599
|
+
throw new BadRequestError(
|
|
1600
|
+
`Cannot reload keystore: validator ${attester} has publisher keys ` +
|
|
1601
|
+
`[${pubs.map(p => p.toString()).join(', ')}] but none match the L1 signers initialized at startup ` +
|
|
1602
|
+
`[${[...availablePublishers].join(', ')}]. Publishers cannot be hot-reloaded — ` +
|
|
1603
|
+
`use an existing publisher key or restart the node.`,
|
|
1604
|
+
);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
// Build adapters for old and new keystores to compute diff
|
|
1610
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1611
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1612
|
+
const oldAddresses = this.keyStoreManager
|
|
1613
|
+
? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses()
|
|
1614
|
+
: [];
|
|
1615
|
+
|
|
1616
|
+
const oldSet = new Set(oldAddresses.map(a => a.toString()));
|
|
1617
|
+
const newSet = new Set(newAddresses.map(a => a.toString()));
|
|
1618
|
+
const added = newAddresses.filter(a => !oldSet.has(a.toString()));
|
|
1619
|
+
const removed = oldAddresses.filter(a => !newSet.has(a.toString()));
|
|
1620
|
+
|
|
1621
|
+
if (added.length > 0) {
|
|
1622
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map(a => a.toString()).join(', ')}`);
|
|
1623
|
+
}
|
|
1624
|
+
if (removed.length > 0) {
|
|
1625
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map(a => a.toString()).join(', ')}`);
|
|
1626
|
+
}
|
|
1627
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1628
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1632
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1633
|
+
|
|
1634
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1635
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1636
|
+
if (this.sequencer) {
|
|
1637
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1641
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1642
|
+
const slashValidatorsNever = unique(
|
|
1643
|
+
[...(this.config.slashValidatorsNever ?? []), ...newAddresses].map(a => a.toString()),
|
|
1644
|
+
).map(EthAddress.fromString);
|
|
1645
|
+
this.slasherClient.updateConfig({ slashValidatorsNever });
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
this.keyStoreManager = newManager;
|
|
1649
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
public async mineBlock(): Promise<void> {
|
|
1653
|
+
if (!this.sequencer) {
|
|
1654
|
+
throw new BadRequestError('Cannot mine block: no sequencer is running');
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
const currentBlockNumber = await this.getBlockNumber();
|
|
1658
|
+
|
|
1659
|
+
// Use slot duration + 50% buffer as the timeout so this works on running networks too
|
|
1660
|
+
const { slotDuration } = await this.blockSource.getL1Constants();
|
|
1661
|
+
const timeoutSeconds = Math.ceil(slotDuration * 1.5);
|
|
1662
|
+
|
|
1663
|
+
// Temporarily set minTxsPerBlock to 0 so the sequencer produces a block even with no txs
|
|
1664
|
+
const originalMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock;
|
|
1665
|
+
this.sequencer.updateConfig({ minTxsPerBlock: 0 });
|
|
1666
|
+
|
|
1667
|
+
try {
|
|
1668
|
+
// Trigger the sequencer to produce a block immediately
|
|
1669
|
+
void this.sequencer.trigger();
|
|
1670
|
+
|
|
1671
|
+
// Wait for the new L2 block to appear
|
|
1672
|
+
await retryUntil(
|
|
1673
|
+
async () => {
|
|
1674
|
+
const newBlockNumber = await this.getBlockNumber();
|
|
1675
|
+
return newBlockNumber > currentBlockNumber ? true : undefined;
|
|
1676
|
+
},
|
|
1677
|
+
'mineBlock',
|
|
1678
|
+
timeoutSeconds,
|
|
1679
|
+
0.1,
|
|
1680
|
+
);
|
|
1681
|
+
} finally {
|
|
1682
|
+
this.sequencer.updateConfig({ minTxsPerBlock: originalMinTxsPerBlock });
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1412
1686
|
#getInitialHeaderHash(): Promise<BlockHash> {
|
|
1413
1687
|
if (!this.initialHeaderHashPromise) {
|
|
1414
1688
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
@@ -1421,7 +1695,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1421
1695
|
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1422
1696
|
* @returns An instance of a committed MerkleTreeOperations
|
|
1423
1697
|
*/
|
|
1424
|
-
async
|
|
1698
|
+
protected async getWorldState(block: BlockParameter) {
|
|
1425
1699
|
let blockSyncedTo: BlockNumber = BlockNumber.ZERO;
|
|
1426
1700
|
try {
|
|
1427
1701
|
// Attempt to sync the world state if necessary
|
|
@@ -1435,36 +1709,65 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1435
1709
|
return this.worldStateSynchronizer.getCommitted();
|
|
1436
1710
|
}
|
|
1437
1711
|
|
|
1438
|
-
|
|
1712
|
+
// Get the block number, either directly from the parameter or by quering the archiver with the block hash
|
|
1713
|
+
let blockNumber: BlockNumber;
|
|
1714
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1439
1715
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1440
1716
|
if (block.equals(initialBlockHash)) {
|
|
1441
1717
|
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1442
1718
|
return this.worldStateSynchronizer.getSnapshot(BlockNumber.ZERO);
|
|
1443
1719
|
}
|
|
1444
1720
|
|
|
1445
|
-
const
|
|
1446
|
-
const header = await this.blockSource.getBlockHeaderByHash(blockHashFr);
|
|
1721
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1447
1722
|
if (!header) {
|
|
1448
1723
|
throw new Error(
|
|
1449
1724
|
`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.`,
|
|
1450
1725
|
);
|
|
1451
1726
|
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1727
|
+
|
|
1728
|
+
blockNumber = header.getBlockNumber();
|
|
1729
|
+
} else {
|
|
1730
|
+
blockNumber = block as BlockNumber;
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
// Check it's within world state sync range
|
|
1734
|
+
if (blockNumber > blockSyncedTo) {
|
|
1735
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1455
1736
|
}
|
|
1737
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1456
1738
|
|
|
1457
|
-
|
|
1458
|
-
{
|
|
1459
|
-
const blockNumber = block as BlockNumber;
|
|
1739
|
+
const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1460
1740
|
|
|
1461
|
-
|
|
1462
|
-
|
|
1741
|
+
// Double-check world-state synced to the same block hash as was requested
|
|
1742
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1743
|
+
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1744
|
+
if (!blockHash || !block.equals(blockHash)) {
|
|
1745
|
+
throw new Error(
|
|
1746
|
+
`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.`,
|
|
1747
|
+
);
|
|
1463
1748
|
}
|
|
1749
|
+
}
|
|
1464
1750
|
|
|
1465
|
-
|
|
1466
|
-
|
|
1751
|
+
return snapshot;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
/** Resolves a block parameter to a block number. */
|
|
1755
|
+
protected async resolveBlockNumber(block: BlockParameter): Promise<BlockNumber> {
|
|
1756
|
+
if (block === 'latest') {
|
|
1757
|
+
return BlockNumber(await this.blockSource.getBlockNumber());
|
|
1758
|
+
}
|
|
1759
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1760
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1761
|
+
if (block.equals(initialBlockHash)) {
|
|
1762
|
+
return BlockNumber.ZERO;
|
|
1763
|
+
}
|
|
1764
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1765
|
+
if (!header) {
|
|
1766
|
+
throw new Error(`Block hash ${block.toString()} not found.`);
|
|
1767
|
+
}
|
|
1768
|
+
return header.getBlockNumber();
|
|
1467
1769
|
}
|
|
1770
|
+
return block as BlockNumber;
|
|
1468
1771
|
}
|
|
1469
1772
|
|
|
1470
1773
|
/**
|