@aztec/aztec-node 0.0.1-commit.381b1a9 → 0.0.1-commit.3a4ae741b

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.
@@ -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, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
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, SlotNumber } from '@aztec/foundation/branded-types';
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, fallback, http } from 'viem';
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
- proofVerifier;
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, proofVerifier, telemetry = getTelemetryClient(), log = createLogger('node'), blobClient, validatorClient, keyStoreManager, debugLogStore = new NullDebugLogStore()){
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.proofVerifier = proofVerifier;
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: fallback(config.l1RpcUrls.map((url)=>http(url, {
563
- batch: false
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 circuitVerifier = config.realProofs || config.debugForceTxProofVerification ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier(config.proverTestVerificationDelayMs);
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, proofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
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 globalVariableBuilder = new GlobalVariableBuilder({
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
  /**
@@ -949,28 +984,36 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
949
984
  return this.contractDataSource.getContract(address);
950
985
  }
951
986
  async getPrivateLogsByTags(tags, page, referenceBlock) {
987
+ let upToBlockNumber;
952
988
  if (referenceBlock) {
953
989
  const initialBlockHash = await this.#getInitialHeaderHash();
954
- if (!referenceBlock.equals(initialBlockHash)) {
990
+ if (referenceBlock.equals(initialBlockHash)) {
991
+ upToBlockNumber = BlockNumber(0);
992
+ } else {
955
993
  const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
956
994
  if (!header) {
957
995
  throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
958
996
  }
997
+ upToBlockNumber = header.globalVariables.blockNumber;
959
998
  }
960
999
  }
961
- return this.logsSource.getPrivateLogsByTags(tags, page);
1000
+ return this.logsSource.getPrivateLogsByTags(tags, page, upToBlockNumber);
962
1001
  }
963
1002
  async getPublicLogsByTagsFromContract(contractAddress, tags, page, referenceBlock) {
1003
+ let upToBlockNumber;
964
1004
  if (referenceBlock) {
965
1005
  const initialBlockHash = await this.#getInitialHeaderHash();
966
- if (!referenceBlock.equals(initialBlockHash)) {
1006
+ if (referenceBlock.equals(initialBlockHash)) {
1007
+ upToBlockNumber = BlockNumber(0);
1008
+ } else {
967
1009
  const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
968
1010
  if (!header) {
969
1011
  throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
970
1012
  }
1013
+ upToBlockNumber = header.globalVariables.blockNumber;
971
1014
  }
972
1015
  }
973
- return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
1016
+ return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
974
1017
  }
975
1018
  /**
976
1019
  * Gets public logs based on the provided filter.
@@ -1043,7 +1086,10 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
1043
1086
  await tryStop(this.validatorsSentinel);
1044
1087
  await tryStop(this.epochPruneWatcher);
1045
1088
  await tryStop(this.slasherClient);
1046
- await tryStop(this.proofVerifier);
1089
+ await Promise.all([
1090
+ tryStop(this.peerProofVerifier),
1091
+ tryStop(this.rpcProofVerifier)
1092
+ ]);
1047
1093
  await tryStop(this.sequencer);
1048
1094
  await tryStop(this.proverNode);
1049
1095
  await tryStop(this.p2pClient);
@@ -1085,7 +1131,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
1085
1131
  return compactArray(await Promise.all(txHashes.map((txHash)=>this.getTxByHash(txHash))));
1086
1132
  }
1087
1133
  async findLeavesIndexes(referenceBlock, treeId, leafValues) {
1088
- const committedDb = await this.#getWorldState(referenceBlock);
1134
+ const committedDb = await this.getWorldState(referenceBlock);
1089
1135
  const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
1090
1136
  // Filter out undefined values to query block numbers only for found leaves
1091
1137
  const definedIndices = maybeIndices.filter((x)=>x !== undefined);
@@ -1142,21 +1188,21 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
1142
1188
  // which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
1143
1189
  // So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
1144
1190
  const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
1145
- const committedDb = await this.#getWorldState(BlockNumber(referenceBlockNumber - 1));
1191
+ const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
1146
1192
  const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
1147
1193
  blockHash
1148
1194
  ]);
1149
1195
  return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
1150
1196
  }
1151
1197
  async getNoteHashMembershipWitness(referenceBlock, noteHash) {
1152
- const committedDb = await this.#getWorldState(referenceBlock);
1198
+ const committedDb = await this.getWorldState(referenceBlock);
1153
1199
  const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
1154
1200
  noteHash
1155
1201
  ]);
1156
1202
  return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
1157
1203
  }
1158
1204
  async getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message) {
1159
- const db = await this.#getWorldState(referenceBlock);
1205
+ const db = await this.getWorldState(referenceBlock);
1160
1206
  const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
1161
1207
  l1ToL2Message
1162
1208
  ]);
@@ -1188,23 +1234,11 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
1188
1234
  */ async getL2ToL1Messages(epoch) {
1189
1235
  // Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
1190
1236
  const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
1191
- const blocksInCheckpoints = [];
1192
- let previousSlotNumber = SlotNumber.ZERO;
1193
- let checkpointIndex = -1;
1194
- for (const checkpointedBlock of checkpointedBlocks){
1195
- const block = checkpointedBlock.block;
1196
- const slotNumber = block.header.globalVariables.slotNumber;
1197
- if (slotNumber !== previousSlotNumber) {
1198
- checkpointIndex++;
1199
- blocksInCheckpoints.push([]);
1200
- previousSlotNumber = slotNumber;
1201
- }
1202
- blocksInCheckpoints[checkpointIndex].push(block);
1203
- }
1237
+ const blocksInCheckpoints = chunkBy(checkpointedBlocks, (cb)=>cb.block.header.globalVariables.slotNumber).map((group)=>group.map((cb)=>cb.block));
1204
1238
  return blocksInCheckpoints.map((blocks)=>blocks.map((block)=>block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs)));
1205
1239
  }
1206
1240
  async getNullifierMembershipWitness(referenceBlock, nullifier) {
1207
- const db = await this.#getWorldState(referenceBlock);
1241
+ const db = await this.getWorldState(referenceBlock);
1208
1242
  const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
1209
1243
  nullifier.toBuffer()
1210
1244
  ]);
@@ -1218,36 +1252,22 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
1218
1252
  }
1219
1253
  return new NullifierMembershipWitness(index, leafPreimage, path);
1220
1254
  }
1221
- /**
1222
- * Returns a low nullifier membership witness for a given nullifier at a given block.
1223
- * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
1224
- * (which contains the root of the nullifier tree in which we are searching for the nullifier).
1225
- * @param nullifier - Nullifier we try to find the low nullifier witness for.
1226
- * @returns The low nullifier membership witness (if found).
1227
- * @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
1228
- * list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
1229
- * we are trying to prove non-inclusion for.
1230
- *
1231
- * Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
1232
- * the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
1233
- * index of the nullifier itself when it already exists in the tree.
1234
- * TODO: This is a confusing behavior and we should eventually address that.
1235
- */ async getLowNullifierMembershipWitness(referenceBlock, nullifier) {
1236
- const committedDb = await this.#getWorldState(referenceBlock);
1255
+ async getLowNullifierMembershipWitness(referenceBlock, nullifier) {
1256
+ const committedDb = await this.getWorldState(referenceBlock);
1237
1257
  const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
1238
1258
  if (!findResult) {
1239
1259
  return undefined;
1240
1260
  }
1241
1261
  const { index, alreadyPresent } = findResult;
1242
1262
  if (alreadyPresent) {
1243
- this.log.warn(`Nullifier ${nullifier.toBigInt()} already exists in the tree`);
1263
+ throw new Error(`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`);
1244
1264
  }
1245
1265
  const preimageData = await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
1246
1266
  const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
1247
1267
  return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
1248
1268
  }
1249
1269
  async getPublicDataWitness(referenceBlock, leafSlot) {
1250
- const committedDb = await this.#getWorldState(referenceBlock);
1270
+ const committedDb = await this.getWorldState(referenceBlock);
1251
1271
  const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
1252
1272
  if (!lowLeafResult) {
1253
1273
  return undefined;
@@ -1258,7 +1278,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
1258
1278
  }
1259
1279
  }
1260
1280
  async getPublicStorageAt(referenceBlock, contract, slot) {
1261
- const committedDb = await this.#getWorldState(referenceBlock);
1281
+ const committedDb = await this.getWorldState(referenceBlock);
1262
1282
  const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
1263
1283
  const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
1264
1284
  if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
@@ -1355,7 +1375,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
1355
1375
  }
1356
1376
  async isValidTx(tx, { isSimulation, skipFeeEnforcement } = {}) {
1357
1377
  const db = this.worldStateSynchronizer.getCommitted();
1358
- const verifier = isSimulation ? undefined : this.proofVerifier;
1378
+ const verifier = isSimulation ? undefined : this.rpcProofVerifier;
1359
1379
  // We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
1360
1380
  const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
1361
1381
  const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
@@ -1397,7 +1417,18 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
1397
1417
  archiver.updateConfig(config);
1398
1418
  }
1399
1419
  if (newConfig.realProofs !== this.config.realProofs) {
1400
- this.proofVerifier = config.realProofs ? await BBCircuitVerifier.new(newConfig) : new TestCircuitVerifier();
1420
+ await Promise.all([
1421
+ tryStop(this.peerProofVerifier),
1422
+ tryStop(this.rpcProofVerifier)
1423
+ ]);
1424
+ if (newConfig.realProofs) {
1425
+ this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
1426
+ const rpcVerifier = await BBCircuitVerifier.new(newConfig);
1427
+ this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
1428
+ } else {
1429
+ this.peerProofVerifier = new TestCircuitVerifier();
1430
+ this.rpcProofVerifier = new TestCircuitVerifier();
1431
+ }
1401
1432
  }
1402
1433
  this.config = newConfig;
1403
1434
  }
@@ -1594,7 +1625,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
1594
1625
  * Returns an instance of MerkleTreeOperations having first ensured the world state is fully synched
1595
1626
  * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
1596
1627
  * @returns An instance of a committed MerkleTreeOperations
1597
- */ async #getWorldState(block) {
1628
+ */ async getWorldState(block) {
1598
1629
  let blockSyncedTo = BlockNumber.ZERO;
1599
1630
  try {
1600
1631
  // Attempt to sync the world state if necessary
@@ -1606,6 +1637,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
1606
1637
  this.log.debug(`Using committed db for block 'latest', world state synced upto ${blockSyncedTo}`);
1607
1638
  return this.worldStateSynchronizer.getCommitted();
1608
1639
  }
1640
+ // Get the block number, either directly from the parameter or by quering the archiver with the block hash
1641
+ let blockNumber;
1609
1642
  if (BlockHash.isBlockHash(block)) {
1610
1643
  const initialBlockHash = await this.#getInitialHeaderHash();
1611
1644
  if (block.equals(initialBlockHash)) {
@@ -1616,19 +1649,24 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
1616
1649
  if (!header) {
1617
1650
  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.`);
1618
1651
  }
1619
- const blockNumber = header.getBlockNumber();
1620
- this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
1621
- return this.worldStateSynchronizer.getSnapshot(blockNumber);
1622
- }
1623
- // Block number provided
1624
- {
1625
- const blockNumber = block;
1626
- if (blockNumber > blockSyncedTo) {
1627
- throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
1652
+ blockNumber = header.getBlockNumber();
1653
+ } else {
1654
+ blockNumber = block;
1655
+ }
1656
+ // Check it's within world state sync range
1657
+ if (blockNumber > blockSyncedTo) {
1658
+ throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
1659
+ }
1660
+ this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
1661
+ const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
1662
+ // Double-check world-state synced to the same block hash as was requested
1663
+ if (BlockHash.isBlockHash(block)) {
1664
+ const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
1665
+ if (!blockHash || !new BlockHash(blockHash).equals(block)) {
1666
+ 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.`);
1628
1667
  }
1629
- this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
1630
- return this.worldStateSynchronizer.getSnapshot(blockNumber);
1631
1668
  }
1669
+ return snapshot;
1632
1670
  }
1633
1671
  /** Resolves a block parameter to a block number. */ async resolveBlockNumber(block) {
1634
1672
  if (block === 'latest') {
@@ -1,9 +1,9 @@
1
1
  import type { EpochCache } from '@aztec/epoch-cache';
2
- import type { DataStoreConfig } from '@aztec/kv-store/config';
3
2
  import type { P2PClient } from '@aztec/p2p';
4
3
  import type { L2BlockSource } from '@aztec/stdlib/block';
5
4
  import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
5
+ import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
6
6
  import type { SentinelConfig } from './config.js';
7
7
  import { Sentinel } from './sentinel.js';
8
8
  export declare function createSentinel(epochCache: EpochCache, archiver: L2BlockSource, p2p: P2PClient, config: SentinelConfig & DataStoreConfig & SlasherConfig, logger?: import("@aztec/foundation/log").Logger): Promise<Sentinel | undefined>;
9
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NlbnRpbmVsL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFckQsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFOUQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sWUFBWSxDQUFDO0FBQzVDLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBRXJFLE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUNsRCxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBR3pDLHdCQUFzQixjQUFjLENBQ2xDLFVBQVUsRUFBRSxVQUFVLEVBQ3RCLFFBQVEsRUFBRSxhQUFhLEVBQ3ZCLEdBQUcsRUFBRSxTQUFTLEVBQ2QsTUFBTSxFQUFFLGNBQWMsR0FBRyxlQUFlLEdBQUcsYUFBYSxFQUN4RCxNQUFNLHlDQUFnQyxHQUNyQyxPQUFPLENBQUMsUUFBUSxHQUFHLFNBQVMsQ0FBQyxDQVkvQiJ9
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NlbnRpbmVsL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFHckQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sWUFBWSxDQUFDO0FBQzVDLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ3JFLE9BQU8sS0FBSyxFQUFFLGVBQWUsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRTlELE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUNsRCxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBR3pDLHdCQUFzQixjQUFjLENBQ2xDLFVBQVUsRUFBRSxVQUFVLEVBQ3RCLFFBQVEsRUFBRSxhQUFhLEVBQ3ZCLEdBQUcsRUFBRSxTQUFTLEVBQ2QsTUFBTSxFQUFFLGNBQWMsR0FBRyxlQUFlLEdBQUcsYUFBYSxFQUN4RCxNQUFNLHlDQUFnQyxHQUNyQyxPQUFPLENBQUMsUUFBUSxHQUFHLFNBQVMsQ0FBQyxDQVkvQiJ9
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/sentinel/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,wBAAsB,cAAc,CAClC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,aAAa,EACvB,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,cAAc,GAAG,eAAe,GAAG,aAAa,EACxD,MAAM,yCAAgC,GACrC,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAY/B"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/sentinel/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,wBAAsB,cAAc,CAClC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,aAAa,EACvB,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,cAAc,GAAG,eAAe,GAAG,aAAa,EACxD,MAAM,yCAAgC,GACrC,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAY/B"}
@@ -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.getEpochAndSlotNow().slot;
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 { slot: currentSlot } = this.epochCache.getEpochAndSlotNow();
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.getEpochAndSlotNow().slot;
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.getEpochAndSlotNow().slot;
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.381b1a9",
3
+ "version": "0.0.1-commit.3a4ae741b",
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.381b1a9",
69
- "@aztec/bb-prover": "0.0.1-commit.381b1a9",
70
- "@aztec/blob-client": "0.0.1-commit.381b1a9",
71
- "@aztec/blob-lib": "0.0.1-commit.381b1a9",
72
- "@aztec/constants": "0.0.1-commit.381b1a9",
73
- "@aztec/epoch-cache": "0.0.1-commit.381b1a9",
74
- "@aztec/ethereum": "0.0.1-commit.381b1a9",
75
- "@aztec/foundation": "0.0.1-commit.381b1a9",
76
- "@aztec/kv-store": "0.0.1-commit.381b1a9",
77
- "@aztec/l1-artifacts": "0.0.1-commit.381b1a9",
78
- "@aztec/merkle-tree": "0.0.1-commit.381b1a9",
79
- "@aztec/node-keystore": "0.0.1-commit.381b1a9",
80
- "@aztec/node-lib": "0.0.1-commit.381b1a9",
81
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.381b1a9",
82
- "@aztec/p2p": "0.0.1-commit.381b1a9",
83
- "@aztec/protocol-contracts": "0.0.1-commit.381b1a9",
84
- "@aztec/prover-client": "0.0.1-commit.381b1a9",
85
- "@aztec/prover-node": "0.0.1-commit.381b1a9",
86
- "@aztec/sequencer-client": "0.0.1-commit.381b1a9",
87
- "@aztec/simulator": "0.0.1-commit.381b1a9",
88
- "@aztec/slasher": "0.0.1-commit.381b1a9",
89
- "@aztec/stdlib": "0.0.1-commit.381b1a9",
90
- "@aztec/telemetry-client": "0.0.1-commit.381b1a9",
91
- "@aztec/validator-client": "0.0.1-commit.381b1a9",
92
- "@aztec/validator-ha-signer": "0.0.1-commit.381b1a9",
93
- "@aztec/world-state": "0.0.1-commit.381b1a9",
68
+ "@aztec/archiver": "0.0.1-commit.3a4ae741b",
69
+ "@aztec/bb-prover": "0.0.1-commit.3a4ae741b",
70
+ "@aztec/blob-client": "0.0.1-commit.3a4ae741b",
71
+ "@aztec/blob-lib": "0.0.1-commit.3a4ae741b",
72
+ "@aztec/constants": "0.0.1-commit.3a4ae741b",
73
+ "@aztec/epoch-cache": "0.0.1-commit.3a4ae741b",
74
+ "@aztec/ethereum": "0.0.1-commit.3a4ae741b",
75
+ "@aztec/foundation": "0.0.1-commit.3a4ae741b",
76
+ "@aztec/kv-store": "0.0.1-commit.3a4ae741b",
77
+ "@aztec/l1-artifacts": "0.0.1-commit.3a4ae741b",
78
+ "@aztec/node-keystore": "0.0.1-commit.3a4ae741b",
79
+ "@aztec/node-lib": "0.0.1-commit.3a4ae741b",
80
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.3a4ae741b",
81
+ "@aztec/p2p": "0.0.1-commit.3a4ae741b",
82
+ "@aztec/protocol-contracts": "0.0.1-commit.3a4ae741b",
83
+ "@aztec/prover-client": "0.0.1-commit.3a4ae741b",
84
+ "@aztec/prover-node": "0.0.1-commit.3a4ae741b",
85
+ "@aztec/sequencer-client": "0.0.1-commit.3a4ae741b",
86
+ "@aztec/simulator": "0.0.1-commit.3a4ae741b",
87
+ "@aztec/slasher": "0.0.1-commit.3a4ae741b",
88
+ "@aztec/stdlib": "0.0.1-commit.3a4ae741b",
89
+ "@aztec/telemetry-client": "0.0.1-commit.3a4ae741b",
90
+ "@aztec/validator-client": "0.0.1-commit.3a4ae741b",
91
+ "@aztec/validator-ha-signer": "0.0.1-commit.3a4ae741b",
92
+ "@aztec/world-state": "0.0.1-commit.3a4ae741b",
94
93
  "koa": "^2.16.1",
95
94
  "koa-router": "^13.1.1",
96
95
  "tslib": "^2.4.0",
@@ -3,7 +3,6 @@ import { type GenesisStateConfig, genesisStateConfigMappings } from '@aztec/ethe
3
3
  import { type L1ContractAddresses, l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
4
4
  import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
5
5
  import { EthAddress } from '@aztec/foundation/eth-address';
6
- import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
7
6
  import {
8
7
  type KeyStore,
9
8
  type ValidatorKeyStore,
@@ -27,6 +26,7 @@ import { slasherConfigMappings } from '@aztec/slasher';
27
26
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
28
27
  import { type NodeRPCConfig, nodeRpcConfigMappings } from '@aztec/stdlib/config';
29
28
  import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
29
+ import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
30
30
  import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
31
31
  import { type WorldStateConfig, worldStateConfigMappings } from '@aztec/world-state/config';
32
32