@aztec/archiver 0.0.1-commit.d1f2d6c → 0.0.1-commit.d431d1c

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 (46) hide show
  1. package/README.md +0 -9
  2. package/dest/archiver.d.ts +3 -3
  3. package/dest/archiver.d.ts.map +1 -1
  4. package/dest/archiver.js +12 -12
  5. package/dest/factory.d.ts +2 -3
  6. package/dest/factory.d.ts.map +1 -1
  7. package/dest/factory.js +3 -5
  8. package/dest/l1/bin/retrieve-calldata.js +2 -2
  9. package/dest/l1/data_retrieval.d.ts +1 -1
  10. package/dest/l1/data_retrieval.d.ts.map +1 -1
  11. package/dest/l1/data_retrieval.js +2 -2
  12. package/dest/modules/data_source_base.d.ts +17 -16
  13. package/dest/modules/data_source_base.d.ts.map +1 -1
  14. package/dest/modules/data_source_base.js +52 -21
  15. package/dest/modules/data_store_updater.d.ts +5 -5
  16. package/dest/modules/data_store_updater.d.ts.map +1 -1
  17. package/dest/modules/instrumentation.d.ts +3 -3
  18. package/dest/modules/instrumentation.d.ts.map +1 -1
  19. package/dest/store/block_store.d.ts +11 -21
  20. package/dest/store/block_store.d.ts.map +1 -1
  21. package/dest/store/block_store.js +5 -34
  22. package/dest/store/kv_archiver_store.d.ts +13 -16
  23. package/dest/store/kv_archiver_store.d.ts.map +1 -1
  24. package/dest/store/kv_archiver_store.js +2 -5
  25. package/dest/store/log_store.d.ts +4 -4
  26. package/dest/store/log_store.d.ts.map +1 -1
  27. package/dest/test/fake_l1_state.d.ts +4 -4
  28. package/dest/test/fake_l1_state.d.ts.map +1 -1
  29. package/dest/test/mock_l2_block_source.d.ts +18 -18
  30. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  31. package/dest/test/mock_l2_block_source.js +38 -37
  32. package/dest/test/mock_structs.js +4 -4
  33. package/package.json +13 -13
  34. package/src/archiver.ts +18 -15
  35. package/src/factory.ts +2 -4
  36. package/src/l1/bin/retrieve-calldata.ts +2 -7
  37. package/src/l1/data_retrieval.ts +3 -3
  38. package/src/modules/data_source_base.ts +76 -25
  39. package/src/modules/data_store_updater.ts +7 -7
  40. package/src/modules/instrumentation.ts +2 -2
  41. package/src/store/block_store.ts +21 -59
  42. package/src/store/kv_archiver_store.ts +12 -19
  43. package/src/store/log_store.ts +8 -8
  44. package/src/test/fake_l1_state.ts +2 -2
  45. package/src/test/mock_l2_block_source.ts +59 -49
  46. package/src/test/mock_structs.ts +4 -4
@@ -4,7 +4,7 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
4
4
  import { isDefined } from '@aztec/foundation/types';
5
5
  import type { FunctionSelector } from '@aztec/stdlib/abi';
6
6
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
- import { CheckpointedL2Block, CommitteeAttestation, L2Block, type L2Tips } from '@aztec/stdlib/block';
7
+ import { CheckpointedL2Block, CommitteeAttestation, L2BlockNew, type L2Tips } from '@aztec/stdlib/block';
8
8
  import { Checkpoint, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
9
9
  import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
10
10
  import { type L1RollupConstants, getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
@@ -87,14 +87,10 @@ export abstract class ArchiverDataSourceBase
87
87
  return this.store.getCheckpointedBlock(number);
88
88
  }
89
89
 
90
- public getCheckpointedL2BlockNumber(): Promise<BlockNumber> {
90
+ public getCheckpointedBlockNumber(): Promise<BlockNumber> {
91
91
  return this.store.getCheckpointedL2BlockNumber();
92
92
  }
93
93
 
94
- public getFinalizedL2BlockNumber(): Promise<BlockNumber> {
95
- return this.store.getFinalizedL2BlockNumber();
96
- }
97
-
98
94
  public async getCheckpointHeader(number: CheckpointNumber | 'latest'): Promise<CheckpointHeader | undefined> {
99
95
  if (number === 'latest') {
100
96
  number = await this.store.getSynchedCheckpointNumber();
@@ -117,8 +113,18 @@ export abstract class ArchiverDataSourceBase
117
113
  return BlockNumber(checkpointData.startBlock + checkpointData.numBlocks - 1);
118
114
  }
119
115
 
120
- public getCheckpointedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]> {
121
- return this.store.getCheckpointedBlocks(from, limit);
116
+ public async getCheckpointedBlocks(
117
+ from: BlockNumber,
118
+ limit: number,
119
+ proven?: boolean,
120
+ ): Promise<CheckpointedL2Block[]> {
121
+ const blocks = await this.store.getCheckpointedBlocks(from, limit);
122
+
123
+ if (proven === true) {
124
+ const provenBlockNumber = await this.store.getProvenBlockNumber();
125
+ return blocks.filter(b => b.block.number <= provenBlockNumber);
126
+ }
127
+ return blocks;
122
128
  }
123
129
 
124
130
  public getBlockHeaderByHash(blockHash: Fr): Promise<BlockHeader | undefined> {
@@ -129,7 +135,7 @@ export abstract class ArchiverDataSourceBase
129
135
  return this.store.getBlockHeaderByArchive(archive);
130
136
  }
131
137
 
132
- public async getL2Block(number: BlockNumber): Promise<L2Block | undefined> {
138
+ public async getL2BlockNew(number: BlockNumber): Promise<L2BlockNew | undefined> {
133
139
  // If the number provided is -ve, then return the latest block.
134
140
  if (number < 0) {
135
141
  number = await this.store.getLatestBlockNumber();
@@ -157,6 +163,16 @@ export abstract class ArchiverDataSourceBase
157
163
  return (await this.store.getPendingChainValidationStatus()) ?? { valid: true };
158
164
  }
159
165
 
166
+ public async getL2BlocksNew(from: BlockNumber, limit: number, proven?: boolean): Promise<L2BlockNew[]> {
167
+ const blocks = await this.store.getBlocks(from, limit);
168
+
169
+ if (proven === true) {
170
+ const provenBlockNumber = await this.store.getProvenBlockNumber();
171
+ return blocks.filter(b => b.number <= provenBlockNumber);
172
+ }
173
+ return blocks;
174
+ }
175
+
160
176
  public getPrivateLogsByTags(tags: SiloedTag[], page?: number): Promise<TxScopedL2Log[][]> {
161
177
  return this.store.getPrivateLogsByTags(tags, page);
162
178
  }
@@ -221,7 +237,10 @@ export abstract class ArchiverDataSourceBase
221
237
  return this.store.getL1ToL2MessageIndex(l1ToL2Message);
222
238
  }
223
239
 
224
- public async getCheckpoints(checkpointNumber: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]> {
240
+ public async getPublishedCheckpoints(
241
+ checkpointNumber: CheckpointNumber,
242
+ limit: number,
243
+ ): Promise<PublishedCheckpoint[]> {
225
244
  const checkpoints = await this.store.getRangeOfCheckpoints(checkpointNumber, limit);
226
245
  const blocks = (
227
246
  await Promise.all(checkpoints.map(ch => this.store.getBlocksForCheckpoint(ch.checkpointNumber)))
@@ -247,17 +266,17 @@ export abstract class ArchiverDataSourceBase
247
266
  return fullCheckpoints;
248
267
  }
249
268
 
250
- public getBlocksForSlot(slotNumber: SlotNumber): Promise<L2Block[]> {
269
+ public getBlocksForSlot(slotNumber: SlotNumber): Promise<L2BlockNew[]> {
251
270
  return this.store.getBlocksForSlot(slotNumber);
252
271
  }
253
272
 
254
- public async getCheckpointedBlocksForEpoch(epochNumber: EpochNumber): Promise<CheckpointedL2Block[]> {
273
+ public async getBlocksForEpoch(epochNumber: EpochNumber): Promise<L2BlockNew[]> {
255
274
  if (!this.l1Constants) {
256
275
  throw new Error('L1 constants not set');
257
276
  }
258
277
 
259
278
  const [start, end] = getSlotRangeForEpoch(epochNumber, this.l1Constants);
260
- const blocks: CheckpointedL2Block[] = [];
279
+ const blocks: L2BlockNew[] = [];
261
280
 
262
281
  // Walk the list of checkpoints backwards and filter by slots matching the requested epoch.
263
282
  // We'll typically ask for checkpoints for a very recent epoch, so we shouldn't need an index here.
@@ -268,9 +287,9 @@ export abstract class ArchiverDataSourceBase
268
287
  // push the blocks on backwards
269
288
  const endBlock = checkpoint.startBlock + checkpoint.numBlocks - 1;
270
289
  for (let i = endBlock; i >= checkpoint.startBlock; i--) {
271
- const checkpointedBlock = await this.getCheckpointedBlock(BlockNumber(i));
272
- if (checkpointedBlock) {
273
- blocks.push(checkpointedBlock);
290
+ const block = await this.getBlock(BlockNumber(i));
291
+ if (block) {
292
+ blocks.push(block);
274
293
  }
275
294
  }
276
295
  }
@@ -280,7 +299,7 @@ export abstract class ArchiverDataSourceBase
280
299
  return blocks.reverse();
281
300
  }
282
301
 
283
- public async getCheckpointedBlockHeadersForEpoch(epochNumber: EpochNumber): Promise<BlockHeader[]> {
302
+ public async getBlockHeadersForEpoch(epochNumber: EpochNumber): Promise<BlockHeader[]> {
284
303
  if (!this.l1Constants) {
285
304
  throw new Error('L1 constants not set');
286
305
  }
@@ -323,7 +342,7 @@ export abstract class ArchiverDataSourceBase
323
342
  while (checkpointData && slot(checkpointData) >= start) {
324
343
  if (slot(checkpointData) <= end) {
325
344
  // push the checkpoints on backwards
326
- const [checkpoint] = await this.getCheckpoints(checkpointData.checkpointNumber, 1);
345
+ const [checkpoint] = await this.getPublishedCheckpoints(checkpointData.checkpointNumber, 1);
327
346
  checkpoints.push(checkpoint.checkpoint);
328
347
  }
329
348
  checkpointData = await this.store.getCheckpointData(CheckpointNumber(checkpointData.checkpointNumber - 1));
@@ -332,7 +351,33 @@ export abstract class ArchiverDataSourceBase
332
351
  return checkpoints.reverse();
333
352
  }
334
353
 
335
- public async getBlock(number: BlockNumber): Promise<L2Block | undefined> {
354
+ public async getPublishedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<CheckpointedL2Block[]> {
355
+ const checkpoints = await this.store.getRangeOfCheckpoints(CheckpointNumber(from), limit);
356
+ const provenCheckpointNumber = await this.store.getProvenCheckpointNumber();
357
+ const blocks = (
358
+ await Promise.all(checkpoints.map(ch => this.store.getBlocksForCheckpoint(ch.checkpointNumber)))
359
+ ).filter(isDefined);
360
+
361
+ const publishedBlocks: CheckpointedL2Block[] = [];
362
+ for (let i = 0; i < checkpoints.length; i++) {
363
+ const blockForCheckpoint = blocks[i][0];
364
+ const checkpoint = checkpoints[i];
365
+ if (checkpoint.checkpointNumber > provenCheckpointNumber && proven === true) {
366
+ // this checkpoint isn't proven and we only want proven
367
+ continue;
368
+ }
369
+ const publishedBlock = new CheckpointedL2Block(
370
+ checkpoint.checkpointNumber,
371
+ blockForCheckpoint,
372
+ checkpoint.l1,
373
+ checkpoint.attestations.map(x => CommitteeAttestation.fromBuffer(x)),
374
+ );
375
+ publishedBlocks.push(publishedBlock);
376
+ }
377
+ return publishedBlocks;
378
+ }
379
+
380
+ public async getBlock(number: BlockNumber): Promise<L2BlockNew | undefined> {
336
381
  // If the number provided is -ve, then return the latest block.
337
382
  if (number < 0) {
338
383
  number = await this.store.getLatestBlockNumber();
@@ -343,24 +388,30 @@ export abstract class ArchiverDataSourceBase
343
388
  return this.store.getBlock(number);
344
389
  }
345
390
 
346
- public getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]> {
347
- return this.store.getBlocks(from, limit);
391
+ public async getBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<L2BlockNew[]> {
392
+ const blocks = await this.store.getBlocks(from, limit);
393
+
394
+ if (proven === true) {
395
+ const provenBlockNumber = await this.store.getProvenBlockNumber();
396
+ return blocks.filter(b => b.number <= provenBlockNumber);
397
+ }
398
+ return blocks;
348
399
  }
349
400
 
350
- public getCheckpointedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined> {
401
+ public getPublishedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined> {
351
402
  return this.store.getCheckpointedBlockByHash(blockHash);
352
403
  }
353
404
 
354
- public getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined> {
405
+ public getPublishedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined> {
355
406
  return this.store.getCheckpointedBlockByArchive(archive);
356
407
  }
357
408
 
358
- public async getL2BlockByHash(blockHash: Fr): Promise<L2Block | undefined> {
409
+ public async getL2BlockNewByHash(blockHash: Fr): Promise<L2BlockNew | undefined> {
359
410
  const checkpointedBlock = await this.store.getCheckpointedBlockByHash(blockHash);
360
411
  return checkpointedBlock?.block;
361
412
  }
362
413
 
363
- public async getL2BlockByArchive(archive: Fr): Promise<L2Block | undefined> {
414
+ public async getL2BlockNewByArchive(archive: Fr): Promise<L2BlockNew | undefined> {
364
415
  const checkpointedBlock = await this.store.getCheckpointedBlockByArchive(archive);
365
416
  return checkpointedBlock?.block;
366
417
  }
@@ -10,7 +10,7 @@ import {
10
10
  ContractInstancePublishedEvent,
11
11
  ContractInstanceUpdatedEvent,
12
12
  } from '@aztec/protocol-contracts/instance-registry';
13
- import type { L2Block, ValidateCheckpointResult } from '@aztec/stdlib/block';
13
+ import type { L2BlockNew, ValidateCheckpointResult } from '@aztec/stdlib/block';
14
14
  import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
15
15
  import {
16
16
  type ExecutablePrivateFunctionWithMembershipProof,
@@ -35,7 +35,7 @@ enum Operation {
35
35
  /** Result of adding checkpoints with information about any pruned blocks. */
36
36
  type ReconcileCheckpointsResult = {
37
37
  /** Blocks that were pruned due to conflict with L1 checkpoints. */
38
- prunedBlocks: L2Block[] | undefined;
38
+ prunedBlocks: L2BlockNew[] | undefined;
39
39
  /** Last block number that was already inserted locally, or undefined if none. */
40
40
  lastAlreadyInsertedBlockNumber: BlockNumber | undefined;
41
41
  };
@@ -55,7 +55,7 @@ export class ArchiverDataStoreUpdater {
55
55
  * @param pendingChainValidationStatus - Optional validation status to set.
56
56
  * @returns True if the operation is successful.
57
57
  */
58
- public addBlocks(blocks: L2Block[], pendingChainValidationStatus?: ValidateCheckpointResult): Promise<boolean> {
58
+ public addBlocks(blocks: L2BlockNew[], pendingChainValidationStatus?: ValidateCheckpointResult): Promise<boolean> {
59
59
  return this.store.transactionAsync(async () => {
60
60
  await this.store.addBlocks(blocks);
61
61
 
@@ -191,7 +191,7 @@ export class ArchiverDataStoreUpdater {
191
191
  * @param blockNumber - Remove all blocks with number greater than this.
192
192
  * @returns The removed blocks.
193
193
  */
194
- public removeBlocksAfter(blockNumber: BlockNumber): Promise<L2Block[]> {
194
+ public removeBlocksAfter(blockNumber: BlockNumber): Promise<L2BlockNew[]> {
195
195
  return this.store.transactionAsync(async () => {
196
196
  // First get the blocks to be removed so we can clean up contract data
197
197
  const removedBlocks = await this.store.removeBlocksAfter(blockNumber);
@@ -248,17 +248,17 @@ export class ArchiverDataStoreUpdater {
248
248
  }
249
249
 
250
250
  /** Extracts and stores contract data from a single block. */
251
- private addBlockDataToDB(block: L2Block): Promise<boolean> {
251
+ private addBlockDataToDB(block: L2BlockNew): Promise<boolean> {
252
252
  return this.editContractBlockData(block, Operation.Store);
253
253
  }
254
254
 
255
255
  /** Removes contract data associated with a block. */
256
- private removeBlockDataFromDB(block: L2Block): Promise<boolean> {
256
+ private removeBlockDataFromDB(block: L2BlockNew): Promise<boolean> {
257
257
  return this.editContractBlockData(block, Operation.Delete);
258
258
  }
259
259
 
260
260
  /** Adds or remove contract data associated with a block. */
261
- private async editContractBlockData(block: L2Block, operation: Operation): Promise<boolean> {
261
+ private async editContractBlockData(block: L2BlockNew, operation: Operation): Promise<boolean> {
262
262
  const contractClassLogs = block.body.txEffects.flatMap(txEffect => txEffect.contractClassLogs);
263
263
  const privateLogs = block.body.txEffects.flatMap(txEffect => txEffect.privateLogs);
264
264
  const publicLogs = block.body.txEffects.flatMap(txEffect => txEffect.publicLogs);
@@ -1,5 +1,5 @@
1
1
  import { createLogger } from '@aztec/foundation/log';
2
- import type { L2Block } from '@aztec/stdlib/block';
2
+ import type { L2BlockNew } from '@aztec/stdlib/block';
3
3
  import {
4
4
  Attributes,
5
5
  type Gauge,
@@ -97,7 +97,7 @@ export class ArchiverInstrumentation {
97
97
  return this.telemetry.isEnabled();
98
98
  }
99
99
 
100
- public processNewBlocks(syncTimePerBlock: number, blocks: L2Block[]) {
100
+ public processNewBlocks(syncTimePerBlock: number, blocks: L2BlockNew[]) {
101
101
  this.syncDurationPerBlock.record(Math.ceil(syncTimePerBlock));
102
102
  this.blockHeight.record(Math.max(...blocks.map(b => b.number)));
103
103
  this.syncBlockCount.add(blocks.length);
@@ -12,14 +12,13 @@ import {
12
12
  Body,
13
13
  CheckpointedL2Block,
14
14
  CommitteeAttestation,
15
- L2Block,
16
15
  L2BlockHash,
16
+ L2BlockNew,
17
17
  type ValidateCheckpointResult,
18
18
  deserializeValidateCheckpointResult,
19
19
  serializeValidateCheckpointResult,
20
20
  } from '@aztec/stdlib/block';
21
21
  import { L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
22
- import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
23
22
  import { CheckpointHeader } from '@aztec/stdlib/rollup';
24
23
  import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
25
24
  import {
@@ -28,7 +27,6 @@ import {
28
27
  TxEffect,
29
28
  TxHash,
30
29
  TxReceipt,
31
- TxStatus,
32
30
  deserializeIndexedTxEffect,
33
31
  serializeIndexedTxEffect,
34
32
  } from '@aztec/stdlib/tx';
@@ -113,10 +111,7 @@ export class BlockStore {
113
111
 
114
112
  #log = createLogger('archiver:block_store');
115
113
 
116
- constructor(
117
- private db: AztecAsyncKVStore,
118
- private l1Constants: Pick<L1RollupConstants, 'epochDuration'>,
119
- ) {
114
+ constructor(private db: AztecAsyncKVStore) {
120
115
  this.#blocks = db.openMap('archiver_blocks');
121
116
  this.#blockTxs = db.openMap('archiver_block_txs');
122
117
  this.#txEffects = db.openMap('archiver_tx_effects');
@@ -129,24 +124,12 @@ export class BlockStore {
129
124
  this.#checkpoints = db.openMap('archiver_checkpoints');
130
125
  }
131
126
 
132
- /**
133
- * Computes the finalized block number based on the proven block number.
134
- * A block is considered finalized when it's 2 epochs behind the proven block.
135
- * TODO(#13569): Compute proper finalized block number based on L1 finalized block.
136
- * TODO(palla/mbps): Even the provisional computation is wrong, since it should subtract checkpoints, not blocks
137
- * @returns The finalized block number.
138
- */
139
- async getFinalizedL2BlockNumber(): Promise<BlockNumber> {
140
- const provenBlockNumber = await this.getProvenBlockNumber();
141
- return BlockNumber(Math.max(provenBlockNumber - this.l1Constants.epochDuration * 2, 0));
142
- }
143
-
144
127
  /**
145
128
  * Append new blocks to the store's list. All blocks must be for the 'current' checkpoint
146
129
  * @param blocks - The L2 blocks to be added to the store.
147
130
  * @returns True if the operation is successful.
148
131
  */
149
- async addBlocks(blocks: L2Block[], opts: { force?: boolean } = {}): Promise<boolean> {
132
+ async addBlocks(blocks: L2BlockNew[], opts: { force?: boolean } = {}): Promise<boolean> {
150
133
  if (blocks.length === 0) {
151
134
  return true;
152
135
  }
@@ -199,7 +182,7 @@ export class BlockStore {
199
182
  }
200
183
 
201
184
  // 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: L2Block | undefined = undefined;
185
+ let previousBlock: L2BlockNew | undefined = undefined;
203
186
  for (const block of blocks) {
204
187
  if (!opts.force && previousBlock) {
205
188
  if (previousBlock.number + 1 !== block.number) {
@@ -258,7 +241,7 @@ export class BlockStore {
258
241
  }
259
242
 
260
243
  let previousBlockNumber: BlockNumber | undefined = undefined;
261
- let previousBlock: L2Block | undefined = undefined;
244
+ let previousBlock: L2BlockNew | undefined = undefined;
262
245
 
263
246
  // If we have a previous checkpoint then we need to get the previous block number
264
247
  if (previousCheckpointData !== undefined) {
@@ -339,7 +322,7 @@ export class BlockStore {
339
322
  });
340
323
  }
341
324
 
342
- private async addBlockToDatabase(block: L2Block, checkpointNumber: number, indexWithinCheckpoint: number) {
325
+ private async addBlockToDatabase(block: L2BlockNew, checkpointNumber: number, indexWithinCheckpoint: number) {
343
326
  const blockHash = L2BlockHash.fromField(await block.hash());
344
327
 
345
328
  await this.#blocks.set(block.number, {
@@ -368,7 +351,7 @@ export class BlockStore {
368
351
  }
369
352
 
370
353
  /** Deletes a block and all associated data (tx effects, indices). */
371
- private async deleteBlock(block: L2Block): Promise<void> {
354
+ private async deleteBlock(block: L2BlockNew): Promise<void> {
372
355
  // Delete the block from the main blocks map
373
356
  await this.#blocks.delete(block.number);
374
357
 
@@ -466,7 +449,7 @@ export class BlockStore {
466
449
  return data;
467
450
  }
468
451
 
469
- async getBlocksForCheckpoint(checkpointNumber: CheckpointNumber): Promise<L2Block[] | undefined> {
452
+ async getBlocksForCheckpoint(checkpointNumber: CheckpointNumber): Promise<L2BlockNew[] | undefined> {
470
453
  const checkpoint = await this.#checkpoints.getAsync(checkpointNumber);
471
454
  if (!checkpoint) {
472
455
  return undefined;
@@ -489,8 +472,8 @@ export class BlockStore {
489
472
  * @param slotNumber - The slot number to search for.
490
473
  * @returns All blocks with the given slot number, in ascending block number order.
491
474
  */
492
- async getBlocksForSlot(slotNumber: SlotNumber): Promise<L2Block[]> {
493
- const blocks: L2Block[] = [];
475
+ async getBlocksForSlot(slotNumber: SlotNumber): Promise<L2BlockNew[]> {
476
+ const blocks: L2BlockNew[] = [];
494
477
 
495
478
  // Iterate backwards through all blocks and filter by slot number
496
479
  // This is more efficient since we usually query for the most recent slot
@@ -513,9 +496,9 @@ export class BlockStore {
513
496
  * @param blockNumber - The block number to remove after.
514
497
  * @returns The removed blocks (for event emission).
515
498
  */
516
- async unwindBlocksAfter(blockNumber: BlockNumber): Promise<L2Block[]> {
499
+ async unwindBlocksAfter(blockNumber: BlockNumber): Promise<L2BlockNew[]> {
517
500
  return await this.db.transactionAsync(async () => {
518
- const removedBlocks: L2Block[] = [];
501
+ const removedBlocks: L2BlockNew[] = [];
519
502
 
520
503
  // Get the latest block number to determine the range
521
504
  const latestBlockNumber = await this.getLatestBlockNumber();
@@ -637,7 +620,7 @@ export class BlockStore {
637
620
  * @param limit - The number of blocks to return.
638
621
  * @returns The requested L2 blocks
639
622
  */
640
- async *getBlocks(start: BlockNumber, limit: number): AsyncIterableIterator<L2Block> {
623
+ async *getBlocks(start: BlockNumber, limit: number): AsyncIterableIterator<L2BlockNew> {
641
624
  for await (const [blockNumber, blockStorage] of this.getBlockStorages(start, limit)) {
642
625
  const block = await this.getBlockFromBlockStorage(blockNumber, blockStorage);
643
626
  if (block) {
@@ -651,7 +634,7 @@ export class BlockStore {
651
634
  * @param blockNumber - The number of the block to return.
652
635
  * @returns The requested L2 block.
653
636
  */
654
- async getBlock(blockNumber: BlockNumber): Promise<L2Block | undefined> {
637
+ async getBlock(blockNumber: BlockNumber): Promise<L2BlockNew | undefined> {
655
638
  const blockStorage = await this.#blocks.getAsync(blockNumber);
656
639
  if (!blockStorage || !blockStorage.header) {
657
640
  return Promise.resolve(undefined);
@@ -664,7 +647,7 @@ export class BlockStore {
664
647
  * @param blockHash - The hash of the block to return.
665
648
  * @returns The requested L2 block.
666
649
  */
667
- async getBlockByHash(blockHash: L2BlockHash): Promise<L2Block | undefined> {
650
+ async getBlockByHash(blockHash: L2BlockHash): Promise<L2BlockNew | undefined> {
668
651
  const blockNumber = await this.#blockHashIndex.getAsync(blockHash.toString());
669
652
  if (blockNumber === undefined) {
670
653
  return undefined;
@@ -677,7 +660,7 @@ export class BlockStore {
677
660
  * @param archive - The archive root of the block to return.
678
661
  * @returns The requested L2 block.
679
662
  */
680
- async getBlockByArchive(archive: Fr): Promise<L2Block | undefined> {
663
+ async getBlockByArchive(archive: Fr): Promise<L2BlockNew | undefined> {
681
664
  const blockNumber = await this.#blockArchiveIndex.getAsync(archive.toString());
682
665
  if (blockNumber === undefined) {
683
666
  return undefined;
@@ -753,7 +736,7 @@ export class BlockStore {
753
736
  private async getBlockFromBlockStorage(
754
737
  blockNumber: number,
755
738
  blockStorage: BlockStorage,
756
- ): Promise<L2Block | undefined> {
739
+ ): Promise<L2BlockNew | undefined> {
757
740
  const header = BlockHeader.fromBuffer(blockStorage.header);
758
741
  const archive = AppendOnlyTreeSnapshot.fromBuffer(blockStorage.archive);
759
742
  const blockHash = blockStorage.blockHash;
@@ -777,7 +760,7 @@ export class BlockStore {
777
760
  txEffects.push(deserializeIndexedTxEffect(txEffect).data);
778
761
  }
779
762
  const body = new Body(txEffects);
780
- const block = new L2Block(
763
+ const block = new L2BlockNew(
781
764
  archive,
782
765
  header,
783
766
  body,
@@ -819,34 +802,13 @@ export class BlockStore {
819
802
  return undefined;
820
803
  }
821
804
 
822
- const blockNumber = BlockNumber(txEffect.l2BlockNumber);
823
-
824
- // Use existing archiver methods to determine finalization level
825
- const [provenBlockNumber, checkpointedBlockNumber, finalizedBlockNumber] = await Promise.all([
826
- this.getProvenBlockNumber(),
827
- this.getCheckpointedL2BlockNumber(),
828
- this.getFinalizedL2BlockNumber(),
829
- ]);
830
-
831
- let status: TxStatus;
832
- if (blockNumber <= finalizedBlockNumber) {
833
- status = TxStatus.FINALIZED;
834
- } else if (blockNumber <= provenBlockNumber) {
835
- status = TxStatus.PROVEN;
836
- } else if (blockNumber <= checkpointedBlockNumber) {
837
- status = TxStatus.CHECKPOINTED;
838
- } else {
839
- status = TxStatus.PROPOSED;
840
- }
841
-
842
805
  return new TxReceipt(
843
806
  txHash,
844
- status,
845
- TxReceipt.executionResultFromRevertCode(txEffect.data.revertCode),
846
- undefined,
807
+ TxReceipt.statusFromRevertCode(txEffect.data.revertCode),
808
+ '',
847
809
  txEffect.data.transactionFee.toBigInt(),
848
810
  txEffect.l2BlockHash,
849
- blockNumber,
811
+ BlockNumber(txEffect.l2BlockNumber),
850
812
  );
851
813
  }
852
814
 
@@ -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, L2Block, L2BlockHash, type ValidateCheckpointResult } from '@aztec/stdlib/block';
9
+ import { CheckpointedL2Block, L2BlockHash, L2BlockNew, type ValidateCheckpointResult } from '@aztec/stdlib/block';
10
10
  import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
11
11
  import type {
12
12
  ContractClassPublic,
@@ -16,7 +16,6 @@ import type {
16
16
  ExecutablePrivateFunctionWithMembershipProof,
17
17
  UtilityFunctionWithMembershipProof,
18
18
  } from '@aztec/stdlib/contract';
19
- import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
20
19
  import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
21
20
  import type { LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
22
21
  import type { BlockHeader, TxHash, TxReceipt } from '@aztec/stdlib/tx';
@@ -65,9 +64,8 @@ export class KVArchiverDataStore implements ContractDataSource {
65
64
  constructor(
66
65
  private db: AztecAsyncKVStore,
67
66
  logsMaxPageSize: number = 1000,
68
- l1Constants: Pick<L1RollupConstants, 'epochDuration'>,
69
67
  ) {
70
- this.#blockStore = new BlockStore(db, l1Constants);
68
+ this.#blockStore = new BlockStore(db);
71
69
  this.#logStore = new LogStore(db, this.#blockStore, logsMaxPageSize);
72
70
  this.#messageStore = new MessageStore(db);
73
71
  this.#contractClassStore = new ContractClassStore(db);
@@ -103,11 +101,6 @@ export class KVArchiverDataStore implements ContractDataSource {
103
101
  return this.db.close();
104
102
  }
105
103
 
106
- /** Computes the finalized block number based on the proven block number. */
107
- getFinalizedL2BlockNumber(): Promise<BlockNumber> {
108
- return this.#blockStore.getFinalizedL2BlockNumber();
109
- }
110
-
111
104
  /** Looks up a public function name given a selector. */
112
105
  getDebugFunctionName(_address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
113
106
  return Promise.resolve(this.functionNames.get(selector.toString()));
@@ -239,7 +232,7 @@ export class KVArchiverDataStore implements ContractDataSource {
239
232
  * @param blocks - The L2 blocks to be added to the store and the last processed L1 block.
240
233
  * @returns True if the operation is successful.
241
234
  */
242
- addBlocks(blocks: L2Block[], opts: { force?: boolean; checkpointNumber?: number } = {}): Promise<boolean> {
235
+ addBlocks(blocks: L2BlockNew[], opts: { force?: boolean; checkpointNumber?: number } = {}): Promise<boolean> {
243
236
  return this.#blockStore.addBlocks(blocks, opts);
244
237
  }
245
238
 
@@ -305,21 +298,21 @@ export class KVArchiverDataStore implements ContractDataSource {
305
298
  * Returns the block for the given number, or undefined if not exists.
306
299
  * @param number - The block number to return.
307
300
  */
308
- getBlock(number: BlockNumber): Promise<L2Block | undefined> {
301
+ getBlock(number: BlockNumber): Promise<L2BlockNew | undefined> {
309
302
  return this.#blockStore.getBlock(number);
310
303
  }
311
304
  /**
312
305
  * Returns the block for the given hash, or undefined if not exists.
313
306
  * @param blockHash - The block hash to return.
314
307
  */
315
- getBlockByHash(blockHash: Fr): Promise<L2Block | undefined> {
308
+ getBlockByHash(blockHash: Fr): Promise<L2BlockNew | undefined> {
316
309
  return this.#blockStore.getBlockByHash(L2BlockHash.fromField(blockHash));
317
310
  }
318
311
  /**
319
312
  * Returns the block for the given archive root, or undefined if not exists.
320
313
  * @param archive - The archive root to return.
321
314
  */
322
- getBlockByArchive(archive: Fr): Promise<L2Block | undefined> {
315
+ getBlockByArchive(archive: Fr): Promise<L2BlockNew | undefined> {
323
316
  return this.#blockStore.getBlockByArchive(archive);
324
317
  }
325
318
 
@@ -329,7 +322,7 @@ export class KVArchiverDataStore implements ContractDataSource {
329
322
  * @param limit - The number of blocks to return.
330
323
  * @returns The requested L2 blocks.
331
324
  */
332
- getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]> {
325
+ getBlocks(from: BlockNumber, limit: number): Promise<L2BlockNew[]> {
333
326
  return toArray(this.#blockStore.getBlocks(from, limit));
334
327
  }
335
328
 
@@ -392,11 +385,11 @@ export class KVArchiverDataStore implements ContractDataSource {
392
385
  * @param blocks - The blocks for which to add the logs.
393
386
  * @returns True if the operation is successful.
394
387
  */
395
- addLogs(blocks: L2Block[]): Promise<boolean> {
388
+ addLogs(blocks: L2BlockNew[]): Promise<boolean> {
396
389
  return this.#logStore.addLogs(blocks);
397
390
  }
398
391
 
399
- deleteLogs(blocks: L2Block[]): Promise<boolean> {
392
+ deleteLogs(blocks: L2BlockNew[]): Promise<boolean> {
400
393
  return this.#logStore.deleteLogs(blocks);
401
394
  }
402
395
 
@@ -605,7 +598,7 @@ export class KVArchiverDataStore implements ContractDataSource {
605
598
  * @param checkpointNumber Retrieves all blocks for the given checkpoint
606
599
  * @returns The collection of blocks for the requested checkpoint if available (undefined otherwise)
607
600
  */
608
- getBlocksForCheckpoint(checkpointNumber: CheckpointNumber): Promise<L2Block[] | undefined> {
601
+ getBlocksForCheckpoint(checkpointNumber: CheckpointNumber): Promise<L2BlockNew[] | undefined> {
609
602
  return this.#blockStore.getBlocksForCheckpoint(checkpointNumber);
610
603
  }
611
604
 
@@ -623,7 +616,7 @@ export class KVArchiverDataStore implements ContractDataSource {
623
616
  * @param slotNumber - The slot number to search for.
624
617
  * @returns All blocks with the given slot number.
625
618
  */
626
- getBlocksForSlot(slotNumber: SlotNumber): Promise<L2Block[]> {
619
+ getBlocksForSlot(slotNumber: SlotNumber): Promise<L2BlockNew[]> {
627
620
  return this.#blockStore.getBlocksForSlot(slotNumber);
628
621
  }
629
622
 
@@ -632,7 +625,7 @@ export class KVArchiverDataStore implements ContractDataSource {
632
625
  * @param blockNumber - The block number to remove after.
633
626
  * @returns The removed blocks (for event emission).
634
627
  */
635
- removeBlocksAfter(blockNumber: BlockNumber): Promise<L2Block[]> {
628
+ removeBlocksAfter(blockNumber: BlockNumber): Promise<L2BlockNew[]> {
636
629
  return this.#blockStore.unwindBlocksAfter(blockNumber);
637
630
  }
638
631
  }