@aztec/archiver 4.0.0-nightly.20260122 → 4.0.0-nightly.20260123

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 (41) hide show
  1. package/README.md +9 -0
  2. package/dest/archiver.d.ts +3 -3
  3. package/dest/archiver.d.ts.map +1 -1
  4. package/dest/archiver.js +9 -6
  5. package/dest/l1/bin/retrieve-calldata.js +2 -2
  6. package/dest/l1/data_retrieval.d.ts +1 -1
  7. package/dest/l1/data_retrieval.d.ts.map +1 -1
  8. package/dest/l1/data_retrieval.js +2 -2
  9. package/dest/modules/data_source_base.d.ts +14 -16
  10. package/dest/modules/data_source_base.d.ts.map +1 -1
  11. package/dest/modules/data_source_base.js +17 -51
  12. package/dest/modules/data_store_updater.d.ts +5 -5
  13. package/dest/modules/data_store_updater.d.ts.map +1 -1
  14. package/dest/modules/instrumentation.d.ts +3 -3
  15. package/dest/modules/instrumentation.d.ts.map +1 -1
  16. package/dest/store/block_store.d.ts +10 -10
  17. package/dest/store/block_store.d.ts.map +1 -1
  18. package/dest/store/block_store.js +2 -2
  19. package/dest/store/kv_archiver_store.d.ts +12 -12
  20. package/dest/store/kv_archiver_store.d.ts.map +1 -1
  21. package/dest/store/log_store.d.ts +4 -4
  22. package/dest/store/log_store.d.ts.map +1 -1
  23. package/dest/test/fake_l1_state.d.ts +4 -4
  24. package/dest/test/fake_l1_state.d.ts.map +1 -1
  25. package/dest/test/mock_l2_block_source.d.ts +16 -18
  26. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  27. package/dest/test/mock_l2_block_source.js +28 -36
  28. package/dest/test/mock_structs.js +4 -4
  29. package/package.json +13 -13
  30. package/src/archiver.ts +12 -11
  31. package/src/l1/bin/retrieve-calldata.ts +7 -2
  32. package/src/l1/data_retrieval.ts +3 -3
  33. package/src/modules/data_source_base.ts +20 -75
  34. package/src/modules/data_store_updater.ts +7 -7
  35. package/src/modules/instrumentation.ts +2 -2
  36. package/src/store/block_store.ts +17 -17
  37. package/src/store/kv_archiver_store.ts +11 -11
  38. package/src/store/log_store.ts +8 -8
  39. package/src/test/fake_l1_state.ts +2 -2
  40. package/src/test/mock_l2_block_source.ts +36 -56
  41. package/src/test/mock_structs.ts +4 -4
@@ -12,8 +12,8 @@ import {
12
12
  Body,
13
13
  CheckpointedL2Block,
14
14
  CommitteeAttestation,
15
+ L2Block,
15
16
  L2BlockHash,
16
- L2BlockNew,
17
17
  type ValidateCheckpointResult,
18
18
  deserializeValidateCheckpointResult,
19
19
  serializeValidateCheckpointResult,
@@ -146,7 +146,7 @@ export class BlockStore {
146
146
  * @param blocks - The L2 blocks to be added to the store.
147
147
  * @returns True if the operation is successful.
148
148
  */
149
- async addBlocks(blocks: L2BlockNew[], opts: { force?: boolean } = {}): Promise<boolean> {
149
+ async addBlocks(blocks: L2Block[], opts: { force?: boolean } = {}): Promise<boolean> {
150
150
  if (blocks.length === 0) {
151
151
  return true;
152
152
  }
@@ -199,7 +199,7 @@ export class BlockStore {
199
199
  }
200
200
 
201
201
  // Iterate over blocks array and insert them, checking that the block numbers and indexes are sequential. Also check they are for the correct checkpoint.
202
- let previousBlock: L2BlockNew | undefined = undefined;
202
+ let previousBlock: L2Block | undefined = undefined;
203
203
  for (const block of blocks) {
204
204
  if (!opts.force && previousBlock) {
205
205
  if (previousBlock.number + 1 !== block.number) {
@@ -258,7 +258,7 @@ export class BlockStore {
258
258
  }
259
259
 
260
260
  let previousBlockNumber: BlockNumber | undefined = undefined;
261
- let previousBlock: L2BlockNew | undefined = undefined;
261
+ let previousBlock: L2Block | undefined = undefined;
262
262
 
263
263
  // If we have a previous checkpoint then we need to get the previous block number
264
264
  if (previousCheckpointData !== undefined) {
@@ -339,7 +339,7 @@ export class BlockStore {
339
339
  });
340
340
  }
341
341
 
342
- private async addBlockToDatabase(block: L2BlockNew, checkpointNumber: number, indexWithinCheckpoint: number) {
342
+ private async addBlockToDatabase(block: L2Block, checkpointNumber: number, indexWithinCheckpoint: number) {
343
343
  const blockHash = L2BlockHash.fromField(await block.hash());
344
344
 
345
345
  await this.#blocks.set(block.number, {
@@ -368,7 +368,7 @@ export class BlockStore {
368
368
  }
369
369
 
370
370
  /** Deletes a block and all associated data (tx effects, indices). */
371
- private async deleteBlock(block: L2BlockNew): Promise<void> {
371
+ private async deleteBlock(block: L2Block): Promise<void> {
372
372
  // Delete the block from the main blocks map
373
373
  await this.#blocks.delete(block.number);
374
374
 
@@ -466,7 +466,7 @@ export class BlockStore {
466
466
  return data;
467
467
  }
468
468
 
469
- async getBlocksForCheckpoint(checkpointNumber: CheckpointNumber): Promise<L2BlockNew[] | undefined> {
469
+ async getBlocksForCheckpoint(checkpointNumber: CheckpointNumber): Promise<L2Block[] | undefined> {
470
470
  const checkpoint = await this.#checkpoints.getAsync(checkpointNumber);
471
471
  if (!checkpoint) {
472
472
  return undefined;
@@ -489,8 +489,8 @@ export class BlockStore {
489
489
  * @param slotNumber - The slot number to search for.
490
490
  * @returns All blocks with the given slot number, in ascending block number order.
491
491
  */
492
- async getBlocksForSlot(slotNumber: SlotNumber): Promise<L2BlockNew[]> {
493
- const blocks: L2BlockNew[] = [];
492
+ async getBlocksForSlot(slotNumber: SlotNumber): Promise<L2Block[]> {
493
+ const blocks: L2Block[] = [];
494
494
 
495
495
  // Iterate backwards through all blocks and filter by slot number
496
496
  // This is more efficient since we usually query for the most recent slot
@@ -513,9 +513,9 @@ export class BlockStore {
513
513
  * @param blockNumber - The block number to remove after.
514
514
  * @returns The removed blocks (for event emission).
515
515
  */
516
- async unwindBlocksAfter(blockNumber: BlockNumber): Promise<L2BlockNew[]> {
516
+ async unwindBlocksAfter(blockNumber: BlockNumber): Promise<L2Block[]> {
517
517
  return await this.db.transactionAsync(async () => {
518
- const removedBlocks: L2BlockNew[] = [];
518
+ const removedBlocks: L2Block[] = [];
519
519
 
520
520
  // Get the latest block number to determine the range
521
521
  const latestBlockNumber = await this.getLatestBlockNumber();
@@ -637,7 +637,7 @@ export class BlockStore {
637
637
  * @param limit - The number of blocks to return.
638
638
  * @returns The requested L2 blocks
639
639
  */
640
- async *getBlocks(start: BlockNumber, limit: number): AsyncIterableIterator<L2BlockNew> {
640
+ async *getBlocks(start: BlockNumber, limit: number): AsyncIterableIterator<L2Block> {
641
641
  for await (const [blockNumber, blockStorage] of this.getBlockStorages(start, limit)) {
642
642
  const block = await this.getBlockFromBlockStorage(blockNumber, blockStorage);
643
643
  if (block) {
@@ -651,7 +651,7 @@ export class BlockStore {
651
651
  * @param blockNumber - The number of the block to return.
652
652
  * @returns The requested L2 block.
653
653
  */
654
- async getBlock(blockNumber: BlockNumber): Promise<L2BlockNew | undefined> {
654
+ async getBlock(blockNumber: BlockNumber): Promise<L2Block | undefined> {
655
655
  const blockStorage = await this.#blocks.getAsync(blockNumber);
656
656
  if (!blockStorage || !blockStorage.header) {
657
657
  return Promise.resolve(undefined);
@@ -664,7 +664,7 @@ export class BlockStore {
664
664
  * @param blockHash - The hash of the block to return.
665
665
  * @returns The requested L2 block.
666
666
  */
667
- async getBlockByHash(blockHash: L2BlockHash): Promise<L2BlockNew | undefined> {
667
+ async getBlockByHash(blockHash: L2BlockHash): Promise<L2Block | undefined> {
668
668
  const blockNumber = await this.#blockHashIndex.getAsync(blockHash.toString());
669
669
  if (blockNumber === undefined) {
670
670
  return undefined;
@@ -677,7 +677,7 @@ export class BlockStore {
677
677
  * @param archive - The archive root of the block to return.
678
678
  * @returns The requested L2 block.
679
679
  */
680
- async getBlockByArchive(archive: Fr): Promise<L2BlockNew | undefined> {
680
+ async getBlockByArchive(archive: Fr): Promise<L2Block | undefined> {
681
681
  const blockNumber = await this.#blockArchiveIndex.getAsync(archive.toString());
682
682
  if (blockNumber === undefined) {
683
683
  return undefined;
@@ -753,7 +753,7 @@ export class BlockStore {
753
753
  private async getBlockFromBlockStorage(
754
754
  blockNumber: number,
755
755
  blockStorage: BlockStorage,
756
- ): Promise<L2BlockNew | undefined> {
756
+ ): Promise<L2Block | undefined> {
757
757
  const header = BlockHeader.fromBuffer(blockStorage.header);
758
758
  const archive = AppendOnlyTreeSnapshot.fromBuffer(blockStorage.archive);
759
759
  const blockHash = blockStorage.blockHash;
@@ -777,7 +777,7 @@ export class BlockStore {
777
777
  txEffects.push(deserializeIndexedTxEffect(txEffect).data);
778
778
  }
779
779
  const body = new Body(txEffects);
780
- const block = new L2BlockNew(
780
+ const block = new L2Block(
781
781
  archive,
782
782
  header,
783
783
  body,
@@ -6,7 +6,7 @@ import { createLogger } from '@aztec/foundation/log';
6
6
  import type { AztecAsyncKVStore, CustomRange, StoreSize } from '@aztec/kv-store';
7
7
  import { FunctionSelector } from '@aztec/stdlib/abi';
8
8
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
9
- import { CheckpointedL2Block, L2BlockHash, L2BlockNew, type ValidateCheckpointResult } from '@aztec/stdlib/block';
9
+ import { CheckpointedL2Block, L2Block, L2BlockHash, type ValidateCheckpointResult } from '@aztec/stdlib/block';
10
10
  import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
11
11
  import type {
12
12
  ContractClassPublic,
@@ -239,7 +239,7 @@ export class KVArchiverDataStore implements ContractDataSource {
239
239
  * @param blocks - The L2 blocks to be added to the store and the last processed L1 block.
240
240
  * @returns True if the operation is successful.
241
241
  */
242
- addBlocks(blocks: L2BlockNew[], opts: { force?: boolean; checkpointNumber?: number } = {}): Promise<boolean> {
242
+ addBlocks(blocks: L2Block[], opts: { force?: boolean; checkpointNumber?: number } = {}): Promise<boolean> {
243
243
  return this.#blockStore.addBlocks(blocks, opts);
244
244
  }
245
245
 
@@ -305,21 +305,21 @@ export class KVArchiverDataStore implements ContractDataSource {
305
305
  * Returns the block for the given number, or undefined if not exists.
306
306
  * @param number - The block number to return.
307
307
  */
308
- getBlock(number: BlockNumber): Promise<L2BlockNew | undefined> {
308
+ getBlock(number: BlockNumber): Promise<L2Block | undefined> {
309
309
  return this.#blockStore.getBlock(number);
310
310
  }
311
311
  /**
312
312
  * Returns the block for the given hash, or undefined if not exists.
313
313
  * @param blockHash - The block hash to return.
314
314
  */
315
- getBlockByHash(blockHash: Fr): Promise<L2BlockNew | undefined> {
315
+ getBlockByHash(blockHash: Fr): Promise<L2Block | undefined> {
316
316
  return this.#blockStore.getBlockByHash(L2BlockHash.fromField(blockHash));
317
317
  }
318
318
  /**
319
319
  * Returns the block for the given archive root, or undefined if not exists.
320
320
  * @param archive - The archive root to return.
321
321
  */
322
- getBlockByArchive(archive: Fr): Promise<L2BlockNew | undefined> {
322
+ getBlockByArchive(archive: Fr): Promise<L2Block | undefined> {
323
323
  return this.#blockStore.getBlockByArchive(archive);
324
324
  }
325
325
 
@@ -329,7 +329,7 @@ export class KVArchiverDataStore implements ContractDataSource {
329
329
  * @param limit - The number of blocks to return.
330
330
  * @returns The requested L2 blocks.
331
331
  */
332
- getBlocks(from: BlockNumber, limit: number): Promise<L2BlockNew[]> {
332
+ getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]> {
333
333
  return toArray(this.#blockStore.getBlocks(from, limit));
334
334
  }
335
335
 
@@ -392,11 +392,11 @@ export class KVArchiverDataStore implements ContractDataSource {
392
392
  * @param blocks - The blocks for which to add the logs.
393
393
  * @returns True if the operation is successful.
394
394
  */
395
- addLogs(blocks: L2BlockNew[]): Promise<boolean> {
395
+ addLogs(blocks: L2Block[]): Promise<boolean> {
396
396
  return this.#logStore.addLogs(blocks);
397
397
  }
398
398
 
399
- deleteLogs(blocks: L2BlockNew[]): Promise<boolean> {
399
+ deleteLogs(blocks: L2Block[]): Promise<boolean> {
400
400
  return this.#logStore.deleteLogs(blocks);
401
401
  }
402
402
 
@@ -605,7 +605,7 @@ export class KVArchiverDataStore implements ContractDataSource {
605
605
  * @param checkpointNumber Retrieves all blocks for the given checkpoint
606
606
  * @returns The collection of blocks for the requested checkpoint if available (undefined otherwise)
607
607
  */
608
- getBlocksForCheckpoint(checkpointNumber: CheckpointNumber): Promise<L2BlockNew[] | undefined> {
608
+ getBlocksForCheckpoint(checkpointNumber: CheckpointNumber): Promise<L2Block[] | undefined> {
609
609
  return this.#blockStore.getBlocksForCheckpoint(checkpointNumber);
610
610
  }
611
611
 
@@ -623,7 +623,7 @@ export class KVArchiverDataStore implements ContractDataSource {
623
623
  * @param slotNumber - The slot number to search for.
624
624
  * @returns All blocks with the given slot number.
625
625
  */
626
- getBlocksForSlot(slotNumber: SlotNumber): Promise<L2BlockNew[]> {
626
+ getBlocksForSlot(slotNumber: SlotNumber): Promise<L2Block[]> {
627
627
  return this.#blockStore.getBlocksForSlot(slotNumber);
628
628
  }
629
629
 
@@ -632,7 +632,7 @@ export class KVArchiverDataStore implements ContractDataSource {
632
632
  * @param blockNumber - The block number to remove after.
633
633
  * @returns The removed blocks (for event emission).
634
634
  */
635
- removeBlocksAfter(blockNumber: BlockNumber): Promise<L2BlockNew[]> {
635
+ removeBlocksAfter(blockNumber: BlockNumber): Promise<L2Block[]> {
636
636
  return this.#blockStore.unwindBlocksAfter(blockNumber);
637
637
  }
638
638
  }
@@ -6,7 +6,7 @@ import { createLogger } from '@aztec/foundation/log';
6
6
  import { BufferReader, numToUInt32BE } from '@aztec/foundation/serialize';
7
7
  import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
8
8
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
9
- import { L2BlockHash, L2BlockNew } from '@aztec/stdlib/block';
9
+ import { L2Block, L2BlockHash } from '@aztec/stdlib/block';
10
10
  import { MAX_LOGS_PER_TAG } from '@aztec/stdlib/interfaces/api-limit';
11
11
  import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
12
12
  import {
@@ -59,7 +59,7 @@ export class LogStore {
59
59
  * @param block - The L2 block to extract logs from.
60
60
  * @returns An object containing the private and public tagged logs for the block.
61
61
  */
62
- #extractTaggedLogsFromBlock(block: L2BlockNew) {
62
+ #extractTaggedLogsFromBlock(block: L2Block) {
63
63
  // SiloedTag (as string) -> array of log buffers.
64
64
  const privateTaggedLogs = new Map<string, Buffer[]>();
65
65
  // "{contractAddress}_{tag}" (as string) -> array of log buffers.
@@ -120,7 +120,7 @@ export class LogStore {
120
120
  * @returns A map from tag (as string) to an array of serialized private logs belonging to that tag, and a map from
121
121
  * "{contractAddress}_{tag}" (as string) to an array of serialized public logs belonging to that key.
122
122
  */
123
- #extractTaggedLogs(blocks: L2BlockNew[]): {
123
+ #extractTaggedLogs(blocks: L2Block[]): {
124
124
  privateTaggedLogs: Map<string, Buffer[]>;
125
125
  publicTaggedLogs: Map<string, Buffer[]>;
126
126
  } {
@@ -146,7 +146,7 @@ export class LogStore {
146
146
  return { privateTaggedLogs, publicTaggedLogs };
147
147
  }
148
148
 
149
- async #addPrivateLogs(blocks: L2BlockNew[]): Promise<void> {
149
+ async #addPrivateLogs(blocks: L2Block[]): Promise<void> {
150
150
  const newBlocks = await filterAsync(
151
151
  blocks,
152
152
  async block => !(await this.#privateLogKeysByBlock.hasAsync(block.number)),
@@ -181,7 +181,7 @@ export class LogStore {
181
181
  }
182
182
  }
183
183
 
184
- async #addPublicLogs(blocks: L2BlockNew[]): Promise<void> {
184
+ async #addPublicLogs(blocks: L2Block[]): Promise<void> {
185
185
  const newBlocks = await filterAsync(
186
186
  blocks,
187
187
  async block => !(await this.#publicLogKeysByBlock.hasAsync(block.number)),
@@ -229,7 +229,7 @@ export class LogStore {
229
229
  }
230
230
  }
231
231
 
232
- async #addContractClassLogs(blocks: L2BlockNew[]): Promise<void> {
232
+ async #addContractClassLogs(blocks: L2Block[]): Promise<void> {
233
233
  const newBlocks = await filterAsync(
234
234
  blocks,
235
235
  async block => !(await this.#contractClassLogsByBlock.hasAsync(block.number)),
@@ -260,7 +260,7 @@ export class LogStore {
260
260
  * @param blocks - The blocks for which to add the logs.
261
261
  * @returns True if the operation is successful.
262
262
  */
263
- addLogs(blocks: L2BlockNew[]): Promise<boolean> {
263
+ addLogs(blocks: L2Block[]): Promise<boolean> {
264
264
  return this.db.transactionAsync(async () => {
265
265
  await Promise.all([
266
266
  this.#addPrivateLogs(blocks),
@@ -285,7 +285,7 @@ export class LogStore {
285
285
  return L2BlockHash.fromField(blockHash);
286
286
  }
287
287
 
288
- deleteLogs(blocks: L2BlockNew[]): Promise<boolean> {
288
+ deleteLogs(blocks: L2Block[]): Promise<boolean> {
289
289
  return this.db.transactionAsync(async () => {
290
290
  await Promise.all(
291
291
  blocks.map(async block => {
@@ -10,7 +10,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
10
10
  import { EthAddress } from '@aztec/foundation/eth-address';
11
11
  import { createLogger } from '@aztec/foundation/log';
12
12
  import { RollupAbi } from '@aztec/l1-artifacts';
13
- import { CommitteeAttestation, CommitteeAttestationsAndSigners, L2BlockNew } from '@aztec/stdlib/block';
13
+ import { CommitteeAttestation, CommitteeAttestationsAndSigners, L2Block } from '@aztec/stdlib/block';
14
14
  import { Checkpoint } from '@aztec/stdlib/checkpoint';
15
15
  import { getSlotAtTimestamp } from '@aztec/stdlib/epoch-helpers';
16
16
  import { InboxLeaf } from '@aztec/stdlib/messaging';
@@ -51,7 +51,7 @@ type AddCheckpointOptions = {
51
51
  /** Number of L2 blocks in the checkpoint. Default: 1 */
52
52
  numBlocks?: number;
53
53
  /** Or the actual blocks for the checkpoint */
54
- blocks?: L2BlockNew[];
54
+ blocks?: L2Block[];
55
55
  /** Number of transactions per block. Default: 4 */
56
56
  txsPerBlock?: number;
57
57
  /** Max number of effects per tx (for generating large blobs). Default: undefined */
@@ -9,8 +9,8 @@ import type { FunctionSelector } from '@aztec/stdlib/abi';
9
9
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
10
10
  import {
11
11
  CheckpointedL2Block,
12
+ L2Block,
12
13
  L2BlockHash,
13
- L2BlockNew,
14
14
  type L2BlockSource,
15
15
  type L2Tips,
16
16
  type ValidateCheckpointResult,
@@ -25,7 +25,7 @@ import type { UInt64 } from '@aztec/stdlib/types';
25
25
  * A mocked implementation of L2BlockSource to be used in tests.
26
26
  */
27
27
  export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
28
- protected l2Blocks: L2BlockNew[] = [];
28
+ protected l2Blocks: L2Block[] = [];
29
29
 
30
30
  private provenBlockNumber: number = 0;
31
31
  private finalizedBlockNumber: number = 0;
@@ -36,14 +36,14 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
36
36
  public async createBlocks(numBlocks: number) {
37
37
  for (let i = 0; i < numBlocks; i++) {
38
38
  const blockNum = this.l2Blocks.length + 1;
39
- const block = await L2BlockNew.random(BlockNumber(blockNum), { slotNumber: SlotNumber(blockNum) });
39
+ const block = await L2Block.random(BlockNumber(blockNum), { slotNumber: SlotNumber(blockNum) });
40
40
  this.l2Blocks.push(block);
41
41
  }
42
42
 
43
43
  this.log.verbose(`Created ${numBlocks} blocks in the mock L2 block source`);
44
44
  }
45
45
 
46
- public addBlocks(blocks: L2BlockNew[]) {
46
+ public addBlocks(blocks: L2Block[]) {
47
47
  this.l2Blocks.push(...blocks);
48
48
  this.log.verbose(`Added ${blocks.length} blocks to the mock L2 block source`);
49
49
  }
@@ -113,7 +113,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
113
113
  return Promise.resolve(undefined);
114
114
  }
115
115
  const checkpointedBlock = new CheckpointedL2Block(
116
- CheckpointNumber(number),
116
+ CheckpointNumber.fromBlockNumber(number),
117
117
  block,
118
118
  new L1PublishedData(BigInt(number), BigInt(number), `0x${number.toString(16).padStart(64, '0')}`),
119
119
  [],
@@ -121,11 +121,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
121
121
  return Promise.resolve(checkpointedBlock);
122
122
  }
123
123
 
124
- public async getCheckpointedBlocks(
125
- from: BlockNumber,
126
- limit: number,
127
- _proven?: boolean,
128
- ): Promise<CheckpointedL2Block[]> {
124
+ public async getCheckpointedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]> {
129
125
  const result: CheckpointedL2Block[] = [];
130
126
  for (let i = 0; i < limit; i++) {
131
127
  const blockNum = from + i;
@@ -145,7 +141,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
145
141
  * @param number - The block number to return (inclusive).
146
142
  * @returns The requested L2 block.
147
143
  */
148
- public getBlock(number: number): Promise<L2BlockNew | undefined> {
144
+ public getBlock(number: number): Promise<L2Block | undefined> {
149
145
  const block = this.l2Blocks[number - 1];
150
146
  return Promise.resolve(block);
151
147
  }
@@ -155,7 +151,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
155
151
  * @param number - The block number to return.
156
152
  * @returns The requested L2 block.
157
153
  */
158
- public getL2BlockNew(number: BlockNumber): Promise<L2BlockNew | undefined> {
154
+ public getL2Block(number: BlockNumber): Promise<L2Block | undefined> {
159
155
  const block = this.l2Blocks[number - 1];
160
156
  return Promise.resolve(block);
161
157
  }
@@ -166,20 +162,16 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
166
162
  * @param limit - The maximum number of blocks to return.
167
163
  * @returns The requested mocked L2 blocks.
168
164
  */
169
- public getBlocks(from: number, limit: number, proven?: boolean): Promise<L2BlockNew[]> {
170
- return Promise.resolve(
171
- this.l2Blocks
172
- .slice(from - 1, from - 1 + limit)
173
- .filter(b => !proven || this.provenBlockNumber === undefined || b.number <= this.provenBlockNumber),
174
- );
165
+ public getBlocks(from: number, limit: number): Promise<L2Block[]> {
166
+ return Promise.resolve(this.l2Blocks.slice(from - 1, from - 1 + limit));
175
167
  }
176
168
 
177
- public getPublishedCheckpoints(from: CheckpointNumber, limit: number) {
169
+ public getCheckpoints(from: CheckpointNumber, limit: number) {
178
170
  // TODO(mbps): Implement this properly. This only works when we have one block per checkpoint.
179
171
  const blocks = this.l2Blocks.slice(from - 1, from - 1 + limit);
180
172
  return Promise.all(
181
173
  blocks.map(async block => {
182
- // Create a checkpoint from the block - manually construct since L2BlockNew doesn't have toCheckpoint()
174
+ // Create a checkpoint from the block - manually construct since L2Block doesn't have toCheckpoint()
183
175
  const checkpoint = await Checkpoint.random(block.checkpointNumber, { numBlocks: 1 });
184
176
  checkpoint.blocks = [block];
185
177
  return new PublishedCheckpoint(
@@ -197,39 +189,18 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
197
189
  if (!block) {
198
190
  return undefined;
199
191
  }
200
- // Create a checkpoint from the block - manually construct since L2BlockNew doesn't have toCheckpoint()
192
+ // Create a checkpoint from the block - manually construct since L2Block doesn't have toCheckpoint()
201
193
  const checkpoint = await Checkpoint.random(block.checkpointNumber, { numBlocks: 1 });
202
194
  checkpoint.blocks = [block];
203
195
  return checkpoint;
204
196
  }
205
197
 
206
- public getPublishedBlocks(from: number, limit: number, proven?: boolean): Promise<CheckpointedL2Block[]> {
207
- const blocks = this.l2Blocks
208
- .slice(from - 1, from - 1 + limit)
209
- .filter(b => !proven || this.provenBlockNumber === undefined || b.number <= this.provenBlockNumber);
210
- return Promise.resolve(
211
- blocks.map(block =>
212
- CheckpointedL2Block.fromFields({
213
- checkpointNumber: CheckpointNumber(block.number),
214
- block,
215
- l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
216
- attestations: [],
217
- }),
218
- ),
219
- );
220
- }
221
-
222
- getL2BlocksNew(from: BlockNumber, limit: number, proven?: boolean): Promise<L2BlockNew[]> {
223
- // getBlocks already returns L2BlockNew[], so just return directly
224
- return this.getBlocks(from, limit, proven);
225
- }
226
-
227
- public async getPublishedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined> {
198
+ public async getCheckpointedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined> {
228
199
  for (const block of this.l2Blocks) {
229
200
  const hash = await block.hash();
230
201
  if (hash.equals(blockHash)) {
231
202
  return CheckpointedL2Block.fromFields({
232
- checkpointNumber: CheckpointNumber(block.number),
203
+ checkpointNumber: CheckpointNumber.fromBlockNumber(block.number),
233
204
  block,
234
205
  l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
235
206
  attestations: [],
@@ -239,14 +210,14 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
239
210
  return undefined;
240
211
  }
241
212
 
242
- public getPublishedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined> {
213
+ public getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined> {
243
214
  const block = this.l2Blocks.find(b => b.archive.root.equals(archive));
244
215
  if (!block) {
245
216
  return Promise.resolve(undefined);
246
217
  }
247
218
  return Promise.resolve(
248
219
  CheckpointedL2Block.fromFields({
249
- checkpointNumber: CheckpointNumber(block.number),
220
+ checkpointNumber: CheckpointNumber.fromBlockNumber(block.number),
250
221
  block,
251
222
  l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
252
223
  attestations: [],
@@ -254,7 +225,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
254
225
  );
255
226
  }
256
227
 
257
- public async getL2BlockNewByHash(blockHash: Fr): Promise<L2BlockNew | undefined> {
228
+ public async getL2BlockByHash(blockHash: Fr): Promise<L2Block | undefined> {
258
229
  for (const block of this.l2Blocks) {
259
230
  const hash = await block.hash();
260
231
  if (hash.equals(blockHash)) {
@@ -264,7 +235,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
264
235
  return undefined;
265
236
  }
266
237
 
267
- public getL2BlockNewByArchive(archive: Fr): Promise<L2BlockNew | undefined> {
238
+ public getL2BlockByArchive(archive: Fr): Promise<L2Block | undefined> {
268
239
  const block = this.l2Blocks.find(b => b.archive.root.equals(archive));
269
240
  return Promise.resolve(block);
270
241
  }
@@ -296,7 +267,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
296
267
  const slot = b.header.globalVariables.slotNumber;
297
268
  return slot >= start && slot <= end;
298
269
  });
299
- // Create checkpoints from blocks - manually construct since L2BlockNew doesn't have toCheckpoint()
270
+ // Create checkpoints from blocks - manually construct since L2Block doesn't have toCheckpoint()
300
271
  return Promise.all(
301
272
  blocks.map(async block => {
302
273
  const checkpoint = await Checkpoint.random(block.checkpointNumber, { numBlocks: 1 });
@@ -306,24 +277,33 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
306
277
  );
307
278
  }
308
279
 
309
- getBlocksForEpoch(epochNumber: EpochNumber): Promise<L2BlockNew[]> {
280
+ getCheckpointedBlocksForEpoch(epochNumber: EpochNumber): Promise<CheckpointedL2Block[]> {
310
281
  const epochDuration = DefaultL1ContractsConfig.aztecEpochDuration;
311
282
  const [start, end] = getSlotRangeForEpoch(epochNumber, { epochDuration });
312
283
  const blocks = this.l2Blocks.filter(b => {
313
284
  const slot = b.header.globalVariables.slotNumber;
314
285
  return slot >= start && slot <= end;
315
286
  });
316
- return Promise.resolve(blocks);
287
+ return Promise.resolve(
288
+ blocks.map(block =>
289
+ CheckpointedL2Block.fromFields({
290
+ checkpointNumber: CheckpointNumber.fromBlockNumber(block.number),
291
+ block,
292
+ l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
293
+ attestations: [],
294
+ }),
295
+ ),
296
+ );
317
297
  }
318
298
 
319
- getBlocksForSlot(slotNumber: SlotNumber): Promise<L2BlockNew[]> {
299
+ getBlocksForSlot(slotNumber: SlotNumber): Promise<L2Block[]> {
320
300
  const blocks = this.l2Blocks.filter(b => b.header.globalVariables.slotNumber === slotNumber);
321
301
  return Promise.resolve(blocks);
322
302
  }
323
303
 
324
- async getBlockHeadersForEpoch(epochNumber: EpochNumber): Promise<BlockHeader[]> {
325
- const blocks = await this.getBlocksForEpoch(epochNumber);
326
- return blocks.map(b => b.header);
304
+ async getCheckpointedBlockHeadersForEpoch(epochNumber: EpochNumber): Promise<BlockHeader[]> {
305
+ const checkpointedBlocks = await this.getCheckpointedBlocksForEpoch(epochNumber);
306
+ return checkpointedBlocks.map(b => b.block.header);
327
307
  }
328
308
 
329
309
  /**
@@ -404,7 +384,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
404
384
 
405
385
  const makeTipId = (blockId: typeof latestBlockId) => ({
406
386
  block: blockId,
407
- checkpoint: { number: CheckpointNumber(blockId.number), hash: blockId.hash },
387
+ checkpoint: { number: CheckpointNumber.fromBlockNumber(blockId.number), hash: blockId.hash },
408
388
  });
409
389
 
410
390
  return {
@@ -12,7 +12,7 @@ import type { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer'
12
12
  import { Fr } from '@aztec/foundation/curves/bn254';
13
13
  import { EthAddress } from '@aztec/foundation/eth-address';
14
14
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
15
- import { CommitteeAttestation, L2BlockNew } from '@aztec/stdlib/block';
15
+ import { CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
16
16
  import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
17
17
  import { PrivateLog, PublicLog, SiloedTag, Tag } from '@aztec/stdlib/logs';
18
18
  import { InboxLeaf } from '@aztec/stdlib/messaging';
@@ -268,8 +268,8 @@ export async function makeCheckpointWithLogs(
268
268
  ): Promise<PublishedCheckpoint> {
269
269
  const { previousArchive, numTxsPerBlock = 4, privateLogs, publicLogs } = options;
270
270
 
271
- const block = await L2BlockNew.random(BlockNumber(blockNumber), {
272
- checkpointNumber: CheckpointNumber(blockNumber),
271
+ const block = await L2Block.random(BlockNumber(blockNumber), {
272
+ checkpointNumber: CheckpointNumber.fromBlockNumber(BlockNumber(blockNumber)),
273
273
  indexWithinCheckpoint: IndexWithinCheckpoint(0),
274
274
  state: makeStateForBlock(blockNumber, numTxsPerBlock),
275
275
  ...(previousArchive ? { lastArchive: previousArchive } : {}),
@@ -289,7 +289,7 @@ export async function makeCheckpointWithLogs(
289
289
  AppendOnlyTreeSnapshot.random(),
290
290
  CheckpointHeader.random(),
291
291
  [block],
292
- CheckpointNumber(blockNumber),
292
+ CheckpointNumber.fromBlockNumber(BlockNumber(blockNumber)),
293
293
  );
294
294
  return makePublishedCheckpoint(checkpoint, blockNumber);
295
295
  }