@aztec/archiver 0.0.0-test.1 → 0.0.1-commit.5476d83
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 +27 -6
- package/dest/archiver/archiver.d.ts +147 -57
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +841 -333
- package/dest/archiver/archiver_store.d.ts +85 -50
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.js +708 -213
- package/dest/archiver/config.d.ts +5 -21
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +21 -12
- package/dest/archiver/data_retrieval.d.ts +32 -27
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +197 -94
- package/dest/archiver/errors.d.ts +9 -1
- package/dest/archiver/errors.d.ts.map +1 -1
- package/dest/archiver/errors.js +12 -0
- package/dest/archiver/index.d.ts +3 -4
- package/dest/archiver/index.d.ts.map +1 -1
- package/dest/archiver/index.js +1 -2
- package/dest/archiver/instrumentation.d.ts +12 -6
- package/dest/archiver/instrumentation.d.ts.map +1 -1
- package/dest/archiver/instrumentation.js +58 -17
- package/dest/archiver/kv_archiver_store/block_store.d.ts +48 -11
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +216 -63
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +3 -3
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +12 -18
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +11 -8
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.js +30 -16
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +50 -35
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +88 -46
- package/dest/archiver/kv_archiver_store/log_store.d.ts +2 -2
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +18 -46
- package/dest/archiver/kv_archiver_store/message_store.d.ts +23 -17
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.js +150 -48
- package/dest/archiver/structs/data_retrieval.d.ts +1 -1
- package/dest/archiver/structs/inbox_message.d.ts +15 -0
- package/dest/archiver/structs/inbox_message.d.ts.map +1 -0
- package/dest/archiver/structs/inbox_message.js +38 -0
- package/dest/archiver/structs/published.d.ts +3 -11
- package/dest/archiver/structs/published.d.ts.map +1 -1
- package/dest/archiver/structs/published.js +1 -1
- package/dest/archiver/validation.d.ts +17 -0
- package/dest/archiver/validation.d.ts.map +1 -0
- package/dest/archiver/validation.js +98 -0
- package/dest/factory.d.ts +8 -13
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +18 -49
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/rpc/index.d.ts +2 -3
- package/dest/rpc/index.d.ts.map +1 -1
- package/dest/rpc/index.js +1 -4
- package/dest/test/index.d.ts +1 -1
- package/dest/test/mock_archiver.d.ts +2 -2
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.d.ts +5 -3
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +14 -1
- package/dest/test/mock_l2_block_source.d.ts +38 -10
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +119 -8
- package/dest/test/mock_structs.d.ts +9 -0
- package/dest/test/mock_structs.d.ts.map +1 -0
- package/dest/test/mock_structs.js +37 -0
- package/package.json +28 -30
- package/src/archiver/archiver.ts +1087 -410
- package/src/archiver/archiver_store.ts +97 -55
- package/src/archiver/archiver_store_test_suite.ts +664 -210
- package/src/archiver/config.ts +28 -41
- package/src/archiver/data_retrieval.ts +279 -125
- package/src/archiver/errors.ts +21 -0
- package/src/archiver/index.ts +2 -3
- package/src/archiver/instrumentation.ts +77 -22
- package/src/archiver/kv_archiver_store/block_store.ts +270 -72
- package/src/archiver/kv_archiver_store/contract_class_store.ts +13 -23
- package/src/archiver/kv_archiver_store/contract_instance_store.ts +35 -27
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +127 -63
- package/src/archiver/kv_archiver_store/log_store.ts +24 -62
- package/src/archiver/kv_archiver_store/message_store.ts +209 -53
- package/src/archiver/structs/inbox_message.ts +41 -0
- package/src/archiver/structs/published.ts +2 -11
- package/src/archiver/validation.ts +124 -0
- package/src/factory.ts +24 -66
- package/src/index.ts +1 -1
- package/src/rpc/index.ts +1 -5
- package/src/test/mock_archiver.ts +1 -1
- package/src/test/mock_l1_to_l2_message_source.ts +14 -3
- package/src/test/mock_l2_block_source.ts +158 -13
- package/src/test/mock_structs.ts +49 -0
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +0 -23
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +0 -49
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -636
- package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
- package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +0 -61
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
package/src/archiver/errors.ts
CHANGED
|
@@ -3,3 +3,24 @@ export class NoBlobBodiesFoundError extends Error {
|
|
|
3
3
|
super(`No blob bodies found for block ${l2BlockNum}`);
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
+
|
|
7
|
+
export class InitialBlockNumberNotSequentialError extends Error {
|
|
8
|
+
constructor(
|
|
9
|
+
public readonly newBlockNumber: number,
|
|
10
|
+
public readonly previousBlockNumber: number | undefined,
|
|
11
|
+
) {
|
|
12
|
+
super(
|
|
13
|
+
`Cannot insert new block ${newBlockNumber} given previous block number in store is ${
|
|
14
|
+
previousBlockNumber ?? 'undefined'
|
|
15
|
+
}`,
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class BlockNumberNotSequentialError extends Error {
|
|
21
|
+
constructor(newBlockNumber: number, previous: number | undefined) {
|
|
22
|
+
super(
|
|
23
|
+
`Cannot insert new block ${newBlockNumber} given previous block number in batch is ${previous ?? 'undefined'}`,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/archiver/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './archiver.js';
|
|
2
2
|
export * from './config.js';
|
|
3
|
-
export { type
|
|
4
|
-
export { MemoryArchiverStore } from './memory_archiver_store/memory_archiver_store.js';
|
|
3
|
+
export { type PublishedL2Block, type L1PublishedData } from './structs/published.js';
|
|
5
4
|
export type { ArchiverDataStore } from './archiver_store.js';
|
|
6
|
-
export { KVArchiverDataStore } from './kv_archiver_store/kv_archiver_store.js';
|
|
5
|
+
export { KVArchiverDataStore, ARCHIVER_DB_VERSION } from './kv_archiver_store/kv_archiver_store.js';
|
|
7
6
|
export { ContractInstanceStore } from './kv_archiver_store/contract_instance_store.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import type {
|
|
2
|
+
import type { L2BlockNew } from '@aztec/stdlib/block';
|
|
3
3
|
import {
|
|
4
4
|
Attributes,
|
|
5
5
|
type Gauge,
|
|
@@ -18,32 +18,43 @@ export class ArchiverInstrumentation {
|
|
|
18
18
|
|
|
19
19
|
private blockHeight: Gauge;
|
|
20
20
|
private txCount: UpDownCounter;
|
|
21
|
-
private syncDuration: Histogram;
|
|
22
|
-
private l1BlocksSynced: UpDownCounter;
|
|
23
21
|
private l1BlockHeight: Gauge;
|
|
24
22
|
private proofsSubmittedDelay: Histogram;
|
|
25
23
|
private proofsSubmittedCount: UpDownCounter;
|
|
26
24
|
private dbMetrics: LmdbMetrics;
|
|
25
|
+
|
|
26
|
+
private pruneDuration: Histogram;
|
|
27
27
|
private pruneCount: UpDownCounter;
|
|
28
28
|
|
|
29
|
+
private syncDurationPerBlock: Histogram;
|
|
30
|
+
private syncBlockCount: UpDownCounter;
|
|
31
|
+
private manaPerBlock: Histogram;
|
|
32
|
+
private txsPerBlock: Histogram;
|
|
33
|
+
|
|
34
|
+
private syncDurationPerMessage: Histogram;
|
|
35
|
+
private syncMessageCount: UpDownCounter;
|
|
36
|
+
|
|
29
37
|
private log = createLogger('archiver:instrumentation');
|
|
30
38
|
|
|
31
|
-
private constructor(
|
|
39
|
+
private constructor(
|
|
40
|
+
private telemetry: TelemetryClient,
|
|
41
|
+
lmdbStats?: LmdbStatsCallback,
|
|
42
|
+
) {
|
|
32
43
|
this.tracer = telemetry.getTracer('Archiver');
|
|
33
44
|
const meter = telemetry.getMeter('Archiver');
|
|
45
|
+
|
|
34
46
|
this.blockHeight = meter.createGauge(Metrics.ARCHIVER_BLOCK_HEIGHT, {
|
|
35
47
|
description: 'The height of the latest block processed by the archiver',
|
|
36
48
|
valueType: ValueType.INT,
|
|
37
49
|
});
|
|
38
50
|
|
|
39
|
-
this.
|
|
40
|
-
description: 'The
|
|
51
|
+
this.l1BlockHeight = meter.createGauge(Metrics.ARCHIVER_L1_BLOCK_HEIGHT, {
|
|
52
|
+
description: 'The height of the latest L1 block processed by the archiver',
|
|
41
53
|
valueType: ValueType.INT,
|
|
42
54
|
});
|
|
43
55
|
|
|
44
|
-
this.
|
|
45
|
-
|
|
46
|
-
description: 'Duration to sync a block',
|
|
56
|
+
this.txCount = meter.createUpDownCounter(Metrics.ARCHIVER_TOTAL_TXS, {
|
|
57
|
+
description: 'The total number of transactions',
|
|
47
58
|
valueType: ValueType.INT,
|
|
48
59
|
});
|
|
49
60
|
|
|
@@ -58,13 +69,48 @@ export class ArchiverInstrumentation {
|
|
|
58
69
|
valueType: ValueType.INT,
|
|
59
70
|
});
|
|
60
71
|
|
|
61
|
-
this.
|
|
72
|
+
this.syncDurationPerBlock = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_BLOCK, {
|
|
73
|
+
unit: 'ms',
|
|
74
|
+
description: 'Duration to sync a block',
|
|
75
|
+
valueType: ValueType.INT,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
this.syncBlockCount = meter.createUpDownCounter(Metrics.ARCHIVER_SYNC_BLOCK_COUNT, {
|
|
62
79
|
description: 'Number of blocks synced from L1',
|
|
63
80
|
valueType: ValueType.INT,
|
|
64
81
|
});
|
|
65
82
|
|
|
66
|
-
this.
|
|
67
|
-
description: 'The
|
|
83
|
+
this.manaPerBlock = meter.createHistogram(Metrics.ARCHIVER_MANA_PER_BLOCK, {
|
|
84
|
+
description: 'The mana consumed by blocks',
|
|
85
|
+
valueType: ValueType.DOUBLE,
|
|
86
|
+
unit: 'Mmana',
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
this.txsPerBlock = meter.createHistogram(Metrics.ARCHIVER_TXS_PER_BLOCK, {
|
|
90
|
+
description: 'The block tx count',
|
|
91
|
+
valueType: ValueType.INT,
|
|
92
|
+
unit: 'tx',
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
this.syncDurationPerMessage = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_MESSAGE, {
|
|
96
|
+
unit: 'ms',
|
|
97
|
+
description: 'Duration to sync a message',
|
|
98
|
+
valueType: ValueType.INT,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
this.syncMessageCount = meter.createUpDownCounter(Metrics.ARCHIVER_SYNC_MESSAGE_COUNT, {
|
|
102
|
+
description: 'Number of L1 to L2 messages synced',
|
|
103
|
+
valueType: ValueType.INT,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
this.pruneDuration = meter.createHistogram(Metrics.ARCHIVER_PRUNE_DURATION, {
|
|
107
|
+
unit: 'ms',
|
|
108
|
+
description: 'Duration to sync a message',
|
|
109
|
+
valueType: ValueType.INT,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
this.pruneCount = meter.createUpDownCounter(Metrics.ARCHIVER_PRUNE_COUNT, {
|
|
113
|
+
description: 'Number of prunes detected',
|
|
68
114
|
valueType: ValueType.INT,
|
|
69
115
|
});
|
|
70
116
|
|
|
@@ -75,17 +121,14 @@ export class ArchiverInstrumentation {
|
|
|
75
121
|
},
|
|
76
122
|
lmdbStats,
|
|
77
123
|
);
|
|
78
|
-
|
|
79
|
-
this.pruneCount = meter.createUpDownCounter(Metrics.ARCHIVER_PRUNE_COUNT, {
|
|
80
|
-
description: 'Number of prunes detected',
|
|
81
|
-
valueType: ValueType.INT,
|
|
82
|
-
});
|
|
83
124
|
}
|
|
84
125
|
|
|
85
126
|
public static async new(telemetry: TelemetryClient, lmdbStats?: LmdbStatsCallback) {
|
|
86
127
|
const instance = new ArchiverInstrumentation(telemetry, lmdbStats);
|
|
87
128
|
|
|
88
|
-
instance.
|
|
129
|
+
instance.syncBlockCount.add(0);
|
|
130
|
+
instance.syncMessageCount.add(0);
|
|
131
|
+
instance.pruneCount.add(0);
|
|
89
132
|
|
|
90
133
|
await instance.telemetry.flush();
|
|
91
134
|
|
|
@@ -96,17 +139,29 @@ export class ArchiverInstrumentation {
|
|
|
96
139
|
return this.telemetry.isEnabled();
|
|
97
140
|
}
|
|
98
141
|
|
|
99
|
-
public processNewBlocks(syncTimePerBlock: number, blocks:
|
|
100
|
-
this.
|
|
142
|
+
public processNewBlocks(syncTimePerBlock: number, blocks: L2BlockNew[]) {
|
|
143
|
+
this.syncDurationPerBlock.record(Math.ceil(syncTimePerBlock));
|
|
101
144
|
this.blockHeight.record(Math.max(...blocks.map(b => b.number)));
|
|
102
|
-
this.
|
|
145
|
+
this.syncBlockCount.add(blocks.length);
|
|
146
|
+
|
|
103
147
|
for (const block of blocks) {
|
|
104
148
|
this.txCount.add(block.body.txEffects.length);
|
|
149
|
+
this.txsPerBlock.record(block.body.txEffects.length);
|
|
150
|
+
this.manaPerBlock.record(block.header.totalManaUsed.toNumber() / 1e6);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
public processNewMessages(count: number, syncPerMessageMs: number) {
|
|
155
|
+
if (count === 0) {
|
|
156
|
+
return;
|
|
105
157
|
}
|
|
158
|
+
this.syncMessageCount.add(count);
|
|
159
|
+
this.syncDurationPerMessage.record(Math.ceil(syncPerMessageMs));
|
|
106
160
|
}
|
|
107
161
|
|
|
108
|
-
public processPrune() {
|
|
162
|
+
public processPrune(duration: number) {
|
|
109
163
|
this.pruneCount.add(1);
|
|
164
|
+
this.pruneDuration.record(Math.ceil(duration));
|
|
110
165
|
}
|
|
111
166
|
|
|
112
167
|
public updateLastProvenBlock(blockNumber: number) {
|