@aztec/aztec-node 0.0.1-commit.db765a8 → 0.0.1-commit.ddcf04837
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 +31 -32
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +263 -145
- package/dest/sentinel/factory.d.ts +2 -2
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +9 -9
- package/package.json +26 -27
- package/src/aztec-node/config.ts +1 -1
- package/src/aztec-node/server.ts +290 -153
- package/src/sentinel/factory.ts +1 -1
- package/src/sentinel/sentinel.ts +9 -9
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';
|
|
@@ -30,7 +33,12 @@ import {
|
|
|
30
33
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
31
34
|
import { type ProverNode, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
|
|
32
35
|
import { createKeyStoreForProver } from '@aztec/prover-node/config';
|
|
33
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
FeeProviderImpl,
|
|
38
|
+
GlobalVariableBuilder,
|
|
39
|
+
SequencerClient,
|
|
40
|
+
type SequencerPublisher,
|
|
41
|
+
} from '@aztec/sequencer-client';
|
|
34
42
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
35
43
|
import {
|
|
36
44
|
AttestationsBlockWatcher,
|
|
@@ -57,13 +65,14 @@ import type {
|
|
|
57
65
|
NodeInfo,
|
|
58
66
|
ProtocolContractAddresses,
|
|
59
67
|
} from '@aztec/stdlib/contract';
|
|
60
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
68
|
+
import { GasFees, type ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
61
69
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
62
70
|
import {
|
|
63
71
|
type AztecNode,
|
|
64
72
|
type AztecNodeAdmin,
|
|
65
73
|
type AztecNodeAdminConfig,
|
|
66
74
|
AztecNodeAdminConfigSchema,
|
|
75
|
+
type AztecNodeDebug,
|
|
67
76
|
type GetContractClassLogsResponse,
|
|
68
77
|
type GetPublicLogsResponse,
|
|
69
78
|
} from '@aztec/stdlib/interfaces/client';
|
|
@@ -79,11 +88,12 @@ import {
|
|
|
79
88
|
import type { DebugLogStore, LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
80
89
|
import { InMemoryDebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
81
90
|
import { InboxLeaf, type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
82
|
-
import type { Offense
|
|
83
|
-
import type { NullifierLeafPreimage,
|
|
91
|
+
import type { Offense } from '@aztec/stdlib/slashing';
|
|
92
|
+
import type { NullifierLeafPreimage, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
84
93
|
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
85
94
|
import {
|
|
86
95
|
type BlockHeader,
|
|
96
|
+
type FeeProvider,
|
|
87
97
|
type GlobalVariableBuilder as GlobalVariableBuilderInterface,
|
|
88
98
|
type IndexedTxEffect,
|
|
89
99
|
PublicSimulationOutput,
|
|
@@ -95,6 +105,7 @@ import {
|
|
|
95
105
|
} from '@aztec/stdlib/tx';
|
|
96
106
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
97
107
|
import type { SingleValidatorStats, ValidatorsStats } from '@aztec/stdlib/validators';
|
|
108
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
98
109
|
import {
|
|
99
110
|
Attributes,
|
|
100
111
|
type TelemetryClient,
|
|
@@ -108,12 +119,13 @@ import {
|
|
|
108
119
|
FullNodeCheckpointsBuilder,
|
|
109
120
|
NodeKeystoreAdapter,
|
|
110
121
|
ValidatorClient,
|
|
111
|
-
|
|
122
|
+
createProposalHandler,
|
|
112
123
|
createValidatorClient,
|
|
113
124
|
} from '@aztec/validator-client';
|
|
125
|
+
import type { SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
|
|
114
126
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
115
127
|
|
|
116
|
-
import { createPublicClient
|
|
128
|
+
import { createPublicClient } from 'viem';
|
|
117
129
|
|
|
118
130
|
import { createSentinel } from '../sentinel/factory.js';
|
|
119
131
|
import { Sentinel } from '../sentinel/sentinel.js';
|
|
@@ -123,7 +135,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
123
135
|
/**
|
|
124
136
|
* The aztec node.
|
|
125
137
|
*/
|
|
126
|
-
export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
138
|
+
export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDebug, Traceable {
|
|
127
139
|
private metrics: NodeMetrics;
|
|
128
140
|
private initialHeaderHashPromise: Promise<BlockHash> | undefined = undefined;
|
|
129
141
|
|
|
@@ -148,9 +160,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
148
160
|
protected readonly l1ChainId: number,
|
|
149
161
|
protected readonly version: number,
|
|
150
162
|
protected readonly globalVariableBuilder: GlobalVariableBuilderInterface,
|
|
163
|
+
protected readonly feeProvider: FeeProvider,
|
|
151
164
|
protected readonly epochCache: EpochCacheInterface,
|
|
152
165
|
protected readonly packageVersion: string,
|
|
153
|
-
private
|
|
166
|
+
private peerProofVerifier: ClientProtocolCircuitVerifier,
|
|
167
|
+
private rpcProofVerifier: ClientProtocolCircuitVerifier,
|
|
154
168
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
155
169
|
private log = createLogger('node'),
|
|
156
170
|
private blobClient?: BlobClientInterface,
|
|
@@ -172,6 +186,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
172
186
|
}
|
|
173
187
|
}
|
|
174
188
|
|
|
189
|
+
/** @internal Exposed for testing — returns the RPC proof verifier. */
|
|
190
|
+
public getProofVerifier(): ClientProtocolCircuitVerifier {
|
|
191
|
+
return this.rpcProofVerifier;
|
|
192
|
+
}
|
|
193
|
+
|
|
175
194
|
public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
|
|
176
195
|
const status = await this.worldStateSynchronizer.status();
|
|
177
196
|
return status.syncSummary;
|
|
@@ -195,9 +214,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
195
214
|
dateProvider?: DateProvider;
|
|
196
215
|
p2pClientDeps?: P2PClientDeps;
|
|
197
216
|
proverNodeDeps?: Partial<ProverNodeDeps>;
|
|
217
|
+
slashingProtectionDb?: SlashingProtectionDatabase;
|
|
198
218
|
} = {},
|
|
199
219
|
options: {
|
|
200
|
-
|
|
220
|
+
genesis?: GenesisData;
|
|
201
221
|
dontStartSequencer?: boolean;
|
|
202
222
|
dontStartProverNode?: boolean;
|
|
203
223
|
} = {},
|
|
@@ -257,7 +277,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
257
277
|
|
|
258
278
|
const publicClient = createPublicClient({
|
|
259
279
|
chain: ethereumChain.chainInfo,
|
|
260
|
-
transport:
|
|
280
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, { timeout: config.l1HttpTimeoutMS }),
|
|
261
281
|
pollingInterval: config.viemPollingIntervalMS,
|
|
262
282
|
});
|
|
263
283
|
|
|
@@ -271,10 +291,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
271
291
|
config.l1Contracts = { ...config.l1Contracts, ...l1ContractsAddresses };
|
|
272
292
|
|
|
273
293
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
274
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
294
|
+
const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
|
|
275
295
|
rollupContract.getL1GenesisTime(),
|
|
276
296
|
rollupContract.getSlotDuration(),
|
|
277
297
|
rollupContract.getVersion(),
|
|
298
|
+
rollupContract.getManaLimit().then(Number),
|
|
278
299
|
] as const);
|
|
279
300
|
|
|
280
301
|
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
@@ -299,16 +320,18 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
299
320
|
);
|
|
300
321
|
|
|
301
322
|
// now create the merkle trees and the world state synchronizer
|
|
302
|
-
const worldStateSynchronizer = await createWorldStateSynchronizer(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
323
|
+
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.genesis, telemetry);
|
|
324
|
+
const useRealVerifiers = config.realProofs || config.debugForceTxProofVerification;
|
|
325
|
+
let peerProofVerifier: ClientProtocolCircuitVerifier;
|
|
326
|
+
let rpcProofVerifier: ClientProtocolCircuitVerifier;
|
|
327
|
+
if (useRealVerifiers) {
|
|
328
|
+
peerProofVerifier = await BatchChonkVerifier.new(config, config.bbChonkVerifyMaxBatch, 'peer');
|
|
329
|
+
const rpcVerifier = await BBCircuitVerifier.new(config);
|
|
330
|
+
rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, config.numConcurrentIVCVerifiers);
|
|
331
|
+
} else {
|
|
332
|
+
peerProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
333
|
+
rpcProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
334
|
+
}
|
|
312
335
|
|
|
313
336
|
let debugLogStore: DebugLogStore;
|
|
314
337
|
if (!config.realProofs) {
|
|
@@ -322,8 +345,6 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
322
345
|
debugLogStore = new NullDebugLogStore();
|
|
323
346
|
}
|
|
324
347
|
|
|
325
|
-
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
326
|
-
|
|
327
348
|
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
328
349
|
if (proverOnly) {
|
|
329
350
|
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
@@ -333,7 +354,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
333
354
|
const p2pClient = await createP2PClient(
|
|
334
355
|
config,
|
|
335
356
|
archiver,
|
|
336
|
-
|
|
357
|
+
peerProofVerifier,
|
|
337
358
|
worldStateSynchronizer,
|
|
338
359
|
epochCache,
|
|
339
360
|
packageVersion,
|
|
@@ -345,9 +366,16 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
345
366
|
// We'll accumulate sentinel watchers here
|
|
346
367
|
const watchers: Watcher[] = [];
|
|
347
368
|
|
|
348
|
-
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation
|
|
369
|
+
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
370
|
+
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
349
371
|
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder(
|
|
350
|
-
{
|
|
372
|
+
{
|
|
373
|
+
...config,
|
|
374
|
+
l1GenesisTime,
|
|
375
|
+
slotDuration: Number(slotDuration),
|
|
376
|
+
rollupManaLimit,
|
|
377
|
+
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint,
|
|
378
|
+
},
|
|
351
379
|
worldStateSynchronizer,
|
|
352
380
|
archiver,
|
|
353
381
|
dateProvider,
|
|
@@ -369,6 +397,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
369
397
|
l1ToL2MessageSource: archiver,
|
|
370
398
|
keyStoreManager,
|
|
371
399
|
blobClient,
|
|
400
|
+
slashingProtectionDb: deps.slashingProtectionDb,
|
|
372
401
|
});
|
|
373
402
|
|
|
374
403
|
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
@@ -376,26 +405,35 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
376
405
|
// like attestations or auths will fail.
|
|
377
406
|
if (validatorClient) {
|
|
378
407
|
watchers.push(validatorClient);
|
|
408
|
+
|
|
409
|
+
const vc = validatorClient;
|
|
410
|
+
const getValidatorAddresses = () => vc.getValidatorAddresses().map(a => a.toString());
|
|
411
|
+
validatorClient.getProposalHandler().register(p2pClient, true, archiver, getValidatorAddresses);
|
|
412
|
+
|
|
379
413
|
if (!options.dontStartSequencer) {
|
|
380
414
|
await validatorClient.registerHandlers();
|
|
381
415
|
}
|
|
382
416
|
}
|
|
417
|
+
}
|
|
383
418
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
419
|
+
// If there's no validator client, create a ProposalHandler to handle block and checkpoint proposals
|
|
420
|
+
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
421
|
+
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
422
|
+
// Checkpoint proposals rebuild blobs if the blob client can upload blobs.
|
|
423
|
+
if (!validatorClient) {
|
|
424
|
+
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
425
|
+
log.info(`Setting up proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
426
|
+
createProposalHandler(config, {
|
|
427
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
428
|
+
worldState: worldStateSynchronizer,
|
|
429
|
+
epochCache,
|
|
430
|
+
blockSource: archiver,
|
|
431
|
+
l1ToL2MessageSource: archiver,
|
|
432
|
+
p2pClient,
|
|
433
|
+
blobClient,
|
|
434
|
+
dateProvider,
|
|
435
|
+
telemetry,
|
|
436
|
+
}).register(p2pClient, reexecute, archiver);
|
|
399
437
|
}
|
|
400
438
|
|
|
401
439
|
// Start world state and wait for it to sync to the archiver.
|
|
@@ -437,7 +475,6 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
437
475
|
void archiver
|
|
438
476
|
.waitForInitialSync()
|
|
439
477
|
.then(async () => {
|
|
440
|
-
await p2pClient.start();
|
|
441
478
|
await validatorsSentinel?.start();
|
|
442
479
|
await epochPruneWatcher?.start();
|
|
443
480
|
await attestationsBlockWatcher?.start();
|
|
@@ -445,6 +482,17 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
445
482
|
})
|
|
446
483
|
.catch(err => log.error('Failed to start p2p services after archiver sync', err));
|
|
447
484
|
|
|
485
|
+
const globalVariableBuilderConfig = {
|
|
486
|
+
l1Contracts: config.l1Contracts,
|
|
487
|
+
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
488
|
+
rollupVersion: BigInt(config.rollupVersion),
|
|
489
|
+
l1GenesisTime,
|
|
490
|
+
slotDuration: Number(slotDuration),
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
const globalVariableBuilder = new GlobalVariableBuilder(dateProvider, publicClient, globalVariableBuilderConfig);
|
|
494
|
+
const feeProvider = new FeeProviderImpl(dateProvider, publicClient, globalVariableBuilderConfig);
|
|
495
|
+
|
|
448
496
|
// Validator enabled, create/start relevant service
|
|
449
497
|
let sequencer: SequencerClient | undefined;
|
|
450
498
|
let slasherClient: SlasherClientInterface | undefined;
|
|
@@ -482,9 +530,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
482
530
|
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
483
531
|
);
|
|
484
532
|
|
|
533
|
+
// Create a funder L1TxUtils from the keystore funding account (if configured)
|
|
534
|
+
const fundingSigner = keyStoreManager?.createFundingSigner();
|
|
535
|
+
let funderL1TxUtils: L1TxUtils | undefined;
|
|
536
|
+
if (fundingSigner) {
|
|
537
|
+
const [funder] = await createL1TxUtilsFromSigners(
|
|
538
|
+
publicClient,
|
|
539
|
+
[fundingSigner],
|
|
540
|
+
{ ...config, scope: 'sequencer' },
|
|
541
|
+
{ telemetry, logger: log.createChild('l1-tx-utils:funder'), dateProvider },
|
|
542
|
+
);
|
|
543
|
+
funderL1TxUtils = funder;
|
|
544
|
+
}
|
|
545
|
+
|
|
485
546
|
// Create and start the sequencer client
|
|
486
547
|
const checkpointsBuilder = new CheckpointsBuilder(
|
|
487
|
-
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
|
|
548
|
+
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration), rollupManaLimit },
|
|
488
549
|
worldStateSynchronizer,
|
|
489
550
|
archiver,
|
|
490
551
|
dateProvider,
|
|
@@ -496,6 +557,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
496
557
|
...deps,
|
|
497
558
|
epochCache,
|
|
498
559
|
l1TxUtils,
|
|
560
|
+
funderL1TxUtils,
|
|
499
561
|
validatorClient,
|
|
500
562
|
p2pClient,
|
|
501
563
|
worldStateSynchronizer,
|
|
@@ -507,6 +569,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
507
569
|
dateProvider,
|
|
508
570
|
blobClient,
|
|
509
571
|
nodeKeyStore: keyStoreManager!,
|
|
572
|
+
globalVariableBuilder,
|
|
510
573
|
});
|
|
511
574
|
}
|
|
512
575
|
|
|
@@ -540,13 +603,6 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
540
603
|
}
|
|
541
604
|
}
|
|
542
605
|
|
|
543
|
-
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
544
|
-
...config,
|
|
545
|
-
rollupVersion: BigInt(config.rollupVersion),
|
|
546
|
-
l1GenesisTime,
|
|
547
|
-
slotDuration: Number(slotDuration),
|
|
548
|
-
});
|
|
549
|
-
|
|
550
606
|
const node = new AztecNodeService(
|
|
551
607
|
config,
|
|
552
608
|
p2pClient,
|
|
@@ -563,9 +619,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
563
619
|
ethereumChain.chainInfo.id,
|
|
564
620
|
config.rollupVersion,
|
|
565
621
|
globalVariableBuilder,
|
|
622
|
+
feeProvider,
|
|
566
623
|
epochCache,
|
|
567
624
|
packageVersion,
|
|
568
|
-
|
|
625
|
+
peerProofVerifier,
|
|
626
|
+
rpcProofVerifier,
|
|
569
627
|
telemetry,
|
|
570
628
|
log,
|
|
571
629
|
blobClient,
|
|
@@ -710,12 +768,17 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
710
768
|
return (await this.blockSource.getCheckpointedBlocks(from, limit)) ?? [];
|
|
711
769
|
}
|
|
712
770
|
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
771
|
+
public getCheckpointsDataForEpoch(epochNumber: EpochNumber) {
|
|
772
|
+
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
773
|
+
}
|
|
774
|
+
|
|
717
775
|
public async getCurrentMinFees(): Promise<GasFees> {
|
|
718
|
-
return await this.
|
|
776
|
+
return await this.feeProvider.getCurrentMinFees();
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/** Returns predicted min fees for the current slot and next N slots. */
|
|
780
|
+
public async getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]> {
|
|
781
|
+
return await this.feeProvider.getPredictedMinFees(manaUsage);
|
|
719
782
|
}
|
|
720
783
|
|
|
721
784
|
public async getMaxPriorityFees(): Promise<GasFees> {
|
|
@@ -742,6 +805,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
742
805
|
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
743
806
|
}
|
|
744
807
|
|
|
808
|
+
public getCheckpointNumber(): Promise<CheckpointNumber> {
|
|
809
|
+
return this.blockSource.getCheckpointNumber();
|
|
810
|
+
}
|
|
811
|
+
|
|
745
812
|
/**
|
|
746
813
|
* Method to fetch the version of the package.
|
|
747
814
|
* @returns The node package version
|
|
@@ -779,18 +846,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
779
846
|
page?: number,
|
|
780
847
|
referenceBlock?: BlockHash,
|
|
781
848
|
): Promise<TxScopedL2Log[][]> {
|
|
849
|
+
let upToBlockNumber: BlockNumber | undefined;
|
|
782
850
|
if (referenceBlock) {
|
|
783
851
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
784
|
-
if (
|
|
852
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
853
|
+
upToBlockNumber = BlockNumber(0);
|
|
854
|
+
} else {
|
|
785
855
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
786
856
|
if (!header) {
|
|
787
857
|
throw new Error(
|
|
788
858
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
789
859
|
);
|
|
790
860
|
}
|
|
861
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
791
862
|
}
|
|
792
863
|
}
|
|
793
|
-
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
864
|
+
return this.logsSource.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
794
865
|
}
|
|
795
866
|
|
|
796
867
|
public async getPublicLogsByTagsFromContract(
|
|
@@ -799,18 +870,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
799
870
|
page?: number,
|
|
800
871
|
referenceBlock?: BlockHash,
|
|
801
872
|
): Promise<TxScopedL2Log[][]> {
|
|
873
|
+
let upToBlockNumber: BlockNumber | undefined;
|
|
802
874
|
if (referenceBlock) {
|
|
803
875
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
804
|
-
if (
|
|
876
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
877
|
+
upToBlockNumber = BlockNumber(0);
|
|
878
|
+
} else {
|
|
805
879
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
806
880
|
if (!header) {
|
|
807
881
|
throw new Error(
|
|
808
882
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
809
883
|
);
|
|
810
884
|
}
|
|
885
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
811
886
|
}
|
|
812
887
|
}
|
|
813
|
-
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
|
|
888
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
814
889
|
}
|
|
815
890
|
|
|
816
891
|
/**
|
|
@@ -896,7 +971,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
896
971
|
await tryStop(this.validatorsSentinel);
|
|
897
972
|
await tryStop(this.epochPruneWatcher);
|
|
898
973
|
await tryStop(this.slasherClient);
|
|
899
|
-
await tryStop(this.
|
|
974
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
900
975
|
await tryStop(this.sequencer);
|
|
901
976
|
await tryStop(this.proverNode);
|
|
902
977
|
await tryStop(this.p2pClient);
|
|
@@ -952,59 +1027,65 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
952
1027
|
treeId: MerkleTreeId,
|
|
953
1028
|
leafValues: Fr[],
|
|
954
1029
|
): Promise<(DataInBlock<bigint> | undefined)[]> {
|
|
955
|
-
const committedDb = await this
|
|
1030
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
956
1031
|
const maybeIndices = await committedDb.findLeafIndices(
|
|
957
1032
|
treeId,
|
|
958
1033
|
leafValues.map(x => x.toBuffer()),
|
|
959
1034
|
);
|
|
960
|
-
//
|
|
961
|
-
const
|
|
1035
|
+
// Filter out undefined values to query block numbers only for found leaves
|
|
1036
|
+
const definedIndices = maybeIndices.filter(x => x !== undefined);
|
|
962
1037
|
|
|
963
|
-
// Now we find the block numbers for the indices
|
|
964
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId,
|
|
1038
|
+
// Now we find the block numbers for the defined indices
|
|
1039
|
+
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
965
1040
|
|
|
966
|
-
//
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1041
|
+
// Build a map from leaf index to block number
|
|
1042
|
+
const indexToBlockNumber = new Map<bigint, BlockNumber>();
|
|
1043
|
+
for (let i = 0; i < definedIndices.length; i++) {
|
|
1044
|
+
const blockNumber = blockNumbers[i];
|
|
1045
|
+
if (blockNumber === undefined) {
|
|
1046
|
+
throw new Error(
|
|
1047
|
+
`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`,
|
|
1048
|
+
);
|
|
970
1049
|
}
|
|
1050
|
+
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
971
1051
|
}
|
|
972
1052
|
|
|
973
1053
|
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
974
|
-
const uniqueBlockNumbers = [...new Set(
|
|
1054
|
+
const uniqueBlockNumbers = [...new Set(indexToBlockNumber.values())];
|
|
975
1055
|
|
|
976
|
-
// Now we obtain the block hashes from the archive tree
|
|
977
|
-
// (note that block number corresponds to the leaf index in the archive tree).
|
|
1056
|
+
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
978
1057
|
const blockHashes = await Promise.all(
|
|
979
1058
|
uniqueBlockNumbers.map(blockNumber => {
|
|
980
1059
|
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
981
1060
|
}),
|
|
982
1061
|
);
|
|
983
1062
|
|
|
984
|
-
//
|
|
1063
|
+
// Build a map from block number to block hash
|
|
1064
|
+
const blockNumberToHash = new Map<BlockNumber, BlockHash>();
|
|
985
1065
|
for (let i = 0; i < uniqueBlockNumbers.length; i++) {
|
|
986
|
-
|
|
1066
|
+
const blockHash = blockHashes[i];
|
|
1067
|
+
if (blockHash === undefined) {
|
|
987
1068
|
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
988
1069
|
}
|
|
1070
|
+
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
989
1071
|
}
|
|
990
1072
|
|
|
991
1073
|
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
992
|
-
return maybeIndices.map(
|
|
1074
|
+
return maybeIndices.map(index => {
|
|
993
1075
|
if (index === undefined) {
|
|
994
1076
|
return undefined;
|
|
995
1077
|
}
|
|
996
|
-
const blockNumber =
|
|
1078
|
+
const blockNumber = indexToBlockNumber.get(index);
|
|
997
1079
|
if (blockNumber === undefined) {
|
|
998
|
-
|
|
1080
|
+
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
999
1081
|
}
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
return undefined;
|
|
1082
|
+
const l2BlockHash = blockNumberToHash.get(blockNumber);
|
|
1083
|
+
if (l2BlockHash === undefined) {
|
|
1084
|
+
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
1004
1085
|
}
|
|
1005
1086
|
return {
|
|
1006
|
-
l2BlockNumber:
|
|
1007
|
-
l2BlockHash
|
|
1087
|
+
l2BlockNumber: blockNumber,
|
|
1088
|
+
l2BlockHash,
|
|
1008
1089
|
data: index,
|
|
1009
1090
|
};
|
|
1010
1091
|
});
|
|
@@ -1014,7 +1095,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1014
1095
|
referenceBlock: BlockParameter,
|
|
1015
1096
|
blockHash: BlockHash,
|
|
1016
1097
|
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
|
|
1017
|
-
|
|
1098
|
+
// The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
|
|
1099
|
+
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
|
|
1100
|
+
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
|
|
1101
|
+
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
|
|
1102
|
+
if (referenceBlockNumber === BlockNumber.ZERO) {
|
|
1103
|
+
// Block 0 (the initial block) has an empty archive, so no membership witness can exist.
|
|
1104
|
+
return undefined;
|
|
1105
|
+
}
|
|
1106
|
+
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
|
|
1018
1107
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
|
|
1019
1108
|
return pathAndIndex === undefined
|
|
1020
1109
|
? undefined
|
|
@@ -1025,7 +1114,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1025
1114
|
referenceBlock: BlockParameter,
|
|
1026
1115
|
noteHash: Fr,
|
|
1027
1116
|
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
|
|
1028
|
-
const committedDb = await this
|
|
1117
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1029
1118
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.NOTE_HASH_TREE>(
|
|
1030
1119
|
MerkleTreeId.NOTE_HASH_TREE,
|
|
1031
1120
|
[noteHash],
|
|
@@ -1039,7 +1128,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1039
1128
|
referenceBlock: BlockParameter,
|
|
1040
1129
|
l1ToL2Message: Fr,
|
|
1041
1130
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
|
|
1042
|
-
const db = await this
|
|
1131
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1043
1132
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [l1ToL2Message]);
|
|
1044
1133
|
if (!witness) {
|
|
1045
1134
|
return undefined;
|
|
@@ -1049,11 +1138,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1049
1138
|
return [witness.index, witness.path];
|
|
1050
1139
|
}
|
|
1051
1140
|
|
|
1052
|
-
public async
|
|
1141
|
+
public async getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined> {
|
|
1053
1142
|
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
1054
|
-
return messageIndex
|
|
1055
|
-
? BlockNumber.fromCheckpointNumber(InboxLeaf.checkpointNumberFromIndex(messageIndex))
|
|
1056
|
-
: undefined;
|
|
1143
|
+
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
1057
1144
|
}
|
|
1058
1145
|
|
|
1059
1146
|
/**
|
|
@@ -1074,19 +1161,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1074
1161
|
public async getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
|
|
1075
1162
|
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
1076
1163
|
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1077
|
-
const blocksInCheckpoints
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
for (const checkpointedBlock of checkpointedBlocks) {
|
|
1081
|
-
const block = checkpointedBlock.block;
|
|
1082
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
1083
|
-
if (slotNumber !== previousSlotNumber) {
|
|
1084
|
-
checkpointIndex++;
|
|
1085
|
-
blocksInCheckpoints.push([]);
|
|
1086
|
-
previousSlotNumber = slotNumber;
|
|
1087
|
-
}
|
|
1088
|
-
blocksInCheckpoints[checkpointIndex].push(block);
|
|
1089
|
-
}
|
|
1164
|
+
const blocksInCheckpoints = chunkBy(checkpointedBlocks, cb => cb.block.header.globalVariables.slotNumber).map(
|
|
1165
|
+
group => group.map(cb => cb.block),
|
|
1166
|
+
);
|
|
1090
1167
|
return blocksInCheckpoints.map(blocks =>
|
|
1091
1168
|
blocks.map(block => block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs)),
|
|
1092
1169
|
);
|
|
@@ -1096,7 +1173,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1096
1173
|
referenceBlock: BlockParameter,
|
|
1097
1174
|
nullifier: Fr,
|
|
1098
1175
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1099
|
-
const db = await this
|
|
1176
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1100
1177
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]);
|
|
1101
1178
|
if (!witness) {
|
|
1102
1179
|
return undefined;
|
|
@@ -1111,33 +1188,20 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1111
1188
|
return new NullifierMembershipWitness(index, leafPreimage as NullifierLeafPreimage, path);
|
|
1112
1189
|
}
|
|
1113
1190
|
|
|
1114
|
-
/**
|
|
1115
|
-
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
1116
|
-
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
|
|
1117
|
-
* (which contains the root of the nullifier tree in which we are searching for the nullifier).
|
|
1118
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
1119
|
-
* @returns The low nullifier membership witness (if found).
|
|
1120
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
1121
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
1122
|
-
* we are trying to prove non-inclusion for.
|
|
1123
|
-
*
|
|
1124
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
1125
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
1126
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
1127
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
1128
|
-
*/
|
|
1129
1191
|
public async getLowNullifierMembershipWitness(
|
|
1130
1192
|
referenceBlock: BlockParameter,
|
|
1131
1193
|
nullifier: Fr,
|
|
1132
1194
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1133
|
-
const committedDb = await this
|
|
1195
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1134
1196
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1135
1197
|
if (!findResult) {
|
|
1136
1198
|
return undefined;
|
|
1137
1199
|
}
|
|
1138
1200
|
const { index, alreadyPresent } = findResult;
|
|
1139
1201
|
if (alreadyPresent) {
|
|
1140
|
-
|
|
1202
|
+
throw new Error(
|
|
1203
|
+
`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`,
|
|
1204
|
+
);
|
|
1141
1205
|
}
|
|
1142
1206
|
const preimageData = (await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index))!;
|
|
1143
1207
|
|
|
@@ -1146,7 +1210,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1146
1210
|
}
|
|
1147
1211
|
|
|
1148
1212
|
async getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
1149
|
-
const committedDb = await this
|
|
1213
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1150
1214
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1151
1215
|
if (!lowLeafResult) {
|
|
1152
1216
|
return undefined;
|
|
@@ -1161,7 +1225,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1161
1225
|
}
|
|
1162
1226
|
|
|
1163
1227
|
public async getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
1164
|
-
const committedDb = await this
|
|
1228
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1165
1229
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1166
1230
|
|
|
1167
1231
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
@@ -1275,7 +1339,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1275
1339
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1276
1340
|
|
|
1277
1341
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1278
|
-
const [processedTxs, failedTxs, _usedTxs, returns,
|
|
1342
|
+
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([tx]);
|
|
1279
1343
|
// REFACTOR: Consider returning the error rather than throwing
|
|
1280
1344
|
if (failedTxs.length) {
|
|
1281
1345
|
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
|
|
@@ -1301,11 +1365,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1301
1365
|
{ isSimulation, skipFeeEnforcement }: { isSimulation?: boolean; skipFeeEnforcement?: boolean } = {},
|
|
1302
1366
|
): Promise<TxValidationResult> {
|
|
1303
1367
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1304
|
-
const verifier = isSimulation ? undefined : this.
|
|
1368
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
1305
1369
|
|
|
1306
1370
|
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1307
1371
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1308
1372
|
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
1373
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
1309
1374
|
const validator = createTxValidatorForAcceptingTxsOverRPC(
|
|
1310
1375
|
db,
|
|
1311
1376
|
this.contractDataSource,
|
|
@@ -1322,6 +1387,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1322
1387
|
gasFees: await this.getCurrentMinFees(),
|
|
1323
1388
|
skipFeeEnforcement,
|
|
1324
1389
|
txsPermitted: !this.config.disableTransactions,
|
|
1390
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1391
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1392
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas,
|
|
1325
1393
|
},
|
|
1326
1394
|
this.log.getBindings(),
|
|
1327
1395
|
);
|
|
@@ -1346,7 +1414,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1346
1414
|
archiver.updateConfig(config);
|
|
1347
1415
|
}
|
|
1348
1416
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
1349
|
-
|
|
1417
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
1418
|
+
if (newConfig.realProofs) {
|
|
1419
|
+
this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
|
|
1420
|
+
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
|
|
1421
|
+
this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
|
|
1422
|
+
} else {
|
|
1423
|
+
this.peerProofVerifier = new TestCircuitVerifier();
|
|
1424
|
+
this.rpcProofVerifier = new TestCircuitVerifier();
|
|
1425
|
+
}
|
|
1350
1426
|
}
|
|
1351
1427
|
|
|
1352
1428
|
this.config = newConfig;
|
|
@@ -1421,7 +1497,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1421
1497
|
return Promise.resolve();
|
|
1422
1498
|
}
|
|
1423
1499
|
|
|
1424
|
-
public async rollbackTo(targetBlock: BlockNumber, force?: boolean): Promise<void> {
|
|
1500
|
+
public async rollbackTo(targetBlock: BlockNumber, force?: boolean, resumeSync = true): Promise<void> {
|
|
1425
1501
|
const archiver = this.blockSource as Archiver;
|
|
1426
1502
|
if (!('rollbackTo' in archiver)) {
|
|
1427
1503
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
@@ -1451,9 +1527,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1451
1527
|
this.log.error(`Error during rollback`, err);
|
|
1452
1528
|
throw err;
|
|
1453
1529
|
} finally {
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1530
|
+
if (resumeSync) {
|
|
1531
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
1532
|
+
this.worldStateSynchronizer.resumeSync();
|
|
1533
|
+
archiver.resume();
|
|
1534
|
+
} else {
|
|
1535
|
+
this.log.info(`Sync left paused after rollback (resumeSync=false).`);
|
|
1536
|
+
}
|
|
1457
1537
|
}
|
|
1458
1538
|
}
|
|
1459
1539
|
|
|
@@ -1470,19 +1550,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1470
1550
|
return Promise.resolve();
|
|
1471
1551
|
}
|
|
1472
1552
|
|
|
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
1553
|
public getSlashOffenses(round: bigint | 'all' | 'current'): Promise<Offense[]> {
|
|
1481
1554
|
if (!this.slasherClient) {
|
|
1482
1555
|
throw new Error(`Slasher client not enabled`);
|
|
1483
1556
|
}
|
|
1484
1557
|
if (round === 'all') {
|
|
1485
|
-
return this.slasherClient.
|
|
1558
|
+
return this.slasherClient.getOffenses();
|
|
1486
1559
|
} else {
|
|
1487
1560
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1488
1561
|
}
|
|
@@ -1576,6 +1649,40 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1576
1649
|
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1577
1650
|
}
|
|
1578
1651
|
|
|
1652
|
+
public async mineBlock(): Promise<void> {
|
|
1653
|
+
if (!this.sequencer) {
|
|
1654
|
+
throw new BadRequestError('Cannot mine block: no sequencer is running');
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
const currentBlockNumber = await this.getBlockNumber();
|
|
1658
|
+
|
|
1659
|
+
// Use slot duration + 50% buffer as the timeout so this works on running networks too
|
|
1660
|
+
const { slotDuration } = await this.blockSource.getL1Constants();
|
|
1661
|
+
const timeoutSeconds = Math.ceil(slotDuration * 1.5);
|
|
1662
|
+
|
|
1663
|
+
// Temporarily set minTxsPerBlock to 0 so the sequencer produces a block even with no txs
|
|
1664
|
+
const originalMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock;
|
|
1665
|
+
this.sequencer.updateConfig({ minTxsPerBlock: 0 });
|
|
1666
|
+
|
|
1667
|
+
try {
|
|
1668
|
+
// Trigger the sequencer to produce a block immediately
|
|
1669
|
+
void this.sequencer.trigger();
|
|
1670
|
+
|
|
1671
|
+
// Wait for the new L2 block to appear
|
|
1672
|
+
await retryUntil(
|
|
1673
|
+
async () => {
|
|
1674
|
+
const newBlockNumber = await this.getBlockNumber();
|
|
1675
|
+
return newBlockNumber > currentBlockNumber ? true : undefined;
|
|
1676
|
+
},
|
|
1677
|
+
'mineBlock',
|
|
1678
|
+
timeoutSeconds,
|
|
1679
|
+
0.1,
|
|
1680
|
+
);
|
|
1681
|
+
} finally {
|
|
1682
|
+
this.sequencer.updateConfig({ minTxsPerBlock: originalMinTxsPerBlock });
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1579
1686
|
#getInitialHeaderHash(): Promise<BlockHash> {
|
|
1580
1687
|
if (!this.initialHeaderHashPromise) {
|
|
1581
1688
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
@@ -1588,7 +1695,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1588
1695
|
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1589
1696
|
* @returns An instance of a committed MerkleTreeOperations
|
|
1590
1697
|
*/
|
|
1591
|
-
async
|
|
1698
|
+
protected async getWorldState(block: BlockParameter) {
|
|
1592
1699
|
let blockSyncedTo: BlockNumber = BlockNumber.ZERO;
|
|
1593
1700
|
try {
|
|
1594
1701
|
// Attempt to sync the world state if necessary
|
|
@@ -1602,6 +1709,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1602
1709
|
return this.worldStateSynchronizer.getCommitted();
|
|
1603
1710
|
}
|
|
1604
1711
|
|
|
1712
|
+
// Get the block number, either directly from the parameter or by quering the archiver with the block hash
|
|
1713
|
+
let blockNumber: BlockNumber;
|
|
1605
1714
|
if (BlockHash.isBlockHash(block)) {
|
|
1606
1715
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1607
1716
|
if (block.equals(initialBlockHash)) {
|
|
@@ -1615,22 +1724,50 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1615
1724
|
`Block hash ${block.toString()} not found when querying world state. If the node API has been queried with anchor block hash possibly a reorg has occurred.`,
|
|
1616
1725
|
);
|
|
1617
1726
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1727
|
+
|
|
1728
|
+
blockNumber = header.getBlockNumber();
|
|
1729
|
+
} else {
|
|
1730
|
+
blockNumber = block as BlockNumber;
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
// Check it's within world state sync range
|
|
1734
|
+
if (blockNumber > blockSyncedTo) {
|
|
1735
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1621
1736
|
}
|
|
1737
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1622
1738
|
|
|
1623
|
-
|
|
1624
|
-
{
|
|
1625
|
-
const blockNumber = block as BlockNumber;
|
|
1739
|
+
const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1626
1740
|
|
|
1627
|
-
|
|
1628
|
-
|
|
1741
|
+
// Double-check world-state synced to the same block hash as was requested
|
|
1742
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1743
|
+
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1744
|
+
if (!blockHash || !block.equals(blockHash)) {
|
|
1745
|
+
throw new Error(
|
|
1746
|
+
`Block hash ${block.toString()} not found in world state at block number ${blockNumber}. If the node API has been queried with anchor block hash possibly a reorg has occurred.`,
|
|
1747
|
+
);
|
|
1629
1748
|
}
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
return snapshot;
|
|
1752
|
+
}
|
|
1630
1753
|
|
|
1631
|
-
|
|
1632
|
-
|
|
1754
|
+
/** Resolves a block parameter to a block number. */
|
|
1755
|
+
protected async resolveBlockNumber(block: BlockParameter): Promise<BlockNumber> {
|
|
1756
|
+
if (block === 'latest') {
|
|
1757
|
+
return BlockNumber(await this.blockSource.getBlockNumber());
|
|
1758
|
+
}
|
|
1759
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1760
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1761
|
+
if (block.equals(initialBlockHash)) {
|
|
1762
|
+
return BlockNumber.ZERO;
|
|
1763
|
+
}
|
|
1764
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1765
|
+
if (!header) {
|
|
1766
|
+
throw new Error(`Block hash ${block.toString()} not found.`);
|
|
1767
|
+
}
|
|
1768
|
+
return header.getBlockNumber();
|
|
1633
1769
|
}
|
|
1770
|
+
return block as BlockNumber;
|
|
1634
1771
|
}
|
|
1635
1772
|
|
|
1636
1773
|
/**
|