@aztec/archiver 0.80.0 → 0.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dest/archiver/archiver.d.ts +8 -20
  2. package/dest/archiver/archiver.d.ts.map +1 -1
  3. package/dest/archiver/archiver.js +72 -102
  4. package/dest/archiver/archiver_store.d.ts +5 -19
  5. package/dest/archiver/archiver_store.d.ts.map +1 -1
  6. package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
  7. package/dest/archiver/archiver_store_test_suite.js +105 -142
  8. package/dest/archiver/config.d.ts +2 -0
  9. package/dest/archiver/config.d.ts.map +1 -1
  10. package/dest/archiver/config.js +5 -0
  11. package/dest/archiver/data_retrieval.d.ts +3 -4
  12. package/dest/archiver/data_retrieval.d.ts.map +1 -1
  13. package/dest/archiver/data_retrieval.js +8 -3
  14. package/dest/archiver/index.d.ts +1 -2
  15. package/dest/archiver/index.d.ts.map +1 -1
  16. package/dest/archiver/index.js +0 -1
  17. package/dest/archiver/kv_archiver_store/block_store.d.ts +6 -6
  18. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
  19. package/dest/archiver/kv_archiver_store/block_store.js +24 -21
  20. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +6 -14
  21. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
  22. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +2 -19
  23. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
  24. package/dest/archiver/kv_archiver_store/log_store.js +11 -42
  25. package/dest/archiver/structs/published.d.ts +1 -10
  26. package/dest/archiver/structs/published.d.ts.map +1 -1
  27. package/dest/archiver/structs/published.js +1 -1
  28. package/dest/factory.d.ts +1 -1
  29. package/dest/factory.d.ts.map +1 -1
  30. package/dest/factory.js +6 -24
  31. package/dest/test/mock_l2_block_source.d.ts +10 -0
  32. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  33. package/dest/test/mock_l2_block_source.js +16 -0
  34. package/package.json +12 -13
  35. package/src/archiver/archiver.ts +86 -124
  36. package/src/archiver/archiver_store.ts +5 -21
  37. package/src/archiver/archiver_store_test_suite.ts +116 -147
  38. package/src/archiver/config.ts +8 -0
  39. package/src/archiver/data_retrieval.ts +12 -11
  40. package/src/archiver/index.ts +1 -2
  41. package/src/archiver/kv_archiver_store/block_store.ts +28 -27
  42. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +6 -27
  43. package/src/archiver/kv_archiver_store/log_store.ts +12 -59
  44. package/src/archiver/structs/published.ts +1 -11
  45. package/src/factory.ts +3 -28
  46. package/src/test/mock_l2_block_source.ts +18 -0
  47. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
  48. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
  49. package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
  50. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
  51. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
  52. package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -636
  53. package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
  54. package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
@@ -1,6 +1,7 @@
1
- import { INITIAL_L2_BLOCK_NUM, L1_TO_L2_MSG_SUBTREE_HEIGHT, MAX_NULLIFIERS_PER_TX, PRIVATE_LOG_SIZE_IN_FIELDS, PUBLIC_LOG_DATA_SIZE_IN_FIELDS } from '@aztec/constants';
1
+ import { INITIAL_L2_BLOCK_NUM, L1_TO_L2_MSG_SUBTREE_HEIGHT, PRIVATE_LOG_SIZE_IN_FIELDS, PUBLIC_LOG_DATA_SIZE_IN_FIELDS } from '@aztec/constants';
2
2
  import { times, timesParallel } from '@aztec/foundation/collection';
3
3
  import { randomInt } from '@aztec/foundation/crypto';
4
+ import { Signature } from '@aztec/foundation/eth-signature';
4
5
  import { Fr } from '@aztec/foundation/fields';
5
6
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
7
  import { L2Block, wrapInBlock } from '@aztec/stdlib/block';
@@ -44,17 +45,28 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
44
45
  ()=>blocks.slice(4, 6)
45
46
  ]
46
47
  ];
47
- const makeL1Published = (block, l1BlockNumber)=>({
48
- data: block,
48
+ const makePublished = (block, l1BlockNumber)=>({
49
+ block: block,
49
50
  l1: {
50
51
  blockNumber: BigInt(l1BlockNumber),
51
52
  blockHash: `0x${l1BlockNumber}`,
52
53
  timestamp: BigInt(l1BlockNumber * 1000)
53
- }
54
- });
54
+ },
55
+ signatures: times(3, Signature.random)
56
+ });
57
+ const expectBlocksEqual = (actual, expected)=>{
58
+ expect(actual.length).toEqual(expected.length);
59
+ for(let i = 0; i < expected.length; i++){
60
+ const expectedBlock = expected[i];
61
+ const actualBlock = actual[i];
62
+ expect(actualBlock.l1).toEqual(expectedBlock.l1);
63
+ expect(actualBlock.block.equals(expectedBlock.block)).toBe(true);
64
+ expect(actualBlock.signatures.every((s, i)=>s.equals(expectedBlock.signatures[i]))).toBe(true);
65
+ }
66
+ };
55
67
  beforeEach(async ()=>{
56
68
  store = await getStore();
57
- blocks = await timesParallel(10, async (i)=>makeL1Published(await L2Block.random(i + 1), i + 10));
69
+ blocks = await timesParallel(10, async (i)=>makePublished(await L2Block.random(i + 1), i + 10));
58
70
  });
59
71
  describe('addBlocks', ()=>{
60
72
  it('returns success when adding blocks', async ()=>{
@@ -69,7 +81,7 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
69
81
  it('unwinding blocks will remove blocks from the chain', async ()=>{
70
82
  await store.addBlocks(blocks);
71
83
  const blockNumber = await store.getSynchedL2BlockNumber();
72
- expect(await store.getBlocks(blockNumber, 1)).toEqual([
84
+ expectBlocksEqual(await store.getBlocks(blockNumber, 1), [
73
85
  blocks[blocks.length - 1]
74
86
  ]);
75
87
  await store.unwindBlocks(blockNumber, 1);
@@ -77,12 +89,12 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
77
89
  expect(await store.getBlocks(blockNumber, 1)).toEqual([]);
78
90
  });
79
91
  it('can unwind multiple empty blocks', async ()=>{
80
- const emptyBlocks = await timesParallel(10, async (i)=>makeL1Published(await L2Block.random(i + 1, 0), i + 10));
92
+ const emptyBlocks = await timesParallel(10, async (i)=>makePublished(await L2Block.random(i + 1, 0), i + 10));
81
93
  await store.addBlocks(emptyBlocks);
82
94
  expect(await store.getSynchedL2BlockNumber()).toBe(10);
83
95
  await store.unwindBlocks(10, 3);
84
96
  expect(await store.getSynchedL2BlockNumber()).toBe(7);
85
- expect((await store.getBlocks(1, 10)).map((b)=>b.data.number)).toEqual([
97
+ expect((await store.getBlocks(1, 10)).map((b)=>b.block.number)).toEqual([
86
98
  1,
87
99
  2,
88
100
  3,
@@ -102,7 +114,7 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
102
114
  await store.addBlocks(blocks);
103
115
  });
104
116
  it.each(blockTests)('retrieves previously stored blocks', async (start, limit, getExpectedBlocks)=>{
105
- await expect(store.getBlocks(start, limit)).resolves.toEqual(getExpectedBlocks());
117
+ expectBlocksEqual(await store.getBlocks(start, limit), getExpectedBlocks());
106
118
  });
107
119
  it('returns an empty array if no blocks are found', async ()=>{
108
120
  await expect(store.getBlocks(12, 1)).resolves.toEqual([]);
@@ -120,7 +132,7 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
120
132
  });
121
133
  it("returns the most recently added block's number", async ()=>{
122
134
  await store.addBlocks(blocks);
123
- await expect(store.getSynchedL2BlockNumber()).resolves.toEqual(blocks.at(-1).data.number);
135
+ await expect(store.getSynchedL2BlockNumber()).resolves.toEqual(blocks.at(-1).block.number);
124
136
  });
125
137
  });
126
138
  describe('getSynchPoint', ()=>{
@@ -152,7 +164,7 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
152
164
  });
153
165
  describe('addLogs', ()=>{
154
166
  it('adds private & public logs', async ()=>{
155
- const block = blocks[0].data;
167
+ const block = blocks[0].block;
156
168
  await expect(store.addLogs([
157
169
  block
158
170
  ])).resolves.toEqual(true);
@@ -160,7 +172,7 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
160
172
  });
161
173
  describe('deleteLogs', ()=>{
162
174
  it('deletes private & public logs', async ()=>{
163
- const block = blocks[0].data;
175
+ const block = blocks[0].block;
164
176
  await store.addBlocks([
165
177
  blocks[0]
166
178
  ]);
@@ -183,7 +195,7 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
183
195
  });
184
196
  describe('getPrivateLogs', ()=>{
185
197
  it('gets added private logs', async ()=>{
186
- const block = blocks[0].data;
198
+ const block = blocks[0].block;
187
199
  await store.addBlocks([
188
200
  blocks[0]
189
201
  ]);
@@ -196,15 +208,15 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
196
208
  });
197
209
  describe('getTxEffect', ()=>{
198
210
  beforeEach(async ()=>{
199
- await store.addLogs(blocks.map((b)=>b.data));
211
+ await store.addLogs(blocks.map((b)=>b.block));
200
212
  await store.addBlocks(blocks);
201
213
  });
202
214
  it.each([
203
- ()=>wrapInBlock(blocks[0].data.body.txEffects[0], blocks[0].data),
204
- ()=>wrapInBlock(blocks[9].data.body.txEffects[3], blocks[9].data),
205
- ()=>wrapInBlock(blocks[3].data.body.txEffects[1], blocks[3].data),
206
- ()=>wrapInBlock(blocks[5].data.body.txEffects[2], blocks[5].data),
207
- ()=>wrapInBlock(blocks[1].data.body.txEffects[0], blocks[1].data)
215
+ ()=>wrapInBlock(blocks[0].block.body.txEffects[0], blocks[0].block),
216
+ ()=>wrapInBlock(blocks[9].block.body.txEffects[3], blocks[9].block),
217
+ ()=>wrapInBlock(blocks[3].block.body.txEffects[1], blocks[3].block),
218
+ ()=>wrapInBlock(blocks[5].block.body.txEffects[2], blocks[5].block),
219
+ ()=>wrapInBlock(blocks[1].block.body.txEffects[0], blocks[1].block)
208
220
  ])('retrieves a previously stored transaction', async (getExpectedTx)=>{
209
221
  const expectedTx = await getExpectedTx();
210
222
  const actualTx = await store.getTxEffect(expectedTx.data.txHash);
@@ -214,11 +226,11 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
214
226
  await expect(store.getTxEffect(TxHash.random())).resolves.toBeUndefined();
215
227
  });
216
228
  it.each([
217
- ()=>wrapInBlock(blocks[0].data.body.txEffects[0], blocks[0].data),
218
- ()=>wrapInBlock(blocks[9].data.body.txEffects[3], blocks[9].data),
219
- ()=>wrapInBlock(blocks[3].data.body.txEffects[1], blocks[3].data),
220
- ()=>wrapInBlock(blocks[5].data.body.txEffects[2], blocks[5].data),
221
- ()=>wrapInBlock(blocks[1].data.body.txEffects[0], blocks[1].data)
229
+ ()=>wrapInBlock(blocks[0].block.body.txEffects[0], blocks[0].block),
230
+ ()=>wrapInBlock(blocks[9].block.body.txEffects[3], blocks[9].block),
231
+ ()=>wrapInBlock(blocks[3].block.body.txEffects[1], blocks[3].block),
232
+ ()=>wrapInBlock(blocks[5].block.body.txEffects[2], blocks[5].block),
233
+ ()=>wrapInBlock(blocks[1].block.body.txEffects[0], blocks[1].block)
222
234
  ])('tries to retrieves a previously stored transaction after deleted', async (getExpectedTx)=>{
223
235
  await store.unwindBlocks(blocks.length, blocks.length);
224
236
  const expectedTx = await getExpectedTx();
@@ -279,16 +291,60 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
279
291
  ], blockNum);
280
292
  });
281
293
  it('returns previously stored contract instances', async ()=>{
282
- await expect(store.getContractInstance(contractInstance.address)).resolves.toMatchObject(contractInstance);
294
+ await expect(store.getContractInstance(contractInstance.address, blockNum)).resolves.toMatchObject(contractInstance);
283
295
  });
284
296
  it('returns undefined if contract instance is not found', async ()=>{
285
- await expect(store.getContractInstance(await AztecAddress.random())).resolves.toBeUndefined();
297
+ await expect(store.getContractInstance(await AztecAddress.random(), blockNum)).resolves.toBeUndefined();
286
298
  });
287
299
  it('returns undefined if previously stored contract instances was deleted', async ()=>{
288
300
  await store.deleteContractInstances([
289
301
  contractInstance
290
302
  ], blockNum);
291
- await expect(store.getContractInstance(contractInstance.address)).resolves.toBeUndefined();
303
+ await expect(store.getContractInstance(contractInstance.address, blockNum)).resolves.toBeUndefined();
304
+ });
305
+ });
306
+ describe('contractInstanceUpdates', ()=>{
307
+ let contractInstance;
308
+ let classId;
309
+ let nextClassId;
310
+ const blockOfChange = 10;
311
+ beforeEach(async ()=>{
312
+ classId = Fr.random();
313
+ nextClassId = Fr.random();
314
+ const randomInstance = await SerializableContractInstance.random({
315
+ currentContractClassId: classId,
316
+ originalContractClassId: classId
317
+ });
318
+ contractInstance = {
319
+ ...randomInstance,
320
+ address: await AztecAddress.random()
321
+ };
322
+ await store.addContractInstances([
323
+ contractInstance
324
+ ], 1);
325
+ await store.addContractInstanceUpdates([
326
+ {
327
+ prevContractClassId: classId,
328
+ newContractClassId: nextClassId,
329
+ blockOfChange,
330
+ address: contractInstance.address
331
+ }
332
+ ], blockOfChange - 1);
333
+ });
334
+ it('gets the correct current class id for a contract not updated yet', async ()=>{
335
+ const fetchedInstance = await store.getContractInstance(contractInstance.address, blockOfChange - 1);
336
+ expect(fetchedInstance?.originalContractClassId).toEqual(classId);
337
+ expect(fetchedInstance?.currentContractClassId).toEqual(classId);
338
+ });
339
+ it('gets the correct current class id for a contract that has just been updated', async ()=>{
340
+ const fetchedInstance = await store.getContractInstance(contractInstance.address, blockOfChange);
341
+ expect(fetchedInstance?.originalContractClassId).toEqual(classId);
342
+ expect(fetchedInstance?.currentContractClassId).toEqual(nextClassId);
343
+ });
344
+ it('gets the correct current class id for a contract that was updated in the past', async ()=>{
345
+ const fetchedInstance = await store.getContractInstance(contractInstance.address, blockOfChange + 1);
346
+ expect(fetchedInstance?.originalContractClassId).toEqual(classId);
347
+ expect(fetchedInstance?.currentContractClassId).toEqual(nextClassId);
292
348
  });
293
349
  });
294
350
  describe('contractClasses', ()=>{
@@ -359,23 +415,12 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
359
415
  const numPublicLogsPerTx = 2;
360
416
  let blocks;
361
417
  const makeTag = (blockNumber, txIndex, logIndex, isPublic = false)=>new Fr((blockNumber * 100 + txIndex * 10 + logIndex) * (isPublic ? 123 : 1));
362
- // See parseLogFromPublic
363
- // Search the codebase for "disgusting encoding" to see other hardcoded instances of this encoding, that you might need to change if you ever find yourself here.
364
- const makeLengthsField = (publicValuesLen, privateValuesLen)=>{
365
- const buf = Buffer.alloc(32);
366
- buf.writeUint16BE(publicValuesLen, 27);
367
- buf.writeUint16BE(privateValuesLen, 30);
368
- return Fr.fromBuffer(buf);
369
- };
370
418
  const makePrivateLog = (tag)=>PrivateLog.fromFields([
371
419
  tag,
372
420
  ...times(PRIVATE_LOG_SIZE_IN_FIELDS - 1, (i)=>new Fr(tag.toNumber() + i))
373
421
  ]);
374
- // The tag lives in field 1, not 0, of a public log
375
- // See extractTaggedLogsFromPublic and noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr -> emit_log
376
422
  const makePublicLog = (tag)=>PublicLog.fromFields([
377
423
  AztecAddress.fromNumber(1).toField(),
378
- makeLengthsField(2, PUBLIC_LOG_DATA_SIZE_IN_FIELDS - 3),
379
424
  tag,
380
425
  ...times(PUBLIC_LOG_DATA_SIZE_IN_FIELDS - 1, (i)=>new Fr(tag.toNumber() + i))
381
426
  ]);
@@ -401,7 +446,8 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
401
446
  return txEffect;
402
447
  });
403
448
  return {
404
- data: block,
449
+ block: block,
450
+ signatures: times(3, Signature.random),
405
451
  l1: {
406
452
  blockNumber: BigInt(blockNumber),
407
453
  blockHash: `0x${blockNumber}`,
@@ -412,7 +458,7 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
412
458
  beforeEach(async ()=>{
413
459
  blocks = await timesParallel(numBlocks, (index)=>mockBlockWithLogs(index));
414
460
  await store.addBlocks(blocks);
415
- await store.addLogs(blocks.map((b)=>b.data));
461
+ await store.addLogs(blocks.map((b)=>b.block));
416
462
  });
417
463
  it('is possible to batch request private logs via tags', async ()=>{
418
464
  const tags = [
@@ -424,14 +470,14 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
424
470
  [
425
471
  expect.objectContaining({
426
472
  blockNumber: 1,
427
- logData: makePrivateLog(tags[0]).toBuffer(),
473
+ log: makePrivateLog(tags[0]),
428
474
  isFromPublic: false
429
475
  })
430
476
  ],
431
477
  [
432
478
  expect.objectContaining({
433
479
  blockNumber: 0,
434
- logData: makePrivateLog(tags[1]).toBuffer(),
480
+ log: makePrivateLog(tags[1]),
435
481
  isFromPublic: false
436
482
  })
437
483
  ]
@@ -447,12 +493,12 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
447
493
  [
448
494
  expect.objectContaining({
449
495
  blockNumber: 0,
450
- logData: makePrivateLog(tags[0]).toBuffer(),
496
+ log: makePrivateLog(tags[0]),
451
497
  isFromPublic: false
452
498
  }),
453
499
  expect.objectContaining({
454
500
  blockNumber: 0,
455
- logData: makePublicLog(tags[0]).toBuffer(),
501
+ log: makePublicLog(tags[0]),
456
502
  isFromPublic: true
457
503
  })
458
504
  ]
@@ -465,26 +511,26 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
465
511
  // Create a block containing logs that have the same tag as the blocks before.
466
512
  const newBlockNumber = numBlocks;
467
513
  const newBlock = await mockBlockWithLogs(newBlockNumber);
468
- const newLog = newBlock.data.body.txEffects[1].privateLogs[1];
514
+ const newLog = newBlock.block.body.txEffects[1].privateLogs[1];
469
515
  newLog.fields[0] = tags[0];
470
- newBlock.data.body.txEffects[1].privateLogs[1] = newLog;
516
+ newBlock.block.body.txEffects[1].privateLogs[1] = newLog;
471
517
  await store.addBlocks([
472
518
  newBlock
473
519
  ]);
474
520
  await store.addLogs([
475
- newBlock.data
521
+ newBlock.block
476
522
  ]);
477
523
  const logsByTags = await store.getLogsByTags(tags);
478
524
  expect(logsByTags).toEqual([
479
525
  [
480
526
  expect.objectContaining({
481
527
  blockNumber: 1,
482
- logData: makePrivateLog(tags[0]).toBuffer(),
528
+ log: makePrivateLog(tags[0]),
483
529
  isFromPublic: false
484
530
  }),
485
531
  expect.objectContaining({
486
532
  blockNumber: newBlockNumber,
487
- logData: newLog.toBuffer(),
533
+ log: newLog,
488
534
  isFromPublic: false
489
535
  })
490
536
  ]
@@ -501,46 +547,12 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
501
547
  [
502
548
  expect.objectContaining({
503
549
  blockNumber: 1,
504
- logData: makePrivateLog(tags[1]).toBuffer(),
550
+ log: makePrivateLog(tags[1]),
505
551
  isFromPublic: false
506
552
  })
507
553
  ]
508
554
  ]);
509
555
  });
510
- it('is not possible to add public logs by tag if they are invalid', async ()=>{
511
- const tag = makeTag(99, 88, 77);
512
- const invalidLogs = [
513
- PublicLog.fromFields([
514
- AztecAddress.fromNumber(1).toField(),
515
- makeLengthsField(2, 3),
516
- tag,
517
- ...times(PUBLIC_LOG_DATA_SIZE_IN_FIELDS - 1, (i)=>new Fr(tag.toNumber() + i))
518
- ]),
519
- PublicLog.fromFields([
520
- AztecAddress.fromNumber(1).toField(),
521
- makeLengthsField(2, PUBLIC_LOG_DATA_SIZE_IN_FIELDS),
522
- tag,
523
- ...times(PUBLIC_LOG_DATA_SIZE_IN_FIELDS - 1, (i)=>new Fr(tag.toNumber() + i))
524
- ])
525
- ];
526
- // Create a block containing these invalid logs
527
- const newBlockNumber = numBlocks;
528
- const newBlock = await mockBlockWithLogs(newBlockNumber);
529
- newBlock.data.body.txEffects[0].publicLogs = invalidLogs;
530
- await store.addBlocks([
531
- newBlock
532
- ]);
533
- await store.addLogs([
534
- newBlock.data
535
- ]);
536
- const logsByTags = await store.getLogsByTags([
537
- tag
538
- ]);
539
- // Neither of the logs should have been added:
540
- expect(logsByTags).toEqual([
541
- []
542
- ]);
543
- });
544
556
  });
545
557
  describe('getPublicLogs', ()=>{
546
558
  const txsPerBlock = 4;
@@ -550,24 +562,25 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
550
562
  let blocks;
551
563
  beforeEach(async ()=>{
552
564
  blocks = await timesParallel(numBlocks, async (index)=>({
553
- data: await L2Block.random(index + 1, txsPerBlock, numPublicFunctionCalls, numPublicLogs),
565
+ block: await L2Block.random(index + 1, txsPerBlock, numPublicFunctionCalls, numPublicLogs),
554
566
  l1: {
555
567
  blockNumber: BigInt(index),
556
568
  blockHash: `0x${index}`,
557
569
  timestamp: BigInt(index)
558
- }
570
+ },
571
+ signatures: times(3, Signature.random)
559
572
  }));
560
573
  await store.addBlocks(blocks);
561
- await store.addLogs(blocks.map((b)=>b.data));
574
+ await store.addLogs(blocks.map((b)=>b.block));
562
575
  });
563
576
  it('no logs returned if deleted ("txHash" filter param is respected variant)', async ()=>{
564
577
  // get random tx
565
578
  const targetBlockIndex = randomInt(numBlocks);
566
579
  const targetTxIndex = randomInt(txsPerBlock);
567
- const targetTxHash = blocks[targetBlockIndex].data.body.txEffects[targetTxIndex].txHash;
580
+ const targetTxHash = blocks[targetBlockIndex].block.body.txEffects[targetTxIndex].txHash;
568
581
  await Promise.all([
569
582
  store.unwindBlocks(blocks.length, blocks.length),
570
- store.deleteLogs(blocks.map((b)=>b.data))
583
+ store.deleteLogs(blocks.map((b)=>b.block))
571
584
  ]);
572
585
  const response = await store.getPublicLogs({
573
586
  txHash: targetTxHash
@@ -580,7 +593,7 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
580
593
  // get random tx
581
594
  const targetBlockIndex = randomInt(numBlocks);
582
595
  const targetTxIndex = randomInt(txsPerBlock);
583
- const targetTxHash = blocks[targetBlockIndex].data.body.txEffects[targetTxIndex].txHash;
596
+ const targetTxHash = blocks[targetBlockIndex].block.body.txEffects[targetTxIndex].txHash;
584
597
  const response = await store.getPublicLogs({
585
598
  txHash: targetTxHash
586
599
  });
@@ -617,7 +630,7 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
617
630
  const targetBlockIndex = randomInt(numBlocks);
618
631
  const targetTxIndex = randomInt(txsPerBlock);
619
632
  const targetLogIndex = randomInt(numPublicLogs * numPublicFunctionCalls);
620
- const targetContractAddress = blocks[targetBlockIndex].data.body.txEffects[targetTxIndex].publicLogs[targetLogIndex].contractAddress;
633
+ const targetContractAddress = blocks[targetBlockIndex].block.body.txEffects[targetTxIndex].publicLogs[targetLogIndex].contractAddress;
621
634
  const response = await store.getPublicLogs({
622
635
  contractAddress: targetContractAddress
623
636
  });
@@ -740,55 +753,5 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
740
753
  }
741
754
  });
742
755
  });
743
- describe('findNullifiersIndexesWithBlock', ()=>{
744
- let blocks;
745
- const numBlocks = 10;
746
- const nullifiersPerBlock = new Map();
747
- beforeEach(async ()=>{
748
- blocks = await timesParallel(numBlocks, (index)=>L2Block.random(index + 1, 1));
749
- blocks.forEach((block, blockIndex)=>{
750
- nullifiersPerBlock.set(blockIndex, block.body.txEffects.flatMap((txEffect)=>txEffect.nullifiers));
751
- });
752
- });
753
- it('returns wrapped nullifiers with blocks if they exist', async ()=>{
754
- await store.addNullifiers(blocks);
755
- const nullifiersToRetrieve = [
756
- ...nullifiersPerBlock.get(0),
757
- ...nullifiersPerBlock.get(5),
758
- Fr.random()
759
- ];
760
- const blockScopedNullifiers = await store.findNullifiersIndexesWithBlock(10, nullifiersToRetrieve);
761
- expect(blockScopedNullifiers).toHaveLength(nullifiersToRetrieve.length);
762
- const [undefinedNullifier] = blockScopedNullifiers.slice(-1);
763
- const realNullifiers = blockScopedNullifiers.slice(0, -1);
764
- realNullifiers.forEach((blockScopedNullifier, index)=>{
765
- expect(blockScopedNullifier).not.toBeUndefined();
766
- const { data, l2BlockNumber } = blockScopedNullifier;
767
- expect(data).toEqual(expect.any(BigInt));
768
- expect(l2BlockNumber).toEqual(index < MAX_NULLIFIERS_PER_TX ? 1 : 6);
769
- });
770
- expect(undefinedNullifier).toBeUndefined();
771
- });
772
- it('returns wrapped nullifiers filtering by blockNumber', async ()=>{
773
- await store.addNullifiers(blocks);
774
- const nullifiersToRetrieve = [
775
- ...nullifiersPerBlock.get(0),
776
- ...nullifiersPerBlock.get(5)
777
- ];
778
- const blockScopedNullifiers = await store.findNullifiersIndexesWithBlock(5, nullifiersToRetrieve);
779
- expect(blockScopedNullifiers).toHaveLength(nullifiersToRetrieve.length);
780
- const undefinedNullifiers = blockScopedNullifiers.slice(-MAX_NULLIFIERS_PER_TX);
781
- const realNullifiers = blockScopedNullifiers.slice(0, -MAX_NULLIFIERS_PER_TX);
782
- realNullifiers.forEach((blockScopedNullifier)=>{
783
- expect(blockScopedNullifier).not.toBeUndefined();
784
- const { data, l2BlockNumber } = blockScopedNullifier;
785
- expect(data).toEqual(expect.any(BigInt));
786
- expect(l2BlockNumber).toEqual(1);
787
- });
788
- undefinedNullifiers.forEach((undefinedNullifier)=>{
789
- expect(undefinedNullifier).toBeUndefined();
790
- });
791
- });
792
- });
793
756
  });
794
757
  }
@@ -26,6 +26,8 @@ export type ArchiverConfig = {
26
26
  l1Contracts: L1ContractAddresses;
27
27
  /** The max number of logs that can be obtained in 1 "getPublicLogs" call. */
28
28
  maxLogs?: number;
29
+ /** The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKB. */
30
+ archiverStoreMapSizeKb?: number;
29
31
  } & L1ReaderConfig & L1ContractsConfig & BlobSinkConfig & ChainConfig;
30
32
  export declare const archiverConfigMappings: ConfigMappingsType<ArchiverConfig>;
31
33
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/archiver/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,yBAAyB,CAAC;AACrF,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAGpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,kBAAkB,EAA6C,MAAM,0BAA0B,CAAC;AAC9G,OAAO,EAAE,KAAK,WAAW,EAAu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BAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,2CAA2C;IAC3C,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,yCAAyC;IACzC,WAAW,EAAE,mBAAmB,CAAC;IAEjC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,qGAAqG;IACrG,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,GAAG,cAAc,GAChB,iBAAiB,GACjB,cAAc,GACd,WAAW,CAAC;AAEd,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,CAAC,cAAc,CAwCrE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,CAEzD"}
@@ -28,6 +28,11 @@ export const archiverConfigMappings = {
28
28
  description: 'The max number of logs that can be obtained in 1 "getPublicLogs" call.',
29
29
  ...numberConfigHelper(1_000)
30
30
  },
31
+ archiverStoreMapSizeKb: {
32
+ env: 'ARCHIVER_STORE_MAP_SIZE_KB',
33
+ parseEnv: (val)=>val ? +val : undefined,
34
+ description: 'The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKB.'
35
+ },
31
36
  ...chainConfigMappings,
32
37
  ...l1ReaderConfigMappings,
33
38
  viemPollingIntervalMS: {
@@ -6,12 +6,11 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
6
6
  import { Fr } from '@aztec/foundation/fields';
7
7
  import { type Logger } from '@aztec/foundation/log';
8
8
  import { type InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
9
- import { L2Block } from '@aztec/stdlib/block';
10
9
  import { InboxLeaf } from '@aztec/stdlib/messaging';
11
10
  import { Proof } from '@aztec/stdlib/proofs';
12
11
  import { type GetContractEventsReturnType, type GetContractReturnType, type Hex } from 'viem';
13
12
  import type { DataRetrieval } from './structs/data_retrieval.js';
14
- import type { L1Published } from './structs/published.js';
13
+ import type { PublishedL2Block } from './structs/published.js';
15
14
  /**
16
15
  * Fetches new L2 blocks.
17
16
  * @param publicClient - The viem public client to use for transaction retrieval.
@@ -21,7 +20,7 @@ import type { L1Published } from './structs/published.js';
21
20
  * @param expectedNextL2BlockNum - The next L2 block number that we expect to find.
22
21
  * @returns An array of block; as well as the next eth block to search from.
23
22
  */
24
- export declare function retrieveBlocksFromRollup(rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>, publicClient: ViemPublicClient, blobSinkClient: BlobSinkClientInterface, searchStartBlock: bigint, searchEndBlock: bigint, logger?: Logger): Promise<L1Published<L2Block>[]>;
23
+ export declare function retrieveBlocksFromRollup(rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>, publicClient: ViemPublicClient, blobSinkClient: BlobSinkClientInterface, searchStartBlock: bigint, searchEndBlock: bigint, logger?: Logger): Promise<PublishedL2Block[]>;
25
24
  /**
26
25
  * Processes newly received L2BlockProposed logs.
27
26
  * @param rollup - The rollup contract
@@ -29,7 +28,7 @@ export declare function retrieveBlocksFromRollup(rollup: GetContractReturnType<t
29
28
  * @param logs - L2BlockProposed logs.
30
29
  * @returns - An array blocks.
31
30
  */
32
- export declare function processL2BlockProposedLogs(rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>, publicClient: ViemPublicClient, blobSinkClient: BlobSinkClientInterface, logs: GetContractEventsReturnType<typeof RollupAbi, 'L2BlockProposed'>, logger: Logger): Promise<L1Published<L2Block>[]>;
31
+ export declare function processL2BlockProposedLogs(rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>, publicClient: ViemPublicClient, blobSinkClient: BlobSinkClientInterface, logs: GetContractEventsReturnType<typeof RollupAbi, 'L2BlockProposed'>, logger: Logger): Promise<PublishedL2Block[]>;
33
32
  export declare function getL1BlockTime(publicClient: ViemPublicClient, blockNumber: bigint): Promise<bigint>;
34
33
  /**
35
34
  * Fetch L1 to L2 messages.
@@ -1 +1 @@
1
- {"version":3,"file":"data_retrieval.d.ts","sourceRoot":"","sources":["../../src/archiver/data_retrieval.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,EAAE,u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AAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,EAAE,CAAC;IAChB,QAAQ,EAAE,EAAE,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC7C,YAAY,EAAE,gBAAgB,EAC9B,MAAM,EAAE,KAAK,MAAM,EAAE,EACrB,gBAAgB,EAAE,EAAE,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAuC3B"}
@@ -1,5 +1,6 @@
1
1
  import { Blob, BlobDeserializationError } from '@aztec/blob-lib';
2
2
  import { asyncPool } from '@aztec/foundation/async-pool';
3
+ import { Signature } from '@aztec/foundation/eth-signature';
3
4
  import { Fr } from '@aztec/foundation/fields';
4
5
  import { createLogger } from '@aztec/foundation/log';
5
6
  import { numToUInt32BE } from '@aztec/foundation/serialize';
@@ -65,7 +66,7 @@ import { NoBlobBodiesFoundError } from './errors.js';
65
66
  timestamp: await getL1BlockTime(publicClient, log.blockNumber)
66
67
  };
67
68
  retrievedBlocks.push({
68
- data: block,
69
+ ...block,
69
70
  l1
70
71
  });
71
72
  } else {
@@ -144,7 +145,7 @@ export async function getL1BlockTime(publicClient, blockNumber) {
144
145
  if (rollupFunctionName !== 'propose') {
145
146
  throw new Error(`Unexpected rollup method called ${rollupFunctionName}`);
146
147
  }
147
- const [decodedArgs] = rollupArgs;
148
+ const [decodedArgs, signatures] = rollupArgs;
148
149
  const header = BlockHeader.fromBuffer(Buffer.from(hexToBytes(decodedArgs.header)));
149
150
  const blobBodies = await blobSinkClient.getBlobSidecar(blockHash, blobHashes);
150
151
  if (blobBodies.length === 0) {
@@ -171,7 +172,11 @@ export async function getL1BlockTime(publicClient, blockNumber) {
171
172
  Buffer.from(hexToBytes(decodedArgs.archive)),
172
173
  numToUInt32BE(Number(l2BlockNum + 1n))
173
174
  ]));
174
- return new L2Block(archive, header, blockBody);
175
+ const block = new L2Block(archive, header, blockBody);
176
+ return {
177
+ block,
178
+ signatures: signatures.map(Signature.fromViemSignature)
179
+ };
175
180
  }
176
181
  /**
177
182
  * Fetch L1 to L2 messages.
@@ -1,7 +1,6 @@
1
1
  export * from './archiver.js';
2
2
  export * from './config.js';
3
- export { type L1Published, type L1PublishedData } from './structs/published.js';
4
- export { MemoryArchiverStore } from './memory_archiver_store/memory_archiver_store.js';
3
+ export { type PublishedL2Block, type L1PublishedData } from './structs/published.js';
5
4
  export type { ArchiverDataStore } from './archiver_store.js';
6
5
  export { KVArchiverDataStore } from './kv_archiver_store/kv_archiver_store.js';
7
6
  export { ContractInstanceStore } from './kv_archiver_store/contract_instance_store.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/archiver/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAC;AACvF,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/archiver/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACrF,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC"}
@@ -1,5 +1,4 @@
1
1
  export * from './archiver.js';
2
2
  export * from './config.js';
3
- export { MemoryArchiverStore } from './memory_archiver_store/memory_archiver_store.js';
4
3
  export { KVArchiverDataStore } from './kv_archiver_store/kv_archiver_store.js';
5
4
  export { ContractInstanceStore } from './kv_archiver_store/contract_instance_store.js';
@@ -1,9 +1,9 @@
1
1
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
2
2
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import { type InBlock, L2Block } from '@aztec/stdlib/block';
3
+ import { type InBlock } from '@aztec/stdlib/block';
4
4
  import { BlockHeader, TxEffect, TxHash, TxReceipt } from '@aztec/stdlib/tx';
5
- import type { L1Published } from '../structs/published.js';
6
- export { type TxEffect, type TxHash, TxReceipt } from '@aztec/stdlib/tx';
5
+ import type { PublishedL2Block } from '../structs/published.js';
6
+ export { TxReceipt, type TxEffect, type TxHash } from '@aztec/stdlib/tx';
7
7
  /**
8
8
  * LMDB implementation of the ArchiverDataStore interface.
9
9
  */
@@ -16,7 +16,7 @@ export declare class BlockStore {
16
16
  * @param blocks - The L2 blocks to be added to the store.
17
17
  * @returns True if the operation is successful.
18
18
  */
19
- addBlocks(blocks: L1Published<L2Block>[]): Promise<boolean>;
19
+ addBlocks(blocks: PublishedL2Block[]): Promise<boolean>;
20
20
  /**
21
21
  * Unwinds blocks from the database
22
22
  * @param from - The tip of the chain, passed for verification purposes,
@@ -31,13 +31,13 @@ export declare class BlockStore {
31
31
  * @param limit - The number of blocks to return.
32
32
  * @returns The requested L2 blocks
33
33
  */
34
- getBlocks(start: number, limit: number): AsyncIterableIterator<L1Published<L2Block>>;
34
+ getBlocks(start: number, limit: number): AsyncIterableIterator<PublishedL2Block>;
35
35
  /**
36
36
  * Gets an L2 block.
37
37
  * @param blockNumber - The number of the block to return.
38
38
  * @returns The requested L2 block.
39
39
  */
40
- getBlock(blockNumber: number): Promise<L1Published<L2Block> | undefined>;
40
+ getBlock(blockNumber: number): Promise<PublishedL2Block | undefined>;
41
41
  /**
42
42
  * Gets the headers for a sequence of L2 blocks.
43
43
  * @param start - Number of the first block to return (inclusive).