@aztec/archiver 0.0.1-commit.e558bd1c → 0.0.1-commit.e57c76e

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 (136) hide show
  1. package/README.md +19 -11
  2. package/dest/archiver.d.ts +58 -18
  3. package/dest/archiver.d.ts.map +1 -1
  4. package/dest/archiver.js +284 -160
  5. package/dest/config.d.ts +4 -1
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +21 -14
  8. package/dest/errors.d.ts +55 -9
  9. package/dest/errors.d.ts.map +1 -1
  10. package/dest/errors.js +81 -14
  11. package/dest/factory.d.ts +14 -9
  12. package/dest/factory.d.ts.map +1 -1
  13. package/dest/factory.js +55 -39
  14. package/dest/index.d.ts +12 -3
  15. package/dest/index.d.ts.map +1 -1
  16. package/dest/index.js +11 -2
  17. package/dest/l1/bin/retrieve-calldata.js +32 -28
  18. package/dest/l1/calldata_retriever.d.ts +74 -50
  19. package/dest/l1/calldata_retriever.d.ts.map +1 -1
  20. package/dest/l1/calldata_retriever.js +201 -260
  21. package/dest/l1/data_retrieval.d.ts +26 -17
  22. package/dest/l1/data_retrieval.d.ts.map +1 -1
  23. package/dest/l1/data_retrieval.js +42 -47
  24. package/dest/l1/spire_proposer.d.ts +5 -5
  25. package/dest/l1/spire_proposer.d.ts.map +1 -1
  26. package/dest/l1/spire_proposer.js +9 -17
  27. package/dest/l1/trace_tx.d.ts +12 -66
  28. package/dest/l1/trace_tx.d.ts.map +1 -1
  29. package/dest/l1/validate_historical_logs.d.ts +23 -0
  30. package/dest/l1/validate_historical_logs.d.ts.map +1 -0
  31. package/dest/l1/validate_historical_logs.js +108 -0
  32. package/dest/modules/contract_data_source_adapter.d.ts +25 -0
  33. package/dest/modules/contract_data_source_adapter.d.ts.map +1 -0
  34. package/dest/modules/contract_data_source_adapter.js +40 -0
  35. package/dest/modules/data_source_base.d.ts +74 -45
  36. package/dest/modules/data_source_base.d.ts.map +1 -1
  37. package/dest/modules/data_source_base.js +269 -181
  38. package/dest/modules/data_store_updater.d.ts +49 -17
  39. package/dest/modules/data_store_updater.d.ts.map +1 -1
  40. package/dest/modules/data_store_updater.js +211 -121
  41. package/dest/modules/instrumentation.d.ts +21 -3
  42. package/dest/modules/instrumentation.d.ts.map +1 -1
  43. package/dest/modules/instrumentation.js +44 -9
  44. package/dest/modules/l1_synchronizer.d.ts +14 -12
  45. package/dest/modules/l1_synchronizer.d.ts.map +1 -1
  46. package/dest/modules/l1_synchronizer.js +443 -211
  47. package/dest/modules/outbox_trees_resolver.d.ts +62 -0
  48. package/dest/modules/outbox_trees_resolver.d.ts.map +1 -0
  49. package/dest/modules/outbox_trees_resolver.js +162 -0
  50. package/dest/modules/validation.d.ts +4 -3
  51. package/dest/modules/validation.d.ts.map +1 -1
  52. package/dest/modules/validation.js +6 -6
  53. package/dest/store/block_store.d.ts +174 -72
  54. package/dest/store/block_store.d.ts.map +1 -1
  55. package/dest/store/block_store.js +739 -272
  56. package/dest/store/contract_class_store.d.ts +17 -4
  57. package/dest/store/contract_class_store.d.ts.map +1 -1
  58. package/dest/store/contract_class_store.js +24 -68
  59. package/dest/store/contract_instance_store.d.ts +28 -1
  60. package/dest/store/contract_instance_store.d.ts.map +1 -1
  61. package/dest/store/contract_instance_store.js +37 -2
  62. package/dest/store/data_stores.d.ts +68 -0
  63. package/dest/store/data_stores.d.ts.map +1 -0
  64. package/dest/store/data_stores.js +54 -0
  65. package/dest/store/function_names_cache.d.ts +17 -0
  66. package/dest/store/function_names_cache.d.ts.map +1 -0
  67. package/dest/store/function_names_cache.js +30 -0
  68. package/dest/store/l2_tips_cache.d.ts +25 -0
  69. package/dest/store/l2_tips_cache.d.ts.map +1 -0
  70. package/dest/store/l2_tips_cache.js +26 -0
  71. package/dest/store/log_store.d.ts +42 -37
  72. package/dest/store/log_store.d.ts.map +1 -1
  73. package/dest/store/log_store.js +262 -408
  74. package/dest/store/log_store_codec.d.ts +70 -0
  75. package/dest/store/log_store_codec.d.ts.map +1 -0
  76. package/dest/store/log_store_codec.js +101 -0
  77. package/dest/store/message_store.d.ts +11 -1
  78. package/dest/store/message_store.d.ts.map +1 -1
  79. package/dest/store/message_store.js +51 -9
  80. package/dest/test/fake_l1_state.d.ts +25 -1
  81. package/dest/test/fake_l1_state.d.ts.map +1 -1
  82. package/dest/test/fake_l1_state.js +166 -32
  83. package/dest/test/mock_archiver.d.ts +1 -1
  84. package/dest/test/mock_archiver.d.ts.map +1 -1
  85. package/dest/test/mock_archiver.js +3 -2
  86. package/dest/test/mock_l1_to_l2_message_source.d.ts +1 -1
  87. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
  88. package/dest/test/mock_l1_to_l2_message_source.js +2 -1
  89. package/dest/test/mock_l2_block_source.d.ts +64 -47
  90. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  91. package/dest/test/mock_l2_block_source.js +323 -214
  92. package/dest/test/mock_structs.d.ts +4 -1
  93. package/dest/test/mock_structs.d.ts.map +1 -1
  94. package/dest/test/mock_structs.js +13 -1
  95. package/dest/test/noop_l1_archiver.d.ts +13 -6
  96. package/dest/test/noop_l1_archiver.d.ts.map +1 -1
  97. package/dest/test/noop_l1_archiver.js +27 -10
  98. package/package.json +14 -14
  99. package/src/archiver.ts +359 -183
  100. package/src/config.ts +24 -11
  101. package/src/errors.ts +122 -21
  102. package/src/factory.ts +79 -38
  103. package/src/index.ts +19 -2
  104. package/src/l1/README.md +25 -68
  105. package/src/l1/bin/retrieve-calldata.ts +40 -27
  106. package/src/l1/calldata_retriever.ts +260 -379
  107. package/src/l1/data_retrieval.ts +58 -69
  108. package/src/l1/spire_proposer.ts +7 -15
  109. package/src/l1/validate_historical_logs.ts +140 -0
  110. package/src/modules/contract_data_source_adapter.ts +55 -0
  111. package/src/modules/data_source_base.ts +354 -226
  112. package/src/modules/data_store_updater.ts +248 -153
  113. package/src/modules/instrumentation.ts +56 -9
  114. package/src/modules/l1_synchronizer.ts +585 -258
  115. package/src/modules/outbox_trees_resolver.ts +199 -0
  116. package/src/modules/validation.ts +10 -9
  117. package/src/store/block_store.ts +917 -343
  118. package/src/store/contract_class_store.ts +31 -103
  119. package/src/store/contract_instance_store.ts +51 -5
  120. package/src/store/data_stores.ts +104 -0
  121. package/src/store/function_names_cache.ts +37 -0
  122. package/src/store/l2_tips_cache.ts +35 -0
  123. package/src/store/log_store.ts +301 -559
  124. package/src/store/log_store_codec.ts +132 -0
  125. package/src/store/message_store.ts +60 -10
  126. package/src/structs/inbox_message.ts +1 -1
  127. package/src/test/fake_l1_state.ts +213 -42
  128. package/src/test/mock_archiver.ts +3 -2
  129. package/src/test/mock_l1_to_l2_message_source.ts +1 -0
  130. package/src/test/mock_l2_block_source.ts +391 -232
  131. package/src/test/mock_structs.ts +20 -6
  132. package/src/test/noop_l1_archiver.ts +49 -10
  133. package/dest/store/kv_archiver_store.d.ts +0 -340
  134. package/dest/store/kv_archiver_store.d.ts.map +0 -1
  135. package/dest/store/kv_archiver_store.js +0 -446
  136. package/src/store/kv_archiver_store.ts +0 -639
@@ -1,5 +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';
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';
3
7
  import {
4
8
  Attributes,
5
9
  type Gauge,
@@ -17,6 +21,7 @@ export class ArchiverInstrumentation {
17
21
  public readonly tracer: Tracer;
18
22
 
19
23
  private blockHeight: Gauge;
24
+ private checkpointHeight: Gauge;
20
25
  private txCount: UpDownCounter;
21
26
  private l1BlockHeight: Gauge;
22
27
  private proofsSubmittedDelay: Histogram;
@@ -27,6 +32,7 @@ export class ArchiverInstrumentation {
27
32
  private pruneCount: UpDownCounter;
28
33
 
29
34
  private syncDurationPerBlock: Histogram;
35
+ private syncDurationPerCheckpoint: Histogram;
30
36
  private syncBlockCount: UpDownCounter;
31
37
  private manaPerBlock: Histogram;
32
38
  private txsPerBlock: Histogram;
@@ -36,6 +42,9 @@ export class ArchiverInstrumentation {
36
42
 
37
43
  private blockProposalTxTargetCount: UpDownCounter;
38
44
 
45
+ private checkpointL1InclusionDelay: Histogram;
46
+ private checkpointPromotedCount: UpDownCounter;
47
+
39
48
  private log = createLogger('archiver:instrumentation');
40
49
 
41
50
  private constructor(
@@ -47,6 +56,8 @@ export class ArchiverInstrumentation {
47
56
 
48
57
  this.blockHeight = meter.createGauge(Metrics.ARCHIVER_BLOCK_HEIGHT);
49
58
 
59
+ this.checkpointHeight = meter.createGauge(Metrics.ARCHIVER_CHECKPOINT_HEIGHT);
60
+
50
61
  this.l1BlockHeight = meter.createGauge(Metrics.ARCHIVER_L1_BLOCK_HEIGHT);
51
62
 
52
63
  this.txCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_TOTAL_TXS);
@@ -59,6 +70,8 @@ export class ArchiverInstrumentation {
59
70
 
60
71
  this.syncDurationPerBlock = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_BLOCK);
61
72
 
73
+ this.syncDurationPerCheckpoint = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_CHECKPOINT);
74
+
62
75
  this.syncBlockCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_SYNC_BLOCK_COUNT);
63
76
 
64
77
  this.manaPerBlock = meter.createHistogram(Metrics.ARCHIVER_MANA_PER_BLOCK);
@@ -81,6 +94,10 @@ export class ArchiverInstrumentation {
81
94
  },
82
95
  );
83
96
 
97
+ this.checkpointL1InclusionDelay = meter.createHistogram(Metrics.ARCHIVER_CHECKPOINT_L1_INCLUSION_DELAY);
98
+
99
+ this.checkpointPromotedCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_CHECKPOINT_PROMOTED_COUNT);
100
+
84
101
  this.dbMetrics = new LmdbMetrics(
85
102
  meter,
86
103
  {
@@ -102,16 +119,26 @@ export class ArchiverInstrumentation {
102
119
  return this.telemetry.isEnabled();
103
120
  }
104
121
 
105
- 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);
106
125
  this.syncDurationPerBlock.record(Math.ceil(syncTimePerBlock));
107
- this.blockHeight.record(Math.max(...blocks.map(b => b.number)));
108
- this.syncBlockCount.add(blocks.length);
109
126
 
110
- for (const block of blocks) {
111
- this.txCount.add(block.body.txEffects.length);
112
- this.txsPerBlock.record(block.body.txEffects.length);
113
- this.manaPerBlock.record(block.header.totalManaUsed.toNumber() / 1e6);
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;
114
136
  }
137
+
138
+ this.syncDurationPerCheckpoint.record(Math.ceil(syncTimePerCheckpoint));
139
+ this.blockHeight.record(Math.max(...blocks.map(b => b.number)), { [Attributes.STATUS]: 'checkpointed' });
140
+ this.checkpointHeight.record(Math.max(...blocks.map(b => b.checkpointNumber)));
141
+ this.syncBlockCount.add(blocks.length);
115
142
  }
116
143
 
117
144
  public processNewMessages(count: number, syncPerMessageMs: number) {
@@ -127,8 +154,10 @@ export class ArchiverInstrumentation {
127
154
  this.pruneDuration.record(Math.ceil(duration));
128
155
  }
129
156
 
130
- public updateLastProvenBlock(blockNumber: number) {
131
- this.blockHeight.record(blockNumber, { [Attributes.STATUS]: 'proven' });
157
+ public updateLastProvenCheckpoint(checkpoint: CheckpointData) {
158
+ const lastBlockNumberInCheckpoint = checkpoint.startBlock + checkpoint.blockCount - 1;
159
+ this.blockHeight.record(lastBlockNumberInCheckpoint, { [Attributes.STATUS]: 'proven' });
160
+ this.checkpointHeight.record(checkpoint.checkpointNumber, { [Attributes.STATUS]: 'proven' });
132
161
  }
133
162
 
134
163
  public processProofsVerified(logs: { proverId: string; l2BlockNumber: bigint; delay: bigint }[]) {
@@ -154,4 +183,22 @@ export class ArchiverInstrumentation {
154
183
  [Attributes.L1_BLOCK_PROPOSAL_USED_TRACE]: usedTrace,
155
184
  });
156
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
+ }
157
204
  }