@aztec/archiver 0.0.0-test.1 → 0.0.1-commit.1142ef1
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 +204 -94
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +1616 -414
- package/dest/archiver/archiver_store.d.ts +178 -83
- 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 +2373 -397
- package/dest/archiver/config.d.ts +7 -22
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +30 -14
- package/dest/archiver/errors.d.ts +33 -1
- package/dest/archiver/errors.d.ts.map +1 -1
- package/dest/archiver/errors.js +49 -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 +14 -6
- package/dest/archiver/instrumentation.d.ts.map +1 -1
- package/dest/archiver/instrumentation.js +45 -41
- package/dest/archiver/kv_archiver_store/block_store.d.ts +98 -21
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +495 -86
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +4 -4
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +13 -19
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +12 -9
- 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 +81 -75
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +145 -83
- package/dest/archiver/kv_archiver_store/log_store.d.ts +12 -16
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +151 -114
- package/dest/archiver/kv_archiver_store/message_store.d.ts +25 -18
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.js +152 -49
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts +3 -0
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/archiver/l1/bin/retrieve-calldata.js +149 -0
- package/dest/archiver/l1/calldata_retriever.d.ts +112 -0
- package/dest/archiver/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/archiver/l1/calldata_retriever.js +471 -0
- package/dest/archiver/l1/data_retrieval.d.ts +90 -0
- package/dest/archiver/l1/data_retrieval.d.ts.map +1 -0
- package/dest/archiver/l1/data_retrieval.js +331 -0
- package/dest/archiver/l1/debug_tx.d.ts +19 -0
- package/dest/archiver/l1/debug_tx.d.ts.map +1 -0
- package/dest/archiver/l1/debug_tx.js +73 -0
- package/dest/archiver/l1/spire_proposer.d.ts +70 -0
- package/dest/archiver/l1/spire_proposer.d.ts.map +1 -0
- package/dest/archiver/l1/spire_proposer.js +157 -0
- package/dest/archiver/l1/trace_tx.d.ts +97 -0
- package/dest/archiver/l1/trace_tx.d.ts.map +1 -0
- package/dest/archiver/l1/trace_tx.js +91 -0
- package/dest/archiver/l1/types.d.ts +12 -0
- package/dest/archiver/l1/types.d.ts.map +1 -0
- package/dest/archiver/l1/types.js +3 -0
- package/dest/archiver/l1/validate_trace.d.ts +29 -0
- package/dest/archiver/l1/validate_trace.d.ts.map +1 -0
- package/dest/archiver/l1/validate_trace.js +150 -0
- 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 +39 -0
- package/dest/archiver/structs/published.d.ts +2 -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 +9 -14
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +22 -52
- 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 +16 -8
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +19 -14
- package/dest/test/mock_l1_to_l2_message_source.d.ts +9 -6
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +30 -7
- package/dest/test/mock_l2_block_source.d.ts +56 -13
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +196 -25
- package/dest/test/mock_structs.d.ts +10 -0
- package/dest/test/mock_structs.d.ts.map +1 -0
- package/dest/test/mock_structs.js +38 -0
- package/package.json +29 -30
- package/src/archiver/archiver.ts +1596 -512
- package/src/archiver/archiver_store.ts +205 -88
- package/src/archiver/archiver_store_test_suite.ts +2386 -354
- package/src/archiver/config.ts +38 -46
- package/src/archiver/errors.ts +85 -0
- package/src/archiver/index.ts +2 -3
- package/src/archiver/instrumentation.ts +65 -45
- package/src/archiver/kv_archiver_store/block_store.ts +668 -101
- package/src/archiver/kv_archiver_store/contract_class_store.ts +14 -24
- package/src/archiver/kv_archiver_store/contract_instance_store.ts +36 -28
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +197 -113
- package/src/archiver/kv_archiver_store/log_store.ts +204 -132
- package/src/archiver/kv_archiver_store/message_store.ts +213 -54
- package/src/archiver/l1/README.md +98 -0
- package/src/archiver/l1/bin/retrieve-calldata.ts +182 -0
- package/src/archiver/l1/calldata_retriever.ts +641 -0
- package/src/archiver/l1/data_retrieval.ts +512 -0
- package/src/archiver/l1/debug_tx.ts +99 -0
- package/src/archiver/l1/spire_proposer.ts +160 -0
- package/src/archiver/l1/trace_tx.ts +128 -0
- package/src/archiver/l1/types.ts +13 -0
- package/src/archiver/l1/validate_trace.ts +211 -0
- package/src/archiver/structs/inbox_message.ts +41 -0
- package/src/archiver/structs/published.ts +1 -11
- package/src/archiver/validation.ts +124 -0
- package/src/factory.ts +28 -69
- package/src/index.ts +1 -1
- package/src/rpc/index.ts +1 -5
- 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/mock_archiver.ts +22 -16
- package/src/test/mock_l1_to_l2_message_source.ts +26 -8
- package/src/test/mock_l2_block_source.ts +254 -31
- package/src/test/mock_structs.ts +50 -0
- package/dest/archiver/data_retrieval.d.ts +0 -74
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/data_retrieval.js +0 -283
- 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/data_retrieval.ts +0 -422
- 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/config.ts
CHANGED
|
@@ -1,62 +1,31 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type BlobClientConfig, blobClientConfigMapping } from '@aztec/blob-client/client/config';
|
|
2
|
+
import { type L1ContractsConfig, l1ContractsConfigMappings } from '@aztec/ethereum/config';
|
|
3
|
+
import { l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
|
|
4
|
+
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
2
5
|
import {
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from '@aztec/ethereum';
|
|
9
|
-
import { type ConfigMappingsType, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
|
|
6
|
+
type ConfigMappingsType,
|
|
7
|
+
booleanConfigHelper,
|
|
8
|
+
getConfigFromMappings,
|
|
9
|
+
numberConfigHelper,
|
|
10
|
+
} from '@aztec/foundation/config';
|
|
10
11
|
import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
|
|
12
|
+
import type { ArchiverSpecificConfig } from '@aztec/stdlib/interfaces/server';
|
|
11
13
|
|
|
12
14
|
/**
|
|
15
|
+
* The archiver configuration.
|
|
13
16
|
* There are 2 polling intervals used in this configuration. The first is the archiver polling interval, archiverPollingIntervalMS.
|
|
14
17
|
* This is the interval between successive calls to eth_blockNumber via viem.
|
|
15
18
|
* Results of calls to eth_blockNumber are cached by viem with this cache being updated periodically at the interval specified by viemPollingIntervalMS.
|
|
16
19
|
* As a result the maximum observed polling time for new blocks will be viemPollingIntervalMS + archiverPollingIntervalMS.
|
|
17
20
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* The archiver configuration.
|
|
21
|
-
*/
|
|
22
|
-
export type ArchiverConfig = {
|
|
23
|
-
/** URL for an archiver service. If set, will return an archiver client as opposed to starting a new one. */
|
|
24
|
-
archiverUrl?: string;
|
|
25
|
-
|
|
26
|
-
/** URL for an L1 consensus client */
|
|
27
|
-
l1ConsensusHostUrl?: string;
|
|
28
|
-
|
|
29
|
-
/** The polling interval in ms for retrieving new L2 blocks and encrypted logs. */
|
|
30
|
-
archiverPollingIntervalMS?: number;
|
|
31
|
-
|
|
32
|
-
/** The number of L2 blocks the archiver will attempt to download at a time. */
|
|
33
|
-
archiverBatchSize?: number;
|
|
34
|
-
|
|
35
|
-
/** The polling interval viem uses in ms */
|
|
36
|
-
viemPollingIntervalMS?: number;
|
|
37
|
-
|
|
38
|
-
/** The deployed L1 contract addresses */
|
|
39
|
-
l1Contracts: L1ContractAddresses;
|
|
40
|
-
|
|
41
|
-
/** The max number of logs that can be obtained in 1 "getPublicLogs" call. */
|
|
42
|
-
maxLogs?: number;
|
|
43
|
-
} & L1ReaderConfig &
|
|
21
|
+
export type ArchiverConfig = ArchiverSpecificConfig &
|
|
22
|
+
L1ReaderConfig &
|
|
44
23
|
L1ContractsConfig &
|
|
45
|
-
|
|
24
|
+
BlobClientConfig &
|
|
46
25
|
ChainConfig;
|
|
47
26
|
|
|
48
27
|
export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
49
|
-
...
|
|
50
|
-
archiverUrl: {
|
|
51
|
-
env: 'ARCHIVER_URL',
|
|
52
|
-
description:
|
|
53
|
-
'URL for an archiver service. If set, will return an archiver client as opposed to starting a new one.',
|
|
54
|
-
},
|
|
55
|
-
l1ConsensusHostUrl: {
|
|
56
|
-
env: 'L1_CONSENSUS_HOST_URL',
|
|
57
|
-
description: 'URL for an L1 consensus client.',
|
|
58
|
-
parseEnv: (val: string) => val,
|
|
59
|
-
},
|
|
28
|
+
...blobClientConfigMapping,
|
|
60
29
|
archiverPollingIntervalMS: {
|
|
61
30
|
env: 'ARCHIVER_POLLING_INTERVAL_MS',
|
|
62
31
|
description: 'The polling interval in ms for retrieving new L2 blocks and encrypted logs.',
|
|
@@ -72,6 +41,25 @@ export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
|
72
41
|
description: 'The max number of logs that can be obtained in 1 "getPublicLogs" call.',
|
|
73
42
|
...numberConfigHelper(1_000),
|
|
74
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
|
+
skipValidateCheckpointAttestations: {
|
|
50
|
+
description: 'Skip validating checkpoint attestations (for testing purposes only)',
|
|
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
|
+
ethereumAllowNoDebugHosts: {
|
|
59
|
+
env: 'ETHEREUM_ALLOW_NO_DEBUG_HOSTS',
|
|
60
|
+
description: 'Whether to allow starting the archiver without debug/trace method support on Ethereum hosts',
|
|
61
|
+
...booleanConfigHelper(true),
|
|
62
|
+
},
|
|
75
63
|
...chainConfigMappings,
|
|
76
64
|
...l1ReaderConfigMappings,
|
|
77
65
|
viemPollingIntervalMS: {
|
|
@@ -80,6 +68,10 @@ export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
|
80
68
|
...numberConfigHelper(1000),
|
|
81
69
|
},
|
|
82
70
|
...l1ContractsConfigMappings,
|
|
71
|
+
l1Contracts: {
|
|
72
|
+
description: 'The deployed L1 contract addresses',
|
|
73
|
+
nested: l1ContractAddressesMapping,
|
|
74
|
+
},
|
|
83
75
|
};
|
|
84
76
|
|
|
85
77
|
/**
|
package/src/archiver/errors.ts
CHANGED
|
@@ -1,5 +1,90 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/schemas';
|
|
2
|
+
|
|
1
3
|
export class NoBlobBodiesFoundError extends Error {
|
|
2
4
|
constructor(l2BlockNum: number) {
|
|
3
5
|
super(`No blob bodies found for block ${l2BlockNum}`);
|
|
4
6
|
}
|
|
5
7
|
}
|
|
8
|
+
|
|
9
|
+
export class InitialBlockNumberNotSequentialError extends Error {
|
|
10
|
+
constructor(
|
|
11
|
+
public readonly newBlockNumber: number,
|
|
12
|
+
public readonly previousBlockNumber: number | undefined,
|
|
13
|
+
) {
|
|
14
|
+
super(
|
|
15
|
+
`Cannot insert new block ${newBlockNumber} given previous block number in store is ${
|
|
16
|
+
previousBlockNumber ?? 'undefined'
|
|
17
|
+
}`,
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class BlockNumberNotSequentialError extends Error {
|
|
23
|
+
constructor(newBlockNumber: number, previous: number | undefined) {
|
|
24
|
+
super(
|
|
25
|
+
`Cannot insert new block ${newBlockNumber} given previous block number in batch is ${previous ?? 'undefined'}`,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class InitialCheckpointNumberNotSequentialError extends Error {
|
|
31
|
+
constructor(
|
|
32
|
+
public readonly newCheckpointNumber: number,
|
|
33
|
+
public readonly previousCheckpointNumber: number | undefined,
|
|
34
|
+
) {
|
|
35
|
+
super(
|
|
36
|
+
`Cannot insert new checkpoint ${newCheckpointNumber} given previous checkpoint number in store is ${
|
|
37
|
+
previousCheckpointNumber ?? 'undefined'
|
|
38
|
+
}`,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class CheckpointNumberNotSequentialError extends Error {
|
|
44
|
+
constructor(newCheckpointNumber: number, previous: number | undefined) {
|
|
45
|
+
super(
|
|
46
|
+
`Cannot insert new checkpoint ${newCheckpointNumber} given previous checkpoint number in batch is ${previous ?? 'undefined'}`,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class CheckpointNumberNotConsistentError extends Error {
|
|
52
|
+
constructor(newCheckpointNumber: number, previous: number | undefined) {
|
|
53
|
+
super(
|
|
54
|
+
`Cannot insert block for new checkpoint ${newCheckpointNumber} given previous block was checkpoint ${previous ?? 'undefined'}`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export class BlockIndexNotSequentialError extends Error {
|
|
60
|
+
constructor(newBlockIndex: number, previousBlockIndex: number | undefined) {
|
|
61
|
+
super(
|
|
62
|
+
`Cannot insert new block at checkpoint index ${newBlockIndex} given previous block index is ${previousBlockIndex ?? 'undefined'}`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class BlockArchiveNotConsistentError extends Error {
|
|
68
|
+
constructor(
|
|
69
|
+
newBlockNumber: number,
|
|
70
|
+
previousBlockNumber: number | undefined,
|
|
71
|
+
newBlockArchive: Fr,
|
|
72
|
+
previousBlockArchive: Fr,
|
|
73
|
+
) {
|
|
74
|
+
super(
|
|
75
|
+
`Cannot insert new block number ${newBlockNumber} with archive ${newBlockArchive.toString()} previous block number is ${previousBlockNumber ?? 'undefined'}, previous archive is ${previousBlockArchive?.toString() ?? 'undefined'}`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class CheckpointNotFoundError extends Error {
|
|
81
|
+
constructor(checkpointNumber: number) {
|
|
82
|
+
super(`Failed to find expected checkpoint number ${checkpointNumber}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export class BlockNotFoundError extends Error {
|
|
87
|
+
constructor(blockNumber: number) {
|
|
88
|
+
super(`Failed to find expected block number ${blockNumber}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
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 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,
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
type TelemetryClient,
|
|
11
11
|
type Tracer,
|
|
12
12
|
type UpDownCounter,
|
|
13
|
-
ValueType,
|
|
14
13
|
} from '@aztec/telemetry-client';
|
|
15
14
|
|
|
16
15
|
export class ArchiverInstrumentation {
|
|
@@ -18,55 +17,60 @@ export class ArchiverInstrumentation {
|
|
|
18
17
|
|
|
19
18
|
private blockHeight: Gauge;
|
|
20
19
|
private txCount: UpDownCounter;
|
|
21
|
-
private syncDuration: Histogram;
|
|
22
|
-
private l1BlocksSynced: UpDownCounter;
|
|
23
20
|
private l1BlockHeight: Gauge;
|
|
24
21
|
private proofsSubmittedDelay: Histogram;
|
|
25
22
|
private proofsSubmittedCount: UpDownCounter;
|
|
26
23
|
private dbMetrics: LmdbMetrics;
|
|
24
|
+
|
|
25
|
+
private pruneDuration: Histogram;
|
|
27
26
|
private pruneCount: UpDownCounter;
|
|
28
27
|
|
|
28
|
+
private syncDurationPerBlock: Histogram;
|
|
29
|
+
private syncBlockCount: UpDownCounter;
|
|
30
|
+
private manaPerBlock: Histogram;
|
|
31
|
+
private txsPerBlock: Histogram;
|
|
32
|
+
|
|
33
|
+
private syncDurationPerMessage: Histogram;
|
|
34
|
+
private syncMessageCount: UpDownCounter;
|
|
35
|
+
|
|
36
|
+
private blockProposalTxTargetCount: UpDownCounter;
|
|
37
|
+
|
|
29
38
|
private log = createLogger('archiver:instrumentation');
|
|
30
39
|
|
|
31
|
-
private constructor(
|
|
40
|
+
private constructor(
|
|
41
|
+
private telemetry: TelemetryClient,
|
|
42
|
+
lmdbStats?: LmdbStatsCallback,
|
|
43
|
+
) {
|
|
32
44
|
this.tracer = telemetry.getTracer('Archiver');
|
|
33
45
|
const meter = telemetry.getMeter('Archiver');
|
|
34
|
-
this.blockHeight = meter.createGauge(Metrics.ARCHIVER_BLOCK_HEIGHT, {
|
|
35
|
-
description: 'The height of the latest block processed by the archiver',
|
|
36
|
-
valueType: ValueType.INT,
|
|
37
|
-
});
|
|
38
46
|
|
|
39
|
-
this.
|
|
40
|
-
description: 'The total number of transactions',
|
|
41
|
-
valueType: ValueType.INT,
|
|
42
|
-
});
|
|
47
|
+
this.blockHeight = meter.createGauge(Metrics.ARCHIVER_BLOCK_HEIGHT);
|
|
43
48
|
|
|
44
|
-
this.
|
|
45
|
-
unit: 'ms',
|
|
46
|
-
description: 'Duration to sync a block',
|
|
47
|
-
valueType: ValueType.INT,
|
|
48
|
-
});
|
|
49
|
+
this.l1BlockHeight = meter.createGauge(Metrics.ARCHIVER_L1_BLOCK_HEIGHT);
|
|
49
50
|
|
|
50
|
-
this.
|
|
51
|
-
description: 'Number of proofs submitted',
|
|
52
|
-
valueType: ValueType.INT,
|
|
53
|
-
});
|
|
51
|
+
this.txCount = meter.createUpDownCounter(Metrics.ARCHIVER_TOTAL_TXS);
|
|
54
52
|
|
|
55
|
-
this.
|
|
56
|
-
unit: 'ms',
|
|
57
|
-
description: 'Time after a block is submitted until its proof is published',
|
|
58
|
-
valueType: ValueType.INT,
|
|
59
|
-
});
|
|
53
|
+
this.proofsSubmittedCount = meter.createUpDownCounter(Metrics.ARCHIVER_ROLLUP_PROOF_COUNT);
|
|
60
54
|
|
|
61
|
-
this.
|
|
62
|
-
description: 'Number of blocks synced from L1',
|
|
63
|
-
valueType: ValueType.INT,
|
|
64
|
-
});
|
|
55
|
+
this.proofsSubmittedDelay = meter.createHistogram(Metrics.ARCHIVER_ROLLUP_PROOF_DELAY);
|
|
65
56
|
|
|
66
|
-
this.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
this.syncDurationPerBlock = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_BLOCK);
|
|
58
|
+
|
|
59
|
+
this.syncBlockCount = meter.createUpDownCounter(Metrics.ARCHIVER_SYNC_BLOCK_COUNT);
|
|
60
|
+
|
|
61
|
+
this.manaPerBlock = meter.createHistogram(Metrics.ARCHIVER_MANA_PER_BLOCK);
|
|
62
|
+
|
|
63
|
+
this.txsPerBlock = meter.createHistogram(Metrics.ARCHIVER_TXS_PER_BLOCK);
|
|
64
|
+
|
|
65
|
+
this.syncDurationPerMessage = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_MESSAGE);
|
|
66
|
+
|
|
67
|
+
this.syncMessageCount = meter.createUpDownCounter(Metrics.ARCHIVER_SYNC_MESSAGE_COUNT);
|
|
68
|
+
|
|
69
|
+
this.pruneDuration = meter.createHistogram(Metrics.ARCHIVER_PRUNE_DURATION);
|
|
70
|
+
|
|
71
|
+
this.pruneCount = meter.createUpDownCounter(Metrics.ARCHIVER_PRUNE_COUNT);
|
|
72
|
+
|
|
73
|
+
this.blockProposalTxTargetCount = meter.createUpDownCounter(Metrics.ARCHIVER_BLOCK_PROPOSAL_TX_TARGET_COUNT);
|
|
70
74
|
|
|
71
75
|
this.dbMetrics = new LmdbMetrics(
|
|
72
76
|
meter,
|
|
@@ -75,17 +79,14 @@ export class ArchiverInstrumentation {
|
|
|
75
79
|
},
|
|
76
80
|
lmdbStats,
|
|
77
81
|
);
|
|
78
|
-
|
|
79
|
-
this.pruneCount = meter.createUpDownCounter(Metrics.ARCHIVER_PRUNE_COUNT, {
|
|
80
|
-
description: 'Number of prunes detected',
|
|
81
|
-
valueType: ValueType.INT,
|
|
82
|
-
});
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
public static async new(telemetry: TelemetryClient, lmdbStats?: LmdbStatsCallback) {
|
|
86
85
|
const instance = new ArchiverInstrumentation(telemetry, lmdbStats);
|
|
87
86
|
|
|
88
|
-
instance.
|
|
87
|
+
instance.syncBlockCount.add(0);
|
|
88
|
+
instance.syncMessageCount.add(0);
|
|
89
|
+
instance.pruneCount.add(0);
|
|
89
90
|
|
|
90
91
|
await instance.telemetry.flush();
|
|
91
92
|
|
|
@@ -96,17 +97,29 @@ export class ArchiverInstrumentation {
|
|
|
96
97
|
return this.telemetry.isEnabled();
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
public processNewBlocks(syncTimePerBlock: number, blocks:
|
|
100
|
-
this.
|
|
100
|
+
public processNewBlocks(syncTimePerBlock: number, blocks: L2BlockNew[]) {
|
|
101
|
+
this.syncDurationPerBlock.record(Math.ceil(syncTimePerBlock));
|
|
101
102
|
this.blockHeight.record(Math.max(...blocks.map(b => b.number)));
|
|
102
|
-
this.
|
|
103
|
+
this.syncBlockCount.add(blocks.length);
|
|
104
|
+
|
|
103
105
|
for (const block of blocks) {
|
|
104
106
|
this.txCount.add(block.body.txEffects.length);
|
|
107
|
+
this.txsPerBlock.record(block.body.txEffects.length);
|
|
108
|
+
this.manaPerBlock.record(block.header.totalManaUsed.toNumber() / 1e6);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public processNewMessages(count: number, syncPerMessageMs: number) {
|
|
113
|
+
if (count === 0) {
|
|
114
|
+
return;
|
|
105
115
|
}
|
|
116
|
+
this.syncMessageCount.add(count);
|
|
117
|
+
this.syncDurationPerMessage.record(Math.ceil(syncPerMessageMs));
|
|
106
118
|
}
|
|
107
119
|
|
|
108
|
-
public processPrune() {
|
|
120
|
+
public processPrune(duration: number) {
|
|
109
121
|
this.pruneCount.add(1);
|
|
122
|
+
this.pruneDuration.record(Math.ceil(duration));
|
|
110
123
|
}
|
|
111
124
|
|
|
112
125
|
public updateLastProvenBlock(blockNumber: number) {
|
|
@@ -129,4 +142,11 @@ export class ArchiverInstrumentation {
|
|
|
129
142
|
public updateL1BlockHeight(blockNumber: bigint) {
|
|
130
143
|
this.l1BlockHeight.record(Number(blockNumber));
|
|
131
144
|
}
|
|
145
|
+
|
|
146
|
+
public recordBlockProposalTxTarget(target: string, usedTrace: boolean) {
|
|
147
|
+
this.blockProposalTxTargetCount.add(1, {
|
|
148
|
+
[Attributes.L1_BLOCK_PROPOSAL_TX_TARGET]: target.toLowerCase(),
|
|
149
|
+
[Attributes.L1_BLOCK_PROPOSAL_USED_TRACE]: usedTrace,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
132
152
|
}
|