@aztec/archiver 0.81.0 → 0.82.0

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.
Files changed (43) hide show
  1. package/dest/archiver/archiver.d.ts +3 -11
  2. package/dest/archiver/archiver.d.ts.map +1 -1
  3. package/dest/archiver/archiver.js +37 -54
  4. package/dest/archiver/archiver_store.d.ts +0 -15
  5. package/dest/archiver/archiver_store.d.ts.map +1 -1
  6. package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
  7. package/dest/archiver/archiver_store_test_suite.js +1 -51
  8. package/dest/archiver/config.d.ts +2 -0
  9. package/dest/archiver/config.d.ts.map +1 -1
  10. package/dest/archiver/config.js +5 -0
  11. package/dest/archiver/index.d.ts +0 -1
  12. package/dest/archiver/index.d.ts.map +1 -1
  13. package/dest/archiver/index.js +0 -1
  14. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +2 -10
  15. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
  16. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +0 -16
  17. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
  18. package/dest/archiver/kv_archiver_store/log_store.js +2 -1
  19. package/dest/factory.d.ts +1 -1
  20. package/dest/factory.d.ts.map +1 -1
  21. package/dest/factory.js +6 -24
  22. package/dest/test/mock_l2_block_source.d.ts +1 -0
  23. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  24. package/dest/test/mock_l2_block_source.js +3 -0
  25. package/package.json +12 -13
  26. package/src/archiver/archiver.ts +43 -65
  27. package/src/archiver/archiver_store.ts +0 -17
  28. package/src/archiver/archiver_store_test_suite.ts +0 -54
  29. package/src/archiver/config.ts +8 -0
  30. package/src/archiver/data_retrieval.ts +1 -1
  31. package/src/archiver/index.ts +0 -1
  32. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +1 -21
  33. package/src/archiver/kv_archiver_store/log_store.ts +1 -0
  34. package/src/factory.ts +3 -28
  35. package/src/test/mock_l2_block_source.ts +4 -0
  36. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
  37. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
  38. package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
  39. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
  40. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
  41. package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -607
  42. package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
  43. package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -770
package/dest/factory.js CHANGED
@@ -1,12 +1,10 @@
1
1
  import { createLogger } from '@aztec/foundation/log';
2
2
  import { createStore } from '@aztec/kv-store/lmdb-v2';
3
- import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
4
- import { TokenBridgeContractArtifact } from '@aztec/noir-contracts.js/TokenBridge';
5
3
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
6
4
  import { protocolContractNames, protocolContractTreeRoot } from '@aztec/protocol-contracts';
7
5
  import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
8
6
  import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
9
- import { computePublicBytecodeCommitment, getContractClassFromArtifact } from '@aztec/stdlib/contract';
7
+ import { computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
10
8
  import { getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
11
9
  import { getTelemetryClient } from '@aztec/telemetry-client';
12
10
  import { Archiver } from './archiver/archiver.js';
@@ -19,13 +17,16 @@ import { createArchiverClient } from './rpc/index.js';
19
17
  * @param opts - The options.
20
18
  * @param telemetry - The telemetry client.
21
19
  * @returns The local archiver.
22
- */ export async function createArchiver(config, blobSinkClient, opts = {
20
+ */ export async function createArchiver(_config, blobSinkClient, opts = {
23
21
  blockUntilSync: true
24
22
  }, telemetry = getTelemetryClient()) {
23
+ const config = {
24
+ ..._config,
25
+ dataStoreMapSizeKB: _config.archiverStoreMapSizeKb ?? _config.dataStoreMapSizeKB
26
+ };
25
27
  const store = await createStore('archiver', KVArchiverDataStore.SCHEMA_VERSION, config, createLogger('archiver:lmdb'));
26
28
  const archiverStore = new KVArchiverDataStore(store, config.maxLogs);
27
29
  await registerProtocolContracts(archiverStore);
28
- await registerCommonContracts(archiverStore);
29
30
  return Archiver.createAndSync(config, archiverStore, {
30
31
  telemetry,
31
32
  blobSinkClient
@@ -64,22 +65,3 @@ async function registerProtocolContracts(store) {
64
65
  ], blockNumber);
65
66
  }
66
67
  }
67
- // TODO(#10007): Remove this method. We are explicitly registering these contracts
68
- // here to ensure they are available to all nodes and all prover nodes, since the PXE
69
- // was tweaked to automatically push contract classes to the node it is registered,
70
- // but other nodes in the network may require the contract classes to be registered as well.
71
- // TODO(#10007): Remove the dependency on noir-contracts.js from this package once we remove this.
72
- async function registerCommonContracts(store) {
73
- const blockNumber = 0;
74
- const artifacts = [
75
- TokenBridgeContractArtifact,
76
- TokenContractArtifact
77
- ];
78
- const classes = await Promise.all(artifacts.map(async (artifact)=>({
79
- ...await getContractClassFromArtifact(artifact),
80
- privateFunctions: [],
81
- unconstrainedFunctions: []
82
- })));
83
- const bytecodeCommitments = await Promise.all(classes.map((x)=>computePublicBytecodeCommitment(x.packedBytecode)));
84
- await store.addContractClasses(classes, bytecodeCommitments, blockNumber);
85
- }
@@ -53,6 +53,7 @@ export declare class MockL2BlockSource implements L2BlockSource {
53
53
  }[]>;
54
54
  getBlockHeader(number: number | 'latest'): Promise<BlockHeader | undefined>;
55
55
  getBlocksForEpoch(epochNumber: bigint): Promise<L2Block[]>;
56
+ getBlockHeadersForEpoch(epochNumber: bigint): Promise<BlockHeader[]>;
56
57
  /**
57
58
  * Gets a tx effect.
58
59
  * @param txHash - The hash of a transaction which resulted in the returned tx effect.
@@ -1 +1 @@
1
- {"version":3,"file":"mock_l2_block_source.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I,CAAC;CAG7B"}
@@ -92,6 +92,9 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
92
92
  });
93
93
  return Promise.resolve(blocks);
94
94
  }
95
+ getBlockHeadersForEpoch(epochNumber) {
96
+ return this.getBlocksForEpoch(epochNumber).then((blocks)=>blocks.map((b)=>b.header));
97
+ }
95
98
  /**
96
99
  * Gets a tx effect.
97
100
  * @param txHash - The hash of a transaction which resulted in the returned tx effect.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/archiver",
3
- "version": "0.81.0",
3
+ "version": "0.82.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -64,18 +64,17 @@
64
64
  ]
65
65
  },
66
66
  "dependencies": {
67
- "@aztec/blob-lib": "0.81.0",
68
- "@aztec/blob-sink": "0.81.0",
69
- "@aztec/constants": "0.81.0",
70
- "@aztec/ethereum": "0.81.0",
71
- "@aztec/foundation": "0.81.0",
72
- "@aztec/kv-store": "0.81.0",
73
- "@aztec/l1-artifacts": "0.81.0",
74
- "@aztec/noir-contracts.js": "0.81.0",
75
- "@aztec/noir-protocol-circuits-types": "0.81.0",
76
- "@aztec/protocol-contracts": "0.81.0",
77
- "@aztec/stdlib": "0.81.0",
78
- "@aztec/telemetry-client": "0.81.0",
67
+ "@aztec/blob-lib": "0.82.0",
68
+ "@aztec/blob-sink": "0.82.0",
69
+ "@aztec/constants": "0.82.0",
70
+ "@aztec/ethereum": "0.82.0",
71
+ "@aztec/foundation": "0.82.0",
72
+ "@aztec/kv-store": "0.82.0",
73
+ "@aztec/l1-artifacts": "0.82.0",
74
+ "@aztec/noir-protocol-circuits-types": "0.82.0",
75
+ "@aztec/protocol-contracts": "0.82.0",
76
+ "@aztec/stdlib": "0.82.0",
77
+ "@aztec/telemetry-client": "0.82.0",
79
78
  "debug": "^4.3.4",
80
79
  "lodash.groupby": "^4.6.0",
81
80
  "lodash.omit": "^4.5.0",
@@ -1,12 +1,12 @@
1
1
  import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
2
- import { type ViemPublicClient, createEthereumChain } from '@aztec/ethereum';
2
+ import { RollupContract, type ViemPublicClient, createEthereumChain } from '@aztec/ethereum';
3
3
  import type { EthAddress } from '@aztec/foundation/eth-address';
4
4
  import { Fr } from '@aztec/foundation/fields';
5
5
  import { type Logger, createLogger } from '@aztec/foundation/log';
6
6
  import { RunningPromise, makeLoggingErrorHandler } from '@aztec/foundation/running-promise';
7
7
  import { count } from '@aztec/foundation/string';
8
8
  import { elapsed } from '@aztec/foundation/timer';
9
- import { InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
9
+ import { InboxAbi } from '@aztec/l1-artifacts';
10
10
  import {
11
11
  ContractClassRegisteredEvent,
12
12
  PrivateFunctionBroadcastedEvent,
@@ -25,7 +25,6 @@ import {
25
25
  type L2BlockSource,
26
26
  L2BlockSourceEvents,
27
27
  type L2Tips,
28
- type NullifierWithBlockSource,
29
28
  } from '@aztec/stdlib/block';
30
29
  import {
31
30
  type ContractClassPublic,
@@ -67,11 +66,7 @@ import type { PublishedL2Block } from './structs/published.js';
67
66
  /**
68
67
  * Helper interface to combine all sources this archiver implementation provides.
69
68
  */
70
- export type ArchiveSource = L2BlockSource &
71
- L2LogsSource &
72
- ContractDataSource &
73
- L1ToL2MessageSource &
74
- NullifierWithBlockSource;
69
+ export type ArchiveSource = L2BlockSource & L2LogsSource & ContractDataSource & L1ToL2MessageSource;
75
70
 
76
71
  /**
77
72
  * Pulls L2 blocks in a non-blocking manner and provides interface for their retrieval.
@@ -84,7 +79,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
84
79
  */
85
80
  private runningPromise?: RunningPromise;
86
81
 
87
- private rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>;
82
+ private rollup: RollupContract;
88
83
  private inbox: GetContractReturnType<typeof InboxAbi, ViemPublicClient>;
89
84
 
90
85
  private store: ArchiverStoreHelper;
@@ -119,11 +114,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
119
114
  this.tracer = instrumentation.tracer;
120
115
  this.store = new ArchiverStoreHelper(dataStore);
121
116
 
122
- this.rollup = getContract({
123
- address: l1Addresses.rollupAddress.toString(),
124
- abi: RollupAbi,
125
- client: publicClient,
126
- });
117
+ this.rollup = new RollupContract(publicClient, l1Addresses.rollupAddress);
127
118
 
128
119
  this.inbox = getContract({
129
120
  address: l1Addresses.inboxAddress.toString(),
@@ -152,15 +143,11 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
152
143
  pollingInterval: config.viemPollingIntervalMS,
153
144
  });
154
145
 
155
- const rollup = getContract({
156
- address: config.l1Contracts.rollupAddress.toString(),
157
- abi: RollupAbi,
158
- client: publicClient,
159
- });
146
+ const rollup = new RollupContract(publicClient, config.l1Contracts.rollupAddress);
160
147
 
161
148
  const [l1StartBlock, l1GenesisTime] = await Promise.all([
162
- rollup.read.L1_BLOCK_AT_GENESIS(),
163
- rollup.read.getGenesisTime(),
149
+ rollup.getL1StartBlock(),
150
+ rollup.getL1GenesisTime(),
164
151
  ] as const);
165
152
 
166
153
  const { aztecEpochDuration: epochDuration, aztecSlotDuration: slotDuration, ethereumSlotDuration } = config;
@@ -306,7 +293,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
306
293
  /** Queries the rollup contract on whether a prune can be executed on the immediatenext L1 block. */
307
294
  private async canPrune(currentL1BlockNumber: bigint, currentL1Timestamp: bigint) {
308
295
  const time = (currentL1Timestamp ?? 0n) + BigInt(this.l1constants.ethereumSlotDuration);
309
- return await this.rollup.read.canPruneAtTime([time], { blockNumber: currentL1BlockNumber });
296
+ return await this.rollup.canPruneAtTime(time, { blockNumber: currentL1BlockNumber });
310
297
  }
311
298
 
312
299
  /** Checks if there'd be a reorg for the next block submission and start pruning now. */
@@ -394,7 +381,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
394
381
  ): Promise<{ provenBlockNumber: bigint }> {
395
382
  const localPendingBlockNumber = BigInt(await this.getBlockNumber());
396
383
  const [provenBlockNumber, provenArchive, pendingBlockNumber, pendingArchive, archiveForLocalPendingBlockNumber] =
397
- await this.rollup.read.status([localPendingBlockNumber], { blockNumber: currentL1BlockNumber });
384
+ await this.rollup.status(localPendingBlockNumber, { blockNumber: currentL1BlockNumber });
398
385
 
399
386
  const updateProvenBlock = async () => {
400
387
  const localBlockForDestinationProvenBlockNumber = await this.getBlock(Number(provenBlockNumber));
@@ -428,7 +415,9 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
428
415
  const noBlocks = localPendingBlockNumber === 0n && pendingBlockNumber === 0n;
429
416
  if (noBlocks) {
430
417
  await this.store.setBlockSynchedL1BlockNumber(currentL1BlockNumber);
431
- this.log.debug(`No blocks to retrieve from ${blocksSynchedTo + 1n} to ${currentL1BlockNumber}`);
418
+ this.log.debug(
419
+ `No blocks to retrieve from ${blocksSynchedTo + 1n} to ${currentL1BlockNumber}, no blocks on chain`,
420
+ );
432
421
  return { provenBlockNumber };
433
422
  }
434
423
 
@@ -444,7 +433,14 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
444
433
 
445
434
  const noBlockSinceLast = localPendingBlock && pendingArchive === localPendingBlock.archive.root.toString();
446
435
  if (noBlockSinceLast) {
447
- await this.store.setBlockSynchedL1BlockNumber(currentL1BlockNumber);
436
+ // We believe the following line causes a problem when we encounter L1 re-orgs.
437
+ // Basically, by setting the synched L1 block number here, we are saying that we have
438
+ // processed all blocks up to the current L1 block number and we will not attempt to retrieve logs from
439
+ // this block again (or any blocks before).
440
+ // However, in the re-org scenario, our L1 node is temporarily lying to us and we end up potentially missing blocks
441
+ // We must only set this block number based on actually retrieved logs.
442
+ // TODO(https://github.com/AztecProtocol/aztec-packages/issues/8621): Tackle this properly when we handle L1 Re-orgs.
443
+ //await this.store.setBlockSynchedL1BlockNumber(currentL1BlockNumber);
448
444
  this.log.debug(`No blocks to retrieve from ${blocksSynchedTo + 1n} to ${currentL1BlockNumber}`);
449
445
  return { provenBlockNumber };
450
446
  }
@@ -464,7 +460,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
464
460
  break;
465
461
  }
466
462
 
467
- const archiveAtContract = await this.rollup.read.archiveAt([BigInt(candidateBlock.number)]);
463
+ const archiveAtContract = await this.rollup.archiveAt(BigInt(candidateBlock.number));
468
464
 
469
465
  if (archiveAtContract === candidateBlock.archive.root.toString()) {
470
466
  break;
@@ -483,7 +479,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
483
479
  }
484
480
  }
485
481
 
486
- // Retrieve L2 blocks in batches. Each batch is estimated to acommodate up to L2 'blockBatchSize' blocks,
482
+ // Retrieve L2 blocks in batches. Each batch is estimated to accommodate up to L2 'blockBatchSize' blocks,
487
483
  // computed using the L2 block time vs the L1 block time.
488
484
  let searchStartBlock: bigint = blocksSynchedTo;
489
485
  let searchEndBlock: bigint = blocksSynchedTo;
@@ -493,9 +489,9 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
493
489
 
494
490
  this.log.trace(`Retrieving L2 blocks from L1 block ${searchStartBlock} to ${searchEndBlock}`);
495
491
 
496
- // TODO(md): Retreive from blob sink then from consensus client, then from peers
492
+ // TODO(md): Retrieve from blob sink then from consensus client, then from peers
497
493
  const retrievedBlocks = await retrieveBlocksFromRollup(
498
- this.rollup,
494
+ this.rollup.getContract(),
499
495
  this.publicClient,
500
496
  this.blobSinkClient,
501
497
  searchStartBlock, // TODO(palla/reorg): If the L2 reorg was due to an L1 reorg, we need to start search earlier
@@ -612,6 +608,24 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
612
608
  return blocks.reverse();
613
609
  }
614
610
 
611
+ public async getBlockHeadersForEpoch(epochNumber: bigint): Promise<BlockHeader[]> {
612
+ const [start, end] = getSlotRangeForEpoch(epochNumber, this.l1constants);
613
+ const blocks: BlockHeader[] = [];
614
+
615
+ // Walk the list of blocks backwards and filter by slots matching the requested epoch.
616
+ // We'll typically ask for blocks for a very recent epoch, so we shouldn't need an index here.
617
+ let number = await this.store.getSynchedL2BlockNumber();
618
+ let header = await this.getBlockHeader(number);
619
+ const slot = (b: BlockHeader) => b.globalVariables.slotNumber.toBigInt();
620
+ while (header && slot(header) >= start) {
621
+ if (slot(header) <= end) {
622
+ blocks.push(header);
623
+ }
624
+ header = await this.getBlockHeader(--number);
625
+ }
626
+ return blocks.reverse();
627
+ }
628
+
615
629
  public async isEpochComplete(epochNumber: bigint): Promise<boolean> {
616
630
  // The epoch is complete if the current L2 block is the last one in the epoch (or later)
617
631
  const header = await this.getBlockHeader('latest');
@@ -715,17 +729,6 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
715
729
  return this.store.getLogsByTags(tags);
716
730
  }
717
731
 
718
- /**
719
- * Returns the provided nullifier indexes scoped to the block
720
- * they were first included in, or undefined if they're not present in the tree
721
- * @param blockNumber Max block number to search for the nullifiers
722
- * @param nullifiers Nullifiers to get
723
- * @returns The block scoped indexes of the provided nullifiers, or undefined if the nullifier doesn't exist in the tree
724
- */
725
- findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]> {
726
- return this.store.findNullifiersIndexesWithBlock(blockNumber, nullifiers);
727
- }
728
-
729
732
  /**
730
733
  * Gets public logs based on the provided filter.
731
734
  * @param filter - The filter to apply to the logs.
@@ -798,16 +801,6 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
798
801
  return this.store.getContractClassIds();
799
802
  }
800
803
 
801
- // TODO(#10007): Remove this method
802
- async addContractClass(contractClass: ContractClassPublic): Promise<void> {
803
- await this.store.addContractClasses(
804
- [contractClass],
805
- [await computePublicBytecodeCommitment(contractClass.packedBytecode)],
806
- 0,
807
- );
808
- return;
809
- }
810
-
811
804
  registerContractFunctionSignatures(address: AztecAddress, signatures: string[]): Promise<void> {
812
805
  return this.store.registerContractFunctionSignatures(address, signatures);
813
806
  }
@@ -874,8 +867,6 @@ class ArchiverStoreHelper
874
867
  ArchiverDataStore,
875
868
  | 'addLogs'
876
869
  | 'deleteLogs'
877
- | 'addNullifiers'
878
- | 'deleteNullifiers'
879
870
  | 'addContractClasses'
880
871
  | 'deleteContractClasses'
881
872
  | 'addContractInstances'
@@ -889,15 +880,6 @@ class ArchiverStoreHelper
889
880
 
890
881
  constructor(private readonly store: ArchiverDataStore) {}
891
882
 
892
- // TODO(#10007): Remove this method
893
- addContractClasses(
894
- contractClasses: ContractClassPublic[],
895
- bytecodeCommitments: Fr[],
896
- blockNum: number,
897
- ): Promise<boolean> {
898
- return this.store.addContractClasses(contractClasses, bytecodeCommitments, blockNum);
899
- }
900
-
901
883
  /**
902
884
  * Extracts and stores contract classes out of ContractClassRegistered events emitted by the class registerer contract.
903
885
  * @param allLogs - All logs emitted in a bunch of blocks.
@@ -1050,7 +1032,6 @@ class ArchiverStoreHelper
1050
1032
  ])
1051
1033
  ).every(Boolean);
1052
1034
  }),
1053
- this.store.addNullifiers(blocks.map(block => block.block)),
1054
1035
  this.store.addBlocks(blocks),
1055
1036
  ]);
1056
1037
 
@@ -1117,9 +1098,6 @@ class ArchiverStoreHelper
1117
1098
  getLogsByTags(tags: Fr[]): Promise<TxScopedL2Log[][]> {
1118
1099
  return this.store.getLogsByTags(tags);
1119
1100
  }
1120
- findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]> {
1121
- return this.store.findNullifiersIndexesWithBlock(blockNumber, nullifiers);
1122
- }
1123
1101
  getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
1124
1102
  return this.store.getPublicLogs(filter);
1125
1103
  }
@@ -88,23 +88,6 @@ export interface ArchiverDataStore {
88
88
  addLogs(blocks: L2Block[]): Promise<boolean>;
89
89
  deleteLogs(blocks: L2Block[]): Promise<boolean>;
90
90
 
91
- /**
92
- * Append new nullifiers to the store's list.
93
- * @param blocks - The blocks for which to add the nullifiers.
94
- * @returns True if the operation is successful.
95
- */
96
- addNullifiers(blocks: L2Block[]): Promise<boolean>;
97
- deleteNullifiers(blocks: L2Block[]): Promise<boolean>;
98
-
99
- /**
100
- * Returns the provided nullifier indexes scoped to the block
101
- * they were first included in, or undefined if they're not present in the tree
102
- * @param blockNumber Max block number to search for the nullifiers
103
- * @param nullifiers Nullifiers to get
104
- * @returns The block scoped indexes of the provided nullifiers, or undefined if the nullifier doesn't exist in the tree
105
- */
106
- findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]>;
107
-
108
91
  /**
109
92
  * Append L1 to L2 messages to the store.
110
93
  * @param messages - The L1 to L2 messages to be added to the store and the last processed L1 block.
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  INITIAL_L2_BLOCK_NUM,
3
3
  L1_TO_L2_MSG_SUBTREE_HEIGHT,
4
- MAX_NULLIFIERS_PER_TX,
5
4
  PRIVATE_LOG_SIZE_IN_FIELDS,
6
5
  PUBLIC_LOG_DATA_SIZE_IN_FIELDS,
7
6
  } from '@aztec/constants';
@@ -776,58 +775,5 @@ export function describeArchiverDataStore(
776
775
  }
777
776
  });
778
777
  });
779
-
780
- describe('findNullifiersIndexesWithBlock', () => {
781
- let blocks: L2Block[];
782
- const numBlocks = 10;
783
- const nullifiersPerBlock = new Map<number, Fr[]>();
784
-
785
- beforeEach(async () => {
786
- blocks = await timesParallel(numBlocks, (index: number) => L2Block.random(index + 1, 1));
787
-
788
- blocks.forEach((block, blockIndex) => {
789
- nullifiersPerBlock.set(
790
- blockIndex,
791
- block.body.txEffects.flatMap(txEffect => txEffect.nullifiers),
792
- );
793
- });
794
- });
795
-
796
- it('returns wrapped nullifiers with blocks if they exist', async () => {
797
- await store.addNullifiers(blocks);
798
- const nullifiersToRetrieve = [...nullifiersPerBlock.get(0)!, ...nullifiersPerBlock.get(5)!, Fr.random()];
799
- const blockScopedNullifiers = await store.findNullifiersIndexesWithBlock(10, nullifiersToRetrieve);
800
-
801
- expect(blockScopedNullifiers).toHaveLength(nullifiersToRetrieve.length);
802
- const [undefinedNullifier] = blockScopedNullifiers.slice(-1);
803
- const realNullifiers = blockScopedNullifiers.slice(0, -1);
804
- realNullifiers.forEach((blockScopedNullifier, index) => {
805
- expect(blockScopedNullifier).not.toBeUndefined();
806
- const { data, l2BlockNumber } = blockScopedNullifier!;
807
- expect(data).toEqual(expect.any(BigInt));
808
- expect(l2BlockNumber).toEqual(index < MAX_NULLIFIERS_PER_TX ? 1 : 6);
809
- });
810
- expect(undefinedNullifier).toBeUndefined();
811
- });
812
-
813
- it('returns wrapped nullifiers filtering by blockNumber', async () => {
814
- await store.addNullifiers(blocks);
815
- const nullifiersToRetrieve = [...nullifiersPerBlock.get(0)!, ...nullifiersPerBlock.get(5)!];
816
- const blockScopedNullifiers = await store.findNullifiersIndexesWithBlock(5, nullifiersToRetrieve);
817
-
818
- expect(blockScopedNullifiers).toHaveLength(nullifiersToRetrieve.length);
819
- const undefinedNullifiers = blockScopedNullifiers.slice(-MAX_NULLIFIERS_PER_TX);
820
- const realNullifiers = blockScopedNullifiers.slice(0, -MAX_NULLIFIERS_PER_TX);
821
- realNullifiers.forEach(blockScopedNullifier => {
822
- expect(blockScopedNullifier).not.toBeUndefined();
823
- const { data, l2BlockNumber } = blockScopedNullifier!;
824
- expect(data).toEqual(expect.any(BigInt));
825
- expect(l2BlockNumber).toEqual(1);
826
- });
827
- undefinedNullifiers.forEach(undefinedNullifier => {
828
- expect(undefinedNullifier).toBeUndefined();
829
- });
830
- });
831
- });
832
778
  });
833
779
  }
@@ -40,6 +40,9 @@ export type ArchiverConfig = {
40
40
 
41
41
  /** The max number of logs that can be obtained in 1 "getPublicLogs" call. */
42
42
  maxLogs?: number;
43
+
44
+ /** The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKB. */
45
+ archiverStoreMapSizeKb?: number;
43
46
  } & L1ReaderConfig &
44
47
  L1ContractsConfig &
45
48
  BlobSinkConfig &
@@ -72,6 +75,11 @@ export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
72
75
  description: 'The max number of logs that can be obtained in 1 "getPublicLogs" call.',
73
76
  ...numberConfigHelper(1_000),
74
77
  },
78
+ archiverStoreMapSizeKb: {
79
+ env: 'ARCHIVER_STORE_MAP_SIZE_KB',
80
+ parseEnv: (val: string | undefined) => (val ? +val : undefined),
81
+ description: 'The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKB.',
82
+ },
75
83
  ...chainConfigMappings,
76
84
  ...l1ReaderConfigMappings,
77
85
  viemPollingIntervalMS: {
@@ -203,7 +203,7 @@ async function getBlockFromRollupTx(
203
203
  publicClient: ViemPublicClient,
204
204
  blobSinkClient: BlobSinkClientInterface,
205
205
  txHash: `0x${string}`,
206
- blobHashes: Buffer[], // WORKTODO(md): buffer32?
206
+ blobHashes: Buffer[], // TODO(md): buffer32?
207
207
  l2BlockNum: bigint,
208
208
  rollupAddress: Hex,
209
209
  logger: Logger,
@@ -1,7 +1,6 @@
1
1
  export * from './archiver.js';
2
2
  export * from './config.js';
3
3
  export { type PublishedL2Block, type L1PublishedData } from './structs/published.js';
4
- export { MemoryArchiverStore } from './memory_archiver_store/memory_archiver_store.js';
5
4
  export type { ArchiverDataStore } from './archiver_store.js';
6
5
  export { KVArchiverDataStore } from './kv_archiver_store/kv_archiver_store.js';
7
6
  export { ContractInstanceStore } from './kv_archiver_store/contract_instance_store.js';
@@ -4,7 +4,7 @@ import { createLogger } from '@aztec/foundation/log';
4
4
  import type { AztecAsyncKVStore, StoreSize } from '@aztec/kv-store';
5
5
  import { FunctionSelector } from '@aztec/stdlib/abi';
6
6
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
- import type { InBlock, L2Block } from '@aztec/stdlib/block';
7
+ import type { L2Block } from '@aztec/stdlib/block';
8
8
  import type {
9
9
  ContractClassPublic,
10
10
  ContractInstanceUpdateWithAddress,
@@ -25,7 +25,6 @@ import { ContractClassStore } from './contract_class_store.js';
25
25
  import { ContractInstanceStore } from './contract_instance_store.js';
26
26
  import { LogStore } from './log_store.js';
27
27
  import { MessageStore } from './message_store.js';
28
- import { NullifierStore } from './nullifier_store.js';
29
28
 
30
29
  /**
31
30
  * LMDB implementation of the ArchiverDataStore interface.
@@ -35,7 +34,6 @@ export class KVArchiverDataStore implements ArchiverDataStore {
35
34
 
36
35
  #blockStore: BlockStore;
37
36
  #logStore: LogStore;
38
- #nullifierStore: NullifierStore;
39
37
  #messageStore: MessageStore;
40
38
  #contractClassStore: ContractClassStore;
41
39
  #contractInstanceStore: ContractInstanceStore;
@@ -49,7 +47,6 @@ export class KVArchiverDataStore implements ArchiverDataStore {
49
47
  this.#messageStore = new MessageStore(db);
50
48
  this.#contractClassStore = new ContractClassStore(db);
51
49
  this.#contractInstanceStore = new ContractInstanceStore(db);
52
- this.#nullifierStore = new NullifierStore(db);
53
50
  }
54
51
 
55
52
  // TODO: These function names are in memory only as they are for development/debugging. They require the full contract
@@ -215,23 +212,6 @@ export class KVArchiverDataStore implements ArchiverDataStore {
215
212
  return this.#logStore.deleteLogs(blocks);
216
213
  }
217
214
 
218
- /**
219
- * Append new nullifiers to the store's list.
220
- * @param blocks - The blocks for which to add the nullifiers.
221
- * @returns True if the operation is successful.
222
- */
223
- addNullifiers(blocks: L2Block[]): Promise<boolean> {
224
- return this.#nullifierStore.addNullifiers(blocks);
225
- }
226
-
227
- deleteNullifiers(blocks: L2Block[]): Promise<boolean> {
228
- return this.#nullifierStore.deleteNullifiers(blocks);
229
- }
230
-
231
- findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]> {
232
- return this.#nullifierStore.findNullifiersIndexesWithBlock(blockNumber, nullifiers);
233
- }
234
-
235
215
  getTotalL1ToL2MessageCount(): Promise<bigint> {
236
216
  return this.#messageStore.getTotalL1ToL2MessageCount();
237
217
  }
@@ -158,6 +158,7 @@ export class LogStore {
158
158
  this.#privateLogsByBlock.delete(block.number),
159
159
  this.#publicLogsByBlock.delete(block.number),
160
160
  this.#logTagsByBlock.delete(block.number),
161
+ this.#contractClassLogsByBlock.delete(block.number),
161
162
  ]),
162
163
  ),
163
164
  );
package/src/factory.ts CHANGED
@@ -2,18 +2,12 @@ import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
2
2
  import { createLogger } from '@aztec/foundation/log';
3
3
  import type { DataStoreConfig } from '@aztec/kv-store/config';
4
4
  import { createStore } from '@aztec/kv-store/lmdb-v2';
5
- import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
6
- import { TokenBridgeContractArtifact } from '@aztec/noir-contracts.js/TokenBridge';
7
5
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
8
6
  import { protocolContractNames, protocolContractTreeRoot } from '@aztec/protocol-contracts';
9
7
  import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
10
8
  import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
11
9
  import type { L2BlockSourceEventEmitter } from '@aztec/stdlib/block';
12
- import {
13
- type ContractClassPublic,
14
- computePublicBytecodeCommitment,
15
- getContractClassFromArtifact,
16
- } from '@aztec/stdlib/contract';
10
+ import { type ContractClassPublic, computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
17
11
  import type { ArchiverApi, Service } from '@aztec/stdlib/interfaces/server';
18
12
  import { getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
19
13
  import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
@@ -32,11 +26,12 @@ import { createArchiverClient } from './rpc/index.js';
32
26
  * @returns The local archiver.
33
27
  */
34
28
  export async function createArchiver(
35
- config: ArchiverConfig & DataStoreConfig,
29
+ _config: ArchiverConfig & DataStoreConfig,
36
30
  blobSinkClient: BlobSinkClientInterface,
37
31
  opts: { blockUntilSync: boolean } = { blockUntilSync: true },
38
32
  telemetry: TelemetryClient = getTelemetryClient(),
39
33
  ): Promise<ArchiverApi & Service & L2BlockSourceEventEmitter> {
34
+ const config = { ..._config, dataStoreMapSizeKB: _config.archiverStoreMapSizeKb ?? _config.dataStoreMapSizeKB };
40
35
  const store = await createStore(
41
36
  'archiver',
42
37
  KVArchiverDataStore.SCHEMA_VERSION,
@@ -45,7 +40,6 @@ export async function createArchiver(
45
40
  );
46
41
  const archiverStore = new KVArchiverDataStore(store, config.maxLogs);
47
42
  await registerProtocolContracts(archiverStore);
48
- await registerCommonContracts(archiverStore);
49
43
  return Archiver.createAndSync(config, archiverStore, { telemetry, blobSinkClient }, opts.blockUntilSync);
50
44
  }
51
45
 
@@ -86,22 +80,3 @@ async function registerProtocolContracts(store: KVArchiverDataStore) {
86
80
  await store.addContractInstances([contract.instance], blockNumber);
87
81
  }
88
82
  }
89
-
90
- // TODO(#10007): Remove this method. We are explicitly registering these contracts
91
- // here to ensure they are available to all nodes and all prover nodes, since the PXE
92
- // was tweaked to automatically push contract classes to the node it is registered,
93
- // but other nodes in the network may require the contract classes to be registered as well.
94
- // TODO(#10007): Remove the dependency on noir-contracts.js from this package once we remove this.
95
- async function registerCommonContracts(store: KVArchiverDataStore) {
96
- const blockNumber = 0;
97
- const artifacts = [TokenBridgeContractArtifact, TokenContractArtifact];
98
- const classes = await Promise.all(
99
- artifacts.map(async artifact => ({
100
- ...(await getContractClassFromArtifact(artifact)),
101
- privateFunctions: [],
102
- unconstrainedFunctions: [],
103
- })),
104
- );
105
- const bytecodeCommitments = await Promise.all(classes.map(x => computePublicBytecodeCommitment(x.packedBytecode)));
106
- await store.addContractClasses(classes, bytecodeCommitments, blockNumber);
107
- }
@@ -118,6 +118,10 @@ export class MockL2BlockSource implements L2BlockSource {
118
118
  return Promise.resolve(blocks);
119
119
  }
120
120
 
121
+ getBlockHeadersForEpoch(epochNumber: bigint): Promise<BlockHeader[]> {
122
+ return this.getBlocksForEpoch(epochNumber).then(blocks => blocks.map(b => b.header));
123
+ }
124
+
121
125
  /**
122
126
  * Gets a tx effect.
123
127
  * @param txHash - The hash of a transaction which resulted in the returned tx effect.