@aztec/archiver 0.0.1-commit.f2ce05ee → 0.0.1-commit.f81dbcf

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 (82) hide show
  1. package/dest/archiver.d.ts +7 -4
  2. package/dest/archiver.d.ts.map +1 -1
  3. package/dest/archiver.js +55 -106
  4. package/dest/factory.d.ts +2 -3
  5. package/dest/factory.d.ts.map +1 -1
  6. package/dest/factory.js +13 -13
  7. package/dest/index.d.ts +2 -1
  8. package/dest/index.d.ts.map +1 -1
  9. package/dest/index.js +1 -0
  10. package/dest/l1/bin/retrieve-calldata.js +32 -28
  11. package/dest/l1/calldata_retriever.d.ts +73 -50
  12. package/dest/l1/calldata_retriever.d.ts.map +1 -1
  13. package/dest/l1/calldata_retriever.js +190 -259
  14. package/dest/l1/data_retrieval.d.ts +4 -7
  15. package/dest/l1/data_retrieval.d.ts.map +1 -1
  16. package/dest/l1/data_retrieval.js +9 -13
  17. package/dest/l1/spire_proposer.d.ts +5 -5
  18. package/dest/l1/spire_proposer.d.ts.map +1 -1
  19. package/dest/l1/spire_proposer.js +9 -17
  20. package/dest/modules/data_source_base.d.ts +10 -5
  21. package/dest/modules/data_source_base.d.ts.map +1 -1
  22. package/dest/modules/data_source_base.js +29 -73
  23. package/dest/modules/data_store_updater.d.ts +18 -3
  24. package/dest/modules/data_store_updater.d.ts.map +1 -1
  25. package/dest/modules/data_store_updater.js +75 -23
  26. package/dest/modules/instrumentation.d.ts +4 -2
  27. package/dest/modules/instrumentation.d.ts.map +1 -1
  28. package/dest/modules/instrumentation.js +9 -2
  29. package/dest/modules/l1_synchronizer.d.ts +5 -8
  30. package/dest/modules/l1_synchronizer.d.ts.map +1 -1
  31. package/dest/modules/l1_synchronizer.js +37 -10
  32. package/dest/store/block_store.d.ts +25 -22
  33. package/dest/store/block_store.d.ts.map +1 -1
  34. package/dest/store/block_store.js +100 -30
  35. package/dest/store/kv_archiver_store.d.ts +30 -6
  36. package/dest/store/kv_archiver_store.d.ts.map +1 -1
  37. package/dest/store/kv_archiver_store.js +34 -4
  38. package/dest/store/l2_tips_cache.d.ts +19 -0
  39. package/dest/store/l2_tips_cache.d.ts.map +1 -0
  40. package/dest/store/l2_tips_cache.js +89 -0
  41. package/dest/store/log_store.d.ts +1 -1
  42. package/dest/store/log_store.d.ts.map +1 -1
  43. package/dest/store/log_store.js +48 -10
  44. package/dest/store/message_store.js +1 -1
  45. package/dest/test/fake_l1_state.d.ts +13 -1
  46. package/dest/test/fake_l1_state.d.ts.map +1 -1
  47. package/dest/test/fake_l1_state.js +84 -20
  48. package/dest/test/mock_archiver.d.ts +1 -1
  49. package/dest/test/mock_archiver.d.ts.map +1 -1
  50. package/dest/test/mock_archiver.js +3 -2
  51. package/dest/test/mock_l2_block_source.d.ts +21 -5
  52. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  53. package/dest/test/mock_l2_block_source.js +132 -86
  54. package/dest/test/mock_structs.d.ts +4 -1
  55. package/dest/test/mock_structs.d.ts.map +1 -1
  56. package/dest/test/mock_structs.js +13 -1
  57. package/dest/test/noop_l1_archiver.d.ts +4 -1
  58. package/dest/test/noop_l1_archiver.d.ts.map +1 -1
  59. package/dest/test/noop_l1_archiver.js +5 -1
  60. package/package.json +13 -13
  61. package/src/archiver.ts +67 -128
  62. package/src/factory.ts +12 -5
  63. package/src/index.ts +1 -0
  64. package/src/l1/README.md +25 -68
  65. package/src/l1/bin/retrieve-calldata.ts +40 -27
  66. package/src/l1/calldata_retriever.ts +249 -379
  67. package/src/l1/data_retrieval.ts +6 -16
  68. package/src/l1/spire_proposer.ts +7 -15
  69. package/src/modules/data_source_base.ts +56 -95
  70. package/src/modules/data_store_updater.ts +82 -22
  71. package/src/modules/instrumentation.ts +9 -2
  72. package/src/modules/l1_synchronizer.ts +44 -14
  73. package/src/store/block_store.ts +126 -49
  74. package/src/store/kv_archiver_store.ts +57 -7
  75. package/src/store/l2_tips_cache.ts +89 -0
  76. package/src/store/log_store.ts +66 -12
  77. package/src/store/message_store.ts +1 -1
  78. package/src/test/fake_l1_state.ts +110 -21
  79. package/src/test/mock_archiver.ts +3 -2
  80. package/src/test/mock_l2_block_source.ts +173 -81
  81. package/src/test/mock_structs.ts +20 -6
  82. package/src/test/noop_l1_archiver.ts +7 -1
@@ -8,6 +8,7 @@ import { createLogger } from '@aztec/foundation/log';
8
8
  import type { FunctionSelector } from '@aztec/stdlib/abi';
9
9
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
10
10
  import {
11
+ type BlockData,
11
12
  BlockHash,
12
13
  CheckpointedL2Block,
13
14
  L2Block,
@@ -15,9 +16,16 @@ import {
15
16
  type L2Tips,
16
17
  type ValidateCheckpointResult,
17
18
  } from '@aztec/stdlib/block';
18
- import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
19
+ import { Checkpoint, type CheckpointData, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
19
20
  import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
20
- import { EmptyL1RollupConstants, type L1RollupConstants, getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
21
+ import {
22
+ EmptyL1RollupConstants,
23
+ type L1RollupConstants,
24
+ getEpochAtSlot,
25
+ getSlotRangeForEpoch,
26
+ } from '@aztec/stdlib/epoch-helpers';
27
+ import { computeCheckpointOutHash } from '@aztec/stdlib/messaging';
28
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
21
29
  import { type BlockHeader, TxExecutionResult, TxHash, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
22
30
  import type { UInt64 } from '@aztec/stdlib/types';
23
31
 
@@ -26,6 +34,7 @@ import type { UInt64 } from '@aztec/stdlib/types';
26
34
  */
27
35
  export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
28
36
  protected l2Blocks: L2Block[] = [];
37
+ protected checkpointList: Checkpoint[] = [];
29
38
 
30
39
  private provenBlockNumber: number = 0;
31
40
  private finalizedBlockNumber: number = 0;
@@ -33,14 +42,36 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
33
42
 
34
43
  private log = createLogger('archiver:mock_l2_block_source');
35
44
 
45
+ /** Creates blocks grouped into single-block checkpoints. */
36
46
  public async createBlocks(numBlocks: number) {
37
- for (let i = 0; i < numBlocks; i++) {
38
- const blockNum = this.l2Blocks.length + 1;
39
- const block = await L2Block.random(BlockNumber(blockNum), { slotNumber: SlotNumber(blockNum) });
40
- this.l2Blocks.push(block);
47
+ await this.createCheckpoints(numBlocks, 1);
48
+ }
49
+
50
+ public getCheckpointNumber(): Promise<CheckpointNumber> {
51
+ return Promise.resolve(
52
+ this.checkpointList.length === 0 ? CheckpointNumber.ZERO : CheckpointNumber(this.checkpointList.length),
53
+ );
54
+ }
55
+
56
+ /** Creates checkpoints, each containing `blocksPerCheckpoint` blocks. */
57
+ public async createCheckpoints(numCheckpoints: number, blocksPerCheckpoint: number = 1) {
58
+ for (let c = 0; c < numCheckpoints; c++) {
59
+ const checkpointNum = CheckpointNumber(this.checkpointList.length + 1);
60
+ const startBlockNum = this.l2Blocks.length + 1;
61
+ const slotNumber = SlotNumber(Number(checkpointNum));
62
+ const checkpoint = await Checkpoint.random(checkpointNum, {
63
+ numBlocks: blocksPerCheckpoint,
64
+ startBlockNumber: startBlockNum,
65
+ slotNumber,
66
+ checkpointNumber: checkpointNum,
67
+ });
68
+ this.checkpointList.push(checkpoint);
69
+ this.l2Blocks.push(...checkpoint.blocks);
41
70
  }
42
71
 
43
- this.log.verbose(`Created ${numBlocks} blocks in the mock L2 block source`);
72
+ this.log.verbose(
73
+ `Created ${numCheckpoints} checkpoints with ${blocksPerCheckpoint} blocks each in the mock L2 block source`,
74
+ );
44
75
  }
45
76
 
46
77
  public addProposedBlocks(blocks: L2Block[]) {
@@ -50,6 +81,16 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
50
81
 
51
82
  public removeBlocks(numBlocks: number) {
52
83
  this.l2Blocks = this.l2Blocks.slice(0, -numBlocks);
84
+ const maxBlockNum = this.l2Blocks.length;
85
+ // Remove any checkpoint whose last block is beyond the remaining blocks.
86
+ this.checkpointList = this.checkpointList.filter(c => {
87
+ const lastBlockNum = c.blocks[0].number + c.blocks.length - 1;
88
+ return lastBlockNum <= maxBlockNum;
89
+ });
90
+ // Keep tip numbers consistent with remaining blocks.
91
+ this.checkpointedBlockNumber = Math.min(this.checkpointedBlockNumber, maxBlockNum);
92
+ this.provenBlockNumber = Math.min(this.provenBlockNumber, maxBlockNum);
93
+ this.finalizedBlockNumber = Math.min(this.finalizedBlockNumber, maxBlockNum);
53
94
  this.log.verbose(`Removed ${numBlocks} blocks from the mock L2 block source`);
54
95
  }
55
96
 
@@ -65,7 +106,33 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
65
106
  }
66
107
 
67
108
  public setCheckpointedBlockNumber(checkpointedBlockNumber: number) {
109
+ const prevCheckpointed = this.checkpointedBlockNumber;
68
110
  this.checkpointedBlockNumber = checkpointedBlockNumber;
111
+ // Auto-create single-block checkpoints for newly checkpointed blocks that don't have one yet.
112
+ // This handles blocks added via addProposedBlocks that are now being marked as checkpointed.
113
+ const newCheckpoints: Checkpoint[] = [];
114
+ for (let blockNum = prevCheckpointed + 1; blockNum <= checkpointedBlockNumber; blockNum++) {
115
+ const block = this.l2Blocks[blockNum - 1];
116
+ if (!block) {
117
+ continue;
118
+ }
119
+ if (this.checkpointList.some(c => c.blocks.some(b => b.number === block.number))) {
120
+ continue;
121
+ }
122
+ const checkpointNum = CheckpointNumber(this.checkpointList.length + newCheckpoints.length + 1);
123
+ const checkpoint = new Checkpoint(
124
+ block.archive,
125
+ CheckpointHeader.random({ slotNumber: block.header.globalVariables.slotNumber }),
126
+ [block],
127
+ checkpointNum,
128
+ );
129
+ newCheckpoints.push(checkpoint);
130
+ }
131
+ // Insert new checkpoints in order by number.
132
+ if (newCheckpoints.length > 0) {
133
+ this.checkpointList.push(...newCheckpoints);
134
+ this.checkpointList.sort((a, b) => a.number - b.number);
135
+ }
69
136
  }
70
137
 
71
138
  /**
@@ -112,13 +179,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
112
179
  if (!block) {
113
180
  return Promise.resolve(undefined);
114
181
  }
115
- const checkpointedBlock = new CheckpointedL2Block(
116
- CheckpointNumber.fromBlockNumber(number),
117
- block,
118
- new L1PublishedData(BigInt(number), BigInt(number), `0x${number.toString(16).padStart(64, '0')}`),
119
- [],
120
- );
121
- return Promise.resolve(checkpointedBlock);
182
+ return Promise.resolve(this.toCheckpointedBlock(block));
122
183
  }
123
184
 
124
185
  public async getCheckpointedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]> {
@@ -167,44 +228,22 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
167
228
  }
168
229
 
169
230
  public getCheckpoints(from: CheckpointNumber, limit: number) {
170
- // TODO(mbps): Implement this properly. This only works when we have one block per checkpoint.
171
- const blocks = this.l2Blocks.slice(from - 1, from - 1 + limit);
172
- return Promise.all(
173
- blocks.map(async block => {
174
- // Create a checkpoint from the block - manually construct since L2Block doesn't have toCheckpoint()
175
- const checkpoint = await Checkpoint.random(block.checkpointNumber, { numBlocks: 1 });
176
- checkpoint.blocks = [block];
177
- return new PublishedCheckpoint(
178
- checkpoint,
179
- new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
180
- [],
181
- );
182
- }),
231
+ const checkpoints = this.checkpointList.slice(from - 1, from - 1 + limit);
232
+ return Promise.resolve(
233
+ checkpoints.map(checkpoint => new PublishedCheckpoint(checkpoint, this.mockL1DataForCheckpoint(checkpoint), [])),
183
234
  );
184
235
  }
185
236
 
186
- public async getCheckpointByArchive(archive: Fr): Promise<Checkpoint | undefined> {
187
- // TODO(mbps): Implement this properly. This only works when we have one block per checkpoint.
188
- const block = this.l2Blocks.find(b => b.archive.root.equals(archive));
189
- if (!block) {
190
- return undefined;
191
- }
192
- // Create a checkpoint from the block - manually construct since L2Block doesn't have toCheckpoint()
193
- const checkpoint = await Checkpoint.random(block.checkpointNumber, { numBlocks: 1 });
194
- checkpoint.blocks = [block];
195
- return checkpoint;
237
+ public getCheckpointByArchive(archive: Fr): Promise<Checkpoint | undefined> {
238
+ const checkpoint = this.checkpointList.find(c => c.archive.root.equals(archive));
239
+ return Promise.resolve(checkpoint);
196
240
  }
197
241
 
198
242
  public async getCheckpointedBlockByHash(blockHash: BlockHash): Promise<CheckpointedL2Block | undefined> {
199
243
  for (const block of this.l2Blocks) {
200
244
  const hash = await block.hash();
201
245
  if (hash.equals(blockHash)) {
202
- return CheckpointedL2Block.fromFields({
203
- checkpointNumber: CheckpointNumber.fromBlockNumber(block.number),
204
- block,
205
- l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
206
- attestations: [],
207
- });
246
+ return this.toCheckpointedBlock(block);
208
247
  }
209
248
  }
210
249
  return undefined;
@@ -215,14 +254,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
215
254
  if (!block) {
216
255
  return Promise.resolve(undefined);
217
256
  }
218
- return Promise.resolve(
219
- CheckpointedL2Block.fromFields({
220
- checkpointNumber: CheckpointNumber.fromBlockNumber(block.number),
221
- block,
222
- l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
223
- attestations: [],
224
- }),
225
- );
257
+ return Promise.resolve(this.toCheckpointedBlock(block));
226
258
  }
227
259
 
228
260
  public async getL2BlockByHash(blockHash: BlockHash): Promise<L2Block | undefined> {
@@ -255,47 +287,69 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
255
287
  return Promise.resolve(block?.header);
256
288
  }
257
289
 
290
+ public async getBlockData(number: BlockNumber): Promise<BlockData | undefined> {
291
+ const block = this.l2Blocks[number - 1];
292
+ if (!block) {
293
+ return undefined;
294
+ }
295
+ return {
296
+ header: block.header,
297
+ archive: block.archive,
298
+ blockHash: await block.hash(),
299
+ checkpointNumber: block.checkpointNumber,
300
+ indexWithinCheckpoint: block.indexWithinCheckpoint,
301
+ };
302
+ }
303
+
304
+ public async getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
305
+ const block = this.l2Blocks.find(b => b.archive.root.equals(archive));
306
+ if (!block) {
307
+ return undefined;
308
+ }
309
+ return {
310
+ header: block.header,
311
+ archive: block.archive,
312
+ blockHash: await block.hash(),
313
+ checkpointNumber: block.checkpointNumber,
314
+ indexWithinCheckpoint: block.indexWithinCheckpoint,
315
+ };
316
+ }
317
+
258
318
  getBlockHeader(number: number | 'latest'): Promise<BlockHeader | undefined> {
259
319
  return Promise.resolve(this.l2Blocks.at(typeof number === 'number' ? number - 1 : -1)?.header);
260
320
  }
261
321
 
262
322
  getCheckpointsForEpoch(epochNumber: EpochNumber): Promise<Checkpoint[]> {
263
- // TODO(mbps): Implement this properly. This only works when we have one block per checkpoint.
264
- const epochDuration = DefaultL1ContractsConfig.aztecEpochDuration;
265
- const [start, end] = getSlotRangeForEpoch(epochNumber, { epochDuration });
266
- const blocks = this.l2Blocks.filter(b => {
267
- const slot = b.header.globalVariables.slotNumber;
268
- return slot >= start && slot <= end;
269
- });
270
- // Create checkpoints from blocks - manually construct since L2Block doesn't have toCheckpoint()
271
- return Promise.all(
272
- blocks.map(async block => {
273
- const checkpoint = await Checkpoint.random(block.checkpointNumber, { numBlocks: 1 });
274
- checkpoint.blocks = [block];
275
- return checkpoint;
276
- }),
277
- );
323
+ return Promise.resolve(this.getCheckpointsInEpoch(epochNumber));
278
324
  }
279
325
 
280
- getCheckpointedBlocksForEpoch(epochNumber: EpochNumber): Promise<CheckpointedL2Block[]> {
281
- const epochDuration = DefaultL1ContractsConfig.aztecEpochDuration;
282
- const [start, end] = getSlotRangeForEpoch(epochNumber, { epochDuration });
283
- const blocks = this.l2Blocks.filter(b => {
284
- const slot = b.header.globalVariables.slotNumber;
285
- return slot >= start && slot <= end;
286
- });
326
+ getCheckpointsDataForEpoch(epochNumber: EpochNumber): Promise<CheckpointData[]> {
327
+ const checkpoints = this.getCheckpointsInEpoch(epochNumber);
287
328
  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()),
329
+ checkpoints.map(
330
+ (checkpoint): CheckpointData => ({
331
+ checkpointNumber: checkpoint.number,
332
+ header: checkpoint.header,
333
+ archive: checkpoint.archive,
334
+ checkpointOutHash: computeCheckpointOutHash(
335
+ checkpoint.blocks.map(b => b.body.txEffects.map(tx => tx.l2ToL1Msgs)),
336
+ ),
337
+ startBlock: checkpoint.blocks[0].number,
338
+ blockCount: checkpoint.blocks.length,
293
339
  attestations: [],
340
+ l1: this.mockL1DataForCheckpoint(checkpoint),
294
341
  }),
295
342
  ),
296
343
  );
297
344
  }
298
345
 
346
+ getCheckpointedBlocksForEpoch(epochNumber: EpochNumber): Promise<CheckpointedL2Block[]> {
347
+ const checkpoints = this.getCheckpointsInEpoch(epochNumber);
348
+ return Promise.resolve(
349
+ checkpoints.flatMap(checkpoint => checkpoint.blocks.map(block => this.toCheckpointedBlock(block))),
350
+ );
351
+ }
352
+
299
353
  getBlocksForSlot(slotNumber: SlotNumber): Promise<L2Block[]> {
300
354
  const blocks = this.l2Blocks.filter(b => b.header.globalVariables.slotNumber === slotNumber);
301
355
  return Promise.resolve(blocks);
@@ -345,6 +399,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
345
399
  txEffect.transactionFee.toBigInt(),
346
400
  await block.hash(),
347
401
  block.number,
402
+ getEpochAtSlot(block.slot, EmptyL1RollupConstants),
348
403
  );
349
404
  }
350
405
  }
@@ -384,7 +439,10 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
384
439
 
385
440
  const makeTipId = (blockId: typeof latestBlockId) => ({
386
441
  block: blockId,
387
- checkpoint: { number: CheckpointNumber.fromBlockNumber(blockId.number), hash: blockId.hash },
442
+ checkpoint: {
443
+ number: this.findCheckpointNumberForBlock(blockId.number) ?? CheckpointNumber(0),
444
+ hash: blockId.hash,
445
+ },
388
446
  });
389
447
 
390
448
  return {
@@ -395,11 +453,11 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
395
453
  };
396
454
  }
397
455
 
398
- getL2EpochNumber(): Promise<EpochNumber> {
456
+ getSyncedL2EpochNumber(): Promise<EpochNumber> {
399
457
  throw new Error('Method not implemented.');
400
458
  }
401
459
 
402
- getL2SlotNumber(): Promise<SlotNumber> {
460
+ getSyncedL2SlotNumber(): Promise<SlotNumber> {
403
461
  throw new Error('Method not implemented.');
404
462
  }
405
463
 
@@ -472,4 +530,38 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
472
530
  getPendingChainValidationStatus(): Promise<ValidateCheckpointResult> {
473
531
  return Promise.resolve({ valid: true });
474
532
  }
533
+
534
+ /** Returns checkpoints whose slot falls within the given epoch. */
535
+ private getCheckpointsInEpoch(epochNumber: EpochNumber): Checkpoint[] {
536
+ const epochDuration = DefaultL1ContractsConfig.aztecEpochDuration;
537
+ const [start, end] = getSlotRangeForEpoch(epochNumber, { epochDuration });
538
+ return this.checkpointList.filter(c => c.header.slotNumber >= start && c.header.slotNumber <= end);
539
+ }
540
+
541
+ /** Creates a mock L1PublishedData for a checkpoint. */
542
+ private mockL1DataForCheckpoint(checkpoint: Checkpoint): L1PublishedData {
543
+ return new L1PublishedData(BigInt(checkpoint.number), BigInt(checkpoint.number), Buffer32.random().toString());
544
+ }
545
+
546
+ /** Creates a CheckpointedL2Block from a block using stored checkpoint info. */
547
+ private toCheckpointedBlock(block: L2Block): CheckpointedL2Block {
548
+ const checkpoint = this.checkpointList.find(c => c.blocks.some(b => b.number === block.number));
549
+ const checkpointNumber = checkpoint?.number ?? block.checkpointNumber;
550
+ return new CheckpointedL2Block(
551
+ checkpointNumber,
552
+ block,
553
+ new L1PublishedData(
554
+ BigInt(block.number),
555
+ BigInt(block.number),
556
+ `0x${block.number.toString(16).padStart(64, '0')}`,
557
+ ),
558
+ [],
559
+ );
560
+ }
561
+
562
+ /** Finds the checkpoint number for a block, or undefined if the block is not in any checkpoint. */
563
+ private findCheckpointNumberForBlock(blockNumber: BlockNumber): CheckpointNumber | undefined {
564
+ const checkpoint = this.checkpointList.find(c => c.blocks.some(b => b.number === blockNumber));
565
+ return checkpoint?.number;
566
+ }
475
567
  }
@@ -127,6 +127,25 @@ export function makeL1PublishedData(l1BlockNumber: number): L1PublishedData {
127
127
  return new L1PublishedData(BigInt(l1BlockNumber), BigInt(l1BlockNumber * 1000), makeBlockHash(l1BlockNumber));
128
128
  }
129
129
 
130
+ /** Creates a Checkpoint from a list of blocks with a header that matches the blocks' structure. */
131
+ export function makeCheckpoint(blocks: L2Block[], checkpointNumber = CheckpointNumber(1)): Checkpoint {
132
+ const firstBlock = blocks[0];
133
+ const { slotNumber, timestamp, coinbase, feeRecipient, gasFees } = firstBlock.header.globalVariables;
134
+ return new Checkpoint(
135
+ blocks.at(-1)!.archive,
136
+ CheckpointHeader.random({
137
+ lastArchiveRoot: firstBlock.header.lastArchive.root,
138
+ slotNumber,
139
+ timestamp,
140
+ coinbase,
141
+ feeRecipient,
142
+ gasFees,
143
+ }),
144
+ blocks,
145
+ checkpointNumber,
146
+ );
147
+ }
148
+
130
149
  /** Wraps a Checkpoint with L1 published data and random attestations. */
131
150
  export function makePublishedCheckpoint(
132
151
  checkpoint: Checkpoint,
@@ -301,11 +320,6 @@ export async function makeCheckpointWithLogs(
301
320
  return txEffect;
302
321
  });
303
322
 
304
- const checkpoint = new Checkpoint(
305
- AppendOnlyTreeSnapshot.random(),
306
- CheckpointHeader.random(),
307
- [block],
308
- CheckpointNumber.fromBlockNumber(BlockNumber(blockNumber)),
309
- );
323
+ const checkpoint = makeCheckpoint([block], CheckpointNumber.fromBlockNumber(BlockNumber(blockNumber)));
310
324
  return makePublishedCheckpoint(checkpoint, blockNumber);
311
325
  }
@@ -1,6 +1,7 @@
1
1
  import type { BlobClientInterface } from '@aztec/blob-client/client';
2
2
  import type { RollupContract } from '@aztec/ethereum/contracts';
3
3
  import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
4
+ import { SlotNumber } from '@aztec/foundation/branded-types';
4
5
  import { Buffer32 } from '@aztec/foundation/buffer';
5
6
  import { Fr } from '@aztec/foundation/curves/bn254';
6
7
  import { EthAddress } from '@aztec/foundation/eth-address';
@@ -30,7 +31,7 @@ class NoopL1Synchronizer implements FunctionsOf<ArchiverL1Synchronizer> {
30
31
  return 0n;
31
32
  }
32
33
  getL1Timestamp(): bigint | undefined {
33
- return 0n;
34
+ return undefined;
34
35
  }
35
36
  testEthereumNodeSynced(): Promise<void> {
36
37
  return Promise.resolve();
@@ -96,6 +97,11 @@ export class NoopL1Archiver extends Archiver {
96
97
  this.runningPromise.start();
97
98
  return Promise.resolve();
98
99
  }
100
+
101
+ /** Always reports as fully synced since there is no real L1 to sync from. */
102
+ public override getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
103
+ return Promise.resolve(SlotNumber(Number.MAX_SAFE_INTEGER));
104
+ }
99
105
  }
100
106
 
101
107
  /** Creates an archiver with mocked L1 connectivity for testing. */