@aztec/archiver 4.0.0-nightly.20260121 → 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 (47) 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 +12 -12
  5. package/dest/factory.d.ts +3 -2
  6. package/dest/factory.d.ts.map +1 -1
  7. package/dest/factory.js +5 -3
  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 +18 -19
  13. package/dest/modules/data_source_base.d.ts.map +1 -1
  14. package/dest/modules/data_source_base.js +25 -56
  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 +21 -11
  20. package/dest/store/block_store.d.ts.map +1 -1
  21. package/dest/store/block_store.js +34 -5
  22. package/dest/store/kv_archiver_store.d.ts +25 -17
  23. package/dest/store/kv_archiver_store.d.ts.map +1 -1
  24. package/dest/store/kv_archiver_store.js +16 -8
  25. package/dest/store/log_store.d.ts +17 -8
  26. package/dest/store/log_store.d.ts.map +1 -1
  27. package/dest/store/log_store.js +20 -6
  28. package/dest/test/fake_l1_state.d.ts +4 -4
  29. package/dest/test/fake_l1_state.d.ts.map +1 -1
  30. package/dest/test/mock_l2_block_source.d.ts +18 -18
  31. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  32. package/dest/test/mock_l2_block_source.js +37 -38
  33. package/dest/test/mock_structs.js +4 -4
  34. package/package.json +13 -13
  35. package/src/archiver.ts +15 -18
  36. package/src/factory.ts +4 -2
  37. package/src/l1/bin/retrieve-calldata.ts +7 -2
  38. package/src/l1/data_retrieval.ts +3 -3
  39. package/src/modules/data_source_base.ts +33 -80
  40. package/src/modules/data_store_updater.ts +7 -7
  41. package/src/modules/instrumentation.ts +2 -2
  42. package/src/store/block_store.ts +59 -21
  43. package/src/store/kv_archiver_store.ts +35 -19
  44. package/src/store/log_store.ts +37 -14
  45. package/src/test/fake_l1_state.ts +2 -2
  46. package/src/test/mock_l2_block_source.ts +49 -59
  47. package/src/test/mock_structs.ts +4 -4
package/src/archiver.ts CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  type ArchiverEmitter,
18
18
  type CheckpointId,
19
19
  GENESIS_CHECKPOINT_HEADER_HASH,
20
- L2BlockNew,
20
+ L2Block,
21
21
  type L2BlockSink,
22
22
  type L2Tips,
23
23
  type ValidateCheckpointResult,
@@ -46,7 +46,7 @@ export type { ArchiverEmitter };
46
46
 
47
47
  /** Request to add a block to the archiver, queued for processing by the sync loop. */
48
48
  type AddBlockRequest = {
49
- block: L2BlockNew;
49
+ block: L2Block;
50
50
  resolve: () => void;
51
51
  reject: (err: Error) => void;
52
52
  };
@@ -187,7 +187,7 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
187
187
  * @param block - The L2 block to add.
188
188
  * @returns A promise that resolves when the block has been added to the store, or rejects on error.
189
189
  */
190
- public addBlock(block: L2BlockNew): Promise<void> {
190
+ public addBlock(block: L2Block): Promise<void> {
191
191
  return new Promise<void>((resolve, reject) => {
192
192
  this.blockQueue.push({ block, resolve, reject });
193
193
  this.log.debug(`Queued block ${block.number} for processing`);
@@ -323,8 +323,11 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
323
323
  }
324
324
 
325
325
  public async isEpochComplete(epochNumber: EpochNumber): Promise<boolean> {
326
- // The epoch is complete if the current L2 block is the last one in the epoch (or later)
327
- const header = await this.getBlockHeader('latest');
326
+ // The epoch is complete if the current checkpointed L2 block is the last one in the epoch (or later).
327
+ // We use the checkpointed block number (synced from L1) instead of 'latest' to avoid returning true
328
+ // prematurely when proposed blocks have been pushed to the archiver but not yet checkpointed on L1.
329
+ const checkpointedBlockNumber = await this.getCheckpointedL2BlockNumber();
330
+ const header = checkpointedBlockNumber > 0 ? await this.getBlockHeader(checkpointedBlockNumber) : undefined;
328
331
  const slot = header ? header.globalVariables.slotNumber : undefined;
329
332
  const [_startSlot, endSlot] = getSlotRangeForEpoch(epochNumber, this.l1Constants);
330
333
  if (slot && slot >= endSlot) {
@@ -369,17 +372,13 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
369
372
  }
370
373
 
371
374
  public async getL2Tips(): Promise<L2Tips> {
372
- const [latestBlockNumber, provenBlockNumber, checkpointedBlockNumber] = await Promise.all([
375
+ const [latestBlockNumber, provenBlockNumber, checkpointedBlockNumber, finalizedBlockNumber] = await Promise.all([
373
376
  this.getBlockNumber(),
374
377
  this.getProvenBlockNumber(),
375
- this.getCheckpointedBlockNumber(),
378
+ this.getCheckpointedL2BlockNumber(),
379
+ this.getFinalizedL2BlockNumber(),
376
380
  ] as const);
377
381
 
378
- // TODO(#13569): Compute proper finalized block number based on L1 finalized block.
379
- // We just force it 2 epochs worth of proven data for now.
380
- // NOTE: update end-to-end/src/e2e_epochs/epochs_empty_blocks.test.ts as that uses finalized blocks in computations
381
- const finalizedBlockNumber = BlockNumber(Math.max(provenBlockNumber - this.l1Constants.epochDuration * 2, 0));
382
-
383
382
  const beforeInitialblockNumber = BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
384
383
 
385
384
  // Get the latest block header and checkpointed blocks for proven, finalised and checkpointed blocks
@@ -425,14 +424,12 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
425
424
  // Now attempt to retrieve checkpoints for proven, finalised and checkpointed blocks
426
425
  const [[provenBlockCheckpoint], [finalizedBlockCheckpoint], [checkpointedBlockCheckpoint]] = await Promise.all([
427
426
  provenCheckpointedBlock !== undefined
428
- ? await this.getPublishedCheckpoints(provenCheckpointedBlock?.checkpointNumber, 1)
427
+ ? await this.getCheckpoints(provenCheckpointedBlock?.checkpointNumber, 1)
429
428
  : [undefined],
430
429
  finalizedCheckpointedBlock !== undefined
431
- ? await this.getPublishedCheckpoints(finalizedCheckpointedBlock?.checkpointNumber, 1)
432
- : [undefined],
433
- checkpointedBlock !== undefined
434
- ? await this.getPublishedCheckpoints(checkpointedBlock?.checkpointNumber, 1)
430
+ ? await this.getCheckpoints(finalizedCheckpointedBlock?.checkpointNumber, 1)
435
431
  : [undefined],
432
+ checkpointedBlock !== undefined ? await this.getCheckpoints(checkpointedBlock?.checkpointNumber, 1) : [undefined],
436
433
  ]);
437
434
 
438
435
  const initialcheckpointId: CheckpointId = {
@@ -506,7 +503,7 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
506
503
  }
507
504
  const targetL1BlockHash = Buffer32.fromString(targetL1Block.hash);
508
505
  this.log.info(`Unwinding ${blocksToUnwind} checkpoints from L2 block ${currentL2Block}`);
509
- await this.updater.unwindCheckpoints(CheckpointNumber(currentL2Block), blocksToUnwind);
506
+ await this.updater.unwindCheckpoints(CheckpointNumber.fromBlockNumber(currentL2Block), blocksToUnwind);
510
507
  this.log.info(`Unwinding L1 to L2 messages to checkpoint ${targetCheckpointNumber}`);
511
508
  await this.store.rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber);
512
509
  this.log.info(`Setting L1 syncpoints to ${targetL1BlockNumber}`);
package/src/factory.ts CHANGED
@@ -15,6 +15,7 @@ import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/prov
15
15
  import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
16
16
  import type { ArchiverEmitter } from '@aztec/stdlib/block';
17
17
  import { type ContractClassPublic, computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
18
+ import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
18
19
  import { getTelemetryClient } from '@aztec/telemetry-client';
19
20
 
20
21
  import { EventEmitter } from 'events';
@@ -31,13 +32,14 @@ export const ARCHIVER_STORE_NAME = 'archiver';
31
32
  /** Creates an archiver store. */
32
33
  export async function createArchiverStore(
33
34
  userConfig: Pick<ArchiverConfig, 'archiverStoreMapSizeKb' | 'maxLogs'> & DataStoreConfig,
35
+ l1Constants: Pick<L1RollupConstants, 'epochDuration'>,
34
36
  ) {
35
37
  const config = {
36
38
  ...userConfig,
37
39
  dataStoreMapSizeKb: userConfig.archiverStoreMapSizeKb ?? userConfig.dataStoreMapSizeKb,
38
40
  };
39
41
  const store = await createStore(ARCHIVER_STORE_NAME, ARCHIVER_DB_VERSION, config, createLogger('archiver:lmdb'));
40
- return new KVArchiverDataStore(store, config.maxLogs);
42
+ return new KVArchiverDataStore(store, config.maxLogs, l1Constants);
41
43
  }
42
44
 
43
45
  /**
@@ -52,7 +54,7 @@ export async function createArchiver(
52
54
  deps: ArchiverDeps,
53
55
  opts: { blockUntilSync: boolean } = { blockUntilSync: true },
54
56
  ): Promise<Archiver> {
55
- const archiverStore = await createArchiverStore(config);
57
+ const archiverStore = await createArchiverStore(config, { epochDuration: config.aztecEpochDuration });
56
58
  await registerProtocolContracts(archiverStore);
57
59
 
58
60
  // Create Ethereum clients
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
3
- import { CheckpointNumber } from '@aztec/foundation/branded-types';
3
+ import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
4
4
  import { EthAddress } from '@aztec/foundation/eth-address';
5
5
  import { createLogger } from '@aztec/foundation/log';
6
6
 
@@ -142,7 +142,12 @@ async function main() {
142
142
  logger.info('');
143
143
 
144
144
  // For this script, we don't have blob hashes or expected hashes, so pass empty arrays/objects
145
- const result = await retriever.getCheckpointFromRollupTx(txHash, [], CheckpointNumber(l2BlockNumber), {});
145
+ const result = await retriever.getCheckpointFromRollupTx(
146
+ txHash,
147
+ [],
148
+ CheckpointNumber.fromBlockNumber(BlockNumber(l2BlockNumber)),
149
+ {},
150
+ );
146
151
 
147
152
  logger.info(' Successfully retrieved block header!');
148
153
  logger.info('');
@@ -20,7 +20,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
20
20
  import { EthAddress } from '@aztec/foundation/eth-address';
21
21
  import { type Logger, createLogger } from '@aztec/foundation/log';
22
22
  import { RollupAbi } from '@aztec/l1-artifacts';
23
- import { Body, CommitteeAttestation, L2BlockNew } from '@aztec/stdlib/block';
23
+ import { Body, CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
24
24
  import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
25
25
  import { Proof } from '@aztec/stdlib/proofs';
26
26
  import { CheckpointHeader } from '@aztec/stdlib/rollup';
@@ -69,7 +69,7 @@ export async function retrievedToPublishedCheckpoint({
69
69
  const l1toL2MessageTreeRoot = blocksBlobData[0].l1ToL2MessageRoot!;
70
70
 
71
71
  const spongeBlob = SpongeBlob.init();
72
- const l2Blocks: L2BlockNew[] = [];
72
+ const l2Blocks: L2Block[] = [];
73
73
  for (let i = 0; i < blocksBlobData.length; i++) {
74
74
  const blockBlobData = blocksBlobData[i];
75
75
  const { blockEndMarker, blockEndStateField, lastArchiveRoot, noteHashRoot, nullifierRoot, publicDataRoot } =
@@ -119,7 +119,7 @@ export async function retrievedToPublishedCheckpoint({
119
119
 
120
120
  const newArchive = new AppendOnlyTreeSnapshot(newArchiveRoots[i], l2BlockNumber + 1);
121
121
 
122
- l2Blocks.push(new L2BlockNew(newArchive, header, body, checkpointNumber, IndexWithinCheckpoint(i)));
122
+ l2Blocks.push(new L2Block(newArchive, header, body, checkpointNumber, IndexWithinCheckpoint(i)));
123
123
  }
124
124
 
125
125
  const lastBlock = l2Blocks.at(-1)!;
@@ -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, L2BlockNew, type L2Tips } from '@aztec/stdlib/block';
7
+ import { CheckpointedL2Block, CommitteeAttestation, L2Block, 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,10 +87,14 @@ export abstract class ArchiverDataSourceBase
87
87
  return this.store.getCheckpointedBlock(number);
88
88
  }
89
89
 
90
- public getCheckpointedBlockNumber(): Promise<BlockNumber> {
90
+ public getCheckpointedL2BlockNumber(): Promise<BlockNumber> {
91
91
  return this.store.getCheckpointedL2BlockNumber();
92
92
  }
93
93
 
94
+ public getFinalizedL2BlockNumber(): Promise<BlockNumber> {
95
+ return this.store.getFinalizedL2BlockNumber();
96
+ }
97
+
94
98
  public async getCheckpointHeader(number: CheckpointNumber | 'latest'): Promise<CheckpointHeader | undefined> {
95
99
  if (number === 'latest') {
96
100
  number = await this.store.getSynchedCheckpointNumber();
@@ -113,18 +117,8 @@ export abstract class ArchiverDataSourceBase
113
117
  return BlockNumber(checkpointData.startBlock + checkpointData.numBlocks - 1);
114
118
  }
115
119
 
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;
120
+ public getCheckpointedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]> {
121
+ return this.store.getCheckpointedBlocks(from, limit);
128
122
  }
129
123
 
130
124
  public getBlockHeaderByHash(blockHash: Fr): Promise<BlockHeader | undefined> {
@@ -135,7 +129,7 @@ export abstract class ArchiverDataSourceBase
135
129
  return this.store.getBlockHeaderByArchive(archive);
136
130
  }
137
131
 
138
- public async getL2BlockNew(number: BlockNumber): Promise<L2BlockNew | undefined> {
132
+ public async getL2Block(number: BlockNumber): Promise<L2Block | undefined> {
139
133
  // If the number provided is -ve, then return the latest block.
140
134
  if (number < 0) {
141
135
  number = await this.store.getLatestBlockNumber();
@@ -163,22 +157,16 @@ export abstract class ArchiverDataSourceBase
163
157
  return (await this.store.getPendingChainValidationStatus()) ?? { valid: true };
164
158
  }
165
159
 
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;
160
+ public getPrivateLogsByTags(tags: SiloedTag[], page?: number): Promise<TxScopedL2Log[][]> {
161
+ return this.store.getPrivateLogsByTags(tags, page);
174
162
  }
175
163
 
176
- public getPrivateLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]> {
177
- return this.store.getPrivateLogsByTags(tags);
178
- }
179
-
180
- public getPublicLogsByTagsFromContract(contractAddress: AztecAddress, tags: Tag[]): Promise<TxScopedL2Log[][]> {
181
- return this.store.getPublicLogsByTagsFromContract(contractAddress, tags);
164
+ public getPublicLogsByTagsFromContract(
165
+ contractAddress: AztecAddress,
166
+ tags: Tag[],
167
+ page?: number,
168
+ ): Promise<TxScopedL2Log[][]> {
169
+ return this.store.getPublicLogsByTagsFromContract(contractAddress, tags, page);
182
170
  }
183
171
 
184
172
  public getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
@@ -233,10 +221,7 @@ export abstract class ArchiverDataSourceBase
233
221
  return this.store.getL1ToL2MessageIndex(l1ToL2Message);
234
222
  }
235
223
 
236
- public async getPublishedCheckpoints(
237
- checkpointNumber: CheckpointNumber,
238
- limit: number,
239
- ): Promise<PublishedCheckpoint[]> {
224
+ public async getCheckpoints(checkpointNumber: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]> {
240
225
  const checkpoints = await this.store.getRangeOfCheckpoints(checkpointNumber, limit);
241
226
  const blocks = (
242
227
  await Promise.all(checkpoints.map(ch => this.store.getBlocksForCheckpoint(ch.checkpointNumber)))
@@ -262,17 +247,17 @@ export abstract class ArchiverDataSourceBase
262
247
  return fullCheckpoints;
263
248
  }
264
249
 
265
- public getBlocksForSlot(slotNumber: SlotNumber): Promise<L2BlockNew[]> {
250
+ public getBlocksForSlot(slotNumber: SlotNumber): Promise<L2Block[]> {
266
251
  return this.store.getBlocksForSlot(slotNumber);
267
252
  }
268
253
 
269
- public async getBlocksForEpoch(epochNumber: EpochNumber): Promise<L2BlockNew[]> {
254
+ public async getCheckpointedBlocksForEpoch(epochNumber: EpochNumber): Promise<CheckpointedL2Block[]> {
270
255
  if (!this.l1Constants) {
271
256
  throw new Error('L1 constants not set');
272
257
  }
273
258
 
274
259
  const [start, end] = getSlotRangeForEpoch(epochNumber, this.l1Constants);
275
- const blocks: L2BlockNew[] = [];
260
+ const blocks: CheckpointedL2Block[] = [];
276
261
 
277
262
  // Walk the list of checkpoints backwards and filter by slots matching the requested epoch.
278
263
  // We'll typically ask for checkpoints for a very recent epoch, so we shouldn't need an index here.
@@ -283,9 +268,9 @@ export abstract class ArchiverDataSourceBase
283
268
  // push the blocks on backwards
284
269
  const endBlock = checkpoint.startBlock + checkpoint.numBlocks - 1;
285
270
  for (let i = endBlock; i >= checkpoint.startBlock; i--) {
286
- const block = await this.getBlock(BlockNumber(i));
287
- if (block) {
288
- blocks.push(block);
271
+ const checkpointedBlock = await this.getCheckpointedBlock(BlockNumber(i));
272
+ if (checkpointedBlock) {
273
+ blocks.push(checkpointedBlock);
289
274
  }
290
275
  }
291
276
  }
@@ -295,7 +280,7 @@ export abstract class ArchiverDataSourceBase
295
280
  return blocks.reverse();
296
281
  }
297
282
 
298
- public async getBlockHeadersForEpoch(epochNumber: EpochNumber): Promise<BlockHeader[]> {
283
+ public async getCheckpointedBlockHeadersForEpoch(epochNumber: EpochNumber): Promise<BlockHeader[]> {
299
284
  if (!this.l1Constants) {
300
285
  throw new Error('L1 constants not set');
301
286
  }
@@ -338,7 +323,7 @@ export abstract class ArchiverDataSourceBase
338
323
  while (checkpointData && slot(checkpointData) >= start) {
339
324
  if (slot(checkpointData) <= end) {
340
325
  // push the checkpoints on backwards
341
- const [checkpoint] = await this.getPublishedCheckpoints(checkpointData.checkpointNumber, 1);
326
+ const [checkpoint] = await this.getCheckpoints(checkpointData.checkpointNumber, 1);
342
327
  checkpoints.push(checkpoint.checkpoint);
343
328
  }
344
329
  checkpointData = await this.store.getCheckpointData(CheckpointNumber(checkpointData.checkpointNumber - 1));
@@ -347,33 +332,7 @@ export abstract class ArchiverDataSourceBase
347
332
  return checkpoints.reverse();
348
333
  }
349
334
 
350
- public async getPublishedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<CheckpointedL2Block[]> {
351
- const checkpoints = await this.store.getRangeOfCheckpoints(CheckpointNumber(from), limit);
352
- const provenCheckpointNumber = await this.store.getProvenCheckpointNumber();
353
- const blocks = (
354
- await Promise.all(checkpoints.map(ch => this.store.getBlocksForCheckpoint(ch.checkpointNumber)))
355
- ).filter(isDefined);
356
-
357
- const publishedBlocks: CheckpointedL2Block[] = [];
358
- for (let i = 0; i < checkpoints.length; i++) {
359
- const blockForCheckpoint = blocks[i][0];
360
- const checkpoint = checkpoints[i];
361
- if (checkpoint.checkpointNumber > provenCheckpointNumber && proven === true) {
362
- // this checkpoint isn't proven and we only want proven
363
- continue;
364
- }
365
- const publishedBlock = new CheckpointedL2Block(
366
- checkpoint.checkpointNumber,
367
- blockForCheckpoint,
368
- checkpoint.l1,
369
- checkpoint.attestations.map(x => CommitteeAttestation.fromBuffer(x)),
370
- );
371
- publishedBlocks.push(publishedBlock);
372
- }
373
- return publishedBlocks;
374
- }
375
-
376
- public async getBlock(number: BlockNumber): Promise<L2BlockNew | undefined> {
335
+ public async getBlock(number: BlockNumber): Promise<L2Block | undefined> {
377
336
  // If the number provided is -ve, then return the latest block.
378
337
  if (number < 0) {
379
338
  number = await this.store.getLatestBlockNumber();
@@ -384,30 +343,24 @@ export abstract class ArchiverDataSourceBase
384
343
  return this.store.getBlock(number);
385
344
  }
386
345
 
387
- public async getBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<L2BlockNew[]> {
388
- const blocks = await this.store.getBlocks(from, limit);
389
-
390
- if (proven === true) {
391
- const provenBlockNumber = await this.store.getProvenBlockNumber();
392
- return blocks.filter(b => b.number <= provenBlockNumber);
393
- }
394
- return blocks;
346
+ public getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]> {
347
+ return this.store.getBlocks(from, limit);
395
348
  }
396
349
 
397
- public getPublishedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined> {
350
+ public getCheckpointedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined> {
398
351
  return this.store.getCheckpointedBlockByHash(blockHash);
399
352
  }
400
353
 
401
- public getPublishedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined> {
354
+ public getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined> {
402
355
  return this.store.getCheckpointedBlockByArchive(archive);
403
356
  }
404
357
 
405
- public async getL2BlockNewByHash(blockHash: Fr): Promise<L2BlockNew | undefined> {
358
+ public async getL2BlockByHash(blockHash: Fr): Promise<L2Block | undefined> {
406
359
  const checkpointedBlock = await this.store.getCheckpointedBlockByHash(blockHash);
407
360
  return checkpointedBlock?.block;
408
361
  }
409
362
 
410
- public async getL2BlockNewByArchive(archive: Fr): Promise<L2BlockNew | undefined> {
363
+ public async getL2BlockByArchive(archive: Fr): Promise<L2Block | undefined> {
411
364
  const checkpointedBlock = await this.store.getCheckpointedBlockByArchive(archive);
412
365
  return checkpointedBlock?.block;
413
366
  }
@@ -10,7 +10,7 @@ import {
10
10
  ContractInstancePublishedEvent,
11
11
  ContractInstanceUpdatedEvent,
12
12
  } from '@aztec/protocol-contracts/instance-registry';
13
- import type { L2BlockNew, ValidateCheckpointResult } from '@aztec/stdlib/block';
13
+ import type { L2Block, 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: L2BlockNew[] | undefined;
38
+ prunedBlocks: L2Block[] | 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: L2BlockNew[], pendingChainValidationStatus?: ValidateCheckpointResult): Promise<boolean> {
58
+ public addBlocks(blocks: L2Block[], 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<L2BlockNew[]> {
194
+ public removeBlocksAfter(blockNumber: BlockNumber): Promise<L2Block[]> {
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: L2BlockNew): Promise<boolean> {
251
+ private addBlockDataToDB(block: L2Block): 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: L2BlockNew): Promise<boolean> {
256
+ private removeBlockDataFromDB(block: L2Block): 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: L2BlockNew, operation: Operation): Promise<boolean> {
261
+ private async editContractBlockData(block: L2Block, 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 { L2BlockNew } from '@aztec/stdlib/block';
2
+ import type { L2Block } 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: L2BlockNew[]) {
100
+ public processNewBlocks(syncTimePerBlock: number, blocks: L2Block[]) {
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);