@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
|
@@ -372,19 +372,21 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
372
372
|
}
|
|
373
373
|
var _dec, _initProto;
|
|
374
374
|
import { createArchiver } from '@aztec/archiver';
|
|
375
|
-
import { BBCircuitVerifier,
|
|
375
|
+
import { BBCircuitVerifier, BatchChonkVerifier, QueuedIVCVerifier } from '@aztec/bb-prover';
|
|
376
|
+
import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
376
377
|
import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
377
378
|
import { Blob } from '@aztec/blob-lib';
|
|
378
379
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
379
380
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
380
|
-
import { getPublicClient } from '@aztec/ethereum/client';
|
|
381
|
+
import { getPublicClient, makeL1HttpTransport } from '@aztec/ethereum/client';
|
|
381
382
|
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
382
|
-
import { BlockNumber
|
|
383
|
-
import { compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
383
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
384
|
+
import { chunkBy, compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
384
385
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
385
386
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
386
387
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
387
388
|
import { createLogger } from '@aztec/foundation/log';
|
|
389
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
388
390
|
import { count } from '@aztec/foundation/string';
|
|
389
391
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
390
392
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
@@ -395,7 +397,7 @@ import { createP2PClient, createTxValidatorForAcceptingTxsOverRPC, getDefaultAll
|
|
|
395
397
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
396
398
|
import { createProverNode } from '@aztec/prover-node';
|
|
397
399
|
import { createKeyStoreForProver } from '@aztec/prover-node/config';
|
|
398
|
-
import { GlobalVariableBuilder, SequencerClient } from '@aztec/sequencer-client';
|
|
400
|
+
import { FeeProviderImpl, GlobalVariableBuilder, SequencerClient } from '@aztec/sequencer-client';
|
|
399
401
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
400
402
|
import { AttestationsBlockWatcher, EpochPruneWatcher, createSlasher } from '@aztec/slasher';
|
|
401
403
|
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
@@ -411,9 +413,9 @@ import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@az
|
|
|
411
413
|
import { PublicSimulationOutput, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
412
414
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
413
415
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
414
|
-
import { FullNodeCheckpointsBuilder as CheckpointsBuilder, FullNodeCheckpointsBuilder, NodeKeystoreAdapter, ValidatorClient,
|
|
416
|
+
import { FullNodeCheckpointsBuilder as CheckpointsBuilder, FullNodeCheckpointsBuilder, NodeKeystoreAdapter, ValidatorClient, createProposalHandler, createValidatorClient } from '@aztec/validator-client';
|
|
415
417
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
416
|
-
import { createPublicClient
|
|
418
|
+
import { createPublicClient } from 'viem';
|
|
417
419
|
import { createSentinel } from '../sentinel/factory.js';
|
|
418
420
|
import { createKeyStoreForValidator } from './config.js';
|
|
419
421
|
import { NodeMetrics } from './node_metrics.js';
|
|
@@ -438,9 +440,11 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
438
440
|
l1ChainId;
|
|
439
441
|
version;
|
|
440
442
|
globalVariableBuilder;
|
|
443
|
+
feeProvider;
|
|
441
444
|
epochCache;
|
|
442
445
|
packageVersion;
|
|
443
|
-
|
|
446
|
+
peerProofVerifier;
|
|
447
|
+
rpcProofVerifier;
|
|
444
448
|
telemetry;
|
|
445
449
|
log;
|
|
446
450
|
blobClient;
|
|
@@ -461,7 +465,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
461
465
|
// Prevent two snapshot operations to happen simultaneously
|
|
462
466
|
isUploadingSnapshot;
|
|
463
467
|
tracer;
|
|
464
|
-
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, l1ChainId, version, globalVariableBuilder, epochCache, packageVersion,
|
|
468
|
+
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, l1ChainId, version, globalVariableBuilder, feeProvider, epochCache, packageVersion, peerProofVerifier, rpcProofVerifier, telemetry = getTelemetryClient(), log = createLogger('node'), blobClient, validatorClient, keyStoreManager, debugLogStore = new NullDebugLogStore()){
|
|
465
469
|
this.config = config;
|
|
466
470
|
this.p2pClient = p2pClient;
|
|
467
471
|
this.blockSource = blockSource;
|
|
@@ -477,9 +481,11 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
477
481
|
this.l1ChainId = l1ChainId;
|
|
478
482
|
this.version = version;
|
|
479
483
|
this.globalVariableBuilder = globalVariableBuilder;
|
|
484
|
+
this.feeProvider = feeProvider;
|
|
480
485
|
this.epochCache = epochCache;
|
|
481
486
|
this.packageVersion = packageVersion;
|
|
482
|
-
this.
|
|
487
|
+
this.peerProofVerifier = peerProofVerifier;
|
|
488
|
+
this.rpcProofVerifier = rpcProofVerifier;
|
|
483
489
|
this.telemetry = telemetry;
|
|
484
490
|
this.log = log;
|
|
485
491
|
this.blobClient = blobClient;
|
|
@@ -499,6 +505,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
499
505
|
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
500
506
|
}
|
|
501
507
|
}
|
|
508
|
+
/** @internal Exposed for testing — returns the RPC proof verifier. */ getProofVerifier() {
|
|
509
|
+
return this.rpcProofVerifier;
|
|
510
|
+
}
|
|
502
511
|
async getWorldStateSyncStatus() {
|
|
503
512
|
const status = await this.worldStateSynchronizer.status();
|
|
504
513
|
return status.syncSummary;
|
|
@@ -559,9 +568,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
559
568
|
}
|
|
560
569
|
const publicClient = createPublicClient({
|
|
561
570
|
chain: ethereumChain.chainInfo,
|
|
562
|
-
transport:
|
|
563
|
-
|
|
564
|
-
|
|
571
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, {
|
|
572
|
+
timeout: config.l1HttpTimeoutMS
|
|
573
|
+
}),
|
|
565
574
|
pollingInterval: config.viemPollingIntervalMS
|
|
566
575
|
});
|
|
567
576
|
const l1ContractsAddresses = await RegistryContract.collectAddresses(publicClient, config.l1Contracts.registryAddress, config.rollupVersion ?? 'canonical');
|
|
@@ -571,10 +580,11 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
571
580
|
...l1ContractsAddresses
|
|
572
581
|
};
|
|
573
582
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
574
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
583
|
+
const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
|
|
575
584
|
rollupContract.getL1GenesisTime(),
|
|
576
585
|
rollupContract.getSlotDuration(),
|
|
577
|
-
rollupContract.getVersion()
|
|
586
|
+
rollupContract.getVersion(),
|
|
587
|
+
rollupContract.getManaLimit().then(Number)
|
|
578
588
|
]);
|
|
579
589
|
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
580
590
|
if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
|
|
@@ -595,8 +605,18 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
595
605
|
blockUntilSync: !config.skipArchiverInitialSync
|
|
596
606
|
});
|
|
597
607
|
// now create the merkle trees and the world state synchronizer
|
|
598
|
-
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.
|
|
599
|
-
const
|
|
608
|
+
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.genesis, telemetry);
|
|
609
|
+
const useRealVerifiers = config.realProofs || config.debugForceTxProofVerification;
|
|
610
|
+
let peerProofVerifier;
|
|
611
|
+
let rpcProofVerifier;
|
|
612
|
+
if (useRealVerifiers) {
|
|
613
|
+
peerProofVerifier = await BatchChonkVerifier.new(config, config.bbChonkVerifyMaxBatch, 'peer');
|
|
614
|
+
const rpcVerifier = await BBCircuitVerifier.new(config);
|
|
615
|
+
rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, config.numConcurrentIVCVerifiers);
|
|
616
|
+
} else {
|
|
617
|
+
peerProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
618
|
+
rpcProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
619
|
+
}
|
|
600
620
|
let debugLogStore;
|
|
601
621
|
if (!config.realProofs) {
|
|
602
622
|
log.warn(`Aztec node is accepting fake proofs`);
|
|
@@ -605,20 +625,22 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
605
625
|
} else {
|
|
606
626
|
debugLogStore = new NullDebugLogStore();
|
|
607
627
|
}
|
|
608
|
-
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
609
628
|
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
610
629
|
if (proverOnly) {
|
|
611
630
|
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
612
631
|
}
|
|
613
632
|
// create the tx pool and the p2p client, which will need the l2 block source
|
|
614
|
-
const p2pClient = await createP2PClient(config, archiver,
|
|
633
|
+
const p2pClient = await createP2PClient(config, archiver, peerProofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
|
|
615
634
|
// We'll accumulate sentinel watchers here
|
|
616
635
|
const watchers = [];
|
|
617
|
-
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation
|
|
636
|
+
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
637
|
+
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
618
638
|
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder({
|
|
619
639
|
...config,
|
|
620
640
|
l1GenesisTime,
|
|
621
|
-
slotDuration: Number(slotDuration)
|
|
641
|
+
slotDuration: Number(slotDuration),
|
|
642
|
+
rollupManaLimit,
|
|
643
|
+
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint
|
|
622
644
|
}, worldStateSynchronizer, archiver, dateProvider, telemetry);
|
|
623
645
|
let validatorClient;
|
|
624
646
|
if (!proverOnly) {
|
|
@@ -633,32 +655,40 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
633
655
|
blockSource: archiver,
|
|
634
656
|
l1ToL2MessageSource: archiver,
|
|
635
657
|
keyStoreManager,
|
|
636
|
-
blobClient
|
|
658
|
+
blobClient,
|
|
659
|
+
slashingProtectionDb: deps.slashingProtectionDb
|
|
637
660
|
});
|
|
638
661
|
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
639
662
|
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
640
663
|
// like attestations or auths will fail.
|
|
641
664
|
if (validatorClient) {
|
|
642
665
|
watchers.push(validatorClient);
|
|
666
|
+
const vc = validatorClient;
|
|
667
|
+
const getValidatorAddresses = ()=>vc.getValidatorAddresses().map((a)=>a.toString());
|
|
668
|
+
validatorClient.getProposalHandler().register(p2pClient, true, archiver, getValidatorAddresses);
|
|
643
669
|
if (!options.dontStartSequencer) {
|
|
644
670
|
await validatorClient.registerHandlers();
|
|
645
671
|
}
|
|
646
672
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
673
|
+
}
|
|
674
|
+
// If there's no validator client, create a ProposalHandler to handle block and checkpoint proposals
|
|
675
|
+
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
676
|
+
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
677
|
+
// Checkpoint proposals rebuild blobs if the blob client can upload blobs.
|
|
678
|
+
if (!validatorClient) {
|
|
679
|
+
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
680
|
+
log.info(`Setting up proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
681
|
+
createProposalHandler(config, {
|
|
682
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
683
|
+
worldState: worldStateSynchronizer,
|
|
684
|
+
epochCache,
|
|
685
|
+
blockSource: archiver,
|
|
686
|
+
l1ToL2MessageSource: archiver,
|
|
687
|
+
p2pClient,
|
|
688
|
+
blobClient,
|
|
689
|
+
dateProvider,
|
|
690
|
+
telemetry
|
|
691
|
+
}).register(p2pClient, reexecute, archiver);
|
|
662
692
|
}
|
|
663
693
|
// Start world state and wait for it to sync to the archiver.
|
|
664
694
|
await worldStateSynchronizer.start();
|
|
@@ -684,12 +714,20 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
684
714
|
}
|
|
685
715
|
// Start p2p-related services once the archiver has completed sync
|
|
686
716
|
void archiver.waitForInitialSync().then(async ()=>{
|
|
687
|
-
await p2pClient.start();
|
|
688
717
|
await validatorsSentinel?.start();
|
|
689
718
|
await epochPruneWatcher?.start();
|
|
690
719
|
await attestationsBlockWatcher?.start();
|
|
691
720
|
log.info(`All p2p services started`);
|
|
692
721
|
}).catch((err)=>log.error('Failed to start p2p services after archiver sync', err));
|
|
722
|
+
const globalVariableBuilderConfig = {
|
|
723
|
+
l1Contracts: config.l1Contracts,
|
|
724
|
+
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
725
|
+
rollupVersion: BigInt(config.rollupVersion),
|
|
726
|
+
l1GenesisTime,
|
|
727
|
+
slotDuration: Number(slotDuration)
|
|
728
|
+
};
|
|
729
|
+
const globalVariableBuilder = new GlobalVariableBuilder(dateProvider, publicClient, globalVariableBuilderConfig);
|
|
730
|
+
const feeProvider = new FeeProviderImpl(dateProvider, publicClient, globalVariableBuilderConfig);
|
|
693
731
|
// Validator enabled, create/start relevant service
|
|
694
732
|
let sequencer;
|
|
695
733
|
let slasherClient;
|
|
@@ -716,16 +754,34 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
716
754
|
dateProvider,
|
|
717
755
|
kzg: Blob.getViemKzgInstance()
|
|
718
756
|
});
|
|
757
|
+
// Create a funder L1TxUtils from the keystore funding account (if configured)
|
|
758
|
+
const fundingSigner = keyStoreManager?.createFundingSigner();
|
|
759
|
+
let funderL1TxUtils;
|
|
760
|
+
if (fundingSigner) {
|
|
761
|
+
const [funder] = await createL1TxUtilsFromSigners(publicClient, [
|
|
762
|
+
fundingSigner
|
|
763
|
+
], {
|
|
764
|
+
...config,
|
|
765
|
+
scope: 'sequencer'
|
|
766
|
+
}, {
|
|
767
|
+
telemetry,
|
|
768
|
+
logger: log.createChild('l1-tx-utils:funder'),
|
|
769
|
+
dateProvider
|
|
770
|
+
});
|
|
771
|
+
funderL1TxUtils = funder;
|
|
772
|
+
}
|
|
719
773
|
// Create and start the sequencer client
|
|
720
774
|
const checkpointsBuilder = new CheckpointsBuilder({
|
|
721
775
|
...config,
|
|
722
776
|
l1GenesisTime,
|
|
723
|
-
slotDuration: Number(slotDuration)
|
|
777
|
+
slotDuration: Number(slotDuration),
|
|
778
|
+
rollupManaLimit
|
|
724
779
|
}, worldStateSynchronizer, archiver, dateProvider, telemetry, debugLogStore);
|
|
725
780
|
sequencer = await SequencerClient.new(config, {
|
|
726
781
|
...deps,
|
|
727
782
|
epochCache,
|
|
728
783
|
l1TxUtils,
|
|
784
|
+
funderL1TxUtils,
|
|
729
785
|
validatorClient,
|
|
730
786
|
p2pClient,
|
|
731
787
|
worldStateSynchronizer,
|
|
@@ -736,7 +792,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
736
792
|
telemetry,
|
|
737
793
|
dateProvider,
|
|
738
794
|
blobClient,
|
|
739
|
-
nodeKeyStore: keyStoreManager
|
|
795
|
+
nodeKeyStore: keyStoreManager,
|
|
796
|
+
globalVariableBuilder
|
|
740
797
|
});
|
|
741
798
|
}
|
|
742
799
|
if (!options.dontStartSequencer && sequencer) {
|
|
@@ -766,13 +823,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
766
823
|
log.info(`Prover node subsystem created but not started`);
|
|
767
824
|
}
|
|
768
825
|
}
|
|
769
|
-
const
|
|
770
|
-
...config,
|
|
771
|
-
rollupVersion: BigInt(config.rollupVersion),
|
|
772
|
-
l1GenesisTime,
|
|
773
|
-
slotDuration: Number(slotDuration)
|
|
774
|
-
});
|
|
775
|
-
const node = new AztecNodeService(config, p2pClient, archiver, archiver, archiver, archiver, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, ethereumChain.chainInfo.id, config.rollupVersion, globalVariableBuilder, epochCache, packageVersion, proofVerifier, telemetry, log, blobClient, validatorClient, keyStoreManager, debugLogStore);
|
|
826
|
+
const node = new AztecNodeService(config, p2pClient, archiver, archiver, archiver, archiver, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, ethereumChain.chainInfo.id, config.rollupVersion, globalVariableBuilder, feeProvider, epochCache, packageVersion, peerProofVerifier, rpcProofVerifier, telemetry, log, blobClient, validatorClient, keyStoreManager, debugLogStore);
|
|
776
827
|
return node;
|
|
777
828
|
}
|
|
778
829
|
/**
|
|
@@ -884,11 +935,14 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
884
935
|
async getCheckpointedBlocks(from, limit) {
|
|
885
936
|
return await this.blockSource.getCheckpointedBlocks(from, limit) ?? [];
|
|
886
937
|
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
return await this.
|
|
938
|
+
getCheckpointsDataForEpoch(epochNumber) {
|
|
939
|
+
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
940
|
+
}
|
|
941
|
+
async getCurrentMinFees() {
|
|
942
|
+
return await this.feeProvider.getCurrentMinFees();
|
|
943
|
+
}
|
|
944
|
+
/** Returns predicted min fees for the current slot and next N slots. */ async getPredictedMinFees(manaUsage) {
|
|
945
|
+
return await this.feeProvider.getPredictedMinFees(manaUsage);
|
|
892
946
|
}
|
|
893
947
|
async getMaxPriorityFees() {
|
|
894
948
|
for await (const tx of this.p2pClient.iteratePendingTxs()){
|
|
@@ -911,6 +965,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
911
965
|
async getCheckpointedBlockNumber() {
|
|
912
966
|
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
913
967
|
}
|
|
968
|
+
getCheckpointNumber() {
|
|
969
|
+
return this.blockSource.getCheckpointNumber();
|
|
970
|
+
}
|
|
914
971
|
/**
|
|
915
972
|
* Method to fetch the version of the package.
|
|
916
973
|
* @returns The node package version
|
|
@@ -936,28 +993,36 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
936
993
|
return this.contractDataSource.getContract(address);
|
|
937
994
|
}
|
|
938
995
|
async getPrivateLogsByTags(tags, page, referenceBlock) {
|
|
996
|
+
let upToBlockNumber;
|
|
939
997
|
if (referenceBlock) {
|
|
940
998
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
941
|
-
if (
|
|
999
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
1000
|
+
upToBlockNumber = BlockNumber(0);
|
|
1001
|
+
} else {
|
|
942
1002
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
943
1003
|
if (!header) {
|
|
944
1004
|
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
945
1005
|
}
|
|
1006
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
946
1007
|
}
|
|
947
1008
|
}
|
|
948
|
-
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
1009
|
+
return this.logsSource.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
949
1010
|
}
|
|
950
1011
|
async getPublicLogsByTagsFromContract(contractAddress, tags, page, referenceBlock) {
|
|
1012
|
+
let upToBlockNumber;
|
|
951
1013
|
if (referenceBlock) {
|
|
952
1014
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
953
|
-
if (
|
|
1015
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
1016
|
+
upToBlockNumber = BlockNumber(0);
|
|
1017
|
+
} else {
|
|
954
1018
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
955
1019
|
if (!header) {
|
|
956
1020
|
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
957
1021
|
}
|
|
1022
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
958
1023
|
}
|
|
959
1024
|
}
|
|
960
|
-
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
|
|
1025
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
961
1026
|
}
|
|
962
1027
|
/**
|
|
963
1028
|
* Gets public logs based on the provided filter.
|
|
@@ -1030,7 +1095,10 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1030
1095
|
await tryStop(this.validatorsSentinel);
|
|
1031
1096
|
await tryStop(this.epochPruneWatcher);
|
|
1032
1097
|
await tryStop(this.slasherClient);
|
|
1033
|
-
await
|
|
1098
|
+
await Promise.all([
|
|
1099
|
+
tryStop(this.peerProofVerifier),
|
|
1100
|
+
tryStop(this.rpcProofVerifier)
|
|
1101
|
+
]);
|
|
1034
1102
|
await tryStop(this.sequencer);
|
|
1035
1103
|
await tryStop(this.proverNode);
|
|
1036
1104
|
await tryStop(this.p2pClient);
|
|
@@ -1072,70 +1140,82 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1072
1140
|
return compactArray(await Promise.all(txHashes.map((txHash)=>this.getTxByHash(txHash))));
|
|
1073
1141
|
}
|
|
1074
1142
|
async findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
1075
|
-
const committedDb = await this
|
|
1143
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1076
1144
|
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
1077
|
-
//
|
|
1078
|
-
const
|
|
1079
|
-
// Now we find the block numbers for the indices
|
|
1080
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId,
|
|
1081
|
-
//
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1145
|
+
// Filter out undefined values to query block numbers only for found leaves
|
|
1146
|
+
const definedIndices = maybeIndices.filter((x)=>x !== undefined);
|
|
1147
|
+
// Now we find the block numbers for the defined indices
|
|
1148
|
+
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
1149
|
+
// Build a map from leaf index to block number
|
|
1150
|
+
const indexToBlockNumber = new Map();
|
|
1151
|
+
for(let i = 0; i < definedIndices.length; i++){
|
|
1152
|
+
const blockNumber = blockNumbers[i];
|
|
1153
|
+
if (blockNumber === undefined) {
|
|
1154
|
+
throw new Error(`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`);
|
|
1085
1155
|
}
|
|
1156
|
+
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
1086
1157
|
}
|
|
1087
1158
|
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
1088
1159
|
const uniqueBlockNumbers = [
|
|
1089
|
-
...new Set(
|
|
1160
|
+
...new Set(indexToBlockNumber.values())
|
|
1090
1161
|
];
|
|
1091
|
-
// Now we obtain the block hashes from the archive tree
|
|
1092
|
-
// (note that block number corresponds to the leaf index in the archive tree).
|
|
1162
|
+
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
1093
1163
|
const blockHashes = await Promise.all(uniqueBlockNumbers.map((blockNumber)=>{
|
|
1094
1164
|
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1095
1165
|
}));
|
|
1096
|
-
//
|
|
1166
|
+
// Build a map from block number to block hash
|
|
1167
|
+
const blockNumberToHash = new Map();
|
|
1097
1168
|
for(let i = 0; i < uniqueBlockNumbers.length; i++){
|
|
1098
|
-
|
|
1169
|
+
const blockHash = blockHashes[i];
|
|
1170
|
+
if (blockHash === undefined) {
|
|
1099
1171
|
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
1100
1172
|
}
|
|
1173
|
+
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
1101
1174
|
}
|
|
1102
1175
|
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
1103
|
-
return maybeIndices.map((index
|
|
1176
|
+
return maybeIndices.map((index)=>{
|
|
1104
1177
|
if (index === undefined) {
|
|
1105
1178
|
return undefined;
|
|
1106
1179
|
}
|
|
1107
|
-
const blockNumber =
|
|
1180
|
+
const blockNumber = indexToBlockNumber.get(index);
|
|
1108
1181
|
if (blockNumber === undefined) {
|
|
1109
|
-
|
|
1182
|
+
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
1110
1183
|
}
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
return undefined;
|
|
1184
|
+
const l2BlockHash = blockNumberToHash.get(blockNumber);
|
|
1185
|
+
if (l2BlockHash === undefined) {
|
|
1186
|
+
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
1115
1187
|
}
|
|
1116
1188
|
return {
|
|
1117
|
-
l2BlockNumber:
|
|
1118
|
-
l2BlockHash
|
|
1189
|
+
l2BlockNumber: blockNumber,
|
|
1190
|
+
l2BlockHash,
|
|
1119
1191
|
data: index
|
|
1120
1192
|
};
|
|
1121
1193
|
});
|
|
1122
1194
|
}
|
|
1123
1195
|
async getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
1124
|
-
|
|
1196
|
+
// The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
|
|
1197
|
+
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
|
|
1198
|
+
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
|
|
1199
|
+
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
|
|
1200
|
+
if (referenceBlockNumber === BlockNumber.ZERO) {
|
|
1201
|
+
// Block 0 (the initial block) has an empty archive, so no membership witness can exist.
|
|
1202
|
+
return undefined;
|
|
1203
|
+
}
|
|
1204
|
+
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
|
|
1125
1205
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
|
|
1126
1206
|
blockHash
|
|
1127
1207
|
]);
|
|
1128
1208
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
1129
1209
|
}
|
|
1130
1210
|
async getNoteHashMembershipWitness(referenceBlock, noteHash) {
|
|
1131
|
-
const committedDb = await this
|
|
1211
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1132
1212
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
|
|
1133
1213
|
noteHash
|
|
1134
1214
|
]);
|
|
1135
1215
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
1136
1216
|
}
|
|
1137
1217
|
async getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message) {
|
|
1138
|
-
const db = await this
|
|
1218
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1139
1219
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
|
|
1140
1220
|
l1ToL2Message
|
|
1141
1221
|
]);
|
|
@@ -1148,9 +1228,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1148
1228
|
witness.path
|
|
1149
1229
|
];
|
|
1150
1230
|
}
|
|
1151
|
-
async
|
|
1231
|
+
async getL1ToL2MessageCheckpoint(l1ToL2Message) {
|
|
1152
1232
|
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
1153
|
-
return messageIndex ?
|
|
1233
|
+
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
1154
1234
|
}
|
|
1155
1235
|
/**
|
|
1156
1236
|
* Returns whether an L1 to L2 message is synced by archiver and if it's ready to be included in a block.
|
|
@@ -1167,23 +1247,11 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1167
1247
|
*/ async getL2ToL1Messages(epoch) {
|
|
1168
1248
|
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
1169
1249
|
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1170
|
-
const blocksInCheckpoints =
|
|
1171
|
-
let previousSlotNumber = SlotNumber.ZERO;
|
|
1172
|
-
let checkpointIndex = -1;
|
|
1173
|
-
for (const checkpointedBlock of checkpointedBlocks){
|
|
1174
|
-
const block = checkpointedBlock.block;
|
|
1175
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
1176
|
-
if (slotNumber !== previousSlotNumber) {
|
|
1177
|
-
checkpointIndex++;
|
|
1178
|
-
blocksInCheckpoints.push([]);
|
|
1179
|
-
previousSlotNumber = slotNumber;
|
|
1180
|
-
}
|
|
1181
|
-
blocksInCheckpoints[checkpointIndex].push(block);
|
|
1182
|
-
}
|
|
1250
|
+
const blocksInCheckpoints = chunkBy(checkpointedBlocks, (cb)=>cb.block.header.globalVariables.slotNumber).map((group)=>group.map((cb)=>cb.block));
|
|
1183
1251
|
return blocksInCheckpoints.map((blocks)=>blocks.map((block)=>block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs)));
|
|
1184
1252
|
}
|
|
1185
1253
|
async getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1186
|
-
const db = await this
|
|
1254
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1187
1255
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
|
|
1188
1256
|
nullifier.toBuffer()
|
|
1189
1257
|
]);
|
|
@@ -1197,36 +1265,22 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1197
1265
|
}
|
|
1198
1266
|
return new NullifierMembershipWitness(index, leafPreimage, path);
|
|
1199
1267
|
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
|
|
1203
|
-
* (which contains the root of the nullifier tree in which we are searching for the nullifier).
|
|
1204
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
1205
|
-
* @returns The low nullifier membership witness (if found).
|
|
1206
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
1207
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
1208
|
-
* we are trying to prove non-inclusion for.
|
|
1209
|
-
*
|
|
1210
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
1211
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
1212
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
1213
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
1214
|
-
*/ async getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1215
|
-
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1268
|
+
async getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1269
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1216
1270
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1217
1271
|
if (!findResult) {
|
|
1218
1272
|
return undefined;
|
|
1219
1273
|
}
|
|
1220
1274
|
const { index, alreadyPresent } = findResult;
|
|
1221
1275
|
if (alreadyPresent) {
|
|
1222
|
-
|
|
1276
|
+
throw new Error(`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`);
|
|
1223
1277
|
}
|
|
1224
1278
|
const preimageData = await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
1225
1279
|
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
1226
1280
|
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
1227
1281
|
}
|
|
1228
1282
|
async getPublicDataWitness(referenceBlock, leafSlot) {
|
|
1229
|
-
const committedDb = await this
|
|
1283
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1230
1284
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1231
1285
|
if (!lowLeafResult) {
|
|
1232
1286
|
return undefined;
|
|
@@ -1237,7 +1291,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1237
1291
|
}
|
|
1238
1292
|
}
|
|
1239
1293
|
async getPublicStorageAt(referenceBlock, contract, slot) {
|
|
1240
|
-
const committedDb = await this
|
|
1294
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1241
1295
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1242
1296
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1243
1297
|
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
@@ -1316,7 +1370,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1316
1370
|
});
|
|
1317
1371
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1318
1372
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1319
|
-
const [processedTxs, failedTxs, _usedTxs, returns,
|
|
1373
|
+
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([
|
|
1320
1374
|
tx
|
|
1321
1375
|
]);
|
|
1322
1376
|
// REFACTOR: Consider returning the error rather than throwing
|
|
@@ -1334,10 +1388,11 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1334
1388
|
}
|
|
1335
1389
|
async isValidTx(tx, { isSimulation, skipFeeEnforcement } = {}) {
|
|
1336
1390
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1337
|
-
const verifier = isSimulation ? undefined : this.
|
|
1391
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
1338
1392
|
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1339
1393
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1340
1394
|
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
1395
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
1341
1396
|
const validator = createTxValidatorForAcceptingTxsOverRPC(db, this.contractDataSource, verifier, {
|
|
1342
1397
|
timestamp: nextSlotTimestamp,
|
|
1343
1398
|
blockNumber,
|
|
@@ -1349,7 +1404,10 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1349
1404
|
],
|
|
1350
1405
|
gasFees: await this.getCurrentMinFees(),
|
|
1351
1406
|
skipFeeEnforcement,
|
|
1352
|
-
txsPermitted: !this.config.disableTransactions
|
|
1407
|
+
txsPermitted: !this.config.disableTransactions,
|
|
1408
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1409
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1410
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas
|
|
1353
1411
|
}, this.log.getBindings());
|
|
1354
1412
|
return await validator.validateTx(tx);
|
|
1355
1413
|
}
|
|
@@ -1372,7 +1430,18 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1372
1430
|
archiver.updateConfig(config);
|
|
1373
1431
|
}
|
|
1374
1432
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
1375
|
-
|
|
1433
|
+
await Promise.all([
|
|
1434
|
+
tryStop(this.peerProofVerifier),
|
|
1435
|
+
tryStop(this.rpcProofVerifier)
|
|
1436
|
+
]);
|
|
1437
|
+
if (newConfig.realProofs) {
|
|
1438
|
+
this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
|
|
1439
|
+
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
|
|
1440
|
+
this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
|
|
1441
|
+
} else {
|
|
1442
|
+
this.peerProofVerifier = new TestCircuitVerifier();
|
|
1443
|
+
this.rpcProofVerifier = new TestCircuitVerifier();
|
|
1444
|
+
}
|
|
1376
1445
|
}
|
|
1377
1446
|
this.config = newConfig;
|
|
1378
1447
|
}
|
|
@@ -1432,7 +1501,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1432
1501
|
});
|
|
1433
1502
|
return Promise.resolve();
|
|
1434
1503
|
}
|
|
1435
|
-
async rollbackTo(targetBlock, force) {
|
|
1504
|
+
async rollbackTo(targetBlock, force, resumeSync = true) {
|
|
1436
1505
|
const archiver = this.blockSource;
|
|
1437
1506
|
if (!('rollbackTo' in archiver)) {
|
|
1438
1507
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
@@ -1460,9 +1529,13 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1460
1529
|
this.log.error(`Error during rollback`, err);
|
|
1461
1530
|
throw err;
|
|
1462
1531
|
} finally{
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1532
|
+
if (resumeSync) {
|
|
1533
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
1534
|
+
this.worldStateSynchronizer.resumeSync();
|
|
1535
|
+
archiver.resume();
|
|
1536
|
+
} else {
|
|
1537
|
+
this.log.info(`Sync left paused after rollback (resumeSync=false).`);
|
|
1538
|
+
}
|
|
1466
1539
|
}
|
|
1467
1540
|
}
|
|
1468
1541
|
async pauseSync() {
|
|
@@ -1476,18 +1549,12 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1476
1549
|
this.blockSource.resume();
|
|
1477
1550
|
return Promise.resolve();
|
|
1478
1551
|
}
|
|
1479
|
-
getSlashPayloads() {
|
|
1480
|
-
if (!this.slasherClient) {
|
|
1481
|
-
throw new Error(`Slasher client not enabled`);
|
|
1482
|
-
}
|
|
1483
|
-
return this.slasherClient.getSlashPayloads();
|
|
1484
|
-
}
|
|
1485
1552
|
getSlashOffenses(round) {
|
|
1486
1553
|
if (!this.slasherClient) {
|
|
1487
1554
|
throw new Error(`Slasher client not enabled`);
|
|
1488
1555
|
}
|
|
1489
1556
|
if (round === 'all') {
|
|
1490
|
-
return this.slasherClient.
|
|
1557
|
+
return this.slasherClient.getOffenses();
|
|
1491
1558
|
} else {
|
|
1492
1559
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1493
1560
|
}
|
|
@@ -1559,6 +1626,33 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1559
1626
|
this.keyStoreManager = newManager;
|
|
1560
1627
|
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1561
1628
|
}
|
|
1629
|
+
async mineBlock() {
|
|
1630
|
+
if (!this.sequencer) {
|
|
1631
|
+
throw new BadRequestError('Cannot mine block: no sequencer is running');
|
|
1632
|
+
}
|
|
1633
|
+
const currentBlockNumber = await this.getBlockNumber();
|
|
1634
|
+
// Use slot duration + 50% buffer as the timeout so this works on running networks too
|
|
1635
|
+
const { slotDuration } = await this.blockSource.getL1Constants();
|
|
1636
|
+
const timeoutSeconds = Math.ceil(slotDuration * 1.5);
|
|
1637
|
+
// Temporarily set minTxsPerBlock to 0 so the sequencer produces a block even with no txs
|
|
1638
|
+
const originalMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock;
|
|
1639
|
+
this.sequencer.updateConfig({
|
|
1640
|
+
minTxsPerBlock: 0
|
|
1641
|
+
});
|
|
1642
|
+
try {
|
|
1643
|
+
// Trigger the sequencer to produce a block immediately
|
|
1644
|
+
void this.sequencer.trigger();
|
|
1645
|
+
// Wait for the new L2 block to appear
|
|
1646
|
+
await retryUntil(async ()=>{
|
|
1647
|
+
const newBlockNumber = await this.getBlockNumber();
|
|
1648
|
+
return newBlockNumber > currentBlockNumber ? true : undefined;
|
|
1649
|
+
}, 'mineBlock', timeoutSeconds, 0.1);
|
|
1650
|
+
} finally{
|
|
1651
|
+
this.sequencer.updateConfig({
|
|
1652
|
+
minTxsPerBlock: originalMinTxsPerBlock
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1562
1656
|
#getInitialHeaderHash() {
|
|
1563
1657
|
if (!this.initialHeaderHashPromise) {
|
|
1564
1658
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
@@ -1569,7 +1663,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1569
1663
|
* Returns an instance of MerkleTreeOperations having first ensured the world state is fully synched
|
|
1570
1664
|
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1571
1665
|
* @returns An instance of a committed MerkleTreeOperations
|
|
1572
|
-
*/ async
|
|
1666
|
+
*/ async getWorldState(block) {
|
|
1573
1667
|
let blockSyncedTo = BlockNumber.ZERO;
|
|
1574
1668
|
try {
|
|
1575
1669
|
// Attempt to sync the world state if necessary
|
|
@@ -1581,6 +1675,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1581
1675
|
this.log.debug(`Using committed db for block 'latest', world state synced upto ${blockSyncedTo}`);
|
|
1582
1676
|
return this.worldStateSynchronizer.getCommitted();
|
|
1583
1677
|
}
|
|
1678
|
+
// Get the block number, either directly from the parameter or by quering the archiver with the block hash
|
|
1679
|
+
let blockNumber;
|
|
1584
1680
|
if (BlockHash.isBlockHash(block)) {
|
|
1585
1681
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1586
1682
|
if (block.equals(initialBlockHash)) {
|
|
@@ -1591,19 +1687,41 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1591
1687
|
if (!header) {
|
|
1592
1688
|
throw new Error(`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.`);
|
|
1593
1689
|
}
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
}
|
|
1598
|
-
//
|
|
1599
|
-
{
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1690
|
+
blockNumber = header.getBlockNumber();
|
|
1691
|
+
} else {
|
|
1692
|
+
blockNumber = block;
|
|
1693
|
+
}
|
|
1694
|
+
// Check it's within world state sync range
|
|
1695
|
+
if (blockNumber > blockSyncedTo) {
|
|
1696
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1697
|
+
}
|
|
1698
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1699
|
+
const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1700
|
+
// Double-check world-state synced to the same block hash as was requested
|
|
1701
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1702
|
+
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1703
|
+
if (!blockHash || !block.equals(blockHash)) {
|
|
1704
|
+
throw new Error(`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.`);
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
return snapshot;
|
|
1708
|
+
}
|
|
1709
|
+
/** Resolves a block parameter to a block number. */ async resolveBlockNumber(block) {
|
|
1710
|
+
if (block === 'latest') {
|
|
1711
|
+
return BlockNumber(await this.blockSource.getBlockNumber());
|
|
1712
|
+
}
|
|
1713
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1714
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1715
|
+
if (block.equals(initialBlockHash)) {
|
|
1716
|
+
return BlockNumber.ZERO;
|
|
1717
|
+
}
|
|
1718
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1719
|
+
if (!header) {
|
|
1720
|
+
throw new Error(`Block hash ${block.toString()} not found.`);
|
|
1603
1721
|
}
|
|
1604
|
-
|
|
1605
|
-
return this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1722
|
+
return header.getBlockNumber();
|
|
1606
1723
|
}
|
|
1724
|
+
return block;
|
|
1607
1725
|
}
|
|
1608
1726
|
/**
|
|
1609
1727
|
* Ensure we fully sync the world state
|