@aztec/aztec-node 0.0.1-commit.ec5f612 → 0.0.1-commit.ec7ac5448
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 +2 -2
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +1 -1
- package/dest/aztec-node/server.d.ts +26 -26
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +260 -142
- package/dest/sentinel/factory.d.ts +2 -2
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +8 -8
- package/package.json +26 -27
- package/src/aztec-node/config.ts +1 -1
- package/src/aztec-node/server.ts +275 -150
- package/src/sentinel/factory.ts +1 -1
- package/src/sentinel/sentinel.ts +8 -8
package/src/aztec-node/server.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
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
5
|
import { Blob } from '@aztec/blob-lib';
|
|
5
6
|
import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
6
7
|
import { EpochCache, type EpochCacheInterface } from '@aztec/epoch-cache';
|
|
7
8
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
8
|
-
import { getPublicClient } from '@aztec/ethereum/client';
|
|
9
|
+
import { getPublicClient, makeL1HttpTransport } from '@aztec/ethereum/client';
|
|
9
10
|
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
10
11
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
12
|
+
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
11
13
|
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
12
|
-
import { compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
14
|
+
import { chunkBy, compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
13
15
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
14
16
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
15
17
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
16
18
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
19
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
17
20
|
import { count } from '@aztec/foundation/string';
|
|
18
21
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
19
22
|
import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
|
|
@@ -64,6 +67,7 @@ import {
|
|
|
64
67
|
type AztecNodeAdmin,
|
|
65
68
|
type AztecNodeAdminConfig,
|
|
66
69
|
AztecNodeAdminConfigSchema,
|
|
70
|
+
type AztecNodeDebug,
|
|
67
71
|
type GetContractClassLogsResponse,
|
|
68
72
|
type GetPublicLogsResponse,
|
|
69
73
|
} from '@aztec/stdlib/interfaces/client';
|
|
@@ -79,8 +83,8 @@ import {
|
|
|
79
83
|
import type { DebugLogStore, LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
80
84
|
import { InMemoryDebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
81
85
|
import { InboxLeaf, type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
82
|
-
import type { Offense
|
|
83
|
-
import type { NullifierLeafPreimage,
|
|
86
|
+
import type { Offense } from '@aztec/stdlib/slashing';
|
|
87
|
+
import type { NullifierLeafPreimage, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
84
88
|
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
85
89
|
import {
|
|
86
90
|
type BlockHeader,
|
|
@@ -95,6 +99,7 @@ import {
|
|
|
95
99
|
} from '@aztec/stdlib/tx';
|
|
96
100
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
97
101
|
import type { SingleValidatorStats, ValidatorsStats } from '@aztec/stdlib/validators';
|
|
102
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
98
103
|
import {
|
|
99
104
|
Attributes,
|
|
100
105
|
type TelemetryClient,
|
|
@@ -108,12 +113,13 @@ import {
|
|
|
108
113
|
FullNodeCheckpointsBuilder,
|
|
109
114
|
NodeKeystoreAdapter,
|
|
110
115
|
ValidatorClient,
|
|
111
|
-
|
|
116
|
+
createProposalHandler,
|
|
112
117
|
createValidatorClient,
|
|
113
118
|
} from '@aztec/validator-client';
|
|
119
|
+
import type { SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
|
|
114
120
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
115
121
|
|
|
116
|
-
import { createPublicClient
|
|
122
|
+
import { createPublicClient } from 'viem';
|
|
117
123
|
|
|
118
124
|
import { createSentinel } from '../sentinel/factory.js';
|
|
119
125
|
import { Sentinel } from '../sentinel/sentinel.js';
|
|
@@ -123,7 +129,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
123
129
|
/**
|
|
124
130
|
* The aztec node.
|
|
125
131
|
*/
|
|
126
|
-
export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
132
|
+
export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDebug, Traceable {
|
|
127
133
|
private metrics: NodeMetrics;
|
|
128
134
|
private initialHeaderHashPromise: Promise<BlockHash> | undefined = undefined;
|
|
129
135
|
|
|
@@ -150,7 +156,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
150
156
|
protected readonly globalVariableBuilder: GlobalVariableBuilderInterface,
|
|
151
157
|
protected readonly epochCache: EpochCacheInterface,
|
|
152
158
|
protected readonly packageVersion: string,
|
|
153
|
-
private
|
|
159
|
+
private peerProofVerifier: ClientProtocolCircuitVerifier,
|
|
160
|
+
private rpcProofVerifier: ClientProtocolCircuitVerifier,
|
|
154
161
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
155
162
|
private log = createLogger('node'),
|
|
156
163
|
private blobClient?: BlobClientInterface,
|
|
@@ -172,6 +179,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
172
179
|
}
|
|
173
180
|
}
|
|
174
181
|
|
|
182
|
+
/** @internal Exposed for testing — returns the RPC proof verifier. */
|
|
183
|
+
public getProofVerifier(): ClientProtocolCircuitVerifier {
|
|
184
|
+
return this.rpcProofVerifier;
|
|
185
|
+
}
|
|
186
|
+
|
|
175
187
|
public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
|
|
176
188
|
const status = await this.worldStateSynchronizer.status();
|
|
177
189
|
return status.syncSummary;
|
|
@@ -195,9 +207,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
195
207
|
dateProvider?: DateProvider;
|
|
196
208
|
p2pClientDeps?: P2PClientDeps;
|
|
197
209
|
proverNodeDeps?: Partial<ProverNodeDeps>;
|
|
210
|
+
slashingProtectionDb?: SlashingProtectionDatabase;
|
|
198
211
|
} = {},
|
|
199
212
|
options: {
|
|
200
|
-
|
|
213
|
+
genesis?: GenesisData;
|
|
201
214
|
dontStartSequencer?: boolean;
|
|
202
215
|
dontStartProverNode?: boolean;
|
|
203
216
|
} = {},
|
|
@@ -257,7 +270,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
257
270
|
|
|
258
271
|
const publicClient = createPublicClient({
|
|
259
272
|
chain: ethereumChain.chainInfo,
|
|
260
|
-
transport:
|
|
273
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, { timeout: config.l1HttpTimeoutMS }),
|
|
261
274
|
pollingInterval: config.viemPollingIntervalMS,
|
|
262
275
|
});
|
|
263
276
|
|
|
@@ -271,10 +284,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
271
284
|
config.l1Contracts = { ...config.l1Contracts, ...l1ContractsAddresses };
|
|
272
285
|
|
|
273
286
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
274
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
287
|
+
const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
|
|
275
288
|
rollupContract.getL1GenesisTime(),
|
|
276
289
|
rollupContract.getSlotDuration(),
|
|
277
290
|
rollupContract.getVersion(),
|
|
291
|
+
rollupContract.getManaLimit().then(Number),
|
|
278
292
|
] as const);
|
|
279
293
|
|
|
280
294
|
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
@@ -299,16 +313,18 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
299
313
|
);
|
|
300
314
|
|
|
301
315
|
// now create the merkle trees and the world state synchronizer
|
|
302
|
-
const worldStateSynchronizer = await createWorldStateSynchronizer(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
316
|
+
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.genesis, telemetry);
|
|
317
|
+
const useRealVerifiers = config.realProofs || config.debugForceTxProofVerification;
|
|
318
|
+
let peerProofVerifier: ClientProtocolCircuitVerifier;
|
|
319
|
+
let rpcProofVerifier: ClientProtocolCircuitVerifier;
|
|
320
|
+
if (useRealVerifiers) {
|
|
321
|
+
peerProofVerifier = await BatchChonkVerifier.new(config, config.bbChonkVerifyMaxBatch, 'peer');
|
|
322
|
+
const rpcVerifier = await BBCircuitVerifier.new(config);
|
|
323
|
+
rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, config.numConcurrentIVCVerifiers);
|
|
324
|
+
} else {
|
|
325
|
+
peerProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
326
|
+
rpcProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
327
|
+
}
|
|
312
328
|
|
|
313
329
|
let debugLogStore: DebugLogStore;
|
|
314
330
|
if (!config.realProofs) {
|
|
@@ -322,8 +338,6 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
322
338
|
debugLogStore = new NullDebugLogStore();
|
|
323
339
|
}
|
|
324
340
|
|
|
325
|
-
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
326
|
-
|
|
327
341
|
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
328
342
|
if (proverOnly) {
|
|
329
343
|
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
@@ -333,7 +347,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
333
347
|
const p2pClient = await createP2PClient(
|
|
334
348
|
config,
|
|
335
349
|
archiver,
|
|
336
|
-
|
|
350
|
+
peerProofVerifier,
|
|
337
351
|
worldStateSynchronizer,
|
|
338
352
|
epochCache,
|
|
339
353
|
packageVersion,
|
|
@@ -342,15 +356,19 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
342
356
|
deps.p2pClientDeps,
|
|
343
357
|
);
|
|
344
358
|
|
|
345
|
-
// We should really not be modifying the config object
|
|
346
|
-
config.txPublicSetupAllowList = config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions());
|
|
347
|
-
|
|
348
359
|
// We'll accumulate sentinel watchers here
|
|
349
360
|
const watchers: Watcher[] = [];
|
|
350
361
|
|
|
351
|
-
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation
|
|
362
|
+
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
363
|
+
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
352
364
|
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder(
|
|
353
|
-
{
|
|
365
|
+
{
|
|
366
|
+
...config,
|
|
367
|
+
l1GenesisTime,
|
|
368
|
+
slotDuration: Number(slotDuration),
|
|
369
|
+
rollupManaLimit,
|
|
370
|
+
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint,
|
|
371
|
+
},
|
|
354
372
|
worldStateSynchronizer,
|
|
355
373
|
archiver,
|
|
356
374
|
dateProvider,
|
|
@@ -372,6 +390,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
372
390
|
l1ToL2MessageSource: archiver,
|
|
373
391
|
keyStoreManager,
|
|
374
392
|
blobClient,
|
|
393
|
+
slashingProtectionDb: deps.slashingProtectionDb,
|
|
375
394
|
});
|
|
376
395
|
|
|
377
396
|
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
@@ -379,26 +398,35 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
379
398
|
// like attestations or auths will fail.
|
|
380
399
|
if (validatorClient) {
|
|
381
400
|
watchers.push(validatorClient);
|
|
401
|
+
|
|
402
|
+
const vc = validatorClient;
|
|
403
|
+
const getValidatorAddresses = () => vc.getValidatorAddresses().map(a => a.toString());
|
|
404
|
+
validatorClient.getProposalHandler().register(p2pClient, true, archiver, getValidatorAddresses);
|
|
405
|
+
|
|
382
406
|
if (!options.dontStartSequencer) {
|
|
383
407
|
await validatorClient.registerHandlers();
|
|
384
408
|
}
|
|
385
409
|
}
|
|
410
|
+
}
|
|
386
411
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
412
|
+
// If there's no validator client, create a ProposalHandler to handle block and checkpoint proposals
|
|
413
|
+
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
414
|
+
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
415
|
+
// Checkpoint proposals rebuild blobs if the blob client can upload blobs.
|
|
416
|
+
if (!validatorClient) {
|
|
417
|
+
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
418
|
+
log.info(`Setting up proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
419
|
+
createProposalHandler(config, {
|
|
420
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
421
|
+
worldState: worldStateSynchronizer,
|
|
422
|
+
epochCache,
|
|
423
|
+
blockSource: archiver,
|
|
424
|
+
l1ToL2MessageSource: archiver,
|
|
425
|
+
p2pClient,
|
|
426
|
+
blobClient,
|
|
427
|
+
dateProvider,
|
|
428
|
+
telemetry,
|
|
429
|
+
}).register(p2pClient, reexecute, archiver);
|
|
402
430
|
}
|
|
403
431
|
|
|
404
432
|
// Start world state and wait for it to sync to the archiver.
|
|
@@ -440,7 +468,6 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
440
468
|
void archiver
|
|
441
469
|
.waitForInitialSync()
|
|
442
470
|
.then(async () => {
|
|
443
|
-
await p2pClient.start();
|
|
444
471
|
await validatorsSentinel?.start();
|
|
445
472
|
await epochPruneWatcher?.start();
|
|
446
473
|
await attestationsBlockWatcher?.start();
|
|
@@ -448,6 +475,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
448
475
|
})
|
|
449
476
|
.catch(err => log.error('Failed to start p2p services after archiver sync', err));
|
|
450
477
|
|
|
478
|
+
const globalVariableBuilder = new GlobalVariableBuilder(dateProvider, publicClient, {
|
|
479
|
+
l1Contracts: config.l1Contracts,
|
|
480
|
+
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
481
|
+
rollupVersion: BigInt(config.rollupVersion),
|
|
482
|
+
l1GenesisTime,
|
|
483
|
+
slotDuration: Number(slotDuration),
|
|
484
|
+
});
|
|
485
|
+
|
|
451
486
|
// Validator enabled, create/start relevant service
|
|
452
487
|
let sequencer: SequencerClient | undefined;
|
|
453
488
|
let slasherClient: SlasherClientInterface | undefined;
|
|
@@ -485,9 +520,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
485
520
|
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
486
521
|
);
|
|
487
522
|
|
|
523
|
+
// Create a funder L1TxUtils from the keystore funding account (if configured)
|
|
524
|
+
const fundingSigner = keyStoreManager?.createFundingSigner();
|
|
525
|
+
let funderL1TxUtils: L1TxUtils | undefined;
|
|
526
|
+
if (fundingSigner) {
|
|
527
|
+
const [funder] = await createL1TxUtilsFromSigners(
|
|
528
|
+
publicClient,
|
|
529
|
+
[fundingSigner],
|
|
530
|
+
{ ...config, scope: 'sequencer' },
|
|
531
|
+
{ telemetry, logger: log.createChild('l1-tx-utils:funder'), dateProvider },
|
|
532
|
+
);
|
|
533
|
+
funderL1TxUtils = funder;
|
|
534
|
+
}
|
|
535
|
+
|
|
488
536
|
// Create and start the sequencer client
|
|
489
537
|
const checkpointsBuilder = new CheckpointsBuilder(
|
|
490
|
-
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
|
|
538
|
+
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration), rollupManaLimit },
|
|
491
539
|
worldStateSynchronizer,
|
|
492
540
|
archiver,
|
|
493
541
|
dateProvider,
|
|
@@ -499,6 +547,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
499
547
|
...deps,
|
|
500
548
|
epochCache,
|
|
501
549
|
l1TxUtils,
|
|
550
|
+
funderL1TxUtils,
|
|
502
551
|
validatorClient,
|
|
503
552
|
p2pClient,
|
|
504
553
|
worldStateSynchronizer,
|
|
@@ -510,6 +559,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
510
559
|
dateProvider,
|
|
511
560
|
blobClient,
|
|
512
561
|
nodeKeyStore: keyStoreManager!,
|
|
562
|
+
globalVariableBuilder,
|
|
513
563
|
});
|
|
514
564
|
}
|
|
515
565
|
|
|
@@ -543,13 +593,6 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
543
593
|
}
|
|
544
594
|
}
|
|
545
595
|
|
|
546
|
-
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
547
|
-
...config,
|
|
548
|
-
rollupVersion: BigInt(config.rollupVersion),
|
|
549
|
-
l1GenesisTime,
|
|
550
|
-
slotDuration: Number(slotDuration),
|
|
551
|
-
});
|
|
552
|
-
|
|
553
596
|
const node = new AztecNodeService(
|
|
554
597
|
config,
|
|
555
598
|
p2pClient,
|
|
@@ -568,7 +611,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
568
611
|
globalVariableBuilder,
|
|
569
612
|
epochCache,
|
|
570
613
|
packageVersion,
|
|
571
|
-
|
|
614
|
+
peerProofVerifier,
|
|
615
|
+
rpcProofVerifier,
|
|
572
616
|
telemetry,
|
|
573
617
|
log,
|
|
574
618
|
blobClient,
|
|
@@ -618,7 +662,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
618
662
|
}
|
|
619
663
|
|
|
620
664
|
public async getAllowedPublicSetup(): Promise<AllowedElement[]> {
|
|
621
|
-
return this.config.
|
|
665
|
+
return [...(await getDefaultAllowedSetupFunctions()), ...(this.config.txPublicSetupAllowListExtend ?? [])];
|
|
622
666
|
}
|
|
623
667
|
|
|
624
668
|
/**
|
|
@@ -713,6 +757,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
713
757
|
return (await this.blockSource.getCheckpointedBlocks(from, limit)) ?? [];
|
|
714
758
|
}
|
|
715
759
|
|
|
760
|
+
public getCheckpointsDataForEpoch(epochNumber: EpochNumber) {
|
|
761
|
+
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
762
|
+
}
|
|
763
|
+
|
|
716
764
|
/**
|
|
717
765
|
* Method to fetch the current min L2 fees.
|
|
718
766
|
* @returns The current min L2 fees.
|
|
@@ -745,6 +793,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
745
793
|
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
746
794
|
}
|
|
747
795
|
|
|
796
|
+
public getCheckpointNumber(): Promise<CheckpointNumber> {
|
|
797
|
+
return this.blockSource.getCheckpointNumber();
|
|
798
|
+
}
|
|
799
|
+
|
|
748
800
|
/**
|
|
749
801
|
* Method to fetch the version of the package.
|
|
750
802
|
* @returns The node package version
|
|
@@ -782,18 +834,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
782
834
|
page?: number,
|
|
783
835
|
referenceBlock?: BlockHash,
|
|
784
836
|
): Promise<TxScopedL2Log[][]> {
|
|
837
|
+
let upToBlockNumber: BlockNumber | undefined;
|
|
785
838
|
if (referenceBlock) {
|
|
786
839
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
787
|
-
if (
|
|
840
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
841
|
+
upToBlockNumber = BlockNumber(0);
|
|
842
|
+
} else {
|
|
788
843
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
789
844
|
if (!header) {
|
|
790
845
|
throw new Error(
|
|
791
846
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
792
847
|
);
|
|
793
848
|
}
|
|
849
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
794
850
|
}
|
|
795
851
|
}
|
|
796
|
-
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
852
|
+
return this.logsSource.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
797
853
|
}
|
|
798
854
|
|
|
799
855
|
public async getPublicLogsByTagsFromContract(
|
|
@@ -802,18 +858,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
802
858
|
page?: number,
|
|
803
859
|
referenceBlock?: BlockHash,
|
|
804
860
|
): Promise<TxScopedL2Log[][]> {
|
|
861
|
+
let upToBlockNumber: BlockNumber | undefined;
|
|
805
862
|
if (referenceBlock) {
|
|
806
863
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
807
|
-
if (
|
|
864
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
865
|
+
upToBlockNumber = BlockNumber(0);
|
|
866
|
+
} else {
|
|
808
867
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
809
868
|
if (!header) {
|
|
810
869
|
throw new Error(
|
|
811
870
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
812
871
|
);
|
|
813
872
|
}
|
|
873
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
814
874
|
}
|
|
815
875
|
}
|
|
816
|
-
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
|
|
876
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
817
877
|
}
|
|
818
878
|
|
|
819
879
|
/**
|
|
@@ -899,7 +959,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
899
959
|
await tryStop(this.validatorsSentinel);
|
|
900
960
|
await tryStop(this.epochPruneWatcher);
|
|
901
961
|
await tryStop(this.slasherClient);
|
|
902
|
-
await tryStop(this.
|
|
962
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
903
963
|
await tryStop(this.sequencer);
|
|
904
964
|
await tryStop(this.proverNode);
|
|
905
965
|
await tryStop(this.p2pClient);
|
|
@@ -955,58 +1015,64 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
955
1015
|
treeId: MerkleTreeId,
|
|
956
1016
|
leafValues: Fr[],
|
|
957
1017
|
): Promise<(DataInBlock<bigint> | undefined)[]> {
|
|
958
|
-
const committedDb = await this
|
|
1018
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
959
1019
|
const maybeIndices = await committedDb.findLeafIndices(
|
|
960
1020
|
treeId,
|
|
961
1021
|
leafValues.map(x => x.toBuffer()),
|
|
962
1022
|
);
|
|
963
|
-
//
|
|
964
|
-
const
|
|
1023
|
+
// Filter out undefined values to query block numbers only for found leaves
|
|
1024
|
+
const definedIndices = maybeIndices.filter(x => x !== undefined);
|
|
965
1025
|
|
|
966
|
-
// Now we find the block numbers for the indices
|
|
967
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId,
|
|
1026
|
+
// Now we find the block numbers for the defined indices
|
|
1027
|
+
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
968
1028
|
|
|
969
|
-
//
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1029
|
+
// Build a map from leaf index to block number
|
|
1030
|
+
const indexToBlockNumber = new Map<bigint, BlockNumber>();
|
|
1031
|
+
for (let i = 0; i < definedIndices.length; i++) {
|
|
1032
|
+
const blockNumber = blockNumbers[i];
|
|
1033
|
+
if (blockNumber === undefined) {
|
|
1034
|
+
throw new Error(
|
|
1035
|
+
`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`,
|
|
1036
|
+
);
|
|
973
1037
|
}
|
|
1038
|
+
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
974
1039
|
}
|
|
975
1040
|
|
|
976
1041
|
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
977
|
-
const uniqueBlockNumbers = [...new Set(
|
|
1042
|
+
const uniqueBlockNumbers = [...new Set(indexToBlockNumber.values())];
|
|
978
1043
|
|
|
979
|
-
// Now we obtain the block hashes from the archive tree
|
|
980
|
-
// (note that block number corresponds to the leaf index in the archive tree).
|
|
1044
|
+
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
981
1045
|
const blockHashes = await Promise.all(
|
|
982
1046
|
uniqueBlockNumbers.map(blockNumber => {
|
|
983
1047
|
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
984
1048
|
}),
|
|
985
1049
|
);
|
|
986
1050
|
|
|
987
|
-
//
|
|
1051
|
+
// Build a map from block number to block hash
|
|
1052
|
+
const blockNumberToHash = new Map<BlockNumber, Fr>();
|
|
988
1053
|
for (let i = 0; i < uniqueBlockNumbers.length; i++) {
|
|
989
|
-
|
|
1054
|
+
const blockHash = blockHashes[i];
|
|
1055
|
+
if (blockHash === undefined) {
|
|
990
1056
|
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
991
1057
|
}
|
|
1058
|
+
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
992
1059
|
}
|
|
993
1060
|
|
|
994
1061
|
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
995
|
-
return maybeIndices.map(
|
|
1062
|
+
return maybeIndices.map(index => {
|
|
996
1063
|
if (index === undefined) {
|
|
997
1064
|
return undefined;
|
|
998
1065
|
}
|
|
999
|
-
const blockNumber =
|
|
1066
|
+
const blockNumber = indexToBlockNumber.get(index);
|
|
1000
1067
|
if (blockNumber === undefined) {
|
|
1001
|
-
|
|
1068
|
+
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
1002
1069
|
}
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
return undefined;
|
|
1070
|
+
const blockHash = blockNumberToHash.get(blockNumber);
|
|
1071
|
+
if (blockHash === undefined) {
|
|
1072
|
+
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
1007
1073
|
}
|
|
1008
1074
|
return {
|
|
1009
|
-
l2BlockNumber:
|
|
1075
|
+
l2BlockNumber: blockNumber,
|
|
1010
1076
|
l2BlockHash: new BlockHash(blockHash),
|
|
1011
1077
|
data: index,
|
|
1012
1078
|
};
|
|
@@ -1017,7 +1083,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1017
1083
|
referenceBlock: BlockParameter,
|
|
1018
1084
|
blockHash: BlockHash,
|
|
1019
1085
|
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
|
|
1020
|
-
|
|
1086
|
+
// The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
|
|
1087
|
+
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
|
|
1088
|
+
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
|
|
1089
|
+
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
|
|
1090
|
+
if (referenceBlockNumber === BlockNumber.ZERO) {
|
|
1091
|
+
// Block 0 (the initial block) has an empty archive, so no membership witness can exist.
|
|
1092
|
+
return undefined;
|
|
1093
|
+
}
|
|
1094
|
+
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
|
|
1021
1095
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
|
|
1022
1096
|
return pathAndIndex === undefined
|
|
1023
1097
|
? undefined
|
|
@@ -1028,7 +1102,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1028
1102
|
referenceBlock: BlockParameter,
|
|
1029
1103
|
noteHash: Fr,
|
|
1030
1104
|
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
|
|
1031
|
-
const committedDb = await this
|
|
1105
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1032
1106
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.NOTE_HASH_TREE>(
|
|
1033
1107
|
MerkleTreeId.NOTE_HASH_TREE,
|
|
1034
1108
|
[noteHash],
|
|
@@ -1042,7 +1116,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1042
1116
|
referenceBlock: BlockParameter,
|
|
1043
1117
|
l1ToL2Message: Fr,
|
|
1044
1118
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
|
|
1045
|
-
const db = await this
|
|
1119
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1046
1120
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [l1ToL2Message]);
|
|
1047
1121
|
if (!witness) {
|
|
1048
1122
|
return undefined;
|
|
@@ -1052,11 +1126,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1052
1126
|
return [witness.index, witness.path];
|
|
1053
1127
|
}
|
|
1054
1128
|
|
|
1055
|
-
public async
|
|
1129
|
+
public async getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined> {
|
|
1056
1130
|
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
1057
|
-
return messageIndex
|
|
1058
|
-
? BlockNumber.fromCheckpointNumber(InboxLeaf.checkpointNumberFromIndex(messageIndex))
|
|
1059
|
-
: undefined;
|
|
1131
|
+
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
1060
1132
|
}
|
|
1061
1133
|
|
|
1062
1134
|
/**
|
|
@@ -1077,19 +1149,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1077
1149
|
public async getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
|
|
1078
1150
|
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
1079
1151
|
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1080
|
-
const blocksInCheckpoints
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
for (const checkpointedBlock of checkpointedBlocks) {
|
|
1084
|
-
const block = checkpointedBlock.block;
|
|
1085
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
1086
|
-
if (slotNumber !== previousSlotNumber) {
|
|
1087
|
-
checkpointIndex++;
|
|
1088
|
-
blocksInCheckpoints.push([]);
|
|
1089
|
-
previousSlotNumber = slotNumber;
|
|
1090
|
-
}
|
|
1091
|
-
blocksInCheckpoints[checkpointIndex].push(block);
|
|
1092
|
-
}
|
|
1152
|
+
const blocksInCheckpoints = chunkBy(checkpointedBlocks, cb => cb.block.header.globalVariables.slotNumber).map(
|
|
1153
|
+
group => group.map(cb => cb.block),
|
|
1154
|
+
);
|
|
1093
1155
|
return blocksInCheckpoints.map(blocks =>
|
|
1094
1156
|
blocks.map(block => block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs)),
|
|
1095
1157
|
);
|
|
@@ -1099,7 +1161,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1099
1161
|
referenceBlock: BlockParameter,
|
|
1100
1162
|
nullifier: Fr,
|
|
1101
1163
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1102
|
-
const db = await this
|
|
1164
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1103
1165
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]);
|
|
1104
1166
|
if (!witness) {
|
|
1105
1167
|
return undefined;
|
|
@@ -1114,33 +1176,20 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1114
1176
|
return new NullifierMembershipWitness(index, leafPreimage as NullifierLeafPreimage, path);
|
|
1115
1177
|
}
|
|
1116
1178
|
|
|
1117
|
-
/**
|
|
1118
|
-
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
1119
|
-
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
|
|
1120
|
-
* (which contains the root of the nullifier tree in which we are searching for the nullifier).
|
|
1121
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
1122
|
-
* @returns The low nullifier membership witness (if found).
|
|
1123
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
1124
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
1125
|
-
* we are trying to prove non-inclusion for.
|
|
1126
|
-
*
|
|
1127
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
1128
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
1129
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
1130
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
1131
|
-
*/
|
|
1132
1179
|
public async getLowNullifierMembershipWitness(
|
|
1133
1180
|
referenceBlock: BlockParameter,
|
|
1134
1181
|
nullifier: Fr,
|
|
1135
1182
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1136
|
-
const committedDb = await this
|
|
1183
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1137
1184
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1138
1185
|
if (!findResult) {
|
|
1139
1186
|
return undefined;
|
|
1140
1187
|
}
|
|
1141
1188
|
const { index, alreadyPresent } = findResult;
|
|
1142
1189
|
if (alreadyPresent) {
|
|
1143
|
-
|
|
1190
|
+
throw new Error(
|
|
1191
|
+
`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`,
|
|
1192
|
+
);
|
|
1144
1193
|
}
|
|
1145
1194
|
const preimageData = (await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index))!;
|
|
1146
1195
|
|
|
@@ -1149,7 +1198,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1149
1198
|
}
|
|
1150
1199
|
|
|
1151
1200
|
async getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
1152
|
-
const committedDb = await this
|
|
1201
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1153
1202
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1154
1203
|
if (!lowLeafResult) {
|
|
1155
1204
|
return undefined;
|
|
@@ -1164,7 +1213,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1164
1213
|
}
|
|
1165
1214
|
|
|
1166
1215
|
public async getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
1167
|
-
const committedDb = await this
|
|
1216
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1168
1217
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1169
1218
|
|
|
1170
1219
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
@@ -1278,7 +1327,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1278
1327
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1279
1328
|
|
|
1280
1329
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1281
|
-
const [processedTxs, failedTxs, _usedTxs, returns,
|
|
1330
|
+
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([tx]);
|
|
1282
1331
|
// REFACTOR: Consider returning the error rather than throwing
|
|
1283
1332
|
if (failedTxs.length) {
|
|
1284
1333
|
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
|
|
@@ -1304,11 +1353,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1304
1353
|
{ isSimulation, skipFeeEnforcement }: { isSimulation?: boolean; skipFeeEnforcement?: boolean } = {},
|
|
1305
1354
|
): Promise<TxValidationResult> {
|
|
1306
1355
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1307
|
-
const verifier = isSimulation ? undefined : this.
|
|
1356
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
1308
1357
|
|
|
1309
1358
|
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1310
1359
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1311
1360
|
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
1361
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
1312
1362
|
const validator = createTxValidatorForAcceptingTxsOverRPC(
|
|
1313
1363
|
db,
|
|
1314
1364
|
this.contractDataSource,
|
|
@@ -1318,10 +1368,16 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1318
1368
|
blockNumber,
|
|
1319
1369
|
l1ChainId: this.l1ChainId,
|
|
1320
1370
|
rollupVersion: this.version,
|
|
1321
|
-
setupAllowList:
|
|
1371
|
+
setupAllowList: [
|
|
1372
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
1373
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
1374
|
+
],
|
|
1322
1375
|
gasFees: await this.getCurrentMinFees(),
|
|
1323
1376
|
skipFeeEnforcement,
|
|
1324
1377
|
txsPermitted: !this.config.disableTransactions,
|
|
1378
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1379
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1380
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas,
|
|
1325
1381
|
},
|
|
1326
1382
|
this.log.getBindings(),
|
|
1327
1383
|
);
|
|
@@ -1346,7 +1402,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1346
1402
|
archiver.updateConfig(config);
|
|
1347
1403
|
}
|
|
1348
1404
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
1349
|
-
|
|
1405
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
1406
|
+
if (newConfig.realProofs) {
|
|
1407
|
+
this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
|
|
1408
|
+
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
|
|
1409
|
+
this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
|
|
1410
|
+
} else {
|
|
1411
|
+
this.peerProofVerifier = new TestCircuitVerifier();
|
|
1412
|
+
this.rpcProofVerifier = new TestCircuitVerifier();
|
|
1413
|
+
}
|
|
1350
1414
|
}
|
|
1351
1415
|
|
|
1352
1416
|
this.config = newConfig;
|
|
@@ -1421,7 +1485,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1421
1485
|
return Promise.resolve();
|
|
1422
1486
|
}
|
|
1423
1487
|
|
|
1424
|
-
public async rollbackTo(targetBlock: BlockNumber, force?: boolean): Promise<void> {
|
|
1488
|
+
public async rollbackTo(targetBlock: BlockNumber, force?: boolean, resumeSync = true): Promise<void> {
|
|
1425
1489
|
const archiver = this.blockSource as Archiver;
|
|
1426
1490
|
if (!('rollbackTo' in archiver)) {
|
|
1427
1491
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
@@ -1451,9 +1515,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1451
1515
|
this.log.error(`Error during rollback`, err);
|
|
1452
1516
|
throw err;
|
|
1453
1517
|
} finally {
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1518
|
+
if (resumeSync) {
|
|
1519
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
1520
|
+
this.worldStateSynchronizer.resumeSync();
|
|
1521
|
+
archiver.resume();
|
|
1522
|
+
} else {
|
|
1523
|
+
this.log.info(`Sync left paused after rollback (resumeSync=false).`);
|
|
1524
|
+
}
|
|
1457
1525
|
}
|
|
1458
1526
|
}
|
|
1459
1527
|
|
|
@@ -1470,19 +1538,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1470
1538
|
return Promise.resolve();
|
|
1471
1539
|
}
|
|
1472
1540
|
|
|
1473
|
-
public getSlashPayloads(): Promise<SlashPayloadRound[]> {
|
|
1474
|
-
if (!this.slasherClient) {
|
|
1475
|
-
throw new Error(`Slasher client not enabled`);
|
|
1476
|
-
}
|
|
1477
|
-
return this.slasherClient.getSlashPayloads();
|
|
1478
|
-
}
|
|
1479
|
-
|
|
1480
1541
|
public getSlashOffenses(round: bigint | 'all' | 'current'): Promise<Offense[]> {
|
|
1481
1542
|
if (!this.slasherClient) {
|
|
1482
1543
|
throw new Error(`Slasher client not enabled`);
|
|
1483
1544
|
}
|
|
1484
1545
|
if (round === 'all') {
|
|
1485
|
-
return this.slasherClient.
|
|
1546
|
+
return this.slasherClient.getOffenses();
|
|
1486
1547
|
} else {
|
|
1487
1548
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1488
1549
|
}
|
|
@@ -1576,6 +1637,40 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1576
1637
|
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1577
1638
|
}
|
|
1578
1639
|
|
|
1640
|
+
public async mineBlock(): Promise<void> {
|
|
1641
|
+
if (!this.sequencer) {
|
|
1642
|
+
throw new BadRequestError('Cannot mine block: no sequencer is running');
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
const currentBlockNumber = await this.getBlockNumber();
|
|
1646
|
+
|
|
1647
|
+
// Use slot duration + 50% buffer as the timeout so this works on running networks too
|
|
1648
|
+
const { slotDuration } = await this.blockSource.getL1Constants();
|
|
1649
|
+
const timeoutSeconds = Math.ceil(slotDuration * 1.5);
|
|
1650
|
+
|
|
1651
|
+
// Temporarily set minTxsPerBlock to 0 so the sequencer produces a block even with no txs
|
|
1652
|
+
const originalMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock;
|
|
1653
|
+
this.sequencer.updateConfig({ minTxsPerBlock: 0 });
|
|
1654
|
+
|
|
1655
|
+
try {
|
|
1656
|
+
// Trigger the sequencer to produce a block immediately
|
|
1657
|
+
void this.sequencer.trigger();
|
|
1658
|
+
|
|
1659
|
+
// Wait for the new L2 block to appear
|
|
1660
|
+
await retryUntil(
|
|
1661
|
+
async () => {
|
|
1662
|
+
const newBlockNumber = await this.getBlockNumber();
|
|
1663
|
+
return newBlockNumber > currentBlockNumber ? true : undefined;
|
|
1664
|
+
},
|
|
1665
|
+
'mineBlock',
|
|
1666
|
+
timeoutSeconds,
|
|
1667
|
+
0.1,
|
|
1668
|
+
);
|
|
1669
|
+
} finally {
|
|
1670
|
+
this.sequencer.updateConfig({ minTxsPerBlock: originalMinTxsPerBlock });
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1579
1674
|
#getInitialHeaderHash(): Promise<BlockHash> {
|
|
1580
1675
|
if (!this.initialHeaderHashPromise) {
|
|
1581
1676
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
@@ -1588,7 +1683,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1588
1683
|
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1589
1684
|
* @returns An instance of a committed MerkleTreeOperations
|
|
1590
1685
|
*/
|
|
1591
|
-
async
|
|
1686
|
+
protected async getWorldState(block: BlockParameter) {
|
|
1592
1687
|
let blockSyncedTo: BlockNumber = BlockNumber.ZERO;
|
|
1593
1688
|
try {
|
|
1594
1689
|
// Attempt to sync the world state if necessary
|
|
@@ -1602,6 +1697,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1602
1697
|
return this.worldStateSynchronizer.getCommitted();
|
|
1603
1698
|
}
|
|
1604
1699
|
|
|
1700
|
+
// Get the block number, either directly from the parameter or by quering the archiver with the block hash
|
|
1701
|
+
let blockNumber: BlockNumber;
|
|
1605
1702
|
if (BlockHash.isBlockHash(block)) {
|
|
1606
1703
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1607
1704
|
if (block.equals(initialBlockHash)) {
|
|
@@ -1615,22 +1712,50 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1615
1712
|
`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.`,
|
|
1616
1713
|
);
|
|
1617
1714
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1715
|
+
|
|
1716
|
+
blockNumber = header.getBlockNumber();
|
|
1717
|
+
} else {
|
|
1718
|
+
blockNumber = block as BlockNumber;
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
// Check it's within world state sync range
|
|
1722
|
+
if (blockNumber > blockSyncedTo) {
|
|
1723
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1621
1724
|
}
|
|
1725
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1622
1726
|
|
|
1623
|
-
|
|
1624
|
-
{
|
|
1625
|
-
const blockNumber = block as BlockNumber;
|
|
1727
|
+
const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1626
1728
|
|
|
1627
|
-
|
|
1628
|
-
|
|
1729
|
+
// Double-check world-state synced to the same block hash as was requested
|
|
1730
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1731
|
+
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1732
|
+
if (!blockHash || !new BlockHash(blockHash).equals(block)) {
|
|
1733
|
+
throw new Error(
|
|
1734
|
+
`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.`,
|
|
1735
|
+
);
|
|
1629
1736
|
}
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
return snapshot;
|
|
1740
|
+
}
|
|
1630
1741
|
|
|
1631
|
-
|
|
1632
|
-
|
|
1742
|
+
/** Resolves a block parameter to a block number. */
|
|
1743
|
+
protected async resolveBlockNumber(block: BlockParameter): Promise<BlockNumber> {
|
|
1744
|
+
if (block === 'latest') {
|
|
1745
|
+
return BlockNumber(await this.blockSource.getBlockNumber());
|
|
1746
|
+
}
|
|
1747
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1748
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1749
|
+
if (block.equals(initialBlockHash)) {
|
|
1750
|
+
return BlockNumber.ZERO;
|
|
1751
|
+
}
|
|
1752
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1753
|
+
if (!header) {
|
|
1754
|
+
throw new Error(`Block hash ${block.toString()} not found.`);
|
|
1755
|
+
}
|
|
1756
|
+
return header.getBlockNumber();
|
|
1633
1757
|
}
|
|
1758
|
+
return block as BlockNumber;
|
|
1634
1759
|
}
|
|
1635
1760
|
|
|
1636
1761
|
/**
|