@aztec/archiver 0.80.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 (54) hide show
  1. package/dest/archiver/archiver.d.ts +8 -20
  2. package/dest/archiver/archiver.d.ts.map +1 -1
  3. package/dest/archiver/archiver.js +72 -102
  4. package/dest/archiver/archiver_store.d.ts +5 -19
  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 +105 -142
  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/data_retrieval.d.ts +3 -4
  12. package/dest/archiver/data_retrieval.d.ts.map +1 -1
  13. package/dest/archiver/data_retrieval.js +8 -3
  14. package/dest/archiver/index.d.ts +1 -2
  15. package/dest/archiver/index.d.ts.map +1 -1
  16. package/dest/archiver/index.js +0 -1
  17. package/dest/archiver/kv_archiver_store/block_store.d.ts +6 -6
  18. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
  19. package/dest/archiver/kv_archiver_store/block_store.js +24 -21
  20. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +6 -14
  21. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
  22. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +2 -19
  23. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
  24. package/dest/archiver/kv_archiver_store/log_store.js +11 -42
  25. package/dest/archiver/structs/published.d.ts +1 -10
  26. package/dest/archiver/structs/published.d.ts.map +1 -1
  27. package/dest/archiver/structs/published.js +1 -1
  28. package/dest/factory.d.ts +1 -1
  29. package/dest/factory.d.ts.map +1 -1
  30. package/dest/factory.js +6 -24
  31. package/dest/test/mock_l2_block_source.d.ts +10 -0
  32. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  33. package/dest/test/mock_l2_block_source.js +16 -0
  34. package/package.json +12 -13
  35. package/src/archiver/archiver.ts +86 -124
  36. package/src/archiver/archiver_store.ts +5 -21
  37. package/src/archiver/archiver_store_test_suite.ts +116 -147
  38. package/src/archiver/config.ts +8 -0
  39. package/src/archiver/data_retrieval.ts +12 -11
  40. package/src/archiver/index.ts +1 -2
  41. package/src/archiver/kv_archiver_store/block_store.ts +28 -27
  42. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +6 -27
  43. package/src/archiver/kv_archiver_store/log_store.ts +12 -59
  44. package/src/archiver/structs/published.ts +1 -11
  45. package/src/factory.ts +3 -28
  46. package/src/test/mock_l2_block_source.ts +18 -0
  47. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
  48. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
  49. package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
  50. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
  51. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
  52. package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -636
  53. package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
  54. package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
@@ -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,14 +25,12 @@ 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,
32
31
  type ContractDataSource,
33
32
  type ContractInstanceWithAddress,
34
33
  type ExecutablePrivateFunctionWithMembershipProof,
35
- type PublicFunction,
36
34
  type UnconstrainedFunctionWithMembershipProof,
37
35
  computePublicBytecodeCommitment,
38
36
  isValidPrivateFunctionMembershipProof,
@@ -63,16 +61,12 @@ import { retrieveBlocksFromRollup, retrieveL1ToL2Messages } from './data_retriev
63
61
  import { NoBlobBodiesFoundError } from './errors.js';
64
62
  import { ArchiverInstrumentation } from './instrumentation.js';
65
63
  import type { DataRetrieval } from './structs/data_retrieval.js';
66
- import type { L1Published } from './structs/published.js';
64
+ import type { PublishedL2Block } from './structs/published.js';
67
65
 
68
66
  /**
69
67
  * Helper interface to combine all sources this archiver implementation provides.
70
68
  */
71
- export type ArchiveSource = L2BlockSource &
72
- L2LogsSource &
73
- ContractDataSource &
74
- L1ToL2MessageSource &
75
- NullifierWithBlockSource;
69
+ export type ArchiveSource = L2BlockSource & L2LogsSource & ContractDataSource & L1ToL2MessageSource;
76
70
 
77
71
  /**
78
72
  * Pulls L2 blocks in a non-blocking manner and provides interface for their retrieval.
@@ -85,7 +79,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
85
79
  */
86
80
  private runningPromise?: RunningPromise;
87
81
 
88
- private rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>;
82
+ private rollup: RollupContract;
89
83
  private inbox: GetContractReturnType<typeof InboxAbi, ViemPublicClient>;
90
84
 
91
85
  private store: ArchiverStoreHelper;
@@ -120,11 +114,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
120
114
  this.tracer = instrumentation.tracer;
121
115
  this.store = new ArchiverStoreHelper(dataStore);
122
116
 
123
- this.rollup = getContract({
124
- address: l1Addresses.rollupAddress.toString(),
125
- abi: RollupAbi,
126
- client: publicClient,
127
- });
117
+ this.rollup = new RollupContract(publicClient, l1Addresses.rollupAddress);
128
118
 
129
119
  this.inbox = getContract({
130
120
  address: l1Addresses.inboxAddress.toString(),
@@ -153,15 +143,11 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
153
143
  pollingInterval: config.viemPollingIntervalMS,
154
144
  });
155
145
 
156
- const rollup = getContract({
157
- address: config.l1Contracts.rollupAddress.toString(),
158
- abi: RollupAbi,
159
- client: publicClient,
160
- });
146
+ const rollup = new RollupContract(publicClient, config.l1Contracts.rollupAddress);
161
147
 
162
148
  const [l1StartBlock, l1GenesisTime] = await Promise.all([
163
- rollup.read.L1_BLOCK_AT_GENESIS(),
164
- rollup.read.getGenesisTime(),
149
+ rollup.getL1StartBlock(),
150
+ rollup.getL1GenesisTime(),
165
151
  ] as const);
166
152
 
167
153
  const { aztecEpochDuration: epochDuration, aztecSlotDuration: slotDuration, ethereumSlotDuration } = config;
@@ -307,7 +293,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
307
293
  /** Queries the rollup contract on whether a prune can be executed on the immediatenext L1 block. */
308
294
  private async canPrune(currentL1BlockNumber: bigint, currentL1Timestamp: bigint) {
309
295
  const time = (currentL1Timestamp ?? 0n) + BigInt(this.l1constants.ethereumSlotDuration);
310
- return await this.rollup.read.canPruneAtTime([time], { blockNumber: currentL1BlockNumber });
296
+ return await this.rollup.canPruneAtTime(time, { blockNumber: currentL1BlockNumber });
311
297
  }
312
298
 
313
299
  /** Checks if there'd be a reorg for the next block submission and start pruning now. */
@@ -395,7 +381,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
395
381
  ): Promise<{ provenBlockNumber: bigint }> {
396
382
  const localPendingBlockNumber = BigInt(await this.getBlockNumber());
397
383
  const [provenBlockNumber, provenArchive, pendingBlockNumber, pendingArchive, archiveForLocalPendingBlockNumber] =
398
- await this.rollup.read.status([localPendingBlockNumber], { blockNumber: currentL1BlockNumber });
384
+ await this.rollup.status(localPendingBlockNumber, { blockNumber: currentL1BlockNumber });
399
385
 
400
386
  const updateProvenBlock = async () => {
401
387
  const localBlockForDestinationProvenBlockNumber = await this.getBlock(Number(provenBlockNumber));
@@ -429,7 +415,9 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
429
415
  const noBlocks = localPendingBlockNumber === 0n && pendingBlockNumber === 0n;
430
416
  if (noBlocks) {
431
417
  await this.store.setBlockSynchedL1BlockNumber(currentL1BlockNumber);
432
- 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
+ );
433
421
  return { provenBlockNumber };
434
422
  }
435
423
 
@@ -445,7 +433,14 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
445
433
 
446
434
  const noBlockSinceLast = localPendingBlock && pendingArchive === localPendingBlock.archive.root.toString();
447
435
  if (noBlockSinceLast) {
448
- 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);
449
444
  this.log.debug(`No blocks to retrieve from ${blocksSynchedTo + 1n} to ${currentL1BlockNumber}`);
450
445
  return { provenBlockNumber };
451
446
  }
@@ -465,7 +460,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
465
460
  break;
466
461
  }
467
462
 
468
- const archiveAtContract = await this.rollup.read.archiveAt([BigInt(candidateBlock.number)]);
463
+ const archiveAtContract = await this.rollup.archiveAt(BigInt(candidateBlock.number));
469
464
 
470
465
  if (archiveAtContract === candidateBlock.archive.root.toString()) {
471
466
  break;
@@ -484,7 +479,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
484
479
  }
485
480
  }
486
481
 
487
- // 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,
488
483
  // computed using the L2 block time vs the L1 block time.
489
484
  let searchStartBlock: bigint = blocksSynchedTo;
490
485
  let searchEndBlock: bigint = blocksSynchedTo;
@@ -494,9 +489,9 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
494
489
 
495
490
  this.log.trace(`Retrieving L2 blocks from L1 block ${searchStartBlock} to ${searchEndBlock}`);
496
491
 
497
- // 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
498
493
  const retrievedBlocks = await retrieveBlocksFromRollup(
499
- this.rollup,
494
+ this.rollup.getContract(),
500
495
  this.publicClient,
501
496
  this.blobSinkClient,
502
497
  searchStartBlock, // TODO(palla/reorg): If the L2 reorg was due to an L1 reorg, we need to start search earlier
@@ -517,26 +512,26 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
517
512
  );
518
513
 
519
514
  for (const block of retrievedBlocks) {
520
- this.log.debug(`Ingesting new L2 block ${block.data.number} with ${block.data.body.txEffects.length} txs`, {
521
- blockHash: block.data.hash(),
515
+ this.log.debug(`Ingesting new L2 block ${block.block.number} with ${block.block.body.txEffects.length} txs`, {
516
+ blockHash: block.block.hash(),
522
517
  l1BlockNumber: block.l1.blockNumber,
523
- ...block.data.header.globalVariables.toInspect(),
524
- ...block.data.getStats(),
518
+ ...block.block.header.globalVariables.toInspect(),
519
+ ...block.block.getStats(),
525
520
  });
526
521
  }
527
522
 
528
523
  const [processDuration] = await elapsed(() => this.store.addBlocks(retrievedBlocks));
529
524
  this.instrumentation.processNewBlocks(
530
525
  processDuration / retrievedBlocks.length,
531
- retrievedBlocks.map(b => b.data),
526
+ retrievedBlocks.map(b => b.block),
532
527
  );
533
528
 
534
529
  for (const block of retrievedBlocks) {
535
- this.log.info(`Downloaded L2 block ${block.data.number}`, {
536
- blockHash: block.data.hash(),
537
- blockNumber: block.data.number,
538
- txCount: block.data.body.txEffects.length,
539
- globalVariables: block.data.header.globalVariables.toInspect(),
530
+ this.log.info(`Downloaded L2 block ${block.block.number}`, {
531
+ blockHash: block.block.hash(),
532
+ blockNumber: block.block.number,
533
+ txCount: block.block.body.txEffects.length,
534
+ globalVariables: block.block.header.globalVariables.toInspect(),
540
535
  });
541
536
  }
542
537
  } while (searchEndBlock < currentL1BlockNumber);
@@ -613,6 +608,24 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
613
608
  return blocks.reverse();
614
609
  }
615
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
+
616
629
  public async isEpochComplete(epochNumber: bigint): Promise<boolean> {
617
630
  // The epoch is complete if the current L2 block is the last one in the epoch (or later)
618
631
  const header = await this.getBlockHeader('latest');
@@ -648,11 +661,16 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
648
661
  * @param proven - If true, only return blocks that have been proven.
649
662
  * @returns The requested L2 blocks.
650
663
  */
651
- public async getBlocks(from: number, limit: number, proven?: boolean): Promise<L2Block[]> {
664
+ public getBlocks(from: number, limit: number, proven?: boolean): Promise<L2Block[]> {
665
+ return this.getPublishedBlocks(from, limit, proven).then(blocks => blocks.map(b => b.block));
666
+ }
667
+
668
+ /** Equivalent to getBlocks but includes publish data. */
669
+ public async getPublishedBlocks(from: number, limit: number, proven?: boolean): Promise<PublishedL2Block[]> {
652
670
  const limitWithProven = proven
653
671
  ? Math.min(limit, Math.max((await this.store.getProvenL2BlockNumber()) - from + 1, 0))
654
672
  : limit;
655
- return limitWithProven === 0 ? [] : (await this.store.getBlocks(from, limitWithProven)).map(b => b.data);
673
+ return limitWithProven === 0 ? [] : await this.store.getBlocks(from, limitWithProven);
656
674
  }
657
675
 
658
676
  /**
@@ -669,7 +687,7 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
669
687
  return undefined;
670
688
  }
671
689
  const blocks = await this.store.getBlocks(number, 1);
672
- return blocks.length === 0 ? undefined : blocks[0].data;
690
+ return blocks.length === 0 ? undefined : blocks[0].block;
673
691
  }
674
692
 
675
693
  public async getBlockHeader(number: number | 'latest'): Promise<BlockHeader | undefined> {
@@ -691,29 +709,6 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
691
709
  return this.store.getSettledTxReceipt(txHash);
692
710
  }
693
711
 
694
- /**
695
- * Gets the public function data for a contract.
696
- * @param address - The contract address containing the function to fetch.
697
- * @param selector - The function selector of the function to fetch.
698
- * @returns The public function data (if found).
699
- */
700
- public async getPublicFunction(
701
- address: AztecAddress,
702
- selector: FunctionSelector,
703
- ): Promise<PublicFunction | undefined> {
704
- const instance = await this.getContract(address);
705
- if (!instance) {
706
- throw new Error(`Contract ${address.toString()} not found`);
707
- }
708
- const contractClass = await this.getContractClass(instance.currentContractClassId);
709
- if (!contractClass) {
710
- throw new Error(
711
- `Contract class ${instance.currentContractClassId.toString()} for ${address.toString()} not found`,
712
- );
713
- }
714
- return contractClass.publicFunctions.find(f => f.selector.equals(selector));
715
- }
716
-
717
712
  /**
718
713
  * Retrieves all private logs from up to `limit` blocks, starting from the block number `from`.
719
714
  * @param from - The block number from which to begin retrieving logs.
@@ -734,17 +729,6 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
734
729
  return this.store.getLogsByTags(tags);
735
730
  }
736
731
 
737
- /**
738
- * Returns the provided nullifier indexes scoped to the block
739
- * they were first included in, or undefined if they're not present in the tree
740
- * @param blockNumber Max block number to search for the nullifiers
741
- * @param nullifiers Nullifiers to get
742
- * @returns The block scoped indexes of the provided nullifiers, or undefined if the nullifier doesn't exist in the tree
743
- */
744
- findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]> {
745
- return this.store.findNullifiersIndexesWithBlock(blockNumber, nullifiers);
746
- }
747
-
748
732
  /**
749
733
  * Gets public logs based on the provided filter.
750
734
  * @param filter - The filter to apply to the logs.
@@ -788,8 +772,11 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
788
772
  return this.store.getBytecodeCommitment(id);
789
773
  }
790
774
 
791
- public getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
792
- return this.store.getContractInstance(address);
775
+ public async getContract(
776
+ address: AztecAddress,
777
+ blockNumber?: number,
778
+ ): Promise<ContractInstanceWithAddress | undefined> {
779
+ return this.store.getContractInstance(address, blockNumber ?? (await this.getBlockNumber()));
793
780
  }
794
781
 
795
782
  /**
@@ -814,16 +801,6 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
814
801
  return this.store.getContractClassIds();
815
802
  }
816
803
 
817
- // TODO(#10007): Remove this method
818
- async addContractClass(contractClass: ContractClassPublic): Promise<void> {
819
- await this.store.addContractClasses(
820
- [contractClass],
821
- [await computePublicBytecodeCommitment(contractClass.packedBytecode)],
822
- 0,
823
- );
824
- return;
825
- }
826
-
827
804
  registerContractFunctionSignatures(address: AztecAddress, signatures: string[]): Promise<void> {
828
805
  return this.store.registerContractFunctionSignatures(address, signatures);
829
806
  }
@@ -890,8 +867,6 @@ class ArchiverStoreHelper
890
867
  ArchiverDataStore,
891
868
  | 'addLogs'
892
869
  | 'deleteLogs'
893
- | 'addNullifiers'
894
- | 'deleteNullifiers'
895
870
  | 'addContractClasses'
896
871
  | 'deleteContractClasses'
897
872
  | 'addContractInstances'
@@ -905,15 +880,6 @@ class ArchiverStoreHelper
905
880
 
906
881
  constructor(private readonly store: ArchiverDataStore) {}
907
882
 
908
- // TODO(#10007): Remove this method
909
- addContractClasses(
910
- contractClasses: ContractClassPublic[],
911
- bytecodeCommitments: Fr[],
912
- blockNum: number,
913
- ): Promise<boolean> {
914
- return this.store.addContractClasses(contractClasses, bytecodeCommitments, blockNum);
915
- }
916
-
917
883
  /**
918
884
  * Extracts and stores contract classes out of ContractClassRegistered events emitted by the class registerer contract.
919
885
  * @param allLogs - All logs emitted in a bunch of blocks.
@@ -1048,25 +1014,24 @@ class ArchiverStoreHelper
1048
1014
  return true;
1049
1015
  }
1050
1016
 
1051
- async addBlocks(blocks: L1Published<L2Block>[]): Promise<boolean> {
1017
+ async addBlocks(blocks: PublishedL2Block[]): Promise<boolean> {
1052
1018
  const opResults = await Promise.all([
1053
- this.store.addLogs(blocks.map(block => block.data)),
1019
+ this.store.addLogs(blocks.map(block => block.block)),
1054
1020
  // Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
1055
1021
  ...blocks.map(async block => {
1056
- const contractClassLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.contractClassLogs);
1022
+ const contractClassLogs = block.block.body.txEffects.flatMap(txEffect => txEffect.contractClassLogs);
1057
1023
  // ContractInstanceDeployed event logs are broadcast in privateLogs.
1058
- const privateLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.privateLogs);
1059
- const publicLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.publicLogs);
1024
+ const privateLogs = block.block.body.txEffects.flatMap(txEffect => txEffect.privateLogs);
1025
+ const publicLogs = block.block.body.txEffects.flatMap(txEffect => txEffect.publicLogs);
1060
1026
  return (
1061
1027
  await Promise.all([
1062
- this.#updateRegisteredContractClasses(contractClassLogs, block.data.number, Operation.Store),
1063
- this.#updateDeployedContractInstances(privateLogs, block.data.number, Operation.Store),
1064
- this.#updateUpdatedContractInstances(publicLogs, block.data.number, Operation.Store),
1065
- this.#storeBroadcastedIndividualFunctions(contractClassLogs, block.data.number),
1028
+ this.#updateRegisteredContractClasses(contractClassLogs, block.block.number, Operation.Store),
1029
+ this.#updateDeployedContractInstances(privateLogs, block.block.number, Operation.Store),
1030
+ this.#updateUpdatedContractInstances(publicLogs, block.block.number, Operation.Store),
1031
+ this.#storeBroadcastedIndividualFunctions(contractClassLogs, block.block.number),
1066
1032
  ])
1067
1033
  ).every(Boolean);
1068
1034
  }),
1069
- this.store.addNullifiers(blocks.map(block => block.data)),
1070
1035
  this.store.addBlocks(blocks),
1071
1036
  ]);
1072
1037
 
@@ -1085,28 +1050,28 @@ class ArchiverStoreHelper
1085
1050
  const opResults = await Promise.all([
1086
1051
  // Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
1087
1052
  ...blocks.map(async block => {
1088
- const contractClassLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.contractClassLogs);
1053
+ const contractClassLogs = block.block.body.txEffects.flatMap(txEffect => txEffect.contractClassLogs);
1089
1054
  // ContractInstanceDeployed event logs are broadcast in privateLogs.
1090
- const privateLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.privateLogs);
1091
- const publicLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.publicLogs);
1055
+ const privateLogs = block.block.body.txEffects.flatMap(txEffect => txEffect.privateLogs);
1056
+ const publicLogs = block.block.body.txEffects.flatMap(txEffect => txEffect.publicLogs);
1092
1057
 
1093
1058
  return (
1094
1059
  await Promise.all([
1095
- this.#updateRegisteredContractClasses(contractClassLogs, block.data.number, Operation.Delete),
1096
- this.#updateDeployedContractInstances(privateLogs, block.data.number, Operation.Delete),
1097
- this.#updateUpdatedContractInstances(publicLogs, block.data.number, Operation.Delete),
1060
+ this.#updateRegisteredContractClasses(contractClassLogs, block.block.number, Operation.Delete),
1061
+ this.#updateDeployedContractInstances(privateLogs, block.block.number, Operation.Delete),
1062
+ this.#updateUpdatedContractInstances(publicLogs, block.block.number, Operation.Delete),
1098
1063
  ])
1099
1064
  ).every(Boolean);
1100
1065
  }),
1101
1066
 
1102
- this.store.deleteLogs(blocks.map(b => b.data)),
1067
+ this.store.deleteLogs(blocks.map(b => b.block)),
1103
1068
  this.store.unwindBlocks(from, blocksToUnwind),
1104
1069
  ]);
1105
1070
 
1106
1071
  return opResults.every(Boolean);
1107
1072
  }
1108
1073
 
1109
- getBlocks(from: number, limit: number): Promise<L1Published<L2Block>[]> {
1074
+ getBlocks(from: number, limit: number): Promise<PublishedL2Block[]> {
1110
1075
  return this.store.getBlocks(from, limit);
1111
1076
  }
1112
1077
  getBlockHeaders(from: number, limit: number): Promise<BlockHeader[]> {
@@ -1133,9 +1098,6 @@ class ArchiverStoreHelper
1133
1098
  getLogsByTags(tags: Fr[]): Promise<TxScopedL2Log[][]> {
1134
1099
  return this.store.getLogsByTags(tags);
1135
1100
  }
1136
- findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]> {
1137
- return this.store.findNullifiersIndexesWithBlock(blockNumber, nullifiers);
1138
- }
1139
1101
  getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
1140
1102
  return this.store.getPublicLogs(filter);
1141
1103
  }
@@ -1166,8 +1128,8 @@ class ArchiverStoreHelper
1166
1128
  getBytecodeCommitment(contractClassId: Fr): Promise<Fr | undefined> {
1167
1129
  return this.store.getBytecodeCommitment(contractClassId);
1168
1130
  }
1169
- getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
1170
- return this.store.getContractInstance(address);
1131
+ getContractInstance(address: AztecAddress, blockNumber: number): Promise<ContractInstanceWithAddress | undefined> {
1132
+ return this.store.getContractInstance(address, blockNumber);
1171
1133
  }
1172
1134
  getContractClassIds(): Promise<Fr[]> {
1173
1135
  return this.store.getContractClassIds();
@@ -15,7 +15,7 @@ import type { InboxLeaf } from '@aztec/stdlib/messaging';
15
15
  import { BlockHeader, type TxEffect, type TxHash, type TxReceipt } from '@aztec/stdlib/tx';
16
16
 
17
17
  import type { DataRetrieval } from './structs/data_retrieval.js';
18
- import type { L1Published } from './structs/published.js';
18
+ import type { PublishedL2Block } from './structs/published.js';
19
19
 
20
20
  /**
21
21
  * Represents the latest L1 block processed by the archiver for various objects in L2.
@@ -39,7 +39,7 @@ export interface ArchiverDataStore {
39
39
  * @param blocks - The L2 blocks to be added to the store and the last processed L1 block.
40
40
  * @returns True if the operation is successful.
41
41
  */
42
- addBlocks(blocks: L1Published<L2Block>[]): Promise<boolean>;
42
+ addBlocks(blocks: PublishedL2Block[]): Promise<boolean>;
43
43
 
44
44
  /**
45
45
  * Unwinds blocks from the database
@@ -56,7 +56,7 @@ export interface ArchiverDataStore {
56
56
  * @param limit - The number of blocks to return.
57
57
  * @returns The requested L2 blocks.
58
58
  */
59
- getBlocks(from: number, limit: number): Promise<L1Published<L2Block>[]>;
59
+ getBlocks(from: number, limit: number): Promise<PublishedL2Block[]>;
60
60
 
61
61
  /**
62
62
  * Gets up to `limit` amount of L2 block headers starting from `from`.
@@ -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.
@@ -244,8 +227,9 @@ export interface ArchiverDataStore {
244
227
  /**
245
228
  * Returns a contract instance given its address and the given block number, or undefined if not exists.
246
229
  * @param address - Address of the contract.
230
+ * @param blockNumber - Block number to get the contract instance at. Contract updates might change the instance at a given block.
247
231
  */
248
- getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
232
+ getContractInstance(address: AztecAddress, blockNumber: number): Promise<ContractInstanceWithAddress | undefined>;
249
233
 
250
234
  /** Returns the list of all class ids known by the archiver. */
251
235
  getContractClassIds(): Promise<Fr[]>;