@aztec/archiver 0.0.1-commit.f504929 → 0.0.1-commit.f5a9928

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 (121) hide show
  1. package/README.md +19 -13
  2. package/dest/archiver.d.ts +73 -18
  3. package/dest/archiver.d.ts.map +1 -1
  4. package/dest/archiver.js +321 -81
  5. package/dest/config.d.ts +7 -3
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +43 -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 +20 -9
  12. package/dest/factory.d.ts.map +1 -1
  13. package/dest/factory.js +85 -37
  14. package/dest/index.d.ts +11 -3
  15. package/dest/index.d.ts.map +1 -1
  16. package/dest/index.js +10 -2
  17. package/dest/l1/calldata_retriever.d.ts +9 -1
  18. package/dest/l1/calldata_retriever.d.ts.map +1 -1
  19. package/dest/l1/calldata_retriever.js +22 -11
  20. package/dest/l1/data_retrieval.d.ts +25 -11
  21. package/dest/l1/data_retrieval.d.ts.map +1 -1
  22. package/dest/l1/data_retrieval.js +25 -32
  23. package/dest/l1/trace_tx.d.ts +12 -66
  24. package/dest/l1/trace_tx.d.ts.map +1 -1
  25. package/dest/l1/validate_historical_logs.d.ts +23 -0
  26. package/dest/l1/validate_historical_logs.d.ts.map +1 -0
  27. package/dest/l1/validate_historical_logs.js +108 -0
  28. package/dest/modules/contract_data_source_adapter.d.ts +25 -0
  29. package/dest/modules/contract_data_source_adapter.d.ts.map +1 -0
  30. package/dest/modules/contract_data_source_adapter.js +32 -0
  31. package/dest/modules/data_source_base.d.ts +73 -50
  32. package/dest/modules/data_source_base.d.ts.map +1 -1
  33. package/dest/modules/data_source_base.js +250 -144
  34. package/dest/modules/data_store_updater.d.ts +42 -17
  35. package/dest/modules/data_store_updater.d.ts.map +1 -1
  36. package/dest/modules/data_store_updater.js +198 -123
  37. package/dest/modules/instrumentation.d.ts +15 -2
  38. package/dest/modules/instrumentation.d.ts.map +1 -1
  39. package/dest/modules/instrumentation.js +48 -9
  40. package/dest/modules/l1_synchronizer.d.ts +14 -8
  41. package/dest/modules/l1_synchronizer.d.ts.map +1 -1
  42. package/dest/modules/l1_synchronizer.js +477 -213
  43. package/dest/modules/outbox_trees_resolver.d.ts +64 -0
  44. package/dest/modules/outbox_trees_resolver.d.ts.map +1 -0
  45. package/dest/modules/outbox_trees_resolver.js +184 -0
  46. package/dest/modules/validation.d.ts +30 -7
  47. package/dest/modules/validation.d.ts.map +1 -1
  48. package/dest/modules/validation.js +35 -17
  49. package/dest/store/block_store.d.ts +186 -78
  50. package/dest/store/block_store.d.ts.map +1 -1
  51. package/dest/store/block_store.js +763 -290
  52. package/dest/store/contract_class_store.d.ts +17 -4
  53. package/dest/store/contract_class_store.d.ts.map +1 -1
  54. package/dest/store/contract_class_store.js +42 -68
  55. package/dest/store/contract_instance_store.d.ts +28 -1
  56. package/dest/store/contract_instance_store.d.ts.map +1 -1
  57. package/dest/store/contract_instance_store.js +58 -6
  58. package/dest/store/data_stores.d.ts +68 -0
  59. package/dest/store/data_stores.d.ts.map +1 -0
  60. package/dest/store/data_stores.js +54 -0
  61. package/dest/store/function_names_cache.d.ts +17 -0
  62. package/dest/store/function_names_cache.d.ts.map +1 -0
  63. package/dest/store/function_names_cache.js +30 -0
  64. package/dest/store/l2_tips_cache.d.ts +13 -7
  65. package/dest/store/l2_tips_cache.d.ts.map +1 -1
  66. package/dest/store/l2_tips_cache.js +13 -76
  67. package/dest/store/log_store.d.ts +42 -37
  68. package/dest/store/log_store.d.ts.map +1 -1
  69. package/dest/store/log_store.js +262 -408
  70. package/dest/store/log_store_codec.d.ts +78 -0
  71. package/dest/store/log_store_codec.d.ts.map +1 -0
  72. package/dest/store/log_store_codec.js +110 -0
  73. package/dest/store/message_store.d.ts +11 -1
  74. package/dest/store/message_store.d.ts.map +1 -1
  75. package/dest/store/message_store.js +51 -9
  76. package/dest/test/fake_l1_state.d.ts +20 -1
  77. package/dest/test/fake_l1_state.d.ts.map +1 -1
  78. package/dest/test/fake_l1_state.js +117 -21
  79. package/dest/test/mock_l2_block_source.d.ts +51 -52
  80. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  81. package/dest/test/mock_l2_block_source.js +232 -180
  82. package/dest/test/mock_structs.d.ts +4 -1
  83. package/dest/test/mock_structs.d.ts.map +1 -1
  84. package/dest/test/mock_structs.js +15 -3
  85. package/dest/test/noop_l1_archiver.d.ts +17 -6
  86. package/dest/test/noop_l1_archiver.d.ts.map +1 -1
  87. package/dest/test/noop_l1_archiver.js +31 -11
  88. package/package.json +15 -14
  89. package/src/archiver.ts +415 -90
  90. package/src/config.ts +51 -13
  91. package/src/errors.ts +122 -21
  92. package/src/factory.ts +99 -30
  93. package/src/index.ts +18 -2
  94. package/src/l1/calldata_retriever.ts +29 -11
  95. package/src/l1/data_retrieval.ts +44 -46
  96. package/src/l1/validate_historical_logs.ts +140 -0
  97. package/src/modules/contract_data_source_adapter.ts +46 -0
  98. package/src/modules/data_source_base.ts +327 -189
  99. package/src/modules/data_store_updater.ts +235 -155
  100. package/src/modules/instrumentation.ts +43 -10
  101. package/src/modules/l1_synchronizer.ts +646 -259
  102. package/src/modules/outbox_trees_resolver.ts +220 -0
  103. package/src/modules/validation.ts +80 -23
  104. package/src/store/block_store.ts +930 -348
  105. package/src/store/contract_class_store.ts +49 -103
  106. package/src/store/contract_instance_store.ts +74 -11
  107. package/src/store/data_stores.ts +104 -0
  108. package/src/store/function_names_cache.ts +37 -0
  109. package/src/store/l2_tips_cache.ts +16 -70
  110. package/src/store/log_store.ts +302 -559
  111. package/src/store/log_store_codec.ts +143 -0
  112. package/src/store/message_store.ts +60 -10
  113. package/src/structs/inbox_message.ts +1 -1
  114. package/src/test/fake_l1_state.ts +145 -32
  115. package/src/test/mock_l2_block_source.ts +292 -227
  116. package/src/test/mock_structs.ts +25 -8
  117. package/src/test/noop_l1_archiver.ts +61 -12
  118. package/dest/store/kv_archiver_store.d.ts +0 -354
  119. package/dest/store/kv_archiver_store.d.ts.map +0 -1
  120. package/dest/store/kv_archiver_store.js +0 -464
  121. package/src/store/kv_archiver_store.ts +0 -671
@@ -32,6 +32,7 @@ export class ArchiverInstrumentation {
32
32
  private pruneCount: UpDownCounter;
33
33
 
34
34
  private syncDurationPerBlock: Histogram;
35
+ private syncDurationPerCheckpoint: Histogram;
35
36
  private syncBlockCount: UpDownCounter;
36
37
  private manaPerBlock: Histogram;
37
38
  private txsPerBlock: Histogram;
@@ -42,6 +43,7 @@ export class ArchiverInstrumentation {
42
43
  private blockProposalTxTargetCount: UpDownCounter;
43
44
 
44
45
  private checkpointL1InclusionDelay: Histogram;
46
+ private checkpointPromotedCount: UpDownCounter;
45
47
 
46
48
  private log = createLogger('archiver:instrumentation');
47
49
 
@@ -68,6 +70,8 @@ export class ArchiverInstrumentation {
68
70
 
69
71
  this.syncDurationPerBlock = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_BLOCK);
70
72
 
73
+ this.syncDurationPerCheckpoint = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_CHECKPOINT);
74
+
71
75
  this.syncBlockCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_SYNC_BLOCK_COUNT);
72
76
 
73
77
  this.manaPerBlock = meter.createHistogram(Metrics.ARCHIVER_MANA_PER_BLOCK);
@@ -80,7 +84,9 @@ export class ArchiverInstrumentation {
80
84
 
81
85
  this.pruneDuration = meter.createHistogram(Metrics.ARCHIVER_PRUNE_DURATION);
82
86
 
83
- this.pruneCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_PRUNE_COUNT);
87
+ this.pruneCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_PRUNE_COUNT, {
88
+ [Attributes.PRUNE_TYPE]: ['unproven', 'uncheckpointed', 'l1_conflict', 'orphan', 'l1_mismatch'],
89
+ });
84
90
 
85
91
  this.blockProposalTxTargetCount = createUpDownCounterWithDefault(
86
92
  meter,
@@ -92,6 +98,8 @@ export class ArchiverInstrumentation {
92
98
 
93
99
  this.checkpointL1InclusionDelay = meter.createHistogram(Metrics.ARCHIVER_CHECKPOINT_L1_INCLUSION_DELAY);
94
100
 
101
+ this.checkpointPromotedCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_CHECKPOINT_PROMOTED_COUNT);
102
+
95
103
  this.dbMetrics = new LmdbMetrics(
96
104
  meter,
97
105
  {
@@ -113,17 +121,26 @@ export class ArchiverInstrumentation {
113
121
  return this.telemetry.isEnabled();
114
122
  }
115
123
 
116
- public processNewBlocks(syncTimePerBlock: number, blocks: L2Block[]) {
124
+ public processNewProposedBlock(syncTimePerBlock: number, block: L2Block) {
125
+ const attrs = { [Attributes.STATUS]: 'proposed' };
126
+ this.blockHeight.record(block.number, attrs);
117
127
  this.syncDurationPerBlock.record(Math.ceil(syncTimePerBlock));
118
- this.blockHeight.record(Math.max(...blocks.map(b => b.number)));
119
- this.checkpointHeight.record(Math.max(...blocks.map(b => b.checkpointNumber)));
120
- this.syncBlockCount.add(blocks.length);
121
128
 
122
- for (const block of blocks) {
123
- this.txCount.add(block.body.txEffects.length);
124
- this.txsPerBlock.record(block.body.txEffects.length);
125
- this.manaPerBlock.record(block.header.totalManaUsed.toNumber() / 1e6);
129
+ // Per block metrics
130
+ this.txCount.add(block.body.txEffects.length);
131
+ this.txsPerBlock.record(block.body.txEffects.length);
132
+ this.manaPerBlock.record(block.header.totalManaUsed.toNumber() / 1e6);
133
+ }
134
+
135
+ public processNewCheckpointedBlocks(syncTimePerCheckpoint: number, blocks: L2Block[]) {
136
+ if (blocks.length === 0) {
137
+ return;
126
138
  }
139
+
140
+ this.syncDurationPerCheckpoint.record(Math.ceil(syncTimePerCheckpoint));
141
+ this.blockHeight.record(Math.max(...blocks.map(b => b.number)), { [Attributes.STATUS]: 'checkpointed' });
142
+ this.checkpointHeight.record(Math.max(...blocks.map(b => b.checkpointNumber)));
143
+ this.syncBlockCount.add(blocks.length);
127
144
  }
128
145
 
129
146
  public processNewMessages(count: number, syncPerMessageMs: number) {
@@ -135,10 +152,21 @@ export class ArchiverInstrumentation {
135
152
  }
136
153
 
137
154
  public processPrune(duration: number) {
138
- this.pruneCount.add(1);
155
+ this.pruneCount.add(1, { [Attributes.PRUNE_TYPE]: 'unproven' });
139
156
  this.pruneDuration.record(Math.ceil(duration));
140
157
  }
141
158
 
159
+ /**
160
+ * Records a pending-chain reorg, where the archiver dropped proposed blocks (and world-state follows by pruning). The
161
+ * type distinguishes the cause: 'uncheckpointed' (slot ended without a checkpoint), 'l1_conflict' (proposed blocks
162
+ * conflicting with an L1 checkpoint), 'orphan' (no matching proposed checkpoint arrived before the deadline), or
163
+ * 'l1_mismatch' (the local checkpointed tip diverged from L1 — an L1 reorg or a pruned/missed-proof checkpoint — so
164
+ * already-checkpointed blocks were rewound).
165
+ */
166
+ public recordPrune(pruneType: 'uncheckpointed' | 'l1_conflict' | 'orphan' | 'l1_mismatch') {
167
+ this.pruneCount.add(1, { [Attributes.PRUNE_TYPE]: pruneType });
168
+ }
169
+
142
170
  public updateLastProvenCheckpoint(checkpoint: CheckpointData) {
143
171
  const lastBlockNumberInCheckpoint = checkpoint.startBlock + checkpoint.blockCount - 1;
144
172
  this.blockHeight.record(lastBlockNumberInCheckpoint, { [Attributes.STATUS]: 'proven' });
@@ -169,6 +197,11 @@ export class ArchiverInstrumentation {
169
197
  });
170
198
  }
171
199
 
200
+ /** Records a checkpoint promoted from proposed (blob fetch skipped). */
201
+ public processCheckpointPromoted() {
202
+ this.checkpointPromotedCount.add(1);
203
+ }
204
+
172
205
  /**
173
206
  * Records L1 inclusion timing for a checkpoint observed on L1 (seconds into the L2 slot).
174
207
  */