@aztec/archiver 0.0.1-commit.d3ec352c → 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 +164 -22
- package/dest/archiver.d.ts +194 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +949 -0
- package/dest/config.d.ts +34 -0
- package/dest/config.d.ts.map +1 -0
- package/dest/config.js +95 -0
- package/dest/errors.d.ts +87 -0
- package/dest/errors.d.ts.map +1 -0
- package/dest/errors.js +129 -0
- package/dest/factory.d.ts +16 -10
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +117 -20
- package/dest/index.d.ts +19 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +17 -3
- package/dest/interfaces.d.ts +9 -0
- package/dest/interfaces.d.ts.map +1 -0
- package/dest/interfaces.js +3 -0
- package/dest/l1/bin/retrieve-calldata.d.ts +3 -0
- package/dest/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/l1/bin/retrieve-calldata.js +152 -0
- package/dest/l1/calldata_retriever.d.ts +143 -0
- package/dest/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/l1/calldata_retriever.js +413 -0
- package/dest/l1/data_retrieval.d.ts +102 -0
- package/dest/l1/data_retrieval.d.ts.map +1 -0
- package/dest/{archiver → l1}/data_retrieval.js +85 -165
- package/dest/l1/debug_tx.d.ts +19 -0
- package/dest/l1/debug_tx.d.ts.map +1 -0
- package/dest/l1/debug_tx.js +73 -0
- package/dest/l1/spire_proposer.d.ts +70 -0
- package/dest/l1/spire_proposer.d.ts.map +1 -0
- package/dest/l1/spire_proposer.js +149 -0
- package/dest/l1/trace_tx.d.ts +43 -0
- package/dest/l1/trace_tx.d.ts.map +1 -0
- package/dest/l1/trace_tx.js +91 -0
- package/dest/l1/types.d.ts +12 -0
- package/dest/l1/types.d.ts.map +1 -0
- package/dest/l1/types.js +3 -0
- 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 +32 -0
- package/dest/l1/validate_trace.d.ts.map +1 -0
- package/dest/l1/validate_trace.js +154 -0
- 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 +112 -0
- package/dest/modules/data_source_base.d.ts.map +1 -0
- package/dest/modules/data_source_base.js +322 -0
- package/dest/modules/data_store_updater.d.ts +105 -0
- package/dest/modules/data_store_updater.d.ts.map +1 -0
- package/dest/modules/data_store_updater.js +393 -0
- package/dest/modules/instrumentation.d.ts +63 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/modules/instrumentation.js +166 -0
- package/dest/modules/l1_synchronizer.d.ts +77 -0
- package/dest/modules/l1_synchronizer.d.ts.map +1 -0
- package/dest/modules/l1_synchronizer.js +1381 -0
- 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 +40 -0
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/{archiver → modules}/validation.js +41 -17
- package/dest/store/block_store.d.ts +303 -0
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/store/block_store.js +1206 -0
- package/dest/store/contract_class_store.d.ts +31 -0
- package/dest/store/contract_class_store.d.ts.map +1 -0
- package/dest/store/contract_class_store.js +98 -0
- package/dest/store/contract_instance_store.d.ts +51 -0
- package/dest/store/contract_instance_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/contract_instance_store.js +55 -3
- 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 +59 -0
- package/dest/store/log_store.d.ts.map +1 -0
- package/dest/store/log_store.js +310 -0
- 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 +50 -0
- package/dest/store/message_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/message_store.js +66 -23
- package/dest/{archiver/structs → structs}/data_retrieval.d.ts +1 -1
- package/dest/structs/data_retrieval.d.ts.map +1 -0
- package/dest/structs/inbox_message.d.ts +15 -0
- package/dest/structs/inbox_message.d.ts.map +1 -0
- package/dest/{archiver/structs → structs}/inbox_message.js +6 -6
- package/dest/structs/published.d.ts +2 -0
- package/dest/structs/published.d.ts.map +1 -0
- package/dest/test/fake_l1_state.d.ts +214 -0
- package/dest/test/fake_l1_state.d.ts.map +1 -0
- package/dest/test/fake_l1_state.js +517 -0
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +4 -1
- package/dest/test/mock_archiver.d.ts +5 -6
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +8 -12
- package/dest/test/mock_l1_to_l2_message_source.d.ts +6 -7
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +19 -14
- package/dest/test/mock_l2_block_source.d.ts +68 -40
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +347 -145
- package/dest/test/mock_structs.d.ts +83 -4
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +157 -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 +18 -18
- package/src/archiver.ts +785 -0
- package/src/config.ts +125 -0
- package/src/errors.ts +203 -0
- package/src/factory.ts +185 -22
- package/src/index.ts +27 -3
- package/src/interfaces.ts +9 -0
- package/src/l1/README.md +55 -0
- package/src/l1/bin/retrieve-calldata.ts +194 -0
- package/src/l1/calldata_retriever.ts +529 -0
- package/src/{archiver → l1}/data_retrieval.ts +157 -243
- package/src/l1/debug_tx.ts +99 -0
- package/src/l1/spire_proposer.ts +152 -0
- package/src/l1/trace_tx.ts +128 -0
- package/src/l1/types.ts +13 -0
- package/src/l1/validate_historical_logs.ts +140 -0
- package/src/l1/validate_trace.ts +229 -0
- package/src/modules/contract_data_source_adapter.ts +46 -0
- package/src/modules/data_source_base.ts +466 -0
- package/src/modules/data_store_updater.ts +519 -0
- package/src/modules/instrumentation.ts +217 -0
- package/src/modules/l1_synchronizer.ts +1320 -0
- package/src/modules/outbox_trees_resolver.ts +199 -0
- package/src/modules/validation.ts +186 -0
- package/src/store/block_store.ts +1551 -0
- package/src/store/contract_class_store.ts +126 -0
- package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +70 -7
- 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 +380 -0
- package/src/store/log_store_codec.ts +143 -0
- package/src/{archiver/kv_archiver_store → store}/message_store.ts +81 -28
- package/src/{archiver/structs → structs}/inbox_message.ts +8 -9
- package/src/{archiver/structs → structs}/published.ts +0 -1
- package/src/test/fake_l1_state.ts +770 -0
- package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
- package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
- package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
- package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
- package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
- package/src/test/fixtures/trace_transaction-proxied.json +128 -0
- package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
- package/src/test/index.ts +4 -0
- package/src/test/mock_archiver.ts +10 -14
- package/src/test/mock_l1_to_l2_message_source.ts +16 -15
- package/src/test/mock_l2_block_source.ts +416 -161
- package/src/test/mock_structs.ts +292 -14
- package/src/test/noop_l1_archiver.ts +158 -0
- package/dest/archiver/archiver.d.ts +0 -290
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -1434
- package/dest/archiver/archiver_store.d.ts +0 -256
- package/dest/archiver/archiver_store.d.ts.map +0 -1
- package/dest/archiver/archiver_store.js +0 -4
- package/dest/archiver/archiver_store_test_suite.d.ts +0 -8
- package/dest/archiver/archiver_store_test_suite.d.ts.map +0 -1
- package/dest/archiver/archiver_store_test_suite.js +0 -1289
- package/dest/archiver/config.d.ts +0 -21
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/config.js +0 -55
- package/dest/archiver/data_retrieval.d.ts +0 -80
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/errors.d.ts +0 -12
- package/dest/archiver/errors.d.ts.map +0 -1
- package/dest/archiver/errors.js +0 -17
- package/dest/archiver/index.d.ts +0 -7
- package/dest/archiver/index.d.ts.map +0 -1
- package/dest/archiver/index.js +0 -4
- package/dest/archiver/instrumentation.d.ts +0 -35
- package/dest/archiver/instrumentation.d.ts.map +0 -1
- package/dest/archiver/instrumentation.js +0 -140
- package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -125
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.js +0 -371
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +0 -18
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +0 -120
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -24
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -169
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +0 -296
- package/dest/archiver/kv_archiver_store/log_store.d.ts +0 -49
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/log_store.js +0 -337
- package/dest/archiver/kv_archiver_store/message_store.d.ts +0 -39
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
- package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/structs/inbox_message.d.ts +0 -15
- package/dest/archiver/structs/inbox_message.d.ts.map +0 -1
- package/dest/archiver/structs/published.d.ts +0 -3
- package/dest/archiver/structs/published.d.ts.map +0 -1
- package/dest/archiver/validation.d.ts +0 -17
- package/dest/archiver/validation.d.ts.map +0 -1
- package/dest/rpc/index.d.ts +0 -9
- package/dest/rpc/index.d.ts.map +0 -1
- package/dest/rpc/index.js +0 -15
- package/src/archiver/archiver.ts +0 -1880
- package/src/archiver/archiver_store.ts +0 -310
- package/src/archiver/archiver_store_test_suite.ts +0 -1295
- package/src/archiver/config.ts +0 -79
- package/src/archiver/errors.ts +0 -26
- package/src/archiver/index.ts +0 -6
- package/src/archiver/instrumentation.ts +0 -187
- package/src/archiver/kv_archiver_store/block_store.ts +0 -482
- package/src/archiver/kv_archiver_store/contract_class_store.ts +0 -176
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -423
- package/src/archiver/kv_archiver_store/log_store.ts +0 -407
- package/src/archiver/validation.ts +0 -124
- package/src/rpc/index.ts +0 -16
- /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
- /package/dest/{archiver/structs → structs}/published.js +0 -0
- /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
package/src/archiver/config.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { type BlobSinkConfig, blobSinkConfigMapping } from '@aztec/blob-sink/client';
|
|
2
|
-
import {
|
|
3
|
-
type L1ContractsConfig,
|
|
4
|
-
type L1ReaderConfig,
|
|
5
|
-
l1ContractAddressesMapping,
|
|
6
|
-
l1ContractsConfigMappings,
|
|
7
|
-
l1ReaderConfigMappings,
|
|
8
|
-
} from '@aztec/ethereum';
|
|
9
|
-
import {
|
|
10
|
-
type ConfigMappingsType,
|
|
11
|
-
booleanConfigHelper,
|
|
12
|
-
getConfigFromMappings,
|
|
13
|
-
numberConfigHelper,
|
|
14
|
-
} from '@aztec/foundation/config';
|
|
15
|
-
import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
|
|
16
|
-
import type { ArchiverSpecificConfig } from '@aztec/stdlib/interfaces/server';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The archiver configuration.
|
|
20
|
-
* There are 2 polling intervals used in this configuration. The first is the archiver polling interval, archiverPollingIntervalMS.
|
|
21
|
-
* This is the interval between successive calls to eth_blockNumber via viem.
|
|
22
|
-
* Results of calls to eth_blockNumber are cached by viem with this cache being updated periodically at the interval specified by viemPollingIntervalMS.
|
|
23
|
-
* As a result the maximum observed polling time for new blocks will be viemPollingIntervalMS + archiverPollingIntervalMS.
|
|
24
|
-
*/
|
|
25
|
-
export type ArchiverConfig = ArchiverSpecificConfig & L1ReaderConfig & L1ContractsConfig & BlobSinkConfig & ChainConfig;
|
|
26
|
-
|
|
27
|
-
export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
28
|
-
...blobSinkConfigMapping,
|
|
29
|
-
archiverPollingIntervalMS: {
|
|
30
|
-
env: 'ARCHIVER_POLLING_INTERVAL_MS',
|
|
31
|
-
description: 'The polling interval in ms for retrieving new L2 blocks and encrypted logs.',
|
|
32
|
-
...numberConfigHelper(500),
|
|
33
|
-
},
|
|
34
|
-
archiverBatchSize: {
|
|
35
|
-
env: 'ARCHIVER_BATCH_SIZE',
|
|
36
|
-
description: 'The number of L2 blocks the archiver will attempt to download at a time.',
|
|
37
|
-
...numberConfigHelper(100),
|
|
38
|
-
},
|
|
39
|
-
maxLogs: {
|
|
40
|
-
env: 'ARCHIVER_MAX_LOGS',
|
|
41
|
-
description: 'The max number of logs that can be obtained in 1 "getPublicLogs" call.',
|
|
42
|
-
...numberConfigHelper(1_000),
|
|
43
|
-
},
|
|
44
|
-
archiverStoreMapSizeKb: {
|
|
45
|
-
env: 'ARCHIVER_STORE_MAP_SIZE_KB',
|
|
46
|
-
parseEnv: (val: string | undefined) => (val ? +val : undefined),
|
|
47
|
-
description: 'The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
48
|
-
},
|
|
49
|
-
skipValidateBlockAttestations: {
|
|
50
|
-
description: 'Whether to skip validating block attestations (use only for testing).',
|
|
51
|
-
...booleanConfigHelper(false),
|
|
52
|
-
},
|
|
53
|
-
maxAllowedEthClientDriftSeconds: {
|
|
54
|
-
env: 'MAX_ALLOWED_ETH_CLIENT_DRIFT_SECONDS',
|
|
55
|
-
description: 'Maximum allowed drift in seconds between the Ethereum client and current time.',
|
|
56
|
-
...numberConfigHelper(300),
|
|
57
|
-
},
|
|
58
|
-
...chainConfigMappings,
|
|
59
|
-
...l1ReaderConfigMappings,
|
|
60
|
-
viemPollingIntervalMS: {
|
|
61
|
-
env: 'ARCHIVER_VIEM_POLLING_INTERVAL_MS',
|
|
62
|
-
description: 'The polling interval viem uses in ms',
|
|
63
|
-
...numberConfigHelper(1000),
|
|
64
|
-
},
|
|
65
|
-
...l1ContractsConfigMappings,
|
|
66
|
-
l1Contracts: {
|
|
67
|
-
description: 'The deployed L1 contract addresses',
|
|
68
|
-
nested: l1ContractAddressesMapping,
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Returns the archiver configuration from the environment variables.
|
|
74
|
-
* Note: If an environment variable is not set, the default value is used.
|
|
75
|
-
* @returns The archiver configuration.
|
|
76
|
-
*/
|
|
77
|
-
export function getArchiverConfigFromEnv(): ArchiverConfig {
|
|
78
|
-
return getConfigFromMappings<ArchiverConfig>(archiverConfigMappings);
|
|
79
|
-
}
|
package/src/archiver/errors.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export class NoBlobBodiesFoundError extends Error {
|
|
2
|
-
constructor(l2BlockNum: number) {
|
|
3
|
-
super(`No blob bodies found for block ${l2BlockNum}`);
|
|
4
|
-
}
|
|
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
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from './archiver.js';
|
|
2
|
-
export * from './config.js';
|
|
3
|
-
export { type PublishedL2Block, type L1PublishedData } from './structs/published.js';
|
|
4
|
-
export type { ArchiverDataStore } from './archiver_store.js';
|
|
5
|
-
export { KVArchiverDataStore, ARCHIVER_DB_VERSION } from './kv_archiver_store/kv_archiver_store.js';
|
|
6
|
-
export { ContractInstanceStore } from './kv_archiver_store/contract_instance_store.js';
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import type { L2BlockNew } from '@aztec/stdlib/block';
|
|
3
|
-
import {
|
|
4
|
-
Attributes,
|
|
5
|
-
type Gauge,
|
|
6
|
-
type Histogram,
|
|
7
|
-
LmdbMetrics,
|
|
8
|
-
type LmdbStatsCallback,
|
|
9
|
-
Metrics,
|
|
10
|
-
type TelemetryClient,
|
|
11
|
-
type Tracer,
|
|
12
|
-
type UpDownCounter,
|
|
13
|
-
ValueType,
|
|
14
|
-
} from '@aztec/telemetry-client';
|
|
15
|
-
|
|
16
|
-
export class ArchiverInstrumentation {
|
|
17
|
-
public readonly tracer: Tracer;
|
|
18
|
-
|
|
19
|
-
private blockHeight: Gauge;
|
|
20
|
-
private txCount: UpDownCounter;
|
|
21
|
-
private l1BlockHeight: Gauge;
|
|
22
|
-
private proofsSubmittedDelay: Histogram;
|
|
23
|
-
private proofsSubmittedCount: UpDownCounter;
|
|
24
|
-
private dbMetrics: LmdbMetrics;
|
|
25
|
-
|
|
26
|
-
private pruneDuration: Histogram;
|
|
27
|
-
private pruneCount: UpDownCounter;
|
|
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
|
-
|
|
37
|
-
private log = createLogger('archiver:instrumentation');
|
|
38
|
-
|
|
39
|
-
private constructor(
|
|
40
|
-
private telemetry: TelemetryClient,
|
|
41
|
-
lmdbStats?: LmdbStatsCallback,
|
|
42
|
-
) {
|
|
43
|
-
this.tracer = telemetry.getTracer('Archiver');
|
|
44
|
-
const meter = telemetry.getMeter('Archiver');
|
|
45
|
-
|
|
46
|
-
this.blockHeight = meter.createGauge(Metrics.ARCHIVER_BLOCK_HEIGHT, {
|
|
47
|
-
description: 'The height of the latest block processed by the archiver',
|
|
48
|
-
valueType: ValueType.INT,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
this.l1BlockHeight = meter.createGauge(Metrics.ARCHIVER_L1_BLOCK_HEIGHT, {
|
|
52
|
-
description: 'The height of the latest L1 block processed by the archiver',
|
|
53
|
-
valueType: ValueType.INT,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
this.txCount = meter.createUpDownCounter(Metrics.ARCHIVER_TOTAL_TXS, {
|
|
57
|
-
description: 'The total number of transactions',
|
|
58
|
-
valueType: ValueType.INT,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
this.proofsSubmittedCount = meter.createUpDownCounter(Metrics.ARCHIVER_ROLLUP_PROOF_COUNT, {
|
|
62
|
-
description: 'Number of proofs submitted',
|
|
63
|
-
valueType: ValueType.INT,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
this.proofsSubmittedDelay = meter.createHistogram(Metrics.ARCHIVER_ROLLUP_PROOF_DELAY, {
|
|
67
|
-
unit: 'ms',
|
|
68
|
-
description: 'Time after a block is submitted until its proof is published',
|
|
69
|
-
valueType: ValueType.INT,
|
|
70
|
-
});
|
|
71
|
-
|
|
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, {
|
|
79
|
-
description: 'Number of blocks synced from L1',
|
|
80
|
-
valueType: ValueType.INT,
|
|
81
|
-
});
|
|
82
|
-
|
|
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',
|
|
114
|
-
valueType: ValueType.INT,
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
this.dbMetrics = new LmdbMetrics(
|
|
118
|
-
meter,
|
|
119
|
-
{
|
|
120
|
-
[Attributes.DB_DATA_TYPE]: 'archiver',
|
|
121
|
-
},
|
|
122
|
-
lmdbStats,
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
public static async new(telemetry: TelemetryClient, lmdbStats?: LmdbStatsCallback) {
|
|
127
|
-
const instance = new ArchiverInstrumentation(telemetry, lmdbStats);
|
|
128
|
-
|
|
129
|
-
instance.syncBlockCount.add(0);
|
|
130
|
-
instance.syncMessageCount.add(0);
|
|
131
|
-
instance.pruneCount.add(0);
|
|
132
|
-
|
|
133
|
-
await instance.telemetry.flush();
|
|
134
|
-
|
|
135
|
-
return instance;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
public isEnabled(): boolean {
|
|
139
|
-
return this.telemetry.isEnabled();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
public processNewBlocks(syncTimePerBlock: number, blocks: L2BlockNew[]) {
|
|
143
|
-
this.syncDurationPerBlock.record(Math.ceil(syncTimePerBlock));
|
|
144
|
-
this.blockHeight.record(Math.max(...blocks.map(b => b.number)));
|
|
145
|
-
this.syncBlockCount.add(blocks.length);
|
|
146
|
-
|
|
147
|
-
for (const block of blocks) {
|
|
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;
|
|
157
|
-
}
|
|
158
|
-
this.syncMessageCount.add(count);
|
|
159
|
-
this.syncDurationPerMessage.record(Math.ceil(syncPerMessageMs));
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
public processPrune(duration: number) {
|
|
163
|
-
this.pruneCount.add(1);
|
|
164
|
-
this.pruneDuration.record(Math.ceil(duration));
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
public updateLastProvenBlock(blockNumber: number) {
|
|
168
|
-
this.blockHeight.record(blockNumber, { [Attributes.STATUS]: 'proven' });
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
public processProofsVerified(logs: { proverId: string; l2BlockNumber: bigint; delay: bigint }[]) {
|
|
172
|
-
for (const log of logs) {
|
|
173
|
-
this.log.debug('Recording proof verified event', log);
|
|
174
|
-
this.proofsSubmittedCount.add(1, {
|
|
175
|
-
[Attributes.ROLLUP_PROVER_ID]: log.proverId,
|
|
176
|
-
[Attributes.PROOF_TIMED_OUT]: log.delay > 20n * 60n * 1000n,
|
|
177
|
-
});
|
|
178
|
-
this.proofsSubmittedDelay.record(Math.ceil(Number(log.delay)), {
|
|
179
|
-
[Attributes.ROLLUP_PROVER_ID]: log.proverId,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
public updateL1BlockHeight(blockNumber: bigint) {
|
|
185
|
-
this.l1BlockHeight.record(Number(blockNumber));
|
|
186
|
-
}
|
|
187
|
-
}
|