@aztec/archiver 0.0.1-commit.d431d1c → 0.0.1-commit.d58ff9d0
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.
- package/README.md +28 -11
- package/dest/archiver.d.ts +80 -21
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +347 -167
- package/dest/config.d.ts +7 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +38 -14
- package/dest/errors.d.ts +60 -9
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +88 -13
- package/dest/factory.d.ts +13 -6
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +59 -39
- package/dest/index.d.ts +12 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +11 -2
- package/dest/l1/bin/retrieve-calldata.js +35 -32
- package/dest/l1/calldata_retriever.d.ts +81 -50
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +202 -260
- package/dest/l1/data_retrieval.d.ts +32 -18
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +45 -50
- package/dest/l1/spire_proposer.d.ts +5 -5
- package/dest/l1/spire_proposer.d.ts.map +1 -1
- package/dest/l1/spire_proposer.js +9 -17
- package/dest/l1/trace_tx.d.ts +12 -66
- package/dest/l1/trace_tx.d.ts.map +1 -1
- package/dest/l1/validate_historical_logs.d.ts +23 -0
- package/dest/l1/validate_historical_logs.d.ts.map +1 -0
- package/dest/l1/validate_historical_logs.js +108 -0
- package/dest/l1/validate_trace.d.ts +6 -3
- package/dest/l1/validate_trace.d.ts.map +1 -1
- package/dest/l1/validate_trace.js +13 -9
- package/dest/modules/contract_data_source_adapter.d.ts +25 -0
- package/dest/modules/contract_data_source_adapter.d.ts.map +1 -0
- package/dest/modules/contract_data_source_adapter.js +32 -0
- package/dest/modules/data_source_base.d.ts +75 -48
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +251 -220
- package/dest/modules/data_store_updater.d.ts +65 -29
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +242 -153
- package/dest/modules/instrumentation.d.ts +30 -4
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +83 -20
- package/dest/modules/l1_synchronizer.d.ts +16 -14
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +493 -225
- package/dest/modules/outbox_trees_resolver.d.ts +62 -0
- package/dest/modules/outbox_trees_resolver.d.ts.map +1 -0
- package/dest/modules/outbox_trees_resolver.js +162 -0
- package/dest/modules/validation.d.ts +30 -7
- package/dest/modules/validation.d.ts.map +1 -1
- package/dest/modules/validation.js +35 -17
- package/dest/store/block_store.d.ts +200 -75
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +802 -276
- package/dest/store/contract_class_store.d.ts +17 -4
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +51 -73
- package/dest/store/contract_instance_store.d.ts +28 -1
- package/dest/store/contract_instance_store.d.ts.map +1 -1
- package/dest/store/contract_instance_store.js +54 -2
- package/dest/store/data_stores.d.ts +68 -0
- package/dest/store/data_stores.d.ts.map +1 -0
- package/dest/store/data_stores.js +54 -0
- package/dest/store/function_names_cache.d.ts +17 -0
- package/dest/store/function_names_cache.d.ts.map +1 -0
- package/dest/store/function_names_cache.js +30 -0
- package/dest/store/l2_tips_cache.d.ts +25 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +26 -0
- package/dest/store/log_store.d.ts +42 -37
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +262 -388
- package/dest/store/log_store_codec.d.ts +78 -0
- package/dest/store/log_store_codec.d.ts.map +1 -0
- package/dest/store/log_store_codec.js +110 -0
- package/dest/store/message_store.d.ts +11 -1
- package/dest/store/message_store.d.ts.map +1 -1
- package/dest/store/message_store.js +51 -9
- package/dest/test/fake_l1_state.d.ts +28 -4
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +166 -32
- package/dest/test/index.js +3 -1
- package/dest/test/mock_archiver.d.ts +1 -1
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +3 -2
- package/dest/test/mock_l2_block_source.d.ts +65 -51
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +309 -215
- package/dest/test/mock_structs.d.ts +6 -2
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +26 -12
- package/dest/test/noop_l1_archiver.d.ts +34 -0
- package/dest/test/noop_l1_archiver.d.ts.map +1 -0
- package/dest/test/noop_l1_archiver.js +88 -0
- package/package.json +15 -14
- package/src/archiver.ts +458 -198
- package/src/config.ts +43 -13
- package/src/errors.ts +134 -21
- package/src/factory.ts +87 -36
- package/src/index.ts +19 -2
- package/src/l1/README.md +25 -68
- package/src/l1/bin/retrieve-calldata.ts +45 -33
- package/src/l1/calldata_retriever.ts +267 -379
- package/src/l1/data_retrieval.ts +70 -74
- package/src/l1/spire_proposer.ts +7 -15
- package/src/l1/validate_historical_logs.ts +140 -0
- package/src/l1/validate_trace.ts +24 -6
- package/src/modules/contract_data_source_adapter.ts +46 -0
- package/src/modules/data_source_base.ts +336 -288
- package/src/modules/data_store_updater.ts +287 -187
- package/src/modules/instrumentation.ts +86 -21
- package/src/modules/l1_synchronizer.ts +667 -278
- package/src/modules/outbox_trees_resolver.ts +199 -0
- package/src/modules/validation.ts +80 -23
- package/src/store/block_store.ts +984 -352
- package/src/store/contract_class_store.ts +57 -107
- package/src/store/contract_instance_store.ts +68 -5
- package/src/store/data_stores.ts +104 -0
- package/src/store/function_names_cache.ts +37 -0
- package/src/store/l2_tips_cache.ts +35 -0
- package/src/store/log_store.ts +305 -500
- package/src/store/log_store_codec.ts +143 -0
- package/src/store/message_store.ts +60 -10
- package/src/structs/inbox_message.ts +1 -1
- package/src/test/fake_l1_state.ts +215 -44
- package/src/test/index.ts +3 -0
- package/src/test/mock_archiver.ts +3 -2
- package/src/test/mock_l2_block_source.ts +381 -246
- package/src/test/mock_structs.ts +50 -17
- package/src/test/noop_l1_archiver.ts +158 -0
- package/dest/store/kv_archiver_store.d.ts +0 -336
- package/dest/store/kv_archiver_store.d.ts.map +0 -1
- package/dest/store/kv_archiver_store.js +0 -443
- package/src/store/kv_archiver_store.ts +0 -631
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import type {
|
|
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,
|
|
@@ -10,12 +14,14 @@ import {
|
|
|
10
14
|
type TelemetryClient,
|
|
11
15
|
type Tracer,
|
|
12
16
|
type UpDownCounter,
|
|
17
|
+
createUpDownCounterWithDefault,
|
|
13
18
|
} from '@aztec/telemetry-client';
|
|
14
19
|
|
|
15
20
|
export class ArchiverInstrumentation {
|
|
16
21
|
public readonly tracer: Tracer;
|
|
17
22
|
|
|
18
23
|
private blockHeight: Gauge;
|
|
24
|
+
private checkpointHeight: Gauge;
|
|
19
25
|
private txCount: UpDownCounter;
|
|
20
26
|
private l1BlockHeight: Gauge;
|
|
21
27
|
private proofsSubmittedDelay: Histogram;
|
|
@@ -26,6 +32,7 @@ export class ArchiverInstrumentation {
|
|
|
26
32
|
private pruneCount: UpDownCounter;
|
|
27
33
|
|
|
28
34
|
private syncDurationPerBlock: Histogram;
|
|
35
|
+
private syncDurationPerCheckpoint: Histogram;
|
|
29
36
|
private syncBlockCount: UpDownCounter;
|
|
30
37
|
private manaPerBlock: Histogram;
|
|
31
38
|
private txsPerBlock: Histogram;
|
|
@@ -35,6 +42,9 @@ export class ArchiverInstrumentation {
|
|
|
35
42
|
|
|
36
43
|
private blockProposalTxTargetCount: UpDownCounter;
|
|
37
44
|
|
|
45
|
+
private checkpointL1InclusionDelay: Histogram;
|
|
46
|
+
private checkpointPromotedCount: UpDownCounter;
|
|
47
|
+
|
|
38
48
|
private log = createLogger('archiver:instrumentation');
|
|
39
49
|
|
|
40
50
|
private constructor(
|
|
@@ -46,17 +56,23 @@ export class ArchiverInstrumentation {
|
|
|
46
56
|
|
|
47
57
|
this.blockHeight = meter.createGauge(Metrics.ARCHIVER_BLOCK_HEIGHT);
|
|
48
58
|
|
|
59
|
+
this.checkpointHeight = meter.createGauge(Metrics.ARCHIVER_CHECKPOINT_HEIGHT);
|
|
60
|
+
|
|
49
61
|
this.l1BlockHeight = meter.createGauge(Metrics.ARCHIVER_L1_BLOCK_HEIGHT);
|
|
50
62
|
|
|
51
|
-
this.txCount = meter
|
|
63
|
+
this.txCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_TOTAL_TXS);
|
|
52
64
|
|
|
53
|
-
this.proofsSubmittedCount = meter
|
|
65
|
+
this.proofsSubmittedCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_ROLLUP_PROOF_COUNT, {
|
|
66
|
+
[Attributes.PROOF_TIMED_OUT]: [true, false],
|
|
67
|
+
});
|
|
54
68
|
|
|
55
69
|
this.proofsSubmittedDelay = meter.createHistogram(Metrics.ARCHIVER_ROLLUP_PROOF_DELAY);
|
|
56
70
|
|
|
57
71
|
this.syncDurationPerBlock = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_BLOCK);
|
|
58
72
|
|
|
59
|
-
this.
|
|
73
|
+
this.syncDurationPerCheckpoint = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_CHECKPOINT);
|
|
74
|
+
|
|
75
|
+
this.syncBlockCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_SYNC_BLOCK_COUNT);
|
|
60
76
|
|
|
61
77
|
this.manaPerBlock = meter.createHistogram(Metrics.ARCHIVER_MANA_PER_BLOCK);
|
|
62
78
|
|
|
@@ -64,13 +80,25 @@ export class ArchiverInstrumentation {
|
|
|
64
80
|
|
|
65
81
|
this.syncDurationPerMessage = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_MESSAGE);
|
|
66
82
|
|
|
67
|
-
this.syncMessageCount = meter
|
|
83
|
+
this.syncMessageCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_SYNC_MESSAGE_COUNT);
|
|
68
84
|
|
|
69
85
|
this.pruneDuration = meter.createHistogram(Metrics.ARCHIVER_PRUNE_DURATION);
|
|
70
86
|
|
|
71
|
-
this.pruneCount = meter
|
|
87
|
+
this.pruneCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_PRUNE_COUNT, {
|
|
88
|
+
[Attributes.PRUNE_TYPE]: ['unproven', 'uncheckpointed', 'l1_conflict', 'orphan', 'l1_mismatch'],
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
this.blockProposalTxTargetCount = createUpDownCounterWithDefault(
|
|
92
|
+
meter,
|
|
93
|
+
Metrics.ARCHIVER_BLOCK_PROPOSAL_TX_TARGET_COUNT,
|
|
94
|
+
{
|
|
95
|
+
[Attributes.L1_BLOCK_PROPOSAL_USED_TRACE]: [true, false],
|
|
96
|
+
},
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
this.checkpointL1InclusionDelay = meter.createHistogram(Metrics.ARCHIVER_CHECKPOINT_L1_INCLUSION_DELAY);
|
|
72
100
|
|
|
73
|
-
this.
|
|
101
|
+
this.checkpointPromotedCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_CHECKPOINT_PROMOTED_COUNT);
|
|
74
102
|
|
|
75
103
|
this.dbMetrics = new LmdbMetrics(
|
|
76
104
|
meter,
|
|
@@ -84,10 +112,6 @@ export class ArchiverInstrumentation {
|
|
|
84
112
|
public static async new(telemetry: TelemetryClient, lmdbStats?: LmdbStatsCallback) {
|
|
85
113
|
const instance = new ArchiverInstrumentation(telemetry, lmdbStats);
|
|
86
114
|
|
|
87
|
-
instance.syncBlockCount.add(0);
|
|
88
|
-
instance.syncMessageCount.add(0);
|
|
89
|
-
instance.pruneCount.add(0);
|
|
90
|
-
|
|
91
115
|
await instance.telemetry.flush();
|
|
92
116
|
|
|
93
117
|
return instance;
|
|
@@ -97,16 +121,26 @@ export class ArchiverInstrumentation {
|
|
|
97
121
|
return this.telemetry.isEnabled();
|
|
98
122
|
}
|
|
99
123
|
|
|
100
|
-
public
|
|
124
|
+
public processNewProposedBlock(syncTimePerBlock: number, block: L2Block) {
|
|
125
|
+
const attrs = { [Attributes.STATUS]: 'proposed' };
|
|
126
|
+
this.blockHeight.record(block.number, attrs);
|
|
101
127
|
this.syncDurationPerBlock.record(Math.ceil(syncTimePerBlock));
|
|
102
|
-
this.blockHeight.record(Math.max(...blocks.map(b => b.number)));
|
|
103
|
-
this.syncBlockCount.add(blocks.length);
|
|
104
128
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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;
|
|
109
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);
|
|
110
144
|
}
|
|
111
145
|
|
|
112
146
|
public processNewMessages(count: number, syncPerMessageMs: number) {
|
|
@@ -118,12 +152,25 @@ export class ArchiverInstrumentation {
|
|
|
118
152
|
}
|
|
119
153
|
|
|
120
154
|
public processPrune(duration: number) {
|
|
121
|
-
this.pruneCount.add(1);
|
|
155
|
+
this.pruneCount.add(1, { [Attributes.PRUNE_TYPE]: 'unproven' });
|
|
122
156
|
this.pruneDuration.record(Math.ceil(duration));
|
|
123
157
|
}
|
|
124
158
|
|
|
125
|
-
|
|
126
|
-
|
|
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
|
+
|
|
170
|
+
public updateLastProvenCheckpoint(checkpoint: CheckpointData) {
|
|
171
|
+
const lastBlockNumberInCheckpoint = checkpoint.startBlock + checkpoint.blockCount - 1;
|
|
172
|
+
this.blockHeight.record(lastBlockNumberInCheckpoint, { [Attributes.STATUS]: 'proven' });
|
|
173
|
+
this.checkpointHeight.record(checkpoint.checkpointNumber, { [Attributes.STATUS]: 'proven' });
|
|
127
174
|
}
|
|
128
175
|
|
|
129
176
|
public processProofsVerified(logs: { proverId: string; l2BlockNumber: bigint; delay: bigint }[]) {
|
|
@@ -149,4 +196,22 @@ export class ArchiverInstrumentation {
|
|
|
149
196
|
[Attributes.L1_BLOCK_PROPOSAL_USED_TRACE]: usedTrace,
|
|
150
197
|
});
|
|
151
198
|
}
|
|
199
|
+
|
|
200
|
+
/** Records a checkpoint promoted from proposed (blob fetch skipped). */
|
|
201
|
+
public processCheckpointPromoted() {
|
|
202
|
+
this.checkpointPromotedCount.add(1);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Records L1 inclusion timing for a checkpoint observed on L1 (seconds into the L2 slot).
|
|
207
|
+
*/
|
|
208
|
+
public processCheckpointL1Timing(data: {
|
|
209
|
+
slotNumber: SlotNumber;
|
|
210
|
+
l1Timestamp: bigint;
|
|
211
|
+
l1Constants: Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'>;
|
|
212
|
+
}): void {
|
|
213
|
+
const slotStartTs = getTimestampForSlot(data.slotNumber, data.l1Constants);
|
|
214
|
+
const inclusionDelaySeconds = Number(data.l1Timestamp - slotStartTs);
|
|
215
|
+
this.checkpointL1InclusionDelay.record(inclusionDelaySeconds);
|
|
216
|
+
}
|
|
152
217
|
}
|