@aztec/aztec-node 0.0.1-commit.343b43af6 → 0.0.1-commit.35158ae7e
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/server.d.ts +17 -18
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +145 -79
- package/dest/sentinel/sentinel.js +5 -5
- package/package.json +26 -27
- package/src/aztec-node/server.ts +144 -76
- package/src/sentinel/sentinel.ts +5 -5
|
@@ -372,15 +372,16 @@ 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';
|
|
@@ -413,7 +414,7 @@ import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
|
413
414
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
414
415
|
import { FullNodeCheckpointsBuilder as CheckpointsBuilder, FullNodeCheckpointsBuilder, NodeKeystoreAdapter, ValidatorClient, createBlockProposalHandler, createValidatorClient } from '@aztec/validator-client';
|
|
415
416
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
416
|
-
import { createPublicClient
|
|
417
|
+
import { createPublicClient } from 'viem';
|
|
417
418
|
import { createSentinel } from '../sentinel/factory.js';
|
|
418
419
|
import { createKeyStoreForValidator } from './config.js';
|
|
419
420
|
import { NodeMetrics } from './node_metrics.js';
|
|
@@ -440,7 +441,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
440
441
|
globalVariableBuilder;
|
|
441
442
|
epochCache;
|
|
442
443
|
packageVersion;
|
|
443
|
-
|
|
444
|
+
peerProofVerifier;
|
|
445
|
+
rpcProofVerifier;
|
|
444
446
|
telemetry;
|
|
445
447
|
log;
|
|
446
448
|
blobClient;
|
|
@@ -461,7 +463,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
461
463
|
// Prevent two snapshot operations to happen simultaneously
|
|
462
464
|
isUploadingSnapshot;
|
|
463
465
|
tracer;
|
|
464
|
-
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, l1ChainId, version, globalVariableBuilder, epochCache, packageVersion,
|
|
466
|
+
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, l1ChainId, version, globalVariableBuilder, epochCache, packageVersion, peerProofVerifier, rpcProofVerifier, telemetry = getTelemetryClient(), log = createLogger('node'), blobClient, validatorClient, keyStoreManager, debugLogStore = new NullDebugLogStore()){
|
|
465
467
|
this.config = config;
|
|
466
468
|
this.p2pClient = p2pClient;
|
|
467
469
|
this.blockSource = blockSource;
|
|
@@ -479,7 +481,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
479
481
|
this.globalVariableBuilder = globalVariableBuilder;
|
|
480
482
|
this.epochCache = epochCache;
|
|
481
483
|
this.packageVersion = packageVersion;
|
|
482
|
-
this.
|
|
484
|
+
this.peerProofVerifier = peerProofVerifier;
|
|
485
|
+
this.rpcProofVerifier = rpcProofVerifier;
|
|
483
486
|
this.telemetry = telemetry;
|
|
484
487
|
this.log = log;
|
|
485
488
|
this.blobClient = blobClient;
|
|
@@ -499,6 +502,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
499
502
|
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
500
503
|
}
|
|
501
504
|
}
|
|
505
|
+
/** @internal Exposed for testing — returns the RPC proof verifier. */ getProofVerifier() {
|
|
506
|
+
return this.rpcProofVerifier;
|
|
507
|
+
}
|
|
502
508
|
async getWorldStateSyncStatus() {
|
|
503
509
|
const status = await this.worldStateSynchronizer.status();
|
|
504
510
|
return status.syncSummary;
|
|
@@ -559,9 +565,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
559
565
|
}
|
|
560
566
|
const publicClient = createPublicClient({
|
|
561
567
|
chain: ethereumChain.chainInfo,
|
|
562
|
-
transport:
|
|
563
|
-
|
|
564
|
-
|
|
568
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, {
|
|
569
|
+
timeout: config.l1HttpTimeoutMS
|
|
570
|
+
}),
|
|
565
571
|
pollingInterval: config.viemPollingIntervalMS
|
|
566
572
|
});
|
|
567
573
|
const l1ContractsAddresses = await RegistryContract.collectAddresses(publicClient, config.l1Contracts.registryAddress, config.rollupVersion ?? 'canonical');
|
|
@@ -597,7 +603,17 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
597
603
|
});
|
|
598
604
|
// now create the merkle trees and the world state synchronizer
|
|
599
605
|
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.prefilledPublicData, telemetry);
|
|
600
|
-
const
|
|
606
|
+
const useRealVerifiers = config.realProofs || config.debugForceTxProofVerification;
|
|
607
|
+
let peerProofVerifier;
|
|
608
|
+
let rpcProofVerifier;
|
|
609
|
+
if (useRealVerifiers) {
|
|
610
|
+
peerProofVerifier = await BatchChonkVerifier.new(config, config.bbChonkVerifyMaxBatch, 'peer');
|
|
611
|
+
const rpcVerifier = await BBCircuitVerifier.new(config);
|
|
612
|
+
rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, config.numConcurrentIVCVerifiers);
|
|
613
|
+
} else {
|
|
614
|
+
peerProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
615
|
+
rpcProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
616
|
+
}
|
|
601
617
|
let debugLogStore;
|
|
602
618
|
if (!config.realProofs) {
|
|
603
619
|
log.warn(`Aztec node is accepting fake proofs`);
|
|
@@ -606,13 +622,12 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
606
622
|
} else {
|
|
607
623
|
debugLogStore = new NullDebugLogStore();
|
|
608
624
|
}
|
|
609
|
-
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
610
625
|
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
611
626
|
if (proverOnly) {
|
|
612
627
|
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
613
628
|
}
|
|
614
629
|
// create the tx pool and the p2p client, which will need the l2 block source
|
|
615
|
-
const p2pClient = await createP2PClient(config, archiver,
|
|
630
|
+
const p2pClient = await createP2PClient(config, archiver, peerProofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
|
|
616
631
|
// We'll accumulate sentinel watchers here
|
|
617
632
|
const watchers = [];
|
|
618
633
|
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
@@ -637,7 +652,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
637
652
|
blockSource: archiver,
|
|
638
653
|
l1ToL2MessageSource: archiver,
|
|
639
654
|
keyStoreManager,
|
|
640
|
-
blobClient
|
|
655
|
+
blobClient,
|
|
656
|
+
slashingProtectionDb: deps.slashingProtectionDb
|
|
641
657
|
});
|
|
642
658
|
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
643
659
|
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
@@ -696,6 +712,13 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
696
712
|
await attestationsBlockWatcher?.start();
|
|
697
713
|
log.info(`All p2p services started`);
|
|
698
714
|
}).catch((err)=>log.error('Failed to start p2p services after archiver sync', err));
|
|
715
|
+
const globalVariableBuilder = new GlobalVariableBuilder(dateProvider, publicClient, {
|
|
716
|
+
l1Contracts: config.l1Contracts,
|
|
717
|
+
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
718
|
+
rollupVersion: BigInt(config.rollupVersion),
|
|
719
|
+
l1GenesisTime,
|
|
720
|
+
slotDuration: Number(slotDuration)
|
|
721
|
+
});
|
|
699
722
|
// Validator enabled, create/start relevant service
|
|
700
723
|
let sequencer;
|
|
701
724
|
let slasherClient;
|
|
@@ -722,6 +745,22 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
722
745
|
dateProvider,
|
|
723
746
|
kzg: Blob.getViemKzgInstance()
|
|
724
747
|
});
|
|
748
|
+
// Create a funder L1TxUtils from the keystore funding account (if configured)
|
|
749
|
+
const fundingSigner = keyStoreManager?.createFundingSigner();
|
|
750
|
+
let funderL1TxUtils;
|
|
751
|
+
if (fundingSigner) {
|
|
752
|
+
const [funder] = await createL1TxUtilsFromSigners(publicClient, [
|
|
753
|
+
fundingSigner
|
|
754
|
+
], {
|
|
755
|
+
...config,
|
|
756
|
+
scope: 'sequencer'
|
|
757
|
+
}, {
|
|
758
|
+
telemetry,
|
|
759
|
+
logger: log.createChild('l1-tx-utils:funder'),
|
|
760
|
+
dateProvider
|
|
761
|
+
});
|
|
762
|
+
funderL1TxUtils = funder;
|
|
763
|
+
}
|
|
725
764
|
// Create and start the sequencer client
|
|
726
765
|
const checkpointsBuilder = new CheckpointsBuilder({
|
|
727
766
|
...config,
|
|
@@ -733,6 +772,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
733
772
|
...deps,
|
|
734
773
|
epochCache,
|
|
735
774
|
l1TxUtils,
|
|
775
|
+
funderL1TxUtils,
|
|
736
776
|
validatorClient,
|
|
737
777
|
p2pClient,
|
|
738
778
|
worldStateSynchronizer,
|
|
@@ -743,7 +783,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
743
783
|
telemetry,
|
|
744
784
|
dateProvider,
|
|
745
785
|
blobClient,
|
|
746
|
-
nodeKeyStore: keyStoreManager
|
|
786
|
+
nodeKeyStore: keyStoreManager,
|
|
787
|
+
globalVariableBuilder
|
|
747
788
|
});
|
|
748
789
|
}
|
|
749
790
|
if (!options.dontStartSequencer && sequencer) {
|
|
@@ -773,13 +814,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
773
814
|
log.info(`Prover node subsystem created but not started`);
|
|
774
815
|
}
|
|
775
816
|
}
|
|
776
|
-
const
|
|
777
|
-
...config,
|
|
778
|
-
rollupVersion: BigInt(config.rollupVersion),
|
|
779
|
-
l1GenesisTime,
|
|
780
|
-
slotDuration: Number(slotDuration)
|
|
781
|
-
});
|
|
782
|
-
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);
|
|
817
|
+
const node = new AztecNodeService(config, p2pClient, archiver, archiver, archiver, archiver, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, ethereumChain.chainInfo.id, config.rollupVersion, globalVariableBuilder, epochCache, packageVersion, peerProofVerifier, rpcProofVerifier, telemetry, log, blobClient, validatorClient, keyStoreManager, debugLogStore);
|
|
783
818
|
return node;
|
|
784
819
|
}
|
|
785
820
|
/**
|
|
@@ -891,6 +926,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
891
926
|
async getCheckpointedBlocks(from, limit) {
|
|
892
927
|
return await this.blockSource.getCheckpointedBlocks(from, limit) ?? [];
|
|
893
928
|
}
|
|
929
|
+
getCheckpointsDataForEpoch(epochNumber) {
|
|
930
|
+
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
931
|
+
}
|
|
894
932
|
/**
|
|
895
933
|
* Method to fetch the current min L2 fees.
|
|
896
934
|
* @returns The current min L2 fees.
|
|
@@ -946,28 +984,36 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
946
984
|
return this.contractDataSource.getContract(address);
|
|
947
985
|
}
|
|
948
986
|
async getPrivateLogsByTags(tags, page, referenceBlock) {
|
|
987
|
+
let upToBlockNumber;
|
|
949
988
|
if (referenceBlock) {
|
|
950
989
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
951
|
-
if (
|
|
990
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
991
|
+
upToBlockNumber = BlockNumber(0);
|
|
992
|
+
} else {
|
|
952
993
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
953
994
|
if (!header) {
|
|
954
995
|
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
955
996
|
}
|
|
997
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
956
998
|
}
|
|
957
999
|
}
|
|
958
|
-
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
1000
|
+
return this.logsSource.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
959
1001
|
}
|
|
960
1002
|
async getPublicLogsByTagsFromContract(contractAddress, tags, page, referenceBlock) {
|
|
1003
|
+
let upToBlockNumber;
|
|
961
1004
|
if (referenceBlock) {
|
|
962
1005
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
963
|
-
if (
|
|
1006
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
1007
|
+
upToBlockNumber = BlockNumber(0);
|
|
1008
|
+
} else {
|
|
964
1009
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
965
1010
|
if (!header) {
|
|
966
1011
|
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
967
1012
|
}
|
|
1013
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
968
1014
|
}
|
|
969
1015
|
}
|
|
970
|
-
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
|
|
1016
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
971
1017
|
}
|
|
972
1018
|
/**
|
|
973
1019
|
* Gets public logs based on the provided filter.
|
|
@@ -1040,7 +1086,10 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1040
1086
|
await tryStop(this.validatorsSentinel);
|
|
1041
1087
|
await tryStop(this.epochPruneWatcher);
|
|
1042
1088
|
await tryStop(this.slasherClient);
|
|
1043
|
-
await
|
|
1089
|
+
await Promise.all([
|
|
1090
|
+
tryStop(this.peerProofVerifier),
|
|
1091
|
+
tryStop(this.rpcProofVerifier)
|
|
1092
|
+
]);
|
|
1044
1093
|
await tryStop(this.sequencer);
|
|
1045
1094
|
await tryStop(this.proverNode);
|
|
1046
1095
|
await tryStop(this.p2pClient);
|
|
@@ -1082,7 +1131,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1082
1131
|
return compactArray(await Promise.all(txHashes.map((txHash)=>this.getTxByHash(txHash))));
|
|
1083
1132
|
}
|
|
1084
1133
|
async findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
1085
|
-
const committedDb = await this
|
|
1134
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1086
1135
|
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
1087
1136
|
// Filter out undefined values to query block numbers only for found leaves
|
|
1088
1137
|
const definedIndices = maybeIndices.filter((x)=>x !== undefined);
|
|
@@ -1135,21 +1184,29 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1135
1184
|
});
|
|
1136
1185
|
}
|
|
1137
1186
|
async getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
1138
|
-
|
|
1187
|
+
// The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
|
|
1188
|
+
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
|
|
1189
|
+
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
|
|
1190
|
+
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
|
|
1191
|
+
if (referenceBlockNumber === BlockNumber.ZERO) {
|
|
1192
|
+
// Block 0 (the initial block) has an empty archive, so no membership witness can exist.
|
|
1193
|
+
return undefined;
|
|
1194
|
+
}
|
|
1195
|
+
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
|
|
1139
1196
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
|
|
1140
1197
|
blockHash
|
|
1141
1198
|
]);
|
|
1142
1199
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
1143
1200
|
}
|
|
1144
1201
|
async getNoteHashMembershipWitness(referenceBlock, noteHash) {
|
|
1145
|
-
const committedDb = await this
|
|
1202
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1146
1203
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
|
|
1147
1204
|
noteHash
|
|
1148
1205
|
]);
|
|
1149
1206
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
1150
1207
|
}
|
|
1151
1208
|
async getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message) {
|
|
1152
|
-
const db = await this
|
|
1209
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1153
1210
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
|
|
1154
1211
|
l1ToL2Message
|
|
1155
1212
|
]);
|
|
@@ -1181,23 +1238,11 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1181
1238
|
*/ async getL2ToL1Messages(epoch) {
|
|
1182
1239
|
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
1183
1240
|
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1184
|
-
const blocksInCheckpoints =
|
|
1185
|
-
let previousSlotNumber = SlotNumber.ZERO;
|
|
1186
|
-
let checkpointIndex = -1;
|
|
1187
|
-
for (const checkpointedBlock of checkpointedBlocks){
|
|
1188
|
-
const block = checkpointedBlock.block;
|
|
1189
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
1190
|
-
if (slotNumber !== previousSlotNumber) {
|
|
1191
|
-
checkpointIndex++;
|
|
1192
|
-
blocksInCheckpoints.push([]);
|
|
1193
|
-
previousSlotNumber = slotNumber;
|
|
1194
|
-
}
|
|
1195
|
-
blocksInCheckpoints[checkpointIndex].push(block);
|
|
1196
|
-
}
|
|
1241
|
+
const blocksInCheckpoints = chunkBy(checkpointedBlocks, (cb)=>cb.block.header.globalVariables.slotNumber).map((group)=>group.map((cb)=>cb.block));
|
|
1197
1242
|
return blocksInCheckpoints.map((blocks)=>blocks.map((block)=>block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs)));
|
|
1198
1243
|
}
|
|
1199
1244
|
async getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1200
|
-
const db = await this
|
|
1245
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1201
1246
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
|
|
1202
1247
|
nullifier.toBuffer()
|
|
1203
1248
|
]);
|
|
@@ -1211,36 +1256,22 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1211
1256
|
}
|
|
1212
1257
|
return new NullifierMembershipWitness(index, leafPreimage, path);
|
|
1213
1258
|
}
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
|
|
1217
|
-
* (which contains the root of the nullifier tree in which we are searching for the nullifier).
|
|
1218
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
1219
|
-
* @returns The low nullifier membership witness (if found).
|
|
1220
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
1221
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
1222
|
-
* we are trying to prove non-inclusion for.
|
|
1223
|
-
*
|
|
1224
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
1225
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
1226
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
1227
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
1228
|
-
*/ async getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1229
|
-
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1259
|
+
async getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1260
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1230
1261
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1231
1262
|
if (!findResult) {
|
|
1232
1263
|
return undefined;
|
|
1233
1264
|
}
|
|
1234
1265
|
const { index, alreadyPresent } = findResult;
|
|
1235
1266
|
if (alreadyPresent) {
|
|
1236
|
-
|
|
1267
|
+
throw new Error(`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`);
|
|
1237
1268
|
}
|
|
1238
1269
|
const preimageData = await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
1239
1270
|
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
1240
1271
|
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
1241
1272
|
}
|
|
1242
1273
|
async getPublicDataWitness(referenceBlock, leafSlot) {
|
|
1243
|
-
const committedDb = await this
|
|
1274
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1244
1275
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1245
1276
|
if (!lowLeafResult) {
|
|
1246
1277
|
return undefined;
|
|
@@ -1251,7 +1282,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1251
1282
|
}
|
|
1252
1283
|
}
|
|
1253
1284
|
async getPublicStorageAt(referenceBlock, contract, slot) {
|
|
1254
|
-
const committedDb = await this
|
|
1285
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1255
1286
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1256
1287
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1257
1288
|
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
@@ -1348,7 +1379,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1348
1379
|
}
|
|
1349
1380
|
async isValidTx(tx, { isSimulation, skipFeeEnforcement } = {}) {
|
|
1350
1381
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1351
|
-
const verifier = isSimulation ? undefined : this.
|
|
1382
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
1352
1383
|
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1353
1384
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1354
1385
|
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
@@ -1390,7 +1421,18 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1390
1421
|
archiver.updateConfig(config);
|
|
1391
1422
|
}
|
|
1392
1423
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
1393
|
-
|
|
1424
|
+
await Promise.all([
|
|
1425
|
+
tryStop(this.peerProofVerifier),
|
|
1426
|
+
tryStop(this.rpcProofVerifier)
|
|
1427
|
+
]);
|
|
1428
|
+
if (newConfig.realProofs) {
|
|
1429
|
+
this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
|
|
1430
|
+
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
|
|
1431
|
+
this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
|
|
1432
|
+
} else {
|
|
1433
|
+
this.peerProofVerifier = new TestCircuitVerifier();
|
|
1434
|
+
this.rpcProofVerifier = new TestCircuitVerifier();
|
|
1435
|
+
}
|
|
1394
1436
|
}
|
|
1395
1437
|
this.config = newConfig;
|
|
1396
1438
|
}
|
|
@@ -1587,7 +1629,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1587
1629
|
* Returns an instance of MerkleTreeOperations having first ensured the world state is fully synched
|
|
1588
1630
|
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1589
1631
|
* @returns An instance of a committed MerkleTreeOperations
|
|
1590
|
-
*/ async
|
|
1632
|
+
*/ async getWorldState(block) {
|
|
1591
1633
|
let blockSyncedTo = BlockNumber.ZERO;
|
|
1592
1634
|
try {
|
|
1593
1635
|
// Attempt to sync the world state if necessary
|
|
@@ -1599,6 +1641,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1599
1641
|
this.log.debug(`Using committed db for block 'latest', world state synced upto ${blockSyncedTo}`);
|
|
1600
1642
|
return this.worldStateSynchronizer.getCommitted();
|
|
1601
1643
|
}
|
|
1644
|
+
// Get the block number, either directly from the parameter or by quering the archiver with the block hash
|
|
1645
|
+
let blockNumber;
|
|
1602
1646
|
if (BlockHash.isBlockHash(block)) {
|
|
1603
1647
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1604
1648
|
if (block.equals(initialBlockHash)) {
|
|
@@ -1609,19 +1653,41 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1609
1653
|
if (!header) {
|
|
1610
1654
|
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.`);
|
|
1611
1655
|
}
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
}
|
|
1616
|
-
//
|
|
1617
|
-
{
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1656
|
+
blockNumber = header.getBlockNumber();
|
|
1657
|
+
} else {
|
|
1658
|
+
blockNumber = block;
|
|
1659
|
+
}
|
|
1660
|
+
// Check it's within world state sync range
|
|
1661
|
+
if (blockNumber > blockSyncedTo) {
|
|
1662
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1663
|
+
}
|
|
1664
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1665
|
+
const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1666
|
+
// Double-check world-state synced to the same block hash as was requested
|
|
1667
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1668
|
+
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1669
|
+
if (!blockHash || !new BlockHash(blockHash).equals(block)) {
|
|
1670
|
+
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.`);
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
return snapshot;
|
|
1674
|
+
}
|
|
1675
|
+
/** Resolves a block parameter to a block number. */ async resolveBlockNumber(block) {
|
|
1676
|
+
if (block === 'latest') {
|
|
1677
|
+
return BlockNumber(await this.blockSource.getBlockNumber());
|
|
1678
|
+
}
|
|
1679
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1680
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1681
|
+
if (block.equals(initialBlockHash)) {
|
|
1682
|
+
return BlockNumber.ZERO;
|
|
1683
|
+
}
|
|
1684
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1685
|
+
if (!header) {
|
|
1686
|
+
throw new Error(`Block hash ${block.toString()} not found.`);
|
|
1621
1687
|
}
|
|
1622
|
-
|
|
1623
|
-
return this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1688
|
+
return header.getBlockNumber();
|
|
1624
1689
|
}
|
|
1690
|
+
return block;
|
|
1625
1691
|
}
|
|
1626
1692
|
/**
|
|
1627
1693
|
* Ensure we fully sync the world state
|
|
@@ -48,7 +48,7 @@ export class Sentinel extends EventEmitter {
|
|
|
48
48
|
this.runningPromise.start();
|
|
49
49
|
}
|
|
50
50
|
/** Loads initial slot and initializes blockstream. We will not process anything at or before the initial slot. */ async init() {
|
|
51
|
-
this.initialSlot = this.epochCache.
|
|
51
|
+
this.initialSlot = this.epochCache.getSlotNow();
|
|
52
52
|
const startingBlock = BlockNumber(await this.archiver.getBlockNumber());
|
|
53
53
|
this.logger.info(`Starting validator sentinel with initial slot ${this.initialSlot} and block ${startingBlock}`);
|
|
54
54
|
this.blockStream = new L2BlockStream(this.archiver, this.l2TipsStore, this, this.logger, {
|
|
@@ -157,7 +157,7 @@ export class Sentinel extends EventEmitter {
|
|
|
157
157
|
return false;
|
|
158
158
|
}
|
|
159
159
|
// Check that we have at least requiredConsecutiveEpochs and that all of them are above the inactivity threshold
|
|
160
|
-
return pastEpochs.slice(0, requiredConsecutiveEpochs).every((p)=>p.missed / p.total >= this.config.slashInactivityTargetPercentage);
|
|
160
|
+
return pastEpochs.slice(0, requiredConsecutiveEpochs).every((p)=>p.total === 0 ? false : p.missed / p.total >= this.config.slashInactivityTargetPercentage);
|
|
161
161
|
}
|
|
162
162
|
async handleProvenPerformance(epoch, performance) {
|
|
163
163
|
if (this.config.slashInactivityPenalty === 0n) {
|
|
@@ -190,7 +190,7 @@ export class Sentinel extends EventEmitter {
|
|
|
190
190
|
* Note that we do not process historical data, since we rely on p2p data for processing,
|
|
191
191
|
* and we don't have that data if we were offline during the period.
|
|
192
192
|
*/ async work() {
|
|
193
|
-
const
|
|
193
|
+
const currentSlot = this.epochCache.getSlotNow();
|
|
194
194
|
try {
|
|
195
195
|
// Manually sync the block stream to ensure we have the latest data.
|
|
196
196
|
// Note we never `start` the blockstream, so it loops at the same pace as we do.
|
|
@@ -351,7 +351,7 @@ export class Sentinel extends EventEmitter {
|
|
|
351
351
|
v.toString(),
|
|
352
352
|
await this.store.getHistory(v)
|
|
353
353
|
]))) : await this.store.getHistories();
|
|
354
|
-
const slotNow = this.epochCache.
|
|
354
|
+
const slotNow = this.epochCache.getSlotNow();
|
|
355
355
|
fromSlot ??= SlotNumber(Math.max((this.lastProcessedSlot ?? slotNow) - this.store.getHistoryLength(), 0));
|
|
356
356
|
toSlot ??= this.lastProcessedSlot ?? slotNow;
|
|
357
357
|
const stats = mapValues(histories, (history, address)=>this.computeStatsForValidator(address, history ?? [], fromSlot, toSlot));
|
|
@@ -367,7 +367,7 @@ export class Sentinel extends EventEmitter {
|
|
|
367
367
|
if (!history || history.length === 0) {
|
|
368
368
|
return undefined;
|
|
369
369
|
}
|
|
370
|
-
const slotNow = this.epochCache.
|
|
370
|
+
const slotNow = this.epochCache.getSlotNow();
|
|
371
371
|
const effectiveFromSlot = fromSlot ?? SlotNumber(Math.max((this.lastProcessedSlot ?? slotNow) - this.store.getHistoryLength(), 0));
|
|
372
372
|
const effectiveToSlot = toSlot ?? this.lastProcessedSlot ?? slotNow;
|
|
373
373
|
const historyLength = BigInt(this.store.getHistoryLength());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec-node",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.35158ae7e",
|
|
4
4
|
"main": "dest/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -65,32 +65,31 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
69
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
70
|
-
"@aztec/blob-client": "0.0.1-commit.
|
|
71
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
72
|
-
"@aztec/constants": "0.0.1-commit.
|
|
73
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
74
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
75
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
76
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
77
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
78
|
-
"@aztec/
|
|
79
|
-
"@aztec/node-
|
|
80
|
-
"@aztec/
|
|
81
|
-
"@aztec/
|
|
82
|
-
"@aztec/
|
|
83
|
-
"@aztec/
|
|
84
|
-
"@aztec/prover-
|
|
85
|
-
"@aztec/
|
|
86
|
-
"@aztec/
|
|
87
|
-
"@aztec/
|
|
88
|
-
"@aztec/
|
|
89
|
-
"@aztec/
|
|
90
|
-
"@aztec/
|
|
91
|
-
"@aztec/validator-
|
|
92
|
-
"@aztec/
|
|
93
|
-
"@aztec/world-state": "0.0.1-commit.343b43af6",
|
|
68
|
+
"@aztec/archiver": "0.0.1-commit.35158ae7e",
|
|
69
|
+
"@aztec/bb-prover": "0.0.1-commit.35158ae7e",
|
|
70
|
+
"@aztec/blob-client": "0.0.1-commit.35158ae7e",
|
|
71
|
+
"@aztec/blob-lib": "0.0.1-commit.35158ae7e",
|
|
72
|
+
"@aztec/constants": "0.0.1-commit.35158ae7e",
|
|
73
|
+
"@aztec/epoch-cache": "0.0.1-commit.35158ae7e",
|
|
74
|
+
"@aztec/ethereum": "0.0.1-commit.35158ae7e",
|
|
75
|
+
"@aztec/foundation": "0.0.1-commit.35158ae7e",
|
|
76
|
+
"@aztec/kv-store": "0.0.1-commit.35158ae7e",
|
|
77
|
+
"@aztec/l1-artifacts": "0.0.1-commit.35158ae7e",
|
|
78
|
+
"@aztec/node-keystore": "0.0.1-commit.35158ae7e",
|
|
79
|
+
"@aztec/node-lib": "0.0.1-commit.35158ae7e",
|
|
80
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.35158ae7e",
|
|
81
|
+
"@aztec/p2p": "0.0.1-commit.35158ae7e",
|
|
82
|
+
"@aztec/protocol-contracts": "0.0.1-commit.35158ae7e",
|
|
83
|
+
"@aztec/prover-client": "0.0.1-commit.35158ae7e",
|
|
84
|
+
"@aztec/prover-node": "0.0.1-commit.35158ae7e",
|
|
85
|
+
"@aztec/sequencer-client": "0.0.1-commit.35158ae7e",
|
|
86
|
+
"@aztec/simulator": "0.0.1-commit.35158ae7e",
|
|
87
|
+
"@aztec/slasher": "0.0.1-commit.35158ae7e",
|
|
88
|
+
"@aztec/stdlib": "0.0.1-commit.35158ae7e",
|
|
89
|
+
"@aztec/telemetry-client": "0.0.1-commit.35158ae7e",
|
|
90
|
+
"@aztec/validator-client": "0.0.1-commit.35158ae7e",
|
|
91
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.35158ae7e",
|
|
92
|
+
"@aztec/world-state": "0.0.1-commit.35158ae7e",
|
|
94
93
|
"koa": "^2.16.1",
|
|
95
94
|
"koa-router": "^13.1.1",
|
|
96
95
|
"tslib": "^2.4.0",
|