@aztec/archiver 0.0.1-commit.d1f2d6c → 0.0.1-commit.d20b825a7
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 +12 -6
- package/dest/archiver.d.ts +16 -10
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +110 -122
- package/dest/config.d.ts +5 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +15 -3
- package/dest/errors.d.ts +55 -10
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +74 -15
- package/dest/factory.d.ts +5 -4
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +34 -29
- package/dest/index.d.ts +4 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +3 -1
- package/dest/l1/bin/retrieve-calldata.js +36 -33
- package/dest/l1/calldata_retriever.d.ts +73 -50
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +191 -259
- package/dest/l1/data_retrieval.d.ts +26 -17
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +43 -48
- 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/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/data_source_base.d.ts +17 -10
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +39 -77
- package/dest/modules/data_store_updater.d.ts +50 -26
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +169 -130
- package/dest/modules/instrumentation.d.ts +21 -3
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +58 -18
- package/dest/modules/l1_synchronizer.d.ts +10 -9
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +285 -157
- package/dest/modules/validation.d.ts +1 -1
- package/dest/modules/validation.d.ts.map +1 -1
- package/dest/modules/validation.js +2 -2
- package/dest/store/block_store.d.ts +85 -36
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +433 -162
- package/dest/store/contract_class_store.d.ts +2 -3
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +16 -72
- package/dest/store/contract_instance_store.d.ts +1 -1
- package/dest/store/contract_instance_store.d.ts.map +1 -1
- package/dest/store/contract_instance_store.js +6 -2
- package/dest/store/kv_archiver_store.d.ts +76 -32
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +92 -37
- package/dest/store/l2_tips_cache.d.ts +20 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +109 -0
- package/dest/store/log_store.d.ts +6 -3
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +151 -56
- package/dest/store/message_store.d.ts +5 -1
- package/dest/store/message_store.d.ts.map +1 -1
- package/dest/store/message_store.js +21 -9
- package/dest/test/fake_l1_state.d.ts +24 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +145 -28
- 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_l1_to_l2_message_source.d.ts +1 -1
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +2 -1
- package/dest/test/mock_l2_block_source.d.ts +31 -10
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +163 -92
- 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 +20 -6
- package/dest/test/noop_l1_archiver.d.ts +26 -0
- package/dest/test/noop_l1_archiver.d.ts.map +1 -0
- package/dest/test/noop_l1_archiver.js +74 -0
- package/package.json +14 -13
- package/src/archiver.ts +150 -146
- package/src/config.ts +22 -2
- package/src/errors.ts +116 -26
- package/src/factory.ts +49 -26
- package/src/index.ts +3 -1
- package/src/l1/README.md +25 -68
- package/src/l1/bin/retrieve-calldata.ts +46 -39
- package/src/l1/calldata_retriever.ts +250 -379
- package/src/l1/data_retrieval.ts +59 -70
- 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/data_source_base.ts +81 -101
- package/src/modules/data_store_updater.ts +202 -160
- package/src/modules/instrumentation.ts +71 -19
- package/src/modules/l1_synchronizer.ts +365 -197
- package/src/modules/validation.ts +2 -2
- package/src/store/block_store.ts +546 -206
- package/src/store/contract_class_store.ts +16 -110
- package/src/store/contract_instance_store.ts +8 -5
- package/src/store/kv_archiver_store.ts +143 -53
- package/src/store/l2_tips_cache.ts +134 -0
- package/src/store/log_store.ts +225 -67
- package/src/store/message_store.ts +27 -10
- package/src/structs/inbox_message.ts +1 -1
- package/src/test/fake_l1_state.ts +193 -32
- package/src/test/index.ts +3 -0
- package/src/test/mock_archiver.ts +3 -2
- package/src/test/mock_l1_to_l2_message_source.ts +1 -0
- package/src/test/mock_l2_block_source.ts +217 -90
- package/src/test/mock_structs.ts +42 -12
- package/src/test/noop_l1_archiver.ts +117 -0
|
@@ -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,
|
|
@@ -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,23 @@ 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
|
+
|
|
89
|
+
this.blockProposalTxTargetCount = createUpDownCounterWithDefault(
|
|
90
|
+
meter,
|
|
91
|
+
Metrics.ARCHIVER_BLOCK_PROPOSAL_TX_TARGET_COUNT,
|
|
92
|
+
{
|
|
93
|
+
[Attributes.L1_BLOCK_PROPOSAL_USED_TRACE]: [true, false],
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
this.checkpointL1InclusionDelay = meter.createHistogram(Metrics.ARCHIVER_CHECKPOINT_L1_INCLUSION_DELAY);
|
|
72
98
|
|
|
73
|
-
this.
|
|
99
|
+
this.checkpointPromotedCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_CHECKPOINT_PROMOTED_COUNT);
|
|
74
100
|
|
|
75
101
|
this.dbMetrics = new LmdbMetrics(
|
|
76
102
|
meter,
|
|
@@ -84,10 +110,6 @@ export class ArchiverInstrumentation {
|
|
|
84
110
|
public static async new(telemetry: TelemetryClient, lmdbStats?: LmdbStatsCallback) {
|
|
85
111
|
const instance = new ArchiverInstrumentation(telemetry, lmdbStats);
|
|
86
112
|
|
|
87
|
-
instance.syncBlockCount.add(0);
|
|
88
|
-
instance.syncMessageCount.add(0);
|
|
89
|
-
instance.pruneCount.add(0);
|
|
90
|
-
|
|
91
113
|
await instance.telemetry.flush();
|
|
92
114
|
|
|
93
115
|
return instance;
|
|
@@ -97,16 +119,26 @@ export class ArchiverInstrumentation {
|
|
|
97
119
|
return this.telemetry.isEnabled();
|
|
98
120
|
}
|
|
99
121
|
|
|
100
|
-
public
|
|
122
|
+
public processNewProposedBlock(syncTimePerBlock: number, block: L2Block) {
|
|
123
|
+
const attrs = { [Attributes.STATUS]: 'proposed' };
|
|
124
|
+
this.blockHeight.record(block.number, attrs);
|
|
101
125
|
this.syncDurationPerBlock.record(Math.ceil(syncTimePerBlock));
|
|
102
|
-
this.blockHeight.record(Math.max(...blocks.map(b => b.number)));
|
|
103
|
-
this.syncBlockCount.add(blocks.length);
|
|
104
126
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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;
|
|
109
136
|
}
|
|
137
|
+
|
|
138
|
+
this.syncDurationPerCheckpoint.record(Math.ceil(syncTimePerCheckpoint));
|
|
139
|
+
this.blockHeight.record(Math.max(...blocks.map(b => b.number)));
|
|
140
|
+
this.checkpointHeight.record(Math.max(...blocks.map(b => b.checkpointNumber)));
|
|
141
|
+
this.syncBlockCount.add(blocks.length);
|
|
110
142
|
}
|
|
111
143
|
|
|
112
144
|
public processNewMessages(count: number, syncPerMessageMs: number) {
|
|
@@ -122,8 +154,10 @@ export class ArchiverInstrumentation {
|
|
|
122
154
|
this.pruneDuration.record(Math.ceil(duration));
|
|
123
155
|
}
|
|
124
156
|
|
|
125
|
-
public
|
|
126
|
-
|
|
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' });
|
|
127
161
|
}
|
|
128
162
|
|
|
129
163
|
public processProofsVerified(logs: { proverId: string; l2BlockNumber: bigint; delay: bigint }[]) {
|
|
@@ -149,4 +183,22 @@ export class ArchiverInstrumentation {
|
|
|
149
183
|
[Attributes.L1_BLOCK_PROPOSAL_USED_TRACE]: usedTrace,
|
|
150
184
|
});
|
|
151
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
|
+
}
|
|
152
204
|
}
|