@aztec/archiver 0.0.1-commit.5914bae → 0.0.1-commit.59a0419c6

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 (95) hide show
  1. package/README.md +12 -6
  2. package/dest/archiver.d.ts +7 -5
  3. package/dest/archiver.d.ts.map +1 -1
  4. package/dest/archiver.js +18 -5
  5. package/dest/config.d.ts +5 -3
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +15 -3
  8. package/dest/errors.d.ts +44 -2
  9. package/dest/errors.d.ts.map +1 -1
  10. package/dest/errors.js +58 -2
  11. package/dest/factory.d.ts +2 -2
  12. package/dest/factory.d.ts.map +1 -1
  13. package/dest/factory.js +3 -4
  14. package/dest/index.d.ts +3 -2
  15. package/dest/index.d.ts.map +1 -1
  16. package/dest/index.js +2 -1
  17. package/dest/l1/calldata_retriever.d.ts +1 -1
  18. package/dest/l1/calldata_retriever.d.ts.map +1 -1
  19. package/dest/l1/calldata_retriever.js +2 -1
  20. package/dest/l1/data_retrieval.d.ts +24 -12
  21. package/dest/l1/data_retrieval.d.ts.map +1 -1
  22. package/dest/l1/data_retrieval.js +36 -37
  23. package/dest/l1/validate_historical_logs.d.ts +23 -0
  24. package/dest/l1/validate_historical_logs.d.ts.map +1 -0
  25. package/dest/l1/validate_historical_logs.js +108 -0
  26. package/dest/modules/data_source_base.d.ts +6 -4
  27. package/dest/modules/data_source_base.d.ts.map +1 -1
  28. package/dest/modules/data_source_base.js +10 -4
  29. package/dest/modules/data_store_updater.d.ts +15 -10
  30. package/dest/modules/data_store_updater.d.ts.map +1 -1
  31. package/dest/modules/data_store_updater.js +27 -59
  32. package/dest/modules/instrumentation.d.ts +18 -2
  33. package/dest/modules/instrumentation.d.ts.map +1 -1
  34. package/dest/modules/instrumentation.js +32 -6
  35. package/dest/modules/l1_synchronizer.d.ts +6 -2
  36. package/dest/modules/l1_synchronizer.d.ts.map +1 -1
  37. package/dest/modules/l1_synchronizer.js +248 -149
  38. package/dest/modules/validation.d.ts +1 -1
  39. package/dest/modules/validation.d.ts.map +1 -1
  40. package/dest/modules/validation.js +2 -2
  41. package/dest/store/block_store.d.ts +46 -5
  42. package/dest/store/block_store.d.ts.map +1 -1
  43. package/dest/store/block_store.js +225 -63
  44. package/dest/store/contract_class_store.d.ts +2 -3
  45. package/dest/store/contract_class_store.d.ts.map +1 -1
  46. package/dest/store/contract_class_store.js +1 -65
  47. package/dest/store/kv_archiver_store.d.ts +35 -14
  48. package/dest/store/kv_archiver_store.d.ts.map +1 -1
  49. package/dest/store/kv_archiver_store.js +40 -14
  50. package/dest/store/l2_tips_cache.d.ts +2 -1
  51. package/dest/store/l2_tips_cache.d.ts.map +1 -1
  52. package/dest/store/l2_tips_cache.js +27 -7
  53. package/dest/store/log_store.d.ts +6 -3
  54. package/dest/store/log_store.d.ts.map +1 -1
  55. package/dest/store/log_store.js +47 -10
  56. package/dest/store/message_store.d.ts +5 -1
  57. package/dest/store/message_store.d.ts.map +1 -1
  58. package/dest/store/message_store.js +20 -8
  59. package/dest/test/fake_l1_state.d.ts +7 -3
  60. package/dest/test/fake_l1_state.d.ts.map +1 -1
  61. package/dest/test/fake_l1_state.js +50 -10
  62. package/dest/test/mock_l1_to_l2_message_source.d.ts +1 -1
  63. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
  64. package/dest/test/mock_l1_to_l2_message_source.js +2 -1
  65. package/dest/test/mock_l2_block_source.d.ts +7 -2
  66. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  67. package/dest/test/mock_l2_block_source.js +28 -3
  68. package/dest/test/noop_l1_archiver.d.ts +1 -1
  69. package/dest/test/noop_l1_archiver.d.ts.map +1 -1
  70. package/dest/test/noop_l1_archiver.js +4 -2
  71. package/package.json +13 -13
  72. package/src/archiver.ts +33 -8
  73. package/src/config.ts +22 -2
  74. package/src/errors.ts +94 -2
  75. package/src/factory.ts +2 -3
  76. package/src/index.ts +2 -1
  77. package/src/l1/calldata_retriever.ts +2 -1
  78. package/src/l1/data_retrieval.ts +52 -53
  79. package/src/l1/validate_historical_logs.ts +140 -0
  80. package/src/modules/data_source_base.ts +23 -4
  81. package/src/modules/data_store_updater.ts +43 -85
  82. package/src/modules/instrumentation.ts +47 -7
  83. package/src/modules/l1_synchronizer.ts +321 -185
  84. package/src/modules/validation.ts +2 -2
  85. package/src/store/block_store.ts +295 -73
  86. package/src/store/contract_class_store.ts +1 -103
  87. package/src/store/kv_archiver_store.ts +67 -24
  88. package/src/store/l2_tips_cache.ts +58 -13
  89. package/src/store/log_store.ts +62 -20
  90. package/src/store/message_store.ts +26 -9
  91. package/src/structs/inbox_message.ts +1 -1
  92. package/src/test/fake_l1_state.ts +72 -15
  93. package/src/test/mock_l1_to_l2_message_source.ts +1 -0
  94. package/src/test/mock_l2_block_source.ts +37 -2
  95. package/src/test/noop_l1_archiver.ts +3 -1
@@ -1,6 +1,9 @@
1
+ import type { SlotNumber } from '@aztec/foundation/branded-types';
1
2
  import { createLogger } from '@aztec/foundation/log';
2
3
  import type { L2Block } from '@aztec/stdlib/block';
3
4
  import type { CheckpointData } from '@aztec/stdlib/checkpoint';
5
+ import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
6
+ import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
4
7
  import {
5
8
  Attributes,
6
9
  type Gauge,
@@ -29,6 +32,7 @@ export class ArchiverInstrumentation {
29
32
  private pruneCount: UpDownCounter;
30
33
 
31
34
  private syncDurationPerBlock: Histogram;
35
+ private syncDurationPerCheckpoint: Histogram;
32
36
  private syncBlockCount: UpDownCounter;
33
37
  private manaPerBlock: Histogram;
34
38
  private txsPerBlock: Histogram;
@@ -38,6 +42,9 @@ export class ArchiverInstrumentation {
38
42
 
39
43
  private blockProposalTxTargetCount: UpDownCounter;
40
44
 
45
+ private checkpointL1InclusionDelay: Histogram;
46
+ private checkpointPromotedCount: UpDownCounter;
47
+
41
48
  private log = createLogger('archiver:instrumentation');
42
49
 
43
50
  private constructor(
@@ -63,6 +70,8 @@ export class ArchiverInstrumentation {
63
70
 
64
71
  this.syncDurationPerBlock = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_BLOCK);
65
72
 
73
+ this.syncDurationPerCheckpoint = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_CHECKPOINT);
74
+
66
75
  this.syncBlockCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_SYNC_BLOCK_COUNT);
67
76
 
68
77
  this.manaPerBlock = meter.createHistogram(Metrics.ARCHIVER_MANA_PER_BLOCK);
@@ -85,6 +94,10 @@ export class ArchiverInstrumentation {
85
94
  },
86
95
  );
87
96
 
97
+ this.checkpointL1InclusionDelay = meter.createHistogram(Metrics.ARCHIVER_CHECKPOINT_L1_INCLUSION_DELAY);
98
+
99
+ this.checkpointPromotedCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_CHECKPOINT_PROMOTED_COUNT);
100
+
88
101
  this.dbMetrics = new LmdbMetrics(
89
102
  meter,
90
103
  {
@@ -106,17 +119,26 @@ export class ArchiverInstrumentation {
106
119
  return this.telemetry.isEnabled();
107
120
  }
108
121
 
109
- public processNewBlocks(syncTimePerBlock: number, blocks: L2Block[]) {
122
+ public processNewProposedBlock(syncTimePerBlock: number, block: L2Block) {
123
+ const attrs = { [Attributes.STATUS]: 'proposed' };
124
+ this.blockHeight.record(block.number, attrs);
110
125
  this.syncDurationPerBlock.record(Math.ceil(syncTimePerBlock));
126
+
127
+ // Per block metrics
128
+ this.txCount.add(block.body.txEffects.length);
129
+ this.txsPerBlock.record(block.body.txEffects.length);
130
+ this.manaPerBlock.record(block.header.totalManaUsed.toNumber() / 1e6);
131
+ }
132
+
133
+ public processNewCheckpointedBlocks(syncTimePerCheckpoint: number, blocks: L2Block[]) {
134
+ if (blocks.length === 0) {
135
+ return;
136
+ }
137
+
138
+ this.syncDurationPerCheckpoint.record(Math.ceil(syncTimePerCheckpoint));
111
139
  this.blockHeight.record(Math.max(...blocks.map(b => b.number)));
112
140
  this.checkpointHeight.record(Math.max(...blocks.map(b => b.checkpointNumber)));
113
141
  this.syncBlockCount.add(blocks.length);
114
-
115
- for (const block of blocks) {
116
- this.txCount.add(block.body.txEffects.length);
117
- this.txsPerBlock.record(block.body.txEffects.length);
118
- this.manaPerBlock.record(block.header.totalManaUsed.toNumber() / 1e6);
119
- }
120
142
  }
121
143
 
122
144
  public processNewMessages(count: number, syncPerMessageMs: number) {
@@ -161,4 +183,22 @@ export class ArchiverInstrumentation {
161
183
  [Attributes.L1_BLOCK_PROPOSAL_USED_TRACE]: usedTrace,
162
184
  });
163
185
  }
186
+
187
+ /** Records a checkpoint promoted from proposed (blob fetch skipped). */
188
+ public processCheckpointPromoted() {
189
+ this.checkpointPromotedCount.add(1);
190
+ }
191
+
192
+ /**
193
+ * Records L1 inclusion timing for a checkpoint observed on L1 (seconds into the L2 slot).
194
+ */
195
+ public processCheckpointL1Timing(data: {
196
+ slotNumber: SlotNumber;
197
+ l1Timestamp: bigint;
198
+ l1Constants: Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'>;
199
+ }): void {
200
+ const slotStartTs = getTimestampForSlot(data.slotNumber, data.l1Constants);
201
+ const inclusionDelaySeconds = Number(data.l1Timestamp - slotStartTs);
202
+ this.checkpointL1InclusionDelay.record(inclusionDelaySeconds);
203
+ }
164
204
  }