@aztec/aztec-node 0.0.1-commit.aada20e3 → 0.0.1-commit.b2a5d0dd1
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 +48 -36
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +576 -282
- 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 +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/server.ts +711 -354
- package/src/sentinel/factory.ts +1 -1
- package/src/sentinel/sentinel.ts +65 -32
- package/src/sentinel/store.ts +12 -12
package/src/aztec-node/server.ts
CHANGED
|
@@ -1,30 +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';
|
|
5
|
+
import { Blob } from '@aztec/blob-lib';
|
|
4
6
|
import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
5
7
|
import { EpochCache, type EpochCacheInterface } from '@aztec/epoch-cache';
|
|
6
8
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
7
|
-
import { getPublicClient } from '@aztec/ethereum/client';
|
|
9
|
+
import { getPublicClient, makeL1HttpTransport } from '@aztec/ethereum/client';
|
|
8
10
|
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
9
11
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
12
|
+
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
10
13
|
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
11
|
-
import { compactArray, pick } from '@aztec/foundation/collection';
|
|
14
|
+
import { chunkBy, compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
12
15
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
16
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
14
17
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
15
18
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
19
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
16
20
|
import { count } from '@aztec/foundation/string';
|
|
17
21
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
18
22
|
import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
|
|
19
|
-
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
23
|
+
import { type KeyStore, KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
20
24
|
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
25
|
+
import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
|
|
21
26
|
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
type P2P,
|
|
28
|
+
type P2PClientDeps,
|
|
29
|
+
createP2PClient,
|
|
30
|
+
createTxValidatorForAcceptingTxsOverRPC,
|
|
31
|
+
getDefaultAllowedSetupFunctions,
|
|
32
|
+
} from '@aztec/p2p';
|
|
26
33
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
27
|
-
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';
|
|
28
42
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
29
43
|
import {
|
|
30
44
|
AttestationsBlockWatcher,
|
|
@@ -35,7 +49,14 @@ import {
|
|
|
35
49
|
} from '@aztec/slasher';
|
|
36
50
|
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
37
51
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
38
|
-
import {
|
|
52
|
+
import {
|
|
53
|
+
type BlockData,
|
|
54
|
+
BlockHash,
|
|
55
|
+
type BlockParameter,
|
|
56
|
+
type DataInBlock,
|
|
57
|
+
L2Block,
|
|
58
|
+
type L2BlockSource,
|
|
59
|
+
} from '@aztec/stdlib/block';
|
|
39
60
|
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
40
61
|
import type {
|
|
41
62
|
ContractClassPublic,
|
|
@@ -44,13 +65,14 @@ import type {
|
|
|
44
65
|
NodeInfo,
|
|
45
66
|
ProtocolContractAddresses,
|
|
46
67
|
} from '@aztec/stdlib/contract';
|
|
47
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
68
|
+
import { GasFees, type ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
48
69
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
49
70
|
import {
|
|
50
71
|
type AztecNode,
|
|
51
72
|
type AztecNodeAdmin,
|
|
52
73
|
type AztecNodeAdminConfig,
|
|
53
74
|
AztecNodeAdminConfigSchema,
|
|
75
|
+
type AztecNodeDebug,
|
|
54
76
|
type GetContractClassLogsResponse,
|
|
55
77
|
type GetPublicLogsResponse,
|
|
56
78
|
} from '@aztec/stdlib/interfaces/client';
|
|
@@ -63,14 +85,15 @@ import {
|
|
|
63
85
|
type WorldStateSynchronizer,
|
|
64
86
|
tryStop,
|
|
65
87
|
} from '@aztec/stdlib/interfaces/server';
|
|
66
|
-
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';
|
|
67
90
|
import { InboxLeaf, type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
68
|
-
import {
|
|
69
|
-
import type {
|
|
70
|
-
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';
|
|
71
93
|
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
72
94
|
import {
|
|
73
95
|
type BlockHeader,
|
|
96
|
+
type FeeProvider,
|
|
74
97
|
type GlobalVariableBuilder as GlobalVariableBuilderInterface,
|
|
75
98
|
type IndexedTxEffect,
|
|
76
99
|
PublicSimulationOutput,
|
|
@@ -82,6 +105,7 @@ import {
|
|
|
82
105
|
} from '@aztec/stdlib/tx';
|
|
83
106
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
84
107
|
import type { SingleValidatorStats, ValidatorsStats } from '@aztec/stdlib/validators';
|
|
108
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
85
109
|
import {
|
|
86
110
|
Attributes,
|
|
87
111
|
type TelemetryClient,
|
|
@@ -95,13 +119,13 @@ import {
|
|
|
95
119
|
FullNodeCheckpointsBuilder,
|
|
96
120
|
NodeKeystoreAdapter,
|
|
97
121
|
ValidatorClient,
|
|
98
|
-
|
|
122
|
+
createProposalHandler,
|
|
99
123
|
createValidatorClient,
|
|
100
|
-
createValidatorForAcceptingTxs,
|
|
101
124
|
} from '@aztec/validator-client';
|
|
125
|
+
import type { SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
|
|
102
126
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
103
127
|
|
|
104
|
-
import { createPublicClient
|
|
128
|
+
import { createPublicClient } from 'viem';
|
|
105
129
|
|
|
106
130
|
import { createSentinel } from '../sentinel/factory.js';
|
|
107
131
|
import { Sentinel } from '../sentinel/sentinel.js';
|
|
@@ -111,7 +135,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
111
135
|
/**
|
|
112
136
|
* The aztec node.
|
|
113
137
|
*/
|
|
114
|
-
export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
138
|
+
export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDebug, Traceable {
|
|
115
139
|
private metrics: NodeMetrics;
|
|
116
140
|
private initialHeaderHashPromise: Promise<BlockHash> | undefined = undefined;
|
|
117
141
|
|
|
@@ -129,24 +153,42 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
129
153
|
protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
|
|
130
154
|
protected readonly worldStateSynchronizer: WorldStateSynchronizer,
|
|
131
155
|
protected readonly sequencer: SequencerClient | undefined,
|
|
156
|
+
protected readonly proverNode: ProverNode | undefined,
|
|
132
157
|
protected readonly slasherClient: SlasherClientInterface | undefined,
|
|
133
158
|
protected readonly validatorsSentinel: Sentinel | undefined,
|
|
134
159
|
protected readonly epochPruneWatcher: EpochPruneWatcher | undefined,
|
|
135
160
|
protected readonly l1ChainId: number,
|
|
136
161
|
protected readonly version: number,
|
|
137
162
|
protected readonly globalVariableBuilder: GlobalVariableBuilderInterface,
|
|
163
|
+
protected readonly feeProvider: FeeProvider,
|
|
138
164
|
protected readonly epochCache: EpochCacheInterface,
|
|
139
165
|
protected readonly packageVersion: string,
|
|
140
|
-
private
|
|
166
|
+
private peerProofVerifier: ClientProtocolCircuitVerifier,
|
|
167
|
+
private rpcProofVerifier: ClientProtocolCircuitVerifier,
|
|
141
168
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
142
169
|
private log = createLogger('node'),
|
|
143
170
|
private blobClient?: BlobClientInterface,
|
|
171
|
+
private validatorClient?: ValidatorClient,
|
|
172
|
+
private keyStoreManager?: KeystoreManager,
|
|
173
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
144
174
|
) {
|
|
145
175
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
146
176
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
147
177
|
|
|
148
178
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
149
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;
|
|
150
192
|
}
|
|
151
193
|
|
|
152
194
|
public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
|
|
@@ -170,11 +212,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
170
212
|
logger?: Logger;
|
|
171
213
|
publisher?: SequencerPublisher;
|
|
172
214
|
dateProvider?: DateProvider;
|
|
173
|
-
p2pClientDeps?: P2PClientDeps
|
|
215
|
+
p2pClientDeps?: P2PClientDeps;
|
|
216
|
+
proverNodeDeps?: Partial<ProverNodeDeps>;
|
|
217
|
+
slashingProtectionDb?: SlashingProtectionDatabase;
|
|
174
218
|
} = {},
|
|
175
219
|
options: {
|
|
176
|
-
|
|
220
|
+
genesis?: GenesisData;
|
|
177
221
|
dontStartSequencer?: boolean;
|
|
222
|
+
dontStartProverNode?: boolean;
|
|
178
223
|
} = {},
|
|
179
224
|
): Promise<AztecNodeService> {
|
|
180
225
|
const config = { ...inputConfig }; // Copy the config so we dont mutate the input object
|
|
@@ -184,16 +229,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
184
229
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
185
230
|
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
186
231
|
|
|
187
|
-
// 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.
|
|
188
234
|
let keyStoreManager: KeystoreManager | undefined;
|
|
189
235
|
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
190
236
|
if (keyStoreProvided) {
|
|
191
237
|
const keyStores = loadKeystores(config.keyStoreDirectory!);
|
|
192
238
|
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
193
239
|
} else {
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
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
|
+
);
|
|
197
255
|
}
|
|
198
256
|
}
|
|
199
257
|
|
|
@@ -204,10 +262,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
204
262
|
if (keyStoreManager === undefined) {
|
|
205
263
|
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
206
264
|
}
|
|
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
|
-
);
|
|
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");
|
|
211
267
|
}
|
|
212
268
|
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
213
269
|
}
|
|
@@ -221,7 +277,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
221
277
|
|
|
222
278
|
const publicClient = createPublicClient({
|
|
223
279
|
chain: ethereumChain.chainInfo,
|
|
224
|
-
transport:
|
|
280
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, { timeout: config.l1HttpTimeoutMS }),
|
|
225
281
|
pollingInterval: config.viemPollingIntervalMS,
|
|
226
282
|
});
|
|
227
283
|
|
|
@@ -235,10 +291,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
235
291
|
config.l1Contracts = { ...config.l1Contracts, ...l1ContractsAddresses };
|
|
236
292
|
|
|
237
293
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
238
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
294
|
+
const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
|
|
239
295
|
rollupContract.getL1GenesisTime(),
|
|
240
296
|
rollupContract.getSlotDuration(),
|
|
241
297
|
rollupContract.getVersion(),
|
|
298
|
+
rollupContract.getManaLimit().then(Number),
|
|
242
299
|
] as const);
|
|
243
300
|
|
|
244
301
|
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
@@ -249,247 +306,351 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
249
306
|
);
|
|
250
307
|
}
|
|
251
308
|
|
|
252
|
-
const blobClient = await createBlobClientWithFileStores(config,
|
|
309
|
+
const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
|
|
253
310
|
|
|
254
311
|
// attempt snapshot sync if possible
|
|
255
312
|
await trySnapshotSync(config, log);
|
|
256
313
|
|
|
257
314
|
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, { dateProvider });
|
|
258
315
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
316
|
+
// Track started resources so we can clean up on partial failure during node creation.
|
|
317
|
+
const started: { stop?(): Promise<void> | void }[] = [];
|
|
318
|
+
try {
|
|
319
|
+
const archiver = await createArchiver(
|
|
320
|
+
config,
|
|
321
|
+
{ blobClient, epochCache, telemetry, dateProvider },
|
|
322
|
+
{ blockUntilSync: !config.skipArchiverInitialSync },
|
|
323
|
+
);
|
|
324
|
+
started.push(archiver);
|
|
325
|
+
|
|
326
|
+
// now create the merkle trees and the world state synchronizer
|
|
327
|
+
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.genesis, telemetry);
|
|
328
|
+
started.push(worldStateSynchronizer);
|
|
329
|
+
const useRealVerifiers = config.realProofs || config.debugForceTxProofVerification;
|
|
330
|
+
let peerProofVerifier: ClientProtocolCircuitVerifier;
|
|
331
|
+
let rpcProofVerifier: ClientProtocolCircuitVerifier;
|
|
332
|
+
if (useRealVerifiers) {
|
|
333
|
+
peerProofVerifier = await BatchChonkVerifier.new(config, config.bbChonkVerifyMaxBatch, 'peer');
|
|
334
|
+
const rpcVerifier = await BBCircuitVerifier.new(config);
|
|
335
|
+
rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, config.numConcurrentIVCVerifiers);
|
|
336
|
+
} else {
|
|
337
|
+
peerProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
338
|
+
rpcProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
339
|
+
}
|
|
340
|
+
started.push(peerProofVerifier, rpcProofVerifier);
|
|
264
341
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
archiver,
|
|
269
|
-
options.prefilledPublicData,
|
|
270
|
-
telemetry,
|
|
271
|
-
);
|
|
272
|
-
const circuitVerifier =
|
|
273
|
-
config.realProofs || config.debugForceTxProofVerification
|
|
274
|
-
? await BBCircuitVerifier.new(config)
|
|
275
|
-
: new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
276
|
-
if (!config.realProofs) {
|
|
277
|
-
log.warn(`Aztec node is accepting fake proofs`);
|
|
278
|
-
}
|
|
279
|
-
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
280
|
-
|
|
281
|
-
// create the tx pool and the p2p client, which will need the l2 block source
|
|
282
|
-
const p2pClient = await createP2PClient(
|
|
283
|
-
P2PClientType.Full,
|
|
284
|
-
config,
|
|
285
|
-
archiver,
|
|
286
|
-
proofVerifier,
|
|
287
|
-
worldStateSynchronizer,
|
|
288
|
-
epochCache,
|
|
289
|
-
packageVersion,
|
|
290
|
-
dateProvider,
|
|
291
|
-
telemetry,
|
|
292
|
-
deps.p2pClientDeps,
|
|
293
|
-
);
|
|
342
|
+
let debugLogStore: DebugLogStore;
|
|
343
|
+
if (!config.realProofs) {
|
|
344
|
+
log.warn(`Aztec node is accepting fake proofs`);
|
|
294
345
|
|
|
295
|
-
|
|
296
|
-
|
|
346
|
+
debugLogStore = new InMemoryDebugLogStore();
|
|
347
|
+
log.info(
|
|
348
|
+
'Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served',
|
|
349
|
+
);
|
|
350
|
+
} else {
|
|
351
|
+
debugLogStore = new NullDebugLogStore();
|
|
352
|
+
}
|
|
297
353
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
);
|
|
354
|
+
const globalVariableBuilderConfig = {
|
|
355
|
+
l1Contracts: config.l1Contracts,
|
|
356
|
+
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
357
|
+
rollupVersion: BigInt(config.rollupVersion),
|
|
358
|
+
l1GenesisTime,
|
|
359
|
+
slotDuration: Number(slotDuration),
|
|
360
|
+
};
|
|
306
361
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
// Create validator client if required
|
|
311
|
-
const validatorClient = await createValidatorClient(config, {
|
|
312
|
-
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
313
|
-
worldState: worldStateSynchronizer,
|
|
314
|
-
p2pClient,
|
|
315
|
-
telemetry,
|
|
316
|
-
dateProvider,
|
|
317
|
-
epochCache,
|
|
318
|
-
blockSource: archiver,
|
|
319
|
-
l1ToL2MessageSource: archiver,
|
|
320
|
-
keyStoreManager,
|
|
321
|
-
blobClient,
|
|
322
|
-
});
|
|
362
|
+
const globalVariableBuilder = new GlobalVariableBuilder(dateProvider, publicClient, globalVariableBuilderConfig);
|
|
363
|
+
const feeProvider = new FeeProviderImpl(dateProvider, publicClient, globalVariableBuilderConfig);
|
|
323
364
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
if (validatorClient) {
|
|
328
|
-
watchers.push(validatorClient);
|
|
329
|
-
if (!options.dontStartSequencer) {
|
|
330
|
-
await validatorClient.registerHandlers();
|
|
365
|
+
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
366
|
+
if (proverOnly) {
|
|
367
|
+
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
331
368
|
}
|
|
332
|
-
}
|
|
333
369
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
worldState: worldStateSynchronizer,
|
|
370
|
+
// create the tx pool and the p2p client, which will need the l2 block source
|
|
371
|
+
const p2pClient = await createP2PClient(
|
|
372
|
+
config,
|
|
373
|
+
archiver,
|
|
374
|
+
peerProofVerifier,
|
|
375
|
+
worldStateSynchronizer,
|
|
341
376
|
epochCache,
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
p2pClient,
|
|
377
|
+
feeProvider,
|
|
378
|
+
packageVersion,
|
|
345
379
|
dateProvider,
|
|
346
380
|
telemetry,
|
|
347
|
-
|
|
348
|
-
|
|
381
|
+
deps.p2pClientDeps,
|
|
382
|
+
);
|
|
383
|
+
started.push(p2pClient);
|
|
384
|
+
|
|
385
|
+
// We'll accumulate sentinel watchers here
|
|
386
|
+
const watchers: Watcher[] = [];
|
|
387
|
+
|
|
388
|
+
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
389
|
+
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
390
|
+
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder(
|
|
391
|
+
{
|
|
392
|
+
...config,
|
|
393
|
+
l1GenesisTime,
|
|
394
|
+
slotDuration: Number(slotDuration),
|
|
395
|
+
rollupManaLimit,
|
|
396
|
+
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint,
|
|
397
|
+
},
|
|
398
|
+
worldStateSynchronizer,
|
|
399
|
+
archiver,
|
|
400
|
+
dateProvider,
|
|
401
|
+
telemetry,
|
|
402
|
+
);
|
|
349
403
|
|
|
350
|
-
|
|
351
|
-
|
|
404
|
+
let validatorClient: ValidatorClient | undefined;
|
|
405
|
+
|
|
406
|
+
if (!proverOnly) {
|
|
407
|
+
// Create validator client if required
|
|
408
|
+
validatorClient = await createValidatorClient(config, {
|
|
409
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
410
|
+
worldState: worldStateSynchronizer,
|
|
411
|
+
p2pClient,
|
|
412
|
+
telemetry,
|
|
413
|
+
dateProvider,
|
|
414
|
+
epochCache,
|
|
415
|
+
blockSource: archiver,
|
|
416
|
+
l1ToL2MessageSource: archiver,
|
|
417
|
+
keyStoreManager,
|
|
418
|
+
blobClient,
|
|
419
|
+
slashingProtectionDb: deps.slashingProtectionDb,
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
423
|
+
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
424
|
+
// like attestations or auths will fail.
|
|
425
|
+
if (validatorClient) {
|
|
426
|
+
watchers.push(validatorClient);
|
|
427
|
+
|
|
428
|
+
const vc = validatorClient;
|
|
429
|
+
const getValidatorAddresses = () => vc.getValidatorAddresses().map(a => a.toString());
|
|
430
|
+
validatorClient.getProposalHandler().register(p2pClient, true, archiver, getValidatorAddresses);
|
|
431
|
+
|
|
432
|
+
if (!options.dontStartSequencer) {
|
|
433
|
+
await validatorClient.registerHandlers();
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
352
437
|
|
|
353
|
-
|
|
354
|
-
|
|
438
|
+
// If there's no validator client, create a ProposalHandler to handle block and checkpoint proposals
|
|
439
|
+
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
440
|
+
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
441
|
+
// Checkpoint proposals rebuild blobs if the blob client can upload blobs.
|
|
442
|
+
if (!validatorClient) {
|
|
443
|
+
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
444
|
+
log.info(`Setting up proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
445
|
+
createProposalHandler(config, {
|
|
446
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
447
|
+
worldState: worldStateSynchronizer,
|
|
448
|
+
epochCache,
|
|
449
|
+
blockSource: archiver,
|
|
450
|
+
l1ToL2MessageSource: archiver,
|
|
451
|
+
p2pClient,
|
|
452
|
+
blobClient,
|
|
453
|
+
dateProvider,
|
|
454
|
+
telemetry,
|
|
455
|
+
}).register(p2pClient, reexecute, archiver);
|
|
456
|
+
}
|
|
355
457
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
watchers.push(validatorsSentinel);
|
|
359
|
-
}
|
|
458
|
+
// Start world state and wait for it to sync to the archiver.
|
|
459
|
+
await worldStateSynchronizer.start();
|
|
360
460
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
epochPruneWatcher = new EpochPruneWatcher(
|
|
364
|
-
archiver,
|
|
365
|
-
archiver,
|
|
366
|
-
epochCache,
|
|
367
|
-
p2pClient.getTxProvider(),
|
|
368
|
-
validatorCheckpointsBuilder,
|
|
369
|
-
config,
|
|
370
|
-
);
|
|
371
|
-
watchers.push(epochPruneWatcher);
|
|
372
|
-
}
|
|
461
|
+
// Start p2p. Note that it depends on world state to be running.
|
|
462
|
+
await p2pClient.start();
|
|
373
463
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
378
|
-
watchers.push(attestationsBlockWatcher);
|
|
379
|
-
}
|
|
464
|
+
let validatorsSentinel: Awaited<ReturnType<typeof createSentinel>> | undefined;
|
|
465
|
+
let epochPruneWatcher: EpochPruneWatcher | undefined;
|
|
466
|
+
let attestationsBlockWatcher: AttestationsBlockWatcher | undefined;
|
|
380
467
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
await validatorsSentinel?.start();
|
|
387
|
-
await epochPruneWatcher?.start();
|
|
388
|
-
await attestationsBlockWatcher?.start();
|
|
389
|
-
log.info(`All p2p services started`);
|
|
390
|
-
})
|
|
391
|
-
.catch(err => log.error('Failed to start p2p services after archiver sync', err));
|
|
392
|
-
|
|
393
|
-
// Validator enabled, create/start relevant service
|
|
394
|
-
let sequencer: SequencerClient | undefined;
|
|
395
|
-
let slasherClient: SlasherClientInterface | undefined;
|
|
396
|
-
if (!config.disableValidator && validatorClient) {
|
|
397
|
-
// We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
|
|
398
|
-
// as they are executed when the node is selected as proposer.
|
|
399
|
-
const validatorAddresses = keyStoreManager
|
|
400
|
-
? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses()
|
|
401
|
-
: [];
|
|
402
|
-
|
|
403
|
-
slasherClient = await createSlasher(
|
|
404
|
-
config,
|
|
405
|
-
config.l1Contracts,
|
|
406
|
-
getPublicClient(config),
|
|
407
|
-
watchers,
|
|
408
|
-
dateProvider,
|
|
409
|
-
epochCache,
|
|
410
|
-
validatorAddresses,
|
|
411
|
-
undefined, // logger
|
|
412
|
-
);
|
|
413
|
-
await slasherClient.start();
|
|
468
|
+
if (!proverOnly) {
|
|
469
|
+
validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
470
|
+
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
471
|
+
watchers.push(validatorsSentinel);
|
|
472
|
+
}
|
|
414
473
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
474
|
+
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
475
|
+
epochPruneWatcher = new EpochPruneWatcher(
|
|
476
|
+
archiver,
|
|
477
|
+
archiver,
|
|
478
|
+
epochCache,
|
|
479
|
+
p2pClient.getTxProvider(),
|
|
480
|
+
validatorCheckpointsBuilder,
|
|
481
|
+
config,
|
|
482
|
+
);
|
|
483
|
+
watchers.push(epochPruneWatcher);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
487
|
+
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
488
|
+
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
489
|
+
watchers.push(attestationsBlockWatcher);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// Start p2p-related services once the archiver has completed sync
|
|
494
|
+
void archiver
|
|
495
|
+
.waitForInitialSync()
|
|
496
|
+
.then(async () => {
|
|
497
|
+
await validatorsSentinel?.start();
|
|
498
|
+
await epochPruneWatcher?.start();
|
|
499
|
+
await attestationsBlockWatcher?.start();
|
|
500
|
+
log.info(`All p2p services started`);
|
|
501
|
+
})
|
|
502
|
+
.catch(err => log.error('Failed to start p2p services after archiver sync', err));
|
|
503
|
+
|
|
504
|
+
// Validator enabled, create/start relevant service
|
|
505
|
+
let sequencer: SequencerClient | undefined;
|
|
506
|
+
let slasherClient: SlasherClientInterface | undefined;
|
|
507
|
+
if (!config.disableValidator && validatorClient) {
|
|
508
|
+
// We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
|
|
509
|
+
// as they are executed when the node is selected as proposer.
|
|
510
|
+
const validatorAddresses = keyStoreManager
|
|
511
|
+
? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses()
|
|
512
|
+
: [];
|
|
513
|
+
|
|
514
|
+
slasherClient = await createSlasher(
|
|
515
|
+
config,
|
|
516
|
+
config.l1Contracts,
|
|
517
|
+
getPublicClient(config),
|
|
518
|
+
watchers,
|
|
519
|
+
dateProvider,
|
|
520
|
+
epochCache,
|
|
521
|
+
validatorAddresses,
|
|
522
|
+
undefined, // logger
|
|
523
|
+
);
|
|
524
|
+
await slasherClient.start();
|
|
525
|
+
started.push(slasherClient);
|
|
526
|
+
|
|
527
|
+
const l1TxUtils = config.sequencerPublisherForwarderAddress
|
|
528
|
+
? await createForwarderL1TxUtilsFromSigners(
|
|
529
|
+
publicClient,
|
|
530
|
+
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
531
|
+
config.sequencerPublisherForwarderAddress,
|
|
532
|
+
{ ...config, scope: 'sequencer' },
|
|
533
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
534
|
+
)
|
|
535
|
+
: await createL1TxUtilsFromSigners(
|
|
536
|
+
publicClient,
|
|
537
|
+
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
538
|
+
{ ...config, scope: 'sequencer' },
|
|
539
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
540
|
+
);
|
|
541
|
+
|
|
542
|
+
// Create a funder L1TxUtils from the keystore funding account (if configured)
|
|
543
|
+
const fundingSigner = keyStoreManager?.createFundingSigner();
|
|
544
|
+
let funderL1TxUtils: L1TxUtils | undefined;
|
|
545
|
+
if (fundingSigner) {
|
|
546
|
+
const [funder] = await createL1TxUtilsFromSigners(
|
|
424
547
|
publicClient,
|
|
425
|
-
|
|
548
|
+
[fundingSigner],
|
|
426
549
|
{ ...config, scope: 'sequencer' },
|
|
427
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
550
|
+
{ telemetry, logger: log.createChild('l1-tx-utils:funder'), dateProvider },
|
|
428
551
|
);
|
|
552
|
+
funderL1TxUtils = funder;
|
|
553
|
+
}
|
|
429
554
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
555
|
+
// Create and start the sequencer client
|
|
556
|
+
const checkpointsBuilder = new CheckpointsBuilder(
|
|
557
|
+
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration), rollupManaLimit },
|
|
558
|
+
worldStateSynchronizer,
|
|
559
|
+
archiver,
|
|
560
|
+
dateProvider,
|
|
561
|
+
telemetry,
|
|
562
|
+
debugLogStore,
|
|
563
|
+
);
|
|
438
564
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
565
|
+
sequencer = await SequencerClient.new(config, {
|
|
566
|
+
...deps,
|
|
567
|
+
epochCache,
|
|
568
|
+
l1TxUtils,
|
|
569
|
+
funderL1TxUtils,
|
|
570
|
+
validatorClient,
|
|
571
|
+
p2pClient,
|
|
572
|
+
worldStateSynchronizer,
|
|
573
|
+
slasherClient,
|
|
574
|
+
checkpointsBuilder,
|
|
575
|
+
l2BlockSource: archiver,
|
|
576
|
+
l1ToL2MessageSource: archiver,
|
|
577
|
+
telemetry,
|
|
578
|
+
dateProvider,
|
|
579
|
+
blobClient,
|
|
580
|
+
nodeKeyStore: keyStoreManager!,
|
|
581
|
+
globalVariableBuilder,
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
if (!options.dontStartSequencer && sequencer) {
|
|
586
|
+
await sequencer.start();
|
|
587
|
+
started.push(sequencer);
|
|
588
|
+
log.verbose(`Sequencer started`);
|
|
589
|
+
} else if (sequencer) {
|
|
590
|
+
log.warn(`Sequencer created but not started`);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// Create prover node subsystem if enabled
|
|
594
|
+
let proverNode: ProverNode | undefined;
|
|
595
|
+
if (config.enableProverNode) {
|
|
596
|
+
proverNode = await createProverNode(config, {
|
|
597
|
+
...deps.proverNodeDeps,
|
|
598
|
+
telemetry,
|
|
599
|
+
dateProvider,
|
|
600
|
+
archiver,
|
|
601
|
+
worldStateSynchronizer,
|
|
602
|
+
p2pClient,
|
|
603
|
+
epochCache,
|
|
604
|
+
blobClient,
|
|
605
|
+
keyStoreManager,
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
if (!options.dontStartProverNode) {
|
|
609
|
+
await proverNode.start();
|
|
610
|
+
started.push(proverNode);
|
|
611
|
+
log.info(`Prover node subsystem started`);
|
|
612
|
+
} else {
|
|
613
|
+
log.info(`Prover node subsystem created but not started`);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
const node = new AztecNodeService(
|
|
618
|
+
config,
|
|
444
619
|
p2pClient,
|
|
620
|
+
archiver,
|
|
621
|
+
archiver,
|
|
622
|
+
archiver,
|
|
623
|
+
archiver,
|
|
445
624
|
worldStateSynchronizer,
|
|
625
|
+
sequencer,
|
|
626
|
+
proverNode,
|
|
446
627
|
slasherClient,
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
628
|
+
validatorsSentinel,
|
|
629
|
+
epochPruneWatcher,
|
|
630
|
+
ethereumChain.chainInfo.id,
|
|
631
|
+
config.rollupVersion,
|
|
632
|
+
globalVariableBuilder,
|
|
633
|
+
feeProvider,
|
|
634
|
+
epochCache,
|
|
635
|
+
packageVersion,
|
|
636
|
+
peerProofVerifier,
|
|
637
|
+
rpcProofVerifier,
|
|
450
638
|
telemetry,
|
|
451
|
-
|
|
639
|
+
log,
|
|
452
640
|
blobClient,
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
641
|
+
validatorClient,
|
|
642
|
+
keyStoreManager,
|
|
643
|
+
debugLogStore,
|
|
644
|
+
);
|
|
456
645
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
log.
|
|
460
|
-
|
|
461
|
-
|
|
646
|
+
return node;
|
|
647
|
+
} catch (err) {
|
|
648
|
+
log.error('Failed during node creation, stopping started resources', err);
|
|
649
|
+
for (const resource of started.reverse()) {
|
|
650
|
+
await tryStop(resource);
|
|
651
|
+
}
|
|
652
|
+
throw err;
|
|
462
653
|
}
|
|
463
|
-
|
|
464
|
-
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
465
|
-
...config,
|
|
466
|
-
rollupVersion: BigInt(config.rollupVersion),
|
|
467
|
-
l1GenesisTime,
|
|
468
|
-
slotDuration: Number(slotDuration),
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
return new AztecNodeService(
|
|
472
|
-
config,
|
|
473
|
-
p2pClient,
|
|
474
|
-
archiver,
|
|
475
|
-
archiver,
|
|
476
|
-
archiver,
|
|
477
|
-
archiver,
|
|
478
|
-
worldStateSynchronizer,
|
|
479
|
-
sequencer,
|
|
480
|
-
slasherClient,
|
|
481
|
-
validatorsSentinel,
|
|
482
|
-
epochPruneWatcher,
|
|
483
|
-
ethereumChain.chainInfo.id,
|
|
484
|
-
config.rollupVersion,
|
|
485
|
-
globalVariableBuilder,
|
|
486
|
-
epochCache,
|
|
487
|
-
packageVersion,
|
|
488
|
-
proofVerifier,
|
|
489
|
-
telemetry,
|
|
490
|
-
log,
|
|
491
|
-
blobClient,
|
|
492
|
-
);
|
|
493
654
|
}
|
|
494
655
|
|
|
495
656
|
/**
|
|
@@ -500,6 +661,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
500
661
|
return this.sequencer;
|
|
501
662
|
}
|
|
502
663
|
|
|
664
|
+
/** Returns the prover node subsystem, if enabled. */
|
|
665
|
+
public getProverNode(): ProverNode | undefined {
|
|
666
|
+
return this.proverNode;
|
|
667
|
+
}
|
|
668
|
+
|
|
503
669
|
public getBlockSource(): L2BlockSource {
|
|
504
670
|
return this.blockSource;
|
|
505
671
|
}
|
|
@@ -525,7 +691,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
525
691
|
}
|
|
526
692
|
|
|
527
693
|
public async getAllowedPublicSetup(): Promise<AllowedElement[]> {
|
|
528
|
-
return this.config.
|
|
694
|
+
return [...(await getDefaultAllowedSetupFunctions()), ...(this.config.txPublicSetupAllowListExtend ?? [])];
|
|
529
695
|
}
|
|
530
696
|
|
|
531
697
|
/**
|
|
@@ -553,6 +719,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
553
719
|
enr,
|
|
554
720
|
l1ContractAddresses: contractAddresses,
|
|
555
721
|
protocolContractAddresses: protocolContractAddresses,
|
|
722
|
+
realProofs: !!this.config.realProofs,
|
|
556
723
|
};
|
|
557
724
|
|
|
558
725
|
return nodeInfo;
|
|
@@ -619,12 +786,17 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
619
786
|
return (await this.blockSource.getCheckpointedBlocks(from, limit)) ?? [];
|
|
620
787
|
}
|
|
621
788
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
789
|
+
public getCheckpointsDataForEpoch(epochNumber: EpochNumber) {
|
|
790
|
+
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
791
|
+
}
|
|
792
|
+
|
|
626
793
|
public async getCurrentMinFees(): Promise<GasFees> {
|
|
627
|
-
return await this.
|
|
794
|
+
return await this.feeProvider.getCurrentMinFees();
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/** Returns predicted min fees for the current slot and next N slots. */
|
|
798
|
+
public async getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]> {
|
|
799
|
+
return await this.feeProvider.getPredictedMinFees(manaUsage);
|
|
628
800
|
}
|
|
629
801
|
|
|
630
802
|
public async getMaxPriorityFees(): Promise<GasFees> {
|
|
@@ -651,6 +823,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
651
823
|
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
652
824
|
}
|
|
653
825
|
|
|
826
|
+
public getCheckpointNumber(): Promise<CheckpointNumber> {
|
|
827
|
+
return this.blockSource.getCheckpointNumber();
|
|
828
|
+
}
|
|
829
|
+
|
|
654
830
|
/**
|
|
655
831
|
* Method to fetch the version of the package.
|
|
656
832
|
* @returns The node package version
|
|
@@ -688,18 +864,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
688
864
|
page?: number,
|
|
689
865
|
referenceBlock?: BlockHash,
|
|
690
866
|
): Promise<TxScopedL2Log[][]> {
|
|
867
|
+
let upToBlockNumber: BlockNumber | undefined;
|
|
691
868
|
if (referenceBlock) {
|
|
692
869
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
693
|
-
if (
|
|
870
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
871
|
+
upToBlockNumber = BlockNumber(0);
|
|
872
|
+
} else {
|
|
694
873
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
695
874
|
if (!header) {
|
|
696
875
|
throw new Error(
|
|
697
876
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
698
877
|
);
|
|
699
878
|
}
|
|
879
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
700
880
|
}
|
|
701
881
|
}
|
|
702
|
-
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
882
|
+
return this.logsSource.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
703
883
|
}
|
|
704
884
|
|
|
705
885
|
public async getPublicLogsByTagsFromContract(
|
|
@@ -708,18 +888,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
708
888
|
page?: number,
|
|
709
889
|
referenceBlock?: BlockHash,
|
|
710
890
|
): Promise<TxScopedL2Log[][]> {
|
|
891
|
+
let upToBlockNumber: BlockNumber | undefined;
|
|
711
892
|
if (referenceBlock) {
|
|
712
893
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
713
|
-
if (
|
|
894
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
895
|
+
upToBlockNumber = BlockNumber(0);
|
|
896
|
+
} else {
|
|
714
897
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
715
898
|
if (!header) {
|
|
716
899
|
throw new Error(
|
|
717
900
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
718
901
|
);
|
|
719
902
|
}
|
|
903
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
720
904
|
}
|
|
721
905
|
}
|
|
722
|
-
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
|
|
906
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
723
907
|
}
|
|
724
908
|
|
|
725
909
|
/**
|
|
@@ -761,8 +945,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
761
945
|
}
|
|
762
946
|
|
|
763
947
|
await this.p2pClient!.sendTx(tx);
|
|
764
|
-
|
|
765
|
-
this.
|
|
948
|
+
const duration = timer.ms();
|
|
949
|
+
this.metrics.receivedTx(duration, true);
|
|
950
|
+
this.log.info(`Received tx ${txHash} in ${duration}ms`, { txHash });
|
|
766
951
|
}
|
|
767
952
|
|
|
768
953
|
public async getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
@@ -774,18 +959,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
774
959
|
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
775
960
|
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
776
961
|
|
|
962
|
+
let receipt: TxReceipt;
|
|
777
963
|
if (settledTxReceipt) {
|
|
778
|
-
|
|
779
|
-
return settledTxReceipt;
|
|
964
|
+
receipt = settledTxReceipt;
|
|
780
965
|
} else if (isKnownToPool) {
|
|
781
966
|
// If the tx is in the pool but not in the archiver, it's pending.
|
|
782
967
|
// This handles race conditions between archiver and p2p, where the archiver
|
|
783
968
|
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
784
|
-
|
|
969
|
+
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
785
970
|
} else {
|
|
786
971
|
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
787
|
-
|
|
972
|
+
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
788
973
|
}
|
|
974
|
+
|
|
975
|
+
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
976
|
+
|
|
977
|
+
return receipt;
|
|
789
978
|
}
|
|
790
979
|
|
|
791
980
|
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
@@ -800,8 +989,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
800
989
|
await tryStop(this.validatorsSentinel);
|
|
801
990
|
await tryStop(this.epochPruneWatcher);
|
|
802
991
|
await tryStop(this.slasherClient);
|
|
803
|
-
await tryStop(this.
|
|
992
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
804
993
|
await tryStop(this.sequencer);
|
|
994
|
+
await tryStop(this.proverNode);
|
|
805
995
|
await tryStop(this.p2pClient);
|
|
806
996
|
await tryStop(this.worldStateSynchronizer);
|
|
807
997
|
await tryStop(this.blockSource);
|
|
@@ -855,59 +1045,65 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
855
1045
|
treeId: MerkleTreeId,
|
|
856
1046
|
leafValues: Fr[],
|
|
857
1047
|
): Promise<(DataInBlock<bigint> | undefined)[]> {
|
|
858
|
-
const committedDb = await this
|
|
1048
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
859
1049
|
const maybeIndices = await committedDb.findLeafIndices(
|
|
860
1050
|
treeId,
|
|
861
1051
|
leafValues.map(x => x.toBuffer()),
|
|
862
1052
|
);
|
|
863
|
-
//
|
|
864
|
-
const
|
|
1053
|
+
// Filter out undefined values to query block numbers only for found leaves
|
|
1054
|
+
const definedIndices = maybeIndices.filter(x => x !== undefined);
|
|
865
1055
|
|
|
866
|
-
// Now we find the block numbers for the indices
|
|
867
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId,
|
|
1056
|
+
// Now we find the block numbers for the defined indices
|
|
1057
|
+
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
868
1058
|
|
|
869
|
-
//
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
1059
|
+
// Build a map from leaf index to block number
|
|
1060
|
+
const indexToBlockNumber = new Map<bigint, BlockNumber>();
|
|
1061
|
+
for (let i = 0; i < definedIndices.length; i++) {
|
|
1062
|
+
const blockNumber = blockNumbers[i];
|
|
1063
|
+
if (blockNumber === undefined) {
|
|
1064
|
+
throw new Error(
|
|
1065
|
+
`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`,
|
|
1066
|
+
);
|
|
873
1067
|
}
|
|
1068
|
+
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
874
1069
|
}
|
|
875
1070
|
|
|
876
1071
|
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
877
|
-
const uniqueBlockNumbers = [...new Set(
|
|
1072
|
+
const uniqueBlockNumbers = [...new Set(indexToBlockNumber.values())];
|
|
878
1073
|
|
|
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).
|
|
1074
|
+
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
881
1075
|
const blockHashes = await Promise.all(
|
|
882
1076
|
uniqueBlockNumbers.map(blockNumber => {
|
|
883
1077
|
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
884
1078
|
}),
|
|
885
1079
|
);
|
|
886
1080
|
|
|
887
|
-
//
|
|
1081
|
+
// Build a map from block number to block hash
|
|
1082
|
+
const blockNumberToHash = new Map<BlockNumber, BlockHash>();
|
|
888
1083
|
for (let i = 0; i < uniqueBlockNumbers.length; i++) {
|
|
889
|
-
|
|
1084
|
+
const blockHash = blockHashes[i];
|
|
1085
|
+
if (blockHash === undefined) {
|
|
890
1086
|
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
891
1087
|
}
|
|
1088
|
+
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
892
1089
|
}
|
|
893
1090
|
|
|
894
1091
|
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
895
|
-
return maybeIndices.map(
|
|
1092
|
+
return maybeIndices.map(index => {
|
|
896
1093
|
if (index === undefined) {
|
|
897
1094
|
return undefined;
|
|
898
1095
|
}
|
|
899
|
-
const blockNumber =
|
|
1096
|
+
const blockNumber = indexToBlockNumber.get(index);
|
|
900
1097
|
if (blockNumber === undefined) {
|
|
901
|
-
|
|
1098
|
+
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
902
1099
|
}
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
return undefined;
|
|
1100
|
+
const l2BlockHash = blockNumberToHash.get(blockNumber);
|
|
1101
|
+
if (l2BlockHash === undefined) {
|
|
1102
|
+
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
907
1103
|
}
|
|
908
1104
|
return {
|
|
909
|
-
l2BlockNumber:
|
|
910
|
-
l2BlockHash
|
|
1105
|
+
l2BlockNumber: blockNumber,
|
|
1106
|
+
l2BlockHash,
|
|
911
1107
|
data: index,
|
|
912
1108
|
};
|
|
913
1109
|
});
|
|
@@ -917,7 +1113,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
917
1113
|
referenceBlock: BlockParameter,
|
|
918
1114
|
blockHash: BlockHash,
|
|
919
1115
|
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
|
|
920
|
-
|
|
1116
|
+
// The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
|
|
1117
|
+
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
|
|
1118
|
+
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
|
|
1119
|
+
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
|
|
1120
|
+
if (referenceBlockNumber === BlockNumber.ZERO) {
|
|
1121
|
+
// Block 0 (the initial block) has an empty archive, so no membership witness can exist.
|
|
1122
|
+
return undefined;
|
|
1123
|
+
}
|
|
1124
|
+
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
|
|
921
1125
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
|
|
922
1126
|
return pathAndIndex === undefined
|
|
923
1127
|
? undefined
|
|
@@ -928,7 +1132,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
928
1132
|
referenceBlock: BlockParameter,
|
|
929
1133
|
noteHash: Fr,
|
|
930
1134
|
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
|
|
931
|
-
const committedDb = await this
|
|
1135
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
932
1136
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.NOTE_HASH_TREE>(
|
|
933
1137
|
MerkleTreeId.NOTE_HASH_TREE,
|
|
934
1138
|
[noteHash],
|
|
@@ -942,7 +1146,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
942
1146
|
referenceBlock: BlockParameter,
|
|
943
1147
|
l1ToL2Message: Fr,
|
|
944
1148
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
|
|
945
|
-
const db = await this
|
|
1149
|
+
const db = await this.getWorldState(referenceBlock);
|
|
946
1150
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [l1ToL2Message]);
|
|
947
1151
|
if (!witness) {
|
|
948
1152
|
return undefined;
|
|
@@ -952,11 +1156,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
952
1156
|
return [witness.index, witness.path];
|
|
953
1157
|
}
|
|
954
1158
|
|
|
955
|
-
public async
|
|
1159
|
+
public async getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined> {
|
|
956
1160
|
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
957
|
-
return messageIndex
|
|
958
|
-
? BlockNumber.fromCheckpointNumber(InboxLeaf.checkpointNumberFromIndex(messageIndex))
|
|
959
|
-
: undefined;
|
|
1161
|
+
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
960
1162
|
}
|
|
961
1163
|
|
|
962
1164
|
/**
|
|
@@ -977,19 +1179,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
977
1179
|
public async getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
|
|
978
1180
|
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
979
1181
|
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
|
-
}
|
|
1182
|
+
const blocksInCheckpoints = chunkBy(checkpointedBlocks, cb => cb.block.header.globalVariables.slotNumber).map(
|
|
1183
|
+
group => group.map(cb => cb.block),
|
|
1184
|
+
);
|
|
993
1185
|
return blocksInCheckpoints.map(blocks =>
|
|
994
1186
|
blocks.map(block => block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs)),
|
|
995
1187
|
);
|
|
@@ -999,7 +1191,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
999
1191
|
referenceBlock: BlockParameter,
|
|
1000
1192
|
nullifier: Fr,
|
|
1001
1193
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1002
|
-
const db = await this
|
|
1194
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1003
1195
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]);
|
|
1004
1196
|
if (!witness) {
|
|
1005
1197
|
return undefined;
|
|
@@ -1014,33 +1206,20 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1014
1206
|
return new NullifierMembershipWitness(index, leafPreimage as NullifierLeafPreimage, path);
|
|
1015
1207
|
}
|
|
1016
1208
|
|
|
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
1209
|
public async getLowNullifierMembershipWitness(
|
|
1033
1210
|
referenceBlock: BlockParameter,
|
|
1034
1211
|
nullifier: Fr,
|
|
1035
1212
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1036
|
-
const committedDb = await this
|
|
1213
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1037
1214
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1038
1215
|
if (!findResult) {
|
|
1039
1216
|
return undefined;
|
|
1040
1217
|
}
|
|
1041
1218
|
const { index, alreadyPresent } = findResult;
|
|
1042
1219
|
if (alreadyPresent) {
|
|
1043
|
-
|
|
1220
|
+
throw new Error(
|
|
1221
|
+
`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`,
|
|
1222
|
+
);
|
|
1044
1223
|
}
|
|
1045
1224
|
const preimageData = (await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index))!;
|
|
1046
1225
|
|
|
@@ -1049,7 +1228,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1049
1228
|
}
|
|
1050
1229
|
|
|
1051
1230
|
async getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
1052
|
-
const committedDb = await this
|
|
1231
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1053
1232
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1054
1233
|
if (!lowLeafResult) {
|
|
1055
1234
|
return undefined;
|
|
@@ -1064,7 +1243,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1064
1243
|
}
|
|
1065
1244
|
|
|
1066
1245
|
public async getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
1067
|
-
const committedDb = await this
|
|
1246
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1068
1247
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1069
1248
|
|
|
1070
1249
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
@@ -1105,6 +1284,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1105
1284
|
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
1106
1285
|
}
|
|
1107
1286
|
|
|
1287
|
+
public getBlockData(number: BlockNumber): Promise<BlockData | undefined> {
|
|
1288
|
+
return this.blockSource.getBlockData(number);
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
public getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
|
|
1292
|
+
return this.blockSource.getBlockDataByArchive(archive);
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1108
1295
|
/**
|
|
1109
1296
|
* Simulates the public part of a transaction with the current state.
|
|
1110
1297
|
* @param tx - The transaction to simulate.
|
|
@@ -1128,7 +1315,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1128
1315
|
}
|
|
1129
1316
|
|
|
1130
1317
|
const txHash = tx.getTxHash();
|
|
1131
|
-
const
|
|
1318
|
+
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1319
|
+
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
1132
1320
|
|
|
1133
1321
|
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1134
1322
|
const coinbase = EthAddress.ZERO;
|
|
@@ -1152,6 +1340,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1152
1340
|
blockNumber,
|
|
1153
1341
|
});
|
|
1154
1342
|
|
|
1343
|
+
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1344
|
+
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1155
1345
|
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1156
1346
|
try {
|
|
1157
1347
|
const config = PublicSimulatorConfig.from({
|
|
@@ -1167,7 +1357,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1167
1357
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1168
1358
|
|
|
1169
1359
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1170
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([tx]);
|
|
1360
|
+
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([tx]);
|
|
1171
1361
|
// REFACTOR: Consider returning the error rather than throwing
|
|
1172
1362
|
if (failedTxs.length) {
|
|
1173
1363
|
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
|
|
@@ -1181,6 +1371,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1181
1371
|
processedTx.txEffect,
|
|
1182
1372
|
returns,
|
|
1183
1373
|
processedTx.gasUsed,
|
|
1374
|
+
debugLogs,
|
|
1184
1375
|
);
|
|
1185
1376
|
} finally {
|
|
1186
1377
|
await merkleTreeFork.close();
|
|
@@ -1192,12 +1383,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1192
1383
|
{ isSimulation, skipFeeEnforcement }: { isSimulation?: boolean; skipFeeEnforcement?: boolean } = {},
|
|
1193
1384
|
): Promise<TxValidationResult> {
|
|
1194
1385
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1195
|
-
const verifier = isSimulation ? undefined : this.
|
|
1386
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
1196
1387
|
|
|
1197
|
-
// We accept transactions if they are not expired by the next slot (checked based on the
|
|
1388
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1198
1389
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1199
1390
|
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
1200
|
-
const
|
|
1391
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
1392
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(
|
|
1201
1393
|
db,
|
|
1202
1394
|
this.contractDataSource,
|
|
1203
1395
|
verifier,
|
|
@@ -1206,10 +1398,16 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1206
1398
|
blockNumber,
|
|
1207
1399
|
l1ChainId: this.l1ChainId,
|
|
1208
1400
|
rollupVersion: this.version,
|
|
1209
|
-
setupAllowList:
|
|
1401
|
+
setupAllowList: [
|
|
1402
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
1403
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
1404
|
+
],
|
|
1210
1405
|
gasFees: await this.getCurrentMinFees(),
|
|
1211
1406
|
skipFeeEnforcement,
|
|
1212
1407
|
txsPermitted: !this.config.disableTransactions,
|
|
1408
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1409
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1410
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas,
|
|
1213
1411
|
},
|
|
1214
1412
|
this.log.getBindings(),
|
|
1215
1413
|
);
|
|
@@ -1234,7 +1432,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1234
1432
|
archiver.updateConfig(config);
|
|
1235
1433
|
}
|
|
1236
1434
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
1237
|
-
|
|
1435
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
1436
|
+
if (newConfig.realProofs) {
|
|
1437
|
+
this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
|
|
1438
|
+
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
|
|
1439
|
+
this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
|
|
1440
|
+
} else {
|
|
1441
|
+
this.peerProofVerifier = new TestCircuitVerifier();
|
|
1442
|
+
this.rpcProofVerifier = new TestCircuitVerifier();
|
|
1443
|
+
}
|
|
1238
1444
|
}
|
|
1239
1445
|
|
|
1240
1446
|
this.config = newConfig;
|
|
@@ -1309,7 +1515,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1309
1515
|
return Promise.resolve();
|
|
1310
1516
|
}
|
|
1311
1517
|
|
|
1312
|
-
public async rollbackTo(targetBlock: BlockNumber, force?: boolean): Promise<void> {
|
|
1518
|
+
public async rollbackTo(targetBlock: BlockNumber, force?: boolean, resumeSync = true): Promise<void> {
|
|
1313
1519
|
const archiver = this.blockSource as Archiver;
|
|
1314
1520
|
if (!('rollbackTo' in archiver)) {
|
|
1315
1521
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
@@ -1339,9 +1545,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1339
1545
|
this.log.error(`Error during rollback`, err);
|
|
1340
1546
|
throw err;
|
|
1341
1547
|
} finally {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1548
|
+
if (resumeSync) {
|
|
1549
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
1550
|
+
this.worldStateSynchronizer.resumeSync();
|
|
1551
|
+
archiver.resume();
|
|
1552
|
+
} else {
|
|
1553
|
+
this.log.info(`Sync left paused after rollback (resumeSync=false).`);
|
|
1554
|
+
}
|
|
1345
1555
|
}
|
|
1346
1556
|
}
|
|
1347
1557
|
|
|
@@ -1358,24 +1568,139 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1358
1568
|
return Promise.resolve();
|
|
1359
1569
|
}
|
|
1360
1570
|
|
|
1361
|
-
public getSlashPayloads(): Promise<SlashPayloadRound[]> {
|
|
1362
|
-
if (!this.slasherClient) {
|
|
1363
|
-
throw new Error(`Slasher client not enabled`);
|
|
1364
|
-
}
|
|
1365
|
-
return this.slasherClient.getSlashPayloads();
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
1571
|
public getSlashOffenses(round: bigint | 'all' | 'current'): Promise<Offense[]> {
|
|
1369
1572
|
if (!this.slasherClient) {
|
|
1370
1573
|
throw new Error(`Slasher client not enabled`);
|
|
1371
1574
|
}
|
|
1372
1575
|
if (round === 'all') {
|
|
1373
|
-
return this.slasherClient.
|
|
1576
|
+
return this.slasherClient.getOffenses();
|
|
1374
1577
|
} else {
|
|
1375
1578
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1376
1579
|
}
|
|
1377
1580
|
}
|
|
1378
1581
|
|
|
1582
|
+
public async reloadKeystore(): Promise<void> {
|
|
1583
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
1584
|
+
throw new BadRequestError(
|
|
1585
|
+
'Cannot reload keystore: node is not using a file-based keystore. ' +
|
|
1586
|
+
'Set KEY_STORE_DIRECTORY to use file-based keystores.',
|
|
1587
|
+
);
|
|
1588
|
+
}
|
|
1589
|
+
if (!this.validatorClient) {
|
|
1590
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
this.log.info('Reloading keystore from disk');
|
|
1594
|
+
|
|
1595
|
+
// Re-read and validate keystore files
|
|
1596
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1597
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1598
|
+
await newManager.validateSigners();
|
|
1599
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1600
|
+
|
|
1601
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1602
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1603
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1604
|
+
// would silently fail on every proposer slot.
|
|
1605
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1606
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1607
|
+
const availablePublishers = new Set(
|
|
1608
|
+
oldAdapter
|
|
1609
|
+
.getAttesterAddresses()
|
|
1610
|
+
.flatMap(a => oldAdapter.getPublisherAddresses(a).map(p => p.toString().toLowerCase())),
|
|
1611
|
+
);
|
|
1612
|
+
|
|
1613
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1614
|
+
for (const attester of newAdapter.getAttesterAddresses()) {
|
|
1615
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1616
|
+
if (pubs.length > 0 && !pubs.some(p => availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1617
|
+
throw new BadRequestError(
|
|
1618
|
+
`Cannot reload keystore: validator ${attester} has publisher keys ` +
|
|
1619
|
+
`[${pubs.map(p => p.toString()).join(', ')}] but none match the L1 signers initialized at startup ` +
|
|
1620
|
+
`[${[...availablePublishers].join(', ')}]. Publishers cannot be hot-reloaded — ` +
|
|
1621
|
+
`use an existing publisher key or restart the node.`,
|
|
1622
|
+
);
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
// Build adapters for old and new keystores to compute diff
|
|
1628
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1629
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1630
|
+
const oldAddresses = this.keyStoreManager
|
|
1631
|
+
? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses()
|
|
1632
|
+
: [];
|
|
1633
|
+
|
|
1634
|
+
const oldSet = new Set(oldAddresses.map(a => a.toString()));
|
|
1635
|
+
const newSet = new Set(newAddresses.map(a => a.toString()));
|
|
1636
|
+
const added = newAddresses.filter(a => !oldSet.has(a.toString()));
|
|
1637
|
+
const removed = oldAddresses.filter(a => !newSet.has(a.toString()));
|
|
1638
|
+
|
|
1639
|
+
if (added.length > 0) {
|
|
1640
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map(a => a.toString()).join(', ')}`);
|
|
1641
|
+
}
|
|
1642
|
+
if (removed.length > 0) {
|
|
1643
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map(a => a.toString()).join(', ')}`);
|
|
1644
|
+
}
|
|
1645
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1646
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1650
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1651
|
+
|
|
1652
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1653
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1654
|
+
if (this.sequencer) {
|
|
1655
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1659
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1660
|
+
const slashValidatorsNever = unique(
|
|
1661
|
+
[...(this.config.slashValidatorsNever ?? []), ...newAddresses].map(a => a.toString()),
|
|
1662
|
+
).map(EthAddress.fromString);
|
|
1663
|
+
this.slasherClient.updateConfig({ slashValidatorsNever });
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
this.keyStoreManager = newManager;
|
|
1667
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
public async mineBlock(): Promise<void> {
|
|
1671
|
+
if (!this.sequencer) {
|
|
1672
|
+
throw new BadRequestError('Cannot mine block: no sequencer is running');
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
const currentBlockNumber = await this.getBlockNumber();
|
|
1676
|
+
|
|
1677
|
+
// Use slot duration + 50% buffer as the timeout so this works on running networks too
|
|
1678
|
+
const { slotDuration } = await this.blockSource.getL1Constants();
|
|
1679
|
+
const timeoutSeconds = Math.ceil(slotDuration * 1.5);
|
|
1680
|
+
|
|
1681
|
+
// Temporarily set minTxsPerBlock to 0 so the sequencer produces a block even with no txs
|
|
1682
|
+
const originalMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock;
|
|
1683
|
+
this.sequencer.updateConfig({ minTxsPerBlock: 0 });
|
|
1684
|
+
|
|
1685
|
+
try {
|
|
1686
|
+
// Trigger the sequencer to produce a block immediately
|
|
1687
|
+
void this.sequencer.trigger();
|
|
1688
|
+
|
|
1689
|
+
// Wait for the new L2 block to appear
|
|
1690
|
+
await retryUntil(
|
|
1691
|
+
async () => {
|
|
1692
|
+
const newBlockNumber = await this.getBlockNumber();
|
|
1693
|
+
return newBlockNumber > currentBlockNumber ? true : undefined;
|
|
1694
|
+
},
|
|
1695
|
+
'mineBlock',
|
|
1696
|
+
timeoutSeconds,
|
|
1697
|
+
0.1,
|
|
1698
|
+
);
|
|
1699
|
+
} finally {
|
|
1700
|
+
this.sequencer.updateConfig({ minTxsPerBlock: originalMinTxsPerBlock });
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1379
1704
|
#getInitialHeaderHash(): Promise<BlockHash> {
|
|
1380
1705
|
if (!this.initialHeaderHashPromise) {
|
|
1381
1706
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
@@ -1388,7 +1713,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1388
1713
|
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1389
1714
|
* @returns An instance of a committed MerkleTreeOperations
|
|
1390
1715
|
*/
|
|
1391
|
-
async
|
|
1716
|
+
protected async getWorldState(block: BlockParameter) {
|
|
1392
1717
|
let blockSyncedTo: BlockNumber = BlockNumber.ZERO;
|
|
1393
1718
|
try {
|
|
1394
1719
|
// Attempt to sync the world state if necessary
|
|
@@ -1402,35 +1727,67 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1402
1727
|
return this.worldStateSynchronizer.getCommitted();
|
|
1403
1728
|
}
|
|
1404
1729
|
|
|
1730
|
+
// Get the block number, either directly from the parameter or by quering the archiver with the block hash
|
|
1731
|
+
let blockNumber: BlockNumber;
|
|
1405
1732
|
if (BlockHash.isBlockHash(block)) {
|
|
1406
1733
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1407
1734
|
if (block.equals(initialBlockHash)) {
|
|
1408
|
-
// Block
|
|
1409
|
-
|
|
1735
|
+
// Block 0 is a first-class historical block: its state lives in the trees' persisted
|
|
1736
|
+
// block-0 payload. Resolving the genesis hash to block number 0 lets the snapshot path
|
|
1737
|
+
// pin reads to genesis state even after the node has advanced past it.
|
|
1738
|
+
blockNumber = BlockNumber.ZERO;
|
|
1739
|
+
} else {
|
|
1740
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1741
|
+
if (!header) {
|
|
1742
|
+
throw new Error(
|
|
1743
|
+
`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.`,
|
|
1744
|
+
);
|
|
1745
|
+
}
|
|
1746
|
+
blockNumber = header.getBlockNumber();
|
|
1410
1747
|
}
|
|
1748
|
+
} else {
|
|
1749
|
+
blockNumber = block as BlockNumber;
|
|
1750
|
+
}
|
|
1411
1751
|
|
|
1412
|
-
|
|
1413
|
-
|
|
1752
|
+
// Check it's within world state sync range
|
|
1753
|
+
if (blockNumber > blockSyncedTo) {
|
|
1754
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1755
|
+
}
|
|
1756
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1757
|
+
|
|
1758
|
+
const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1759
|
+
|
|
1760
|
+
// Double-check world-state synced to the same block hash as was requested
|
|
1761
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1762
|
+
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1763
|
+
if (!blockHash || !block.equals(blockHash)) {
|
|
1764
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1414
1765
|
throw new Error(
|
|
1415
|
-
`Block hash ${block.toString()} not found
|
|
1766
|
+
`Block hash ${block.toString()} not found in world state at block number ${blockNumber} (world state has ${blockHash?.toString() ?? 'no hash'} at that index, genesis header hash is ${initialBlockHash.toString()}). If the node API has been queried with anchor block hash possibly a reorg has occurred.`,
|
|
1416
1767
|
);
|
|
1417
1768
|
}
|
|
1418
|
-
const blockNumber = header.getBlockNumber();
|
|
1419
|
-
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1420
|
-
return this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1421
1769
|
}
|
|
1422
1770
|
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
const blockNumber = block as BlockNumber;
|
|
1771
|
+
return snapshot;
|
|
1772
|
+
}
|
|
1426
1773
|
|
|
1427
|
-
|
|
1428
|
-
|
|
1774
|
+
/** Resolves a block parameter to a block number. */
|
|
1775
|
+
protected async resolveBlockNumber(block: BlockParameter): Promise<BlockNumber> {
|
|
1776
|
+
if (block === 'latest') {
|
|
1777
|
+
return BlockNumber(await this.blockSource.getBlockNumber());
|
|
1778
|
+
}
|
|
1779
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1780
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1781
|
+
if (block.equals(initialBlockHash)) {
|
|
1782
|
+
return BlockNumber.ZERO;
|
|
1429
1783
|
}
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1784
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1785
|
+
if (!header) {
|
|
1786
|
+
throw new Error(`Block hash ${block.toString()} not found.`);
|
|
1787
|
+
}
|
|
1788
|
+
return header.getBlockNumber();
|
|
1433
1789
|
}
|
|
1790
|
+
return block as BlockNumber;
|
|
1434
1791
|
}
|
|
1435
1792
|
|
|
1436
1793
|
/**
|