@aztec/aztec-node 0.0.1-commit.27d773e65 → 0.0.1-commit.2b2662070
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/aztec-node/config.d.ts +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 +271 -149
- 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 +295 -158
- 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,22 +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,
|
|
615
|
-
// We should really not be modifying the config object
|
|
616
|
-
config.txPublicSetupAllowList = config.txPublicSetupAllowList ?? await getDefaultAllowedSetupFunctions();
|
|
633
|
+
const p2pClient = await createP2PClient(config, archiver, peerProofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
|
|
617
634
|
// We'll accumulate sentinel watchers here
|
|
618
635
|
const watchers = [];
|
|
619
|
-
// 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.
|
|
620
638
|
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder({
|
|
621
639
|
...config,
|
|
622
640
|
l1GenesisTime,
|
|
623
|
-
slotDuration: Number(slotDuration)
|
|
641
|
+
slotDuration: Number(slotDuration),
|
|
642
|
+
rollupManaLimit,
|
|
643
|
+
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint
|
|
624
644
|
}, worldStateSynchronizer, archiver, dateProvider, telemetry);
|
|
625
645
|
let validatorClient;
|
|
626
646
|
if (!proverOnly) {
|
|
@@ -635,32 +655,40 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
635
655
|
blockSource: archiver,
|
|
636
656
|
l1ToL2MessageSource: archiver,
|
|
637
657
|
keyStoreManager,
|
|
638
|
-
blobClient
|
|
658
|
+
blobClient,
|
|
659
|
+
slashingProtectionDb: deps.slashingProtectionDb
|
|
639
660
|
});
|
|
640
661
|
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
641
662
|
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
642
663
|
// like attestations or auths will fail.
|
|
643
664
|
if (validatorClient) {
|
|
644
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);
|
|
645
669
|
if (!options.dontStartSequencer) {
|
|
646
670
|
await validatorClient.registerHandlers();
|
|
647
671
|
}
|
|
648
672
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
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);
|
|
664
692
|
}
|
|
665
693
|
// Start world state and wait for it to sync to the archiver.
|
|
666
694
|
await worldStateSynchronizer.start();
|
|
@@ -686,12 +714,20 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
686
714
|
}
|
|
687
715
|
// Start p2p-related services once the archiver has completed sync
|
|
688
716
|
void archiver.waitForInitialSync().then(async ()=>{
|
|
689
|
-
await p2pClient.start();
|
|
690
717
|
await validatorsSentinel?.start();
|
|
691
718
|
await epochPruneWatcher?.start();
|
|
692
719
|
await attestationsBlockWatcher?.start();
|
|
693
720
|
log.info(`All p2p services started`);
|
|
694
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);
|
|
695
731
|
// Validator enabled, create/start relevant service
|
|
696
732
|
let sequencer;
|
|
697
733
|
let slasherClient;
|
|
@@ -718,16 +754,34 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
718
754
|
dateProvider,
|
|
719
755
|
kzg: Blob.getViemKzgInstance()
|
|
720
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
|
+
}
|
|
721
773
|
// Create and start the sequencer client
|
|
722
774
|
const checkpointsBuilder = new CheckpointsBuilder({
|
|
723
775
|
...config,
|
|
724
776
|
l1GenesisTime,
|
|
725
|
-
slotDuration: Number(slotDuration)
|
|
777
|
+
slotDuration: Number(slotDuration),
|
|
778
|
+
rollupManaLimit
|
|
726
779
|
}, worldStateSynchronizer, archiver, dateProvider, telemetry, debugLogStore);
|
|
727
780
|
sequencer = await SequencerClient.new(config, {
|
|
728
781
|
...deps,
|
|
729
782
|
epochCache,
|
|
730
783
|
l1TxUtils,
|
|
784
|
+
funderL1TxUtils,
|
|
731
785
|
validatorClient,
|
|
732
786
|
p2pClient,
|
|
733
787
|
worldStateSynchronizer,
|
|
@@ -738,7 +792,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
738
792
|
telemetry,
|
|
739
793
|
dateProvider,
|
|
740
794
|
blobClient,
|
|
741
|
-
nodeKeyStore: keyStoreManager
|
|
795
|
+
nodeKeyStore: keyStoreManager,
|
|
796
|
+
globalVariableBuilder
|
|
742
797
|
});
|
|
743
798
|
}
|
|
744
799
|
if (!options.dontStartSequencer && sequencer) {
|
|
@@ -768,13 +823,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
768
823
|
log.info(`Prover node subsystem created but not started`);
|
|
769
824
|
}
|
|
770
825
|
}
|
|
771
|
-
const
|
|
772
|
-
...config,
|
|
773
|
-
rollupVersion: BigInt(config.rollupVersion),
|
|
774
|
-
l1GenesisTime,
|
|
775
|
-
slotDuration: Number(slotDuration)
|
|
776
|
-
});
|
|
777
|
-
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);
|
|
778
827
|
return node;
|
|
779
828
|
}
|
|
780
829
|
/**
|
|
@@ -805,7 +854,10 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
805
854
|
return Promise.resolve(this.p2pClient.getEnr()?.encodeTxt());
|
|
806
855
|
}
|
|
807
856
|
async getAllowedPublicSetup() {
|
|
808
|
-
return
|
|
857
|
+
return [
|
|
858
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
859
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
860
|
+
];
|
|
809
861
|
}
|
|
810
862
|
/**
|
|
811
863
|
* Method to determine if the node is ready to accept transactions.
|
|
@@ -883,11 +935,14 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
883
935
|
async getCheckpointedBlocks(from, limit) {
|
|
884
936
|
return await this.blockSource.getCheckpointedBlocks(from, limit) ?? [];
|
|
885
937
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
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);
|
|
891
946
|
}
|
|
892
947
|
async getMaxPriorityFees() {
|
|
893
948
|
for await (const tx of this.p2pClient.iteratePendingTxs()){
|
|
@@ -910,6 +965,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
910
965
|
async getCheckpointedBlockNumber() {
|
|
911
966
|
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
912
967
|
}
|
|
968
|
+
getCheckpointNumber() {
|
|
969
|
+
return this.blockSource.getCheckpointNumber();
|
|
970
|
+
}
|
|
913
971
|
/**
|
|
914
972
|
* Method to fetch the version of the package.
|
|
915
973
|
* @returns The node package version
|
|
@@ -935,28 +993,36 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
935
993
|
return this.contractDataSource.getContract(address);
|
|
936
994
|
}
|
|
937
995
|
async getPrivateLogsByTags(tags, page, referenceBlock) {
|
|
996
|
+
let upToBlockNumber;
|
|
938
997
|
if (referenceBlock) {
|
|
939
998
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
940
|
-
if (
|
|
999
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
1000
|
+
upToBlockNumber = BlockNumber(0);
|
|
1001
|
+
} else {
|
|
941
1002
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
942
1003
|
if (!header) {
|
|
943
1004
|
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
944
1005
|
}
|
|
1006
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
945
1007
|
}
|
|
946
1008
|
}
|
|
947
|
-
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
1009
|
+
return this.logsSource.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
948
1010
|
}
|
|
949
1011
|
async getPublicLogsByTagsFromContract(contractAddress, tags, page, referenceBlock) {
|
|
1012
|
+
let upToBlockNumber;
|
|
950
1013
|
if (referenceBlock) {
|
|
951
1014
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
952
|
-
if (
|
|
1015
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
1016
|
+
upToBlockNumber = BlockNumber(0);
|
|
1017
|
+
} else {
|
|
953
1018
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
954
1019
|
if (!header) {
|
|
955
1020
|
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
956
1021
|
}
|
|
1022
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
957
1023
|
}
|
|
958
1024
|
}
|
|
959
|
-
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
|
|
1025
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
960
1026
|
}
|
|
961
1027
|
/**
|
|
962
1028
|
* Gets public logs based on the provided filter.
|
|
@@ -1029,7 +1095,10 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1029
1095
|
await tryStop(this.validatorsSentinel);
|
|
1030
1096
|
await tryStop(this.epochPruneWatcher);
|
|
1031
1097
|
await tryStop(this.slasherClient);
|
|
1032
|
-
await
|
|
1098
|
+
await Promise.all([
|
|
1099
|
+
tryStop(this.peerProofVerifier),
|
|
1100
|
+
tryStop(this.rpcProofVerifier)
|
|
1101
|
+
]);
|
|
1033
1102
|
await tryStop(this.sequencer);
|
|
1034
1103
|
await tryStop(this.proverNode);
|
|
1035
1104
|
await tryStop(this.p2pClient);
|
|
@@ -1071,70 +1140,82 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1071
1140
|
return compactArray(await Promise.all(txHashes.map((txHash)=>this.getTxByHash(txHash))));
|
|
1072
1141
|
}
|
|
1073
1142
|
async findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
1074
|
-
const committedDb = await this
|
|
1143
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1075
1144
|
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
1076
|
-
//
|
|
1077
|
-
const
|
|
1078
|
-
// Now we find the block numbers for the indices
|
|
1079
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId,
|
|
1080
|
-
//
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
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]}`);
|
|
1084
1155
|
}
|
|
1156
|
+
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
1085
1157
|
}
|
|
1086
1158
|
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
1087
1159
|
const uniqueBlockNumbers = [
|
|
1088
|
-
...new Set(
|
|
1160
|
+
...new Set(indexToBlockNumber.values())
|
|
1089
1161
|
];
|
|
1090
|
-
// Now we obtain the block hashes from the archive tree
|
|
1091
|
-
// (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).
|
|
1092
1163
|
const blockHashes = await Promise.all(uniqueBlockNumbers.map((blockNumber)=>{
|
|
1093
1164
|
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1094
1165
|
}));
|
|
1095
|
-
//
|
|
1166
|
+
// Build a map from block number to block hash
|
|
1167
|
+
const blockNumberToHash = new Map();
|
|
1096
1168
|
for(let i = 0; i < uniqueBlockNumbers.length; i++){
|
|
1097
|
-
|
|
1169
|
+
const blockHash = blockHashes[i];
|
|
1170
|
+
if (blockHash === undefined) {
|
|
1098
1171
|
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
1099
1172
|
}
|
|
1173
|
+
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
1100
1174
|
}
|
|
1101
1175
|
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
1102
|
-
return maybeIndices.map((index
|
|
1176
|
+
return maybeIndices.map((index)=>{
|
|
1103
1177
|
if (index === undefined) {
|
|
1104
1178
|
return undefined;
|
|
1105
1179
|
}
|
|
1106
|
-
const blockNumber =
|
|
1180
|
+
const blockNumber = indexToBlockNumber.get(index);
|
|
1107
1181
|
if (blockNumber === undefined) {
|
|
1108
|
-
|
|
1182
|
+
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
1109
1183
|
}
|
|
1110
|
-
const
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
return undefined;
|
|
1184
|
+
const l2BlockHash = blockNumberToHash.get(blockNumber);
|
|
1185
|
+
if (l2BlockHash === undefined) {
|
|
1186
|
+
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
1114
1187
|
}
|
|
1115
1188
|
return {
|
|
1116
|
-
l2BlockNumber:
|
|
1117
|
-
l2BlockHash
|
|
1189
|
+
l2BlockNumber: blockNumber,
|
|
1190
|
+
l2BlockHash,
|
|
1118
1191
|
data: index
|
|
1119
1192
|
};
|
|
1120
1193
|
});
|
|
1121
1194
|
}
|
|
1122
1195
|
async getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
1123
|
-
|
|
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));
|
|
1124
1205
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
|
|
1125
1206
|
blockHash
|
|
1126
1207
|
]);
|
|
1127
1208
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
1128
1209
|
}
|
|
1129
1210
|
async getNoteHashMembershipWitness(referenceBlock, noteHash) {
|
|
1130
|
-
const committedDb = await this
|
|
1211
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1131
1212
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
|
|
1132
1213
|
noteHash
|
|
1133
1214
|
]);
|
|
1134
1215
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
1135
1216
|
}
|
|
1136
1217
|
async getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message) {
|
|
1137
|
-
const db = await this
|
|
1218
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1138
1219
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
|
|
1139
1220
|
l1ToL2Message
|
|
1140
1221
|
]);
|
|
@@ -1147,9 +1228,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1147
1228
|
witness.path
|
|
1148
1229
|
];
|
|
1149
1230
|
}
|
|
1150
|
-
async
|
|
1231
|
+
async getL1ToL2MessageCheckpoint(l1ToL2Message) {
|
|
1151
1232
|
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
1152
|
-
return messageIndex ?
|
|
1233
|
+
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
1153
1234
|
}
|
|
1154
1235
|
/**
|
|
1155
1236
|
* Returns whether an L1 to L2 message is synced by archiver and if it's ready to be included in a block.
|
|
@@ -1166,23 +1247,11 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1166
1247
|
*/ async getL2ToL1Messages(epoch) {
|
|
1167
1248
|
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
1168
1249
|
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1169
|
-
const blocksInCheckpoints =
|
|
1170
|
-
let previousSlotNumber = SlotNumber.ZERO;
|
|
1171
|
-
let checkpointIndex = -1;
|
|
1172
|
-
for (const checkpointedBlock of checkpointedBlocks){
|
|
1173
|
-
const block = checkpointedBlock.block;
|
|
1174
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
1175
|
-
if (slotNumber !== previousSlotNumber) {
|
|
1176
|
-
checkpointIndex++;
|
|
1177
|
-
blocksInCheckpoints.push([]);
|
|
1178
|
-
previousSlotNumber = slotNumber;
|
|
1179
|
-
}
|
|
1180
|
-
blocksInCheckpoints[checkpointIndex].push(block);
|
|
1181
|
-
}
|
|
1250
|
+
const blocksInCheckpoints = chunkBy(checkpointedBlocks, (cb)=>cb.block.header.globalVariables.slotNumber).map((group)=>group.map((cb)=>cb.block));
|
|
1182
1251
|
return blocksInCheckpoints.map((blocks)=>blocks.map((block)=>block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs)));
|
|
1183
1252
|
}
|
|
1184
1253
|
async getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1185
|
-
const db = await this
|
|
1254
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1186
1255
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
|
|
1187
1256
|
nullifier.toBuffer()
|
|
1188
1257
|
]);
|
|
@@ -1196,36 +1265,22 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1196
1265
|
}
|
|
1197
1266
|
return new NullifierMembershipWitness(index, leafPreimage, path);
|
|
1198
1267
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
|
|
1202
|
-
* (which contains the root of the nullifier tree in which we are searching for the nullifier).
|
|
1203
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
1204
|
-
* @returns The low nullifier membership witness (if found).
|
|
1205
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
1206
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
1207
|
-
* we are trying to prove non-inclusion for.
|
|
1208
|
-
*
|
|
1209
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
1210
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
1211
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
1212
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
1213
|
-
*/ async getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1214
|
-
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1268
|
+
async getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1269
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1215
1270
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1216
1271
|
if (!findResult) {
|
|
1217
1272
|
return undefined;
|
|
1218
1273
|
}
|
|
1219
1274
|
const { index, alreadyPresent } = findResult;
|
|
1220
1275
|
if (alreadyPresent) {
|
|
1221
|
-
|
|
1276
|
+
throw new Error(`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`);
|
|
1222
1277
|
}
|
|
1223
1278
|
const preimageData = await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
1224
1279
|
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
1225
1280
|
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
1226
1281
|
}
|
|
1227
1282
|
async getPublicDataWitness(referenceBlock, leafSlot) {
|
|
1228
|
-
const committedDb = await this
|
|
1283
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1229
1284
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1230
1285
|
if (!lowLeafResult) {
|
|
1231
1286
|
return undefined;
|
|
@@ -1236,7 +1291,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1236
1291
|
}
|
|
1237
1292
|
}
|
|
1238
1293
|
async getPublicStorageAt(referenceBlock, contract, slot) {
|
|
1239
|
-
const committedDb = await this
|
|
1294
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1240
1295
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1241
1296
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1242
1297
|
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
@@ -1315,7 +1370,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1315
1370
|
});
|
|
1316
1371
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1317
1372
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1318
|
-
const [processedTxs, failedTxs, _usedTxs, returns,
|
|
1373
|
+
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([
|
|
1319
1374
|
tx
|
|
1320
1375
|
]);
|
|
1321
1376
|
// REFACTOR: Consider returning the error rather than throwing
|
|
@@ -1333,19 +1388,26 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1333
1388
|
}
|
|
1334
1389
|
async isValidTx(tx, { isSimulation, skipFeeEnforcement } = {}) {
|
|
1335
1390
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1336
|
-
const verifier = isSimulation ? undefined : this.
|
|
1391
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
1337
1392
|
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1338
1393
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1339
1394
|
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
1395
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
1340
1396
|
const validator = createTxValidatorForAcceptingTxsOverRPC(db, this.contractDataSource, verifier, {
|
|
1341
1397
|
timestamp: nextSlotTimestamp,
|
|
1342
1398
|
blockNumber,
|
|
1343
1399
|
l1ChainId: this.l1ChainId,
|
|
1344
1400
|
rollupVersion: this.version,
|
|
1345
|
-
setupAllowList:
|
|
1401
|
+
setupAllowList: [
|
|
1402
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
1403
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
1404
|
+
],
|
|
1346
1405
|
gasFees: await this.getCurrentMinFees(),
|
|
1347
1406
|
skipFeeEnforcement,
|
|
1348
|
-
txsPermitted: !this.config.disableTransactions
|
|
1407
|
+
txsPermitted: !this.config.disableTransactions,
|
|
1408
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1409
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1410
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas
|
|
1349
1411
|
}, this.log.getBindings());
|
|
1350
1412
|
return await validator.validateTx(tx);
|
|
1351
1413
|
}
|
|
@@ -1368,7 +1430,18 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1368
1430
|
archiver.updateConfig(config);
|
|
1369
1431
|
}
|
|
1370
1432
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
1371
|
-
|
|
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
|
+
}
|
|
1372
1445
|
}
|
|
1373
1446
|
this.config = newConfig;
|
|
1374
1447
|
}
|
|
@@ -1428,7 +1501,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1428
1501
|
});
|
|
1429
1502
|
return Promise.resolve();
|
|
1430
1503
|
}
|
|
1431
|
-
async rollbackTo(targetBlock, force) {
|
|
1504
|
+
async rollbackTo(targetBlock, force, resumeSync = true) {
|
|
1432
1505
|
const archiver = this.blockSource;
|
|
1433
1506
|
if (!('rollbackTo' in archiver)) {
|
|
1434
1507
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
@@ -1456,9 +1529,13 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1456
1529
|
this.log.error(`Error during rollback`, err);
|
|
1457
1530
|
throw err;
|
|
1458
1531
|
} finally{
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
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
|
+
}
|
|
1462
1539
|
}
|
|
1463
1540
|
}
|
|
1464
1541
|
async pauseSync() {
|
|
@@ -1472,18 +1549,12 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1472
1549
|
this.blockSource.resume();
|
|
1473
1550
|
return Promise.resolve();
|
|
1474
1551
|
}
|
|
1475
|
-
getSlashPayloads() {
|
|
1476
|
-
if (!this.slasherClient) {
|
|
1477
|
-
throw new Error(`Slasher client not enabled`);
|
|
1478
|
-
}
|
|
1479
|
-
return this.slasherClient.getSlashPayloads();
|
|
1480
|
-
}
|
|
1481
1552
|
getSlashOffenses(round) {
|
|
1482
1553
|
if (!this.slasherClient) {
|
|
1483
1554
|
throw new Error(`Slasher client not enabled`);
|
|
1484
1555
|
}
|
|
1485
1556
|
if (round === 'all') {
|
|
1486
|
-
return this.slasherClient.
|
|
1557
|
+
return this.slasherClient.getOffenses();
|
|
1487
1558
|
} else {
|
|
1488
1559
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1489
1560
|
}
|
|
@@ -1555,6 +1626,33 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1555
1626
|
this.keyStoreManager = newManager;
|
|
1556
1627
|
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1557
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
|
+
}
|
|
1558
1656
|
#getInitialHeaderHash() {
|
|
1559
1657
|
if (!this.initialHeaderHashPromise) {
|
|
1560
1658
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
@@ -1565,7 +1663,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1565
1663
|
* Returns an instance of MerkleTreeOperations having first ensured the world state is fully synched
|
|
1566
1664
|
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1567
1665
|
* @returns An instance of a committed MerkleTreeOperations
|
|
1568
|
-
*/ async
|
|
1666
|
+
*/ async getWorldState(block) {
|
|
1569
1667
|
let blockSyncedTo = BlockNumber.ZERO;
|
|
1570
1668
|
try {
|
|
1571
1669
|
// Attempt to sync the world state if necessary
|
|
@@ -1577,6 +1675,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1577
1675
|
this.log.debug(`Using committed db for block 'latest', world state synced upto ${blockSyncedTo}`);
|
|
1578
1676
|
return this.worldStateSynchronizer.getCommitted();
|
|
1579
1677
|
}
|
|
1678
|
+
// Get the block number, either directly from the parameter or by quering the archiver with the block hash
|
|
1679
|
+
let blockNumber;
|
|
1580
1680
|
if (BlockHash.isBlockHash(block)) {
|
|
1581
1681
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1582
1682
|
if (block.equals(initialBlockHash)) {
|
|
@@ -1587,19 +1687,41 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1587
1687
|
if (!header) {
|
|
1588
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.`);
|
|
1589
1689
|
}
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
}
|
|
1594
|
-
//
|
|
1595
|
-
{
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
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.`);
|
|
1599
1721
|
}
|
|
1600
|
-
|
|
1601
|
-
return this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1722
|
+
return header.getBlockNumber();
|
|
1602
1723
|
}
|
|
1724
|
+
return block;
|
|
1603
1725
|
}
|
|
1604
1726
|
/**
|
|
1605
1727
|
* Ensure we fully sync the world state
|