@aztec/archiver 0.0.0-test.1 → 0.0.1-commit.03f7ef2

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.
Files changed (151) hide show
  1. package/README.md +27 -6
  2. package/dest/archiver/archiver.d.ts +201 -94
  3. package/dest/archiver/archiver.d.ts.map +1 -1
  4. package/dest/archiver/archiver.js +1141 -396
  5. package/dest/archiver/archiver_store.d.ts +171 -83
  6. package/dest/archiver/archiver_store.d.ts.map +1 -1
  7. package/dest/archiver/archiver_store_test_suite.d.ts +1 -1
  8. package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
  9. package/dest/archiver/archiver_store_test_suite.js +2389 -393
  10. package/dest/archiver/config.d.ts +7 -22
  11. package/dest/archiver/config.d.ts.map +1 -1
  12. package/dest/archiver/config.js +30 -14
  13. package/dest/archiver/errors.d.ts +33 -1
  14. package/dest/archiver/errors.d.ts.map +1 -1
  15. package/dest/archiver/errors.js +49 -0
  16. package/dest/archiver/index.d.ts +3 -4
  17. package/dest/archiver/index.d.ts.map +1 -1
  18. package/dest/archiver/index.js +1 -2
  19. package/dest/archiver/instrumentation.d.ts +14 -6
  20. package/dest/archiver/instrumentation.d.ts.map +1 -1
  21. package/dest/archiver/instrumentation.js +69 -17
  22. package/dest/archiver/kv_archiver_store/block_store.d.ts +91 -21
  23. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
  24. package/dest/archiver/kv_archiver_store/block_store.js +476 -86
  25. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +4 -4
  26. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
  27. package/dest/archiver/kv_archiver_store/contract_class_store.js +13 -19
  28. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +12 -9
  29. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
  30. package/dest/archiver/kv_archiver_store/contract_instance_store.js +30 -16
  31. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +80 -75
  32. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
  33. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +142 -83
  34. package/dest/archiver/kv_archiver_store/log_store.d.ts +12 -16
  35. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
  36. package/dest/archiver/kv_archiver_store/log_store.js +153 -113
  37. package/dest/archiver/kv_archiver_store/message_store.d.ts +25 -18
  38. package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
  39. package/dest/archiver/kv_archiver_store/message_store.js +152 -49
  40. package/dest/archiver/l1/bin/retrieve-calldata.d.ts +3 -0
  41. package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +1 -0
  42. package/dest/archiver/l1/bin/retrieve-calldata.js +149 -0
  43. package/dest/archiver/l1/calldata_retriever.d.ts +112 -0
  44. package/dest/archiver/l1/calldata_retriever.d.ts.map +1 -0
  45. package/dest/archiver/l1/calldata_retriever.js +471 -0
  46. package/dest/archiver/l1/data_retrieval.d.ts +90 -0
  47. package/dest/archiver/l1/data_retrieval.d.ts.map +1 -0
  48. package/dest/archiver/l1/data_retrieval.js +331 -0
  49. package/dest/archiver/l1/debug_tx.d.ts +19 -0
  50. package/dest/archiver/l1/debug_tx.d.ts.map +1 -0
  51. package/dest/archiver/l1/debug_tx.js +73 -0
  52. package/dest/archiver/l1/spire_proposer.d.ts +70 -0
  53. package/dest/archiver/l1/spire_proposer.d.ts.map +1 -0
  54. package/dest/archiver/l1/spire_proposer.js +157 -0
  55. package/dest/archiver/l1/trace_tx.d.ts +97 -0
  56. package/dest/archiver/l1/trace_tx.d.ts.map +1 -0
  57. package/dest/archiver/l1/trace_tx.js +91 -0
  58. package/dest/archiver/l1/types.d.ts +12 -0
  59. package/dest/archiver/l1/types.d.ts.map +1 -0
  60. package/dest/archiver/l1/types.js +3 -0
  61. package/dest/archiver/l1/validate_trace.d.ts +29 -0
  62. package/dest/archiver/l1/validate_trace.d.ts.map +1 -0
  63. package/dest/archiver/l1/validate_trace.js +150 -0
  64. package/dest/archiver/structs/data_retrieval.d.ts +1 -1
  65. package/dest/archiver/structs/inbox_message.d.ts +15 -0
  66. package/dest/archiver/structs/inbox_message.d.ts.map +1 -0
  67. package/dest/archiver/structs/inbox_message.js +39 -0
  68. package/dest/archiver/structs/published.d.ts +2 -11
  69. package/dest/archiver/structs/published.d.ts.map +1 -1
  70. package/dest/archiver/structs/published.js +1 -1
  71. package/dest/archiver/validation.d.ts +17 -0
  72. package/dest/archiver/validation.d.ts.map +1 -0
  73. package/dest/archiver/validation.js +98 -0
  74. package/dest/factory.d.ts +9 -14
  75. package/dest/factory.d.ts.map +1 -1
  76. package/dest/factory.js +22 -52
  77. package/dest/index.d.ts +2 -2
  78. package/dest/index.d.ts.map +1 -1
  79. package/dest/index.js +1 -1
  80. package/dest/rpc/index.d.ts +2 -3
  81. package/dest/rpc/index.d.ts.map +1 -1
  82. package/dest/rpc/index.js +1 -4
  83. package/dest/test/index.d.ts +1 -1
  84. package/dest/test/mock_archiver.d.ts +16 -8
  85. package/dest/test/mock_archiver.d.ts.map +1 -1
  86. package/dest/test/mock_archiver.js +19 -14
  87. package/dest/test/mock_l1_to_l2_message_source.d.ts +9 -6
  88. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
  89. package/dest/test/mock_l1_to_l2_message_source.js +21 -7
  90. package/dest/test/mock_l2_block_source.d.ts +52 -13
  91. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  92. package/dest/test/mock_l2_block_source.js +140 -15
  93. package/dest/test/mock_structs.d.ts +10 -0
  94. package/dest/test/mock_structs.d.ts.map +1 -0
  95. package/dest/test/mock_structs.js +38 -0
  96. package/package.json +29 -30
  97. package/src/archiver/archiver.ts +1477 -501
  98. package/src/archiver/archiver_store.ts +197 -88
  99. package/src/archiver/archiver_store_test_suite.ts +2403 -350
  100. package/src/archiver/config.ts +38 -46
  101. package/src/archiver/errors.ts +85 -0
  102. package/src/archiver/index.ts +2 -3
  103. package/src/archiver/instrumentation.ts +91 -22
  104. package/src/archiver/kv_archiver_store/block_store.ts +640 -101
  105. package/src/archiver/kv_archiver_store/contract_class_store.ts +14 -24
  106. package/src/archiver/kv_archiver_store/contract_instance_store.ts +36 -28
  107. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +193 -113
  108. package/src/archiver/kv_archiver_store/log_store.ts +205 -127
  109. package/src/archiver/kv_archiver_store/message_store.ts +213 -54
  110. package/src/archiver/l1/README.md +98 -0
  111. package/src/archiver/l1/bin/retrieve-calldata.ts +182 -0
  112. package/src/archiver/l1/calldata_retriever.ts +641 -0
  113. package/src/archiver/l1/data_retrieval.ts +512 -0
  114. package/src/archiver/l1/debug_tx.ts +99 -0
  115. package/src/archiver/l1/spire_proposer.ts +160 -0
  116. package/src/archiver/l1/trace_tx.ts +128 -0
  117. package/src/archiver/l1/types.ts +13 -0
  118. package/src/archiver/l1/validate_trace.ts +211 -0
  119. package/src/archiver/structs/inbox_message.ts +41 -0
  120. package/src/archiver/structs/published.ts +1 -11
  121. package/src/archiver/validation.ts +124 -0
  122. package/src/factory.ts +28 -69
  123. package/src/index.ts +1 -1
  124. package/src/rpc/index.ts +1 -5
  125. package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
  126. package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
  127. package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
  128. package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
  129. package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
  130. package/src/test/fixtures/trace_transaction-proxied.json +128 -0
  131. package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
  132. package/src/test/mock_archiver.ts +22 -16
  133. package/src/test/mock_l1_to_l2_message_source.ts +20 -8
  134. package/src/test/mock_l2_block_source.ts +186 -21
  135. package/src/test/mock_structs.ts +50 -0
  136. package/dest/archiver/data_retrieval.d.ts +0 -74
  137. package/dest/archiver/data_retrieval.d.ts.map +0 -1
  138. package/dest/archiver/data_retrieval.js +0 -283
  139. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
  140. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
  141. package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
  142. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +0 -23
  143. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +0 -1
  144. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +0 -49
  145. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
  146. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
  147. package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -636
  148. package/src/archiver/data_retrieval.ts +0 -422
  149. package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
  150. package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +0 -61
  151. package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
@@ -1,62 +1,31 @@
1
- import { type BlobSinkConfig, blobSinkConfigMapping } from '@aztec/blob-sink/client';
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 L1ContractAddresses,
4
- type L1ContractsConfig,
5
- type L1ReaderConfig,
6
- l1ContractsConfigMappings,
7
- l1ReaderConfigMappings,
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
- BlobSinkConfig &
24
+ BlobClientConfig &
46
25
  ChainConfig;
47
26
 
48
27
  export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
49
- ...blobSinkConfigMapping,
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
+ 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
+ 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
  /**
@@ -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
+ }
@@ -1,7 +1,6 @@
1
1
  export * from './archiver.js';
2
2
  export * from './config.js';
3
- export { type L1Published, type L1PublishedData } from './structs/published.js';
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 { L2Block } from '@aztec/stdlib/block';
2
+ import type { L2BlockNew } from '@aztec/stdlib/block';
3
3
  import {
4
4
  Attributes,
5
5
  type Gauge,
@@ -18,32 +18,45 @@ 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
+
37
+ private blockProposalTxTargetCount: UpDownCounter;
38
+
29
39
  private log = createLogger('archiver:instrumentation');
30
40
 
31
- private constructor(private telemetry: TelemetryClient, lmdbStats?: LmdbStatsCallback) {
41
+ private constructor(
42
+ private telemetry: TelemetryClient,
43
+ lmdbStats?: LmdbStatsCallback,
44
+ ) {
32
45
  this.tracer = telemetry.getTracer('Archiver');
33
46
  const meter = telemetry.getMeter('Archiver');
47
+
34
48
  this.blockHeight = meter.createGauge(Metrics.ARCHIVER_BLOCK_HEIGHT, {
35
49
  description: 'The height of the latest block processed by the archiver',
36
50
  valueType: ValueType.INT,
37
51
  });
38
52
 
39
- this.txCount = meter.createUpDownCounter(Metrics.ARCHIVER_TX_COUNT, {
40
- description: 'The total number of transactions',
53
+ this.l1BlockHeight = meter.createGauge(Metrics.ARCHIVER_L1_BLOCK_HEIGHT, {
54
+ description: 'The height of the latest L1 block processed by the archiver',
41
55
  valueType: ValueType.INT,
42
56
  });
43
57
 
44
- this.syncDuration = meter.createHistogram(Metrics.ARCHIVER_SYNC_DURATION, {
45
- unit: 'ms',
46
- description: 'Duration to sync a block',
58
+ this.txCount = meter.createUpDownCounter(Metrics.ARCHIVER_TOTAL_TXS, {
59
+ description: 'The total number of transactions',
47
60
  valueType: ValueType.INT,
48
61
  });
49
62
 
@@ -58,13 +71,53 @@ export class ArchiverInstrumentation {
58
71
  valueType: ValueType.INT,
59
72
  });
60
73
 
61
- this.l1BlocksSynced = meter.createUpDownCounter(Metrics.ARCHIVER_L1_BLOCKS_SYNCED, {
74
+ this.syncDurationPerBlock = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_BLOCK, {
75
+ unit: 'ms',
76
+ description: 'Duration to sync a block',
77
+ valueType: ValueType.INT,
78
+ });
79
+
80
+ this.syncBlockCount = meter.createUpDownCounter(Metrics.ARCHIVER_SYNC_BLOCK_COUNT, {
62
81
  description: 'Number of blocks synced from L1',
63
82
  valueType: ValueType.INT,
64
83
  });
65
84
 
66
- this.l1BlockHeight = meter.createGauge(Metrics.ARCHIVER_L1_BLOCK_HEIGHT, {
67
- description: 'The height of the latest L1 block processed by the archiver',
85
+ this.manaPerBlock = meter.createHistogram(Metrics.ARCHIVER_MANA_PER_BLOCK, {
86
+ description: 'The mana consumed by blocks',
87
+ valueType: ValueType.DOUBLE,
88
+ unit: 'Mmana',
89
+ });
90
+
91
+ this.txsPerBlock = meter.createHistogram(Metrics.ARCHIVER_TXS_PER_BLOCK, {
92
+ description: 'The block tx count',
93
+ valueType: ValueType.INT,
94
+ unit: 'tx',
95
+ });
96
+
97
+ this.syncDurationPerMessage = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_MESSAGE, {
98
+ unit: 'ms',
99
+ description: 'Duration to sync a message',
100
+ valueType: ValueType.INT,
101
+ });
102
+
103
+ this.syncMessageCount = meter.createUpDownCounter(Metrics.ARCHIVER_SYNC_MESSAGE_COUNT, {
104
+ description: 'Number of L1 to L2 messages synced',
105
+ valueType: ValueType.INT,
106
+ });
107
+
108
+ this.pruneDuration = meter.createHistogram(Metrics.ARCHIVER_PRUNE_DURATION, {
109
+ unit: 'ms',
110
+ description: 'Duration to sync a message',
111
+ valueType: ValueType.INT,
112
+ });
113
+
114
+ this.pruneCount = meter.createUpDownCounter(Metrics.ARCHIVER_PRUNE_COUNT, {
115
+ description: 'Number of prunes detected',
116
+ valueType: ValueType.INT,
117
+ });
118
+
119
+ this.blockProposalTxTargetCount = meter.createUpDownCounter(Metrics.ARCHIVER_BLOCK_PROPOSAL_TX_TARGET_COUNT, {
120
+ description: 'Number of block proposals by tx target',
68
121
  valueType: ValueType.INT,
69
122
  });
70
123
 
@@ -75,17 +128,14 @@ export class ArchiverInstrumentation {
75
128
  },
76
129
  lmdbStats,
77
130
  );
78
-
79
- this.pruneCount = meter.createUpDownCounter(Metrics.ARCHIVER_PRUNE_COUNT, {
80
- description: 'Number of prunes detected',
81
- valueType: ValueType.INT,
82
- });
83
131
  }
84
132
 
85
133
  public static async new(telemetry: TelemetryClient, lmdbStats?: LmdbStatsCallback) {
86
134
  const instance = new ArchiverInstrumentation(telemetry, lmdbStats);
87
135
 
88
- instance.l1BlocksSynced.add(0);
136
+ instance.syncBlockCount.add(0);
137
+ instance.syncMessageCount.add(0);
138
+ instance.pruneCount.add(0);
89
139
 
90
140
  await instance.telemetry.flush();
91
141
 
@@ -96,17 +146,29 @@ export class ArchiverInstrumentation {
96
146
  return this.telemetry.isEnabled();
97
147
  }
98
148
 
99
- public processNewBlocks(syncTimePerBlock: number, blocks: L2Block[]) {
100
- this.syncDuration.record(Math.ceil(syncTimePerBlock));
149
+ public processNewBlocks(syncTimePerBlock: number, blocks: L2BlockNew[]) {
150
+ this.syncDurationPerBlock.record(Math.ceil(syncTimePerBlock));
101
151
  this.blockHeight.record(Math.max(...blocks.map(b => b.number)));
102
- this.l1BlocksSynced.add(blocks.length);
152
+ this.syncBlockCount.add(blocks.length);
153
+
103
154
  for (const block of blocks) {
104
155
  this.txCount.add(block.body.txEffects.length);
156
+ this.txsPerBlock.record(block.body.txEffects.length);
157
+ this.manaPerBlock.record(block.header.totalManaUsed.toNumber() / 1e6);
105
158
  }
106
159
  }
107
160
 
108
- public processPrune() {
161
+ public processNewMessages(count: number, syncPerMessageMs: number) {
162
+ if (count === 0) {
163
+ return;
164
+ }
165
+ this.syncMessageCount.add(count);
166
+ this.syncDurationPerMessage.record(Math.ceil(syncPerMessageMs));
167
+ }
168
+
169
+ public processPrune(duration: number) {
109
170
  this.pruneCount.add(1);
171
+ this.pruneDuration.record(Math.ceil(duration));
110
172
  }
111
173
 
112
174
  public updateLastProvenBlock(blockNumber: number) {
@@ -129,4 +191,11 @@ export class ArchiverInstrumentation {
129
191
  public updateL1BlockHeight(blockNumber: bigint) {
130
192
  this.l1BlockHeight.record(Number(blockNumber));
131
193
  }
194
+
195
+ public recordBlockProposalTxTarget(target: string, usedTrace: boolean) {
196
+ this.blockProposalTxTargetCount.add(1, {
197
+ [Attributes.L1_BLOCK_PROPOSAL_TX_TARGET]: target.toLowerCase(),
198
+ [Attributes.L1_BLOCK_PROPOSAL_USED_TRACE]: usedTrace,
199
+ });
200
+ }
132
201
  }