@aztec/archiver 0.0.0-test.0 → 0.0.1-commit.023c3e5

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 (225) hide show
  1. package/README.md +164 -9
  2. package/dest/archiver.d.ts +136 -0
  3. package/dest/archiver.d.ts.map +1 -0
  4. package/dest/archiver.js +781 -0
  5. package/dest/config.d.ts +30 -0
  6. package/dest/config.d.ts.map +1 -0
  7. package/dest/config.js +71 -0
  8. package/dest/errors.d.ts +41 -0
  9. package/dest/errors.d.ts.map +1 -0
  10. package/dest/errors.js +62 -0
  11. package/dest/factory.d.ts +13 -16
  12. package/dest/factory.d.ts.map +1 -1
  13. package/dest/factory.js +103 -55
  14. package/dest/index.d.ts +10 -4
  15. package/dest/index.d.ts.map +1 -1
  16. package/dest/index.js +8 -3
  17. package/dest/interfaces.d.ts +9 -0
  18. package/dest/interfaces.d.ts.map +1 -0
  19. package/dest/interfaces.js +3 -0
  20. package/dest/l1/bin/retrieve-calldata.d.ts +3 -0
  21. package/dest/l1/bin/retrieve-calldata.d.ts.map +1 -0
  22. package/dest/l1/bin/retrieve-calldata.js +149 -0
  23. package/dest/l1/calldata_retriever.d.ts +112 -0
  24. package/dest/l1/calldata_retriever.d.ts.map +1 -0
  25. package/dest/l1/calldata_retriever.js +471 -0
  26. package/dest/l1/data_retrieval.d.ts +88 -0
  27. package/dest/l1/data_retrieval.d.ts.map +1 -0
  28. package/dest/l1/data_retrieval.js +312 -0
  29. package/dest/l1/debug_tx.d.ts +19 -0
  30. package/dest/l1/debug_tx.d.ts.map +1 -0
  31. package/dest/l1/debug_tx.js +73 -0
  32. package/dest/l1/spire_proposer.d.ts +70 -0
  33. package/dest/l1/spire_proposer.d.ts.map +1 -0
  34. package/dest/l1/spire_proposer.js +157 -0
  35. package/dest/l1/trace_tx.d.ts +97 -0
  36. package/dest/l1/trace_tx.d.ts.map +1 -0
  37. package/dest/l1/trace_tx.js +91 -0
  38. package/dest/l1/types.d.ts +12 -0
  39. package/dest/l1/types.d.ts.map +1 -0
  40. package/dest/l1/types.js +3 -0
  41. package/dest/l1/validate_trace.d.ts +32 -0
  42. package/dest/l1/validate_trace.d.ts.map +1 -0
  43. package/dest/l1/validate_trace.js +154 -0
  44. package/dest/modules/data_source_base.d.ts +84 -0
  45. package/dest/modules/data_source_base.d.ts.map +1 -0
  46. package/dest/modules/data_source_base.js +260 -0
  47. package/dest/modules/data_store_updater.d.ts +73 -0
  48. package/dest/modules/data_store_updater.d.ts.map +1 -0
  49. package/dest/modules/data_store_updater.js +302 -0
  50. package/dest/modules/instrumentation.d.ts +37 -0
  51. package/dest/modules/instrumentation.d.ts.map +1 -0
  52. package/dest/modules/instrumentation.js +110 -0
  53. package/dest/modules/l1_synchronizer.d.ts +75 -0
  54. package/dest/modules/l1_synchronizer.d.ts.map +1 -0
  55. package/dest/modules/l1_synchronizer.js +1112 -0
  56. package/dest/modules/validation.d.ts +17 -0
  57. package/dest/modules/validation.d.ts.map +1 -0
  58. package/dest/modules/validation.js +104 -0
  59. package/dest/store/block_store.d.ts +192 -0
  60. package/dest/store/block_store.d.ts.map +1 -0
  61. package/dest/store/block_store.js +721 -0
  62. package/dest/store/contract_class_store.d.ts +18 -0
  63. package/dest/store/contract_class_store.d.ts.map +1 -0
  64. package/dest/{archiver/kv_archiver_store → store}/contract_class_store.js +25 -27
  65. package/dest/store/contract_instance_store.d.ts +24 -0
  66. package/dest/store/contract_instance_store.d.ts.map +1 -0
  67. package/dest/store/contract_instance_store.js +77 -0
  68. package/dest/store/kv_archiver_store.d.ts +340 -0
  69. package/dest/store/kv_archiver_store.d.ts.map +1 -0
  70. package/dest/store/kv_archiver_store.js +446 -0
  71. package/dest/store/log_store.d.ts +54 -0
  72. package/dest/store/log_store.d.ts.map +1 -0
  73. package/dest/store/log_store.js +436 -0
  74. package/dest/store/message_store.d.ts +40 -0
  75. package/dest/store/message_store.d.ts.map +1 -0
  76. package/dest/store/message_store.js +188 -0
  77. package/dest/structs/data_retrieval.d.ts +27 -0
  78. package/dest/structs/data_retrieval.d.ts.map +1 -0
  79. package/dest/structs/inbox_message.d.ts +15 -0
  80. package/dest/structs/inbox_message.d.ts.map +1 -0
  81. package/dest/structs/inbox_message.js +39 -0
  82. package/dest/structs/published.d.ts +2 -0
  83. package/dest/structs/published.d.ts.map +1 -0
  84. package/dest/structs/published.js +1 -0
  85. package/dest/test/fake_l1_state.d.ts +190 -0
  86. package/dest/test/fake_l1_state.d.ts.map +1 -0
  87. package/dest/test/fake_l1_state.js +383 -0
  88. package/dest/test/index.d.ts +2 -1
  89. package/dest/test/index.d.ts.map +1 -1
  90. package/dest/test/index.js +4 -1
  91. package/dest/test/mock_archiver.d.ts +16 -8
  92. package/dest/test/mock_archiver.d.ts.map +1 -1
  93. package/dest/test/mock_archiver.js +18 -14
  94. package/dest/test/mock_l1_to_l2_message_source.d.ts +9 -6
  95. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
  96. package/dest/test/mock_l1_to_l2_message_source.js +30 -7
  97. package/dest/test/mock_l2_block_source.d.ts +62 -16
  98. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  99. package/dest/test/mock_l2_block_source.js +263 -32
  100. package/dest/test/mock_structs.d.ts +85 -0
  101. package/dest/test/mock_structs.d.ts.map +1 -0
  102. package/dest/test/mock_structs.js +171 -0
  103. package/dest/test/noop_l1_archiver.d.ts +23 -0
  104. package/dest/test/noop_l1_archiver.d.ts.map +1 -0
  105. package/dest/test/noop_l1_archiver.js +68 -0
  106. package/package.json +31 -33
  107. package/src/archiver.ts +543 -0
  108. package/src/config.ts +95 -0
  109. package/src/errors.ts +102 -0
  110. package/src/factory.ts +144 -71
  111. package/src/index.ts +10 -3
  112. package/src/interfaces.ts +9 -0
  113. package/src/l1/README.md +98 -0
  114. package/src/l1/bin/retrieve-calldata.ts +187 -0
  115. package/src/l1/calldata_retriever.ts +641 -0
  116. package/src/l1/data_retrieval.ts +495 -0
  117. package/src/l1/debug_tx.ts +99 -0
  118. package/src/l1/spire_proposer.ts +160 -0
  119. package/src/l1/trace_tx.ts +128 -0
  120. package/src/l1/types.ts +13 -0
  121. package/src/l1/validate_trace.ts +229 -0
  122. package/src/modules/data_source_base.ts +367 -0
  123. package/src/modules/data_store_updater.ts +423 -0
  124. package/src/modules/instrumentation.ts +157 -0
  125. package/src/modules/l1_synchronizer.ts +930 -0
  126. package/src/modules/validation.ts +129 -0
  127. package/src/store/block_store.ts +966 -0
  128. package/src/{archiver/kv_archiver_store → store}/contract_class_store.ts +26 -32
  129. package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +37 -29
  130. package/src/store/kv_archiver_store.ts +639 -0
  131. package/src/store/log_store.ts +575 -0
  132. package/src/store/message_store.ts +261 -0
  133. package/src/structs/inbox_message.ts +41 -0
  134. package/src/structs/published.ts +1 -0
  135. package/src/test/fake_l1_state.ts +599 -0
  136. package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
  137. package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
  138. package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
  139. package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
  140. package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
  141. package/src/test/fixtures/trace_transaction-proxied.json +128 -0
  142. package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
  143. package/src/test/index.ts +4 -0
  144. package/src/test/mock_archiver.ts +22 -16
  145. package/src/test/mock_l1_to_l2_message_source.ts +26 -8
  146. package/src/test/mock_l2_block_source.ts +313 -42
  147. package/src/test/mock_structs.ts +311 -0
  148. package/src/test/noop_l1_archiver.ts +109 -0
  149. package/dest/archiver/archiver.d.ts +0 -197
  150. package/dest/archiver/archiver.d.ts.map +0 -1
  151. package/dest/archiver/archiver.js +0 -900
  152. package/dest/archiver/archiver_store.d.ts +0 -220
  153. package/dest/archiver/archiver_store.d.ts.map +0 -1
  154. package/dest/archiver/archiver_store.js +0 -4
  155. package/dest/archiver/archiver_store_test_suite.d.ts +0 -8
  156. package/dest/archiver/archiver_store_test_suite.d.ts.map +0 -1
  157. package/dest/archiver/archiver_store_test_suite.js +0 -794
  158. package/dest/archiver/config.d.ts +0 -37
  159. package/dest/archiver/config.d.ts.map +0 -1
  160. package/dest/archiver/config.js +0 -46
  161. package/dest/archiver/data_retrieval.d.ts +0 -74
  162. package/dest/archiver/data_retrieval.d.ts.map +0 -1
  163. package/dest/archiver/data_retrieval.js +0 -283
  164. package/dest/archiver/errors.d.ts +0 -4
  165. package/dest/archiver/errors.d.ts.map +0 -1
  166. package/dest/archiver/errors.js +0 -5
  167. package/dest/archiver/index.d.ts +0 -8
  168. package/dest/archiver/index.d.ts.map +0 -1
  169. package/dest/archiver/index.js +0 -5
  170. package/dest/archiver/instrumentation.d.ts +0 -29
  171. package/dest/archiver/instrumentation.d.ts.map +0 -1
  172. package/dest/archiver/instrumentation.js +0 -99
  173. package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -87
  174. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
  175. package/dest/archiver/kv_archiver_store/block_store.js +0 -217
  176. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +0 -18
  177. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +0 -1
  178. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -21
  179. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
  180. package/dest/archiver/kv_archiver_store/contract_instance_store.js +0 -63
  181. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -153
  182. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +0 -1
  183. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +0 -254
  184. package/dest/archiver/kv_archiver_store/log_store.d.ts +0 -49
  185. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
  186. package/dest/archiver/kv_archiver_store/log_store.js +0 -364
  187. package/dest/archiver/kv_archiver_store/message_store.d.ts +0 -33
  188. package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
  189. package/dest/archiver/kv_archiver_store/message_store.js +0 -85
  190. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
  191. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
  192. package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
  193. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +0 -23
  194. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +0 -1
  195. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +0 -49
  196. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
  197. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
  198. package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -636
  199. package/dest/archiver/structs/data_retrieval.d.ts +0 -27
  200. package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
  201. package/dest/archiver/structs/published.d.ts +0 -11
  202. package/dest/archiver/structs/published.d.ts.map +0 -1
  203. package/dest/archiver/structs/published.js +0 -1
  204. package/dest/rpc/index.d.ts +0 -10
  205. package/dest/rpc/index.d.ts.map +0 -1
  206. package/dest/rpc/index.js +0 -18
  207. package/src/archiver/archiver.ts +0 -1181
  208. package/src/archiver/archiver_store.ts +0 -263
  209. package/src/archiver/archiver_store_test_suite.ts +0 -810
  210. package/src/archiver/config.ts +0 -92
  211. package/src/archiver/data_retrieval.ts +0 -422
  212. package/src/archiver/errors.ts +0 -5
  213. package/src/archiver/index.ts +0 -7
  214. package/src/archiver/instrumentation.ts +0 -132
  215. package/src/archiver/kv_archiver_store/block_store.ts +0 -283
  216. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -358
  217. package/src/archiver/kv_archiver_store/log_store.ts +0 -444
  218. package/src/archiver/kv_archiver_store/message_store.ts +0 -102
  219. package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
  220. package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +0 -61
  221. package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
  222. package/src/archiver/structs/published.ts +0 -11
  223. package/src/rpc/index.ts +0 -20
  224. /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
  225. /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
@@ -1,37 +0,0 @@
1
- import { type BlobSinkConfig } from '@aztec/blob-sink/client';
2
- import { type L1ContractAddresses, type L1ContractsConfig, type L1ReaderConfig } from '@aztec/ethereum';
3
- import { type ConfigMappingsType } from '@aztec/foundation/config';
4
- import { type ChainConfig } from '@aztec/stdlib/config';
5
- /**
6
- * There are 2 polling intervals used in this configuration. The first is the archiver polling interval, archiverPollingIntervalMS.
7
- * This is the interval between successive calls to eth_blockNumber via viem.
8
- * Results of calls to eth_blockNumber are cached by viem with this cache being updated periodically at the interval specified by viemPollingIntervalMS.
9
- * As a result the maximum observed polling time for new blocks will be viemPollingIntervalMS + archiverPollingIntervalMS.
10
- */
11
- /**
12
- * The archiver configuration.
13
- */
14
- export type ArchiverConfig = {
15
- /** URL for an archiver service. If set, will return an archiver client as opposed to starting a new one. */
16
- archiverUrl?: string;
17
- /** URL for an L1 consensus client */
18
- l1ConsensusHostUrl?: string;
19
- /** The polling interval in ms for retrieving new L2 blocks and encrypted logs. */
20
- archiverPollingIntervalMS?: number;
21
- /** The number of L2 blocks the archiver will attempt to download at a time. */
22
- archiverBatchSize?: number;
23
- /** The polling interval viem uses in ms */
24
- viemPollingIntervalMS?: number;
25
- /** The deployed L1 contract addresses */
26
- l1Contracts: L1ContractAddresses;
27
- /** The max number of logs that can be obtained in 1 "getPublicLogs" call. */
28
- maxLogs?: number;
29
- } & L1ReaderConfig & L1ContractsConfig & BlobSinkConfig & ChainConfig;
30
- export declare const archiverConfigMappings: ConfigMappingsType<ArchiverConfig>;
31
- /**
32
- * Returns the archiver configuration from the environment variables.
33
- * Note: If an environment variable is not set, the default value is used.
34
- * @returns The archiver configuration.
35
- */
36
- export declare function getArchiverConfigFromEnv(): ArchiverConfig;
37
- //# sourceMappingURL=config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/archiver/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,yBAAyB,CAAC;AACrF,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAGpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,kBAAkB,EAA6C,MAAM,0BAA0B,CAAC;AAC9G,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,sBAAsB,CAAC;AAE7E;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,4GAA4G;IAC5G,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,qCAAqC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,kFAAkF;IAClF,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,2CAA2C;IAC3C,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,yCAAyC;IACzC,WAAW,EAAE,mBAAmB,CAAC;IAEjC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,cAAc,GAChB,iBAAiB,GACjB,cAAc,GACd,WAAW,CAAC;AAEd,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,CAAC,cAAc,CAmCrE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,CAEzD"}
@@ -1,46 +0,0 @@
1
- import { blobSinkConfigMapping } from '@aztec/blob-sink/client';
2
- import { l1ContractsConfigMappings, l1ReaderConfigMappings } from '@aztec/ethereum';
3
- import { getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
4
- import { chainConfigMappings } from '@aztec/stdlib/config';
5
- export const archiverConfigMappings = {
6
- ...blobSinkConfigMapping,
7
- archiverUrl: {
8
- env: 'ARCHIVER_URL',
9
- description: 'URL for an archiver service. If set, will return an archiver client as opposed to starting a new one.'
10
- },
11
- l1ConsensusHostUrl: {
12
- env: 'L1_CONSENSUS_HOST_URL',
13
- description: 'URL for an L1 consensus client.',
14
- parseEnv: (val)=>val
15
- },
16
- archiverPollingIntervalMS: {
17
- env: 'ARCHIVER_POLLING_INTERVAL_MS',
18
- description: 'The polling interval in ms for retrieving new L2 blocks and encrypted logs.',
19
- ...numberConfigHelper(500)
20
- },
21
- archiverBatchSize: {
22
- env: 'ARCHIVER_BATCH_SIZE',
23
- description: 'The number of L2 blocks the archiver will attempt to download at a time.',
24
- ...numberConfigHelper(100)
25
- },
26
- maxLogs: {
27
- env: 'ARCHIVER_MAX_LOGS',
28
- description: 'The max number of logs that can be obtained in 1 "getPublicLogs" call.',
29
- ...numberConfigHelper(1_000)
30
- },
31
- ...chainConfigMappings,
32
- ...l1ReaderConfigMappings,
33
- viemPollingIntervalMS: {
34
- env: 'ARCHIVER_VIEM_POLLING_INTERVAL_MS',
35
- description: 'The polling interval viem uses in ms',
36
- ...numberConfigHelper(1000)
37
- },
38
- ...l1ContractsConfigMappings
39
- };
40
- /**
41
- * Returns the archiver configuration from the environment variables.
42
- * Note: If an environment variable is not set, the default value is used.
43
- * @returns The archiver configuration.
44
- */ export function getArchiverConfigFromEnv() {
45
- return getConfigFromMappings(archiverConfigMappings);
46
- }
@@ -1,74 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
4
- import type { ViemPublicClient } from '@aztec/ethereum';
5
- import type { EthAddress } from '@aztec/foundation/eth-address';
6
- import { Fr } from '@aztec/foundation/fields';
7
- import { type Logger } from '@aztec/foundation/log';
8
- import { type InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
9
- import { L2Block } from '@aztec/stdlib/block';
10
- import { InboxLeaf } from '@aztec/stdlib/messaging';
11
- import { Proof } from '@aztec/stdlib/proofs';
12
- import { type GetContractEventsReturnType, type GetContractReturnType, type Hex } from 'viem';
13
- import type { DataRetrieval } from './structs/data_retrieval.js';
14
- import type { L1Published } from './structs/published.js';
15
- /**
16
- * Fetches new L2 blocks.
17
- * @param publicClient - The viem public client to use for transaction retrieval.
18
- * @param rollupAddress - The address of the rollup contract.
19
- * @param searchStartBlock - The block number to use for starting the search.
20
- * @param searchEndBlock - The highest block number that we should search up to.
21
- * @param expectedNextL2BlockNum - The next L2 block number that we expect to find.
22
- * @returns An array of block; as well as the next eth block to search from.
23
- */
24
- export declare function retrieveBlocksFromRollup(rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>, publicClient: ViemPublicClient, blobSinkClient: BlobSinkClientInterface, searchStartBlock: bigint, searchEndBlock: bigint, logger?: Logger): Promise<L1Published<L2Block>[]>;
25
- /**
26
- * Processes newly received L2BlockProposed logs.
27
- * @param rollup - The rollup contract
28
- * @param publicClient - The viem public client to use for transaction retrieval.
29
- * @param logs - L2BlockProposed logs.
30
- * @returns - An array blocks.
31
- */
32
- export declare function processL2BlockProposedLogs(rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>, publicClient: ViemPublicClient, blobSinkClient: BlobSinkClientInterface, logs: GetContractEventsReturnType<typeof RollupAbi, 'L2BlockProposed'>, logger: Logger): Promise<L1Published<L2Block>[]>;
33
- export declare function getL1BlockTime(publicClient: ViemPublicClient, blockNumber: bigint): Promise<bigint>;
34
- /**
35
- * Fetch L1 to L2 messages.
36
- * @param publicClient - The viem public client to use for transaction retrieval.
37
- * @param inboxAddress - The address of the inbox contract to fetch messages from.
38
- * @param blockUntilSynced - If true, blocks until the archiver has fully synced.
39
- * @param searchStartBlock - The block number to use for starting the search.
40
- * @param searchEndBlock - The highest block number that we should search up to.
41
- * @returns An array of InboxLeaf and next eth block to search from.
42
- */
43
- export declare function retrieveL1ToL2Messages(inbox: GetContractReturnType<typeof InboxAbi, ViemPublicClient>, searchStartBlock: bigint, searchEndBlock: bigint): Promise<DataRetrieval<InboxLeaf>>;
44
- /** Retrieves L2ProofVerified events from the rollup contract. */
45
- export declare function retrieveL2ProofVerifiedEvents(publicClient: ViemPublicClient, rollupAddress: EthAddress, searchStartBlock: bigint, searchEndBlock?: bigint): Promise<{
46
- l1BlockNumber: bigint;
47
- l2BlockNumber: bigint;
48
- proverId: Fr;
49
- txHash: Hex;
50
- }[]>;
51
- /** Retrieve submitted proofs from the rollup contract */
52
- export declare function retrieveL2ProofsFromRollup(publicClient: ViemPublicClient, rollupAddress: EthAddress, searchStartBlock: bigint, searchEndBlock?: bigint): Promise<DataRetrieval<{
53
- proof: Proof;
54
- proverId: Fr;
55
- l2BlockNumber: bigint;
56
- txHash: `0x${string}`;
57
- }>>;
58
- export type SubmitBlockProof = {
59
- archiveRoot: Fr;
60
- proverId: Fr;
61
- aggregationObject: Buffer;
62
- proof: Proof;
63
- };
64
- /**
65
- * Gets block metadata (header and archive snapshot) from the calldata of an L1 transaction.
66
- * Assumes that the block was published from an EOA.
67
- * TODO: Add retries and error management.
68
- * @param publicClient - The viem public client to use for transaction retrieval.
69
- * @param txHash - Hash of the tx that published it.
70
- * @param l2BlockNum - L2 block number.
71
- * @returns L2 block metadata (header and archive) from the calldata, deserialized
72
- */
73
- export declare function getProofFromSubmitProofTx(publicClient: ViemPublicClient, txHash: `0x${string}`, expectedProverId: Fr): Promise<SubmitBlockProof>;
74
- //# sourceMappingURL=data_retrieval.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data_retrieval.d.ts","sourceRoot":"","sources":["../../src/archiver/data_retrieval.ts"],"names":[],"mappings":"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"}
@@ -1,283 +0,0 @@
1
- import { Blob, BlobDeserializationError } from '@aztec/blob-lib';
2
- import { asyncPool } from '@aztec/foundation/async-pool';
3
- import { Fr } from '@aztec/foundation/fields';
4
- import { createLogger } from '@aztec/foundation/log';
5
- import { numToUInt32BE } from '@aztec/foundation/serialize';
6
- import { ForwarderAbi, RollupAbi } from '@aztec/l1-artifacts';
7
- import { Body, L2Block } from '@aztec/stdlib/block';
8
- import { InboxLeaf } from '@aztec/stdlib/messaging';
9
- import { Proof } from '@aztec/stdlib/proofs';
10
- import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
11
- import { BlockHeader } from '@aztec/stdlib/tx';
12
- import { decodeFunctionData, getAbiItem, hexToBytes } from 'viem';
13
- import { NoBlobBodiesFoundError } from './errors.js';
14
- /**
15
- * Fetches new L2 blocks.
16
- * @param publicClient - The viem public client to use for transaction retrieval.
17
- * @param rollupAddress - The address of the rollup contract.
18
- * @param searchStartBlock - The block number to use for starting the search.
19
- * @param searchEndBlock - The highest block number that we should search up to.
20
- * @param expectedNextL2BlockNum - The next L2 block number that we expect to find.
21
- * @returns An array of block; as well as the next eth block to search from.
22
- */ export async function retrieveBlocksFromRollup(rollup, publicClient, blobSinkClient, searchStartBlock, searchEndBlock, logger = createLogger('archiver')) {
23
- const retrievedBlocks = [];
24
- do {
25
- if (searchStartBlock > searchEndBlock) {
26
- break;
27
- }
28
- const l2BlockProposedLogs = (await rollup.getEvents.L2BlockProposed({}, {
29
- fromBlock: searchStartBlock,
30
- toBlock: searchEndBlock
31
- })).filter((log)=>log.blockNumber >= searchStartBlock && log.blockNumber <= searchEndBlock);
32
- if (l2BlockProposedLogs.length === 0) {
33
- break;
34
- }
35
- const lastLog = l2BlockProposedLogs[l2BlockProposedLogs.length - 1];
36
- logger.debug(`Got ${l2BlockProposedLogs.length} L2 block processed logs for L2 blocks ${l2BlockProposedLogs[0].args.blockNumber}-${lastLog.args.blockNumber} between L1 blocks ${searchStartBlock}-${searchEndBlock}`);
37
- const newBlocks = await processL2BlockProposedLogs(rollup, publicClient, blobSinkClient, l2BlockProposedLogs, logger);
38
- retrievedBlocks.push(...newBlocks);
39
- searchStartBlock = lastLog.blockNumber + 1n;
40
- }while (searchStartBlock <= searchEndBlock)
41
- // The asyncpool from processL2BlockProposedLogs will not necessarily return the blocks in order, so we sort them before returning.
42
- return retrievedBlocks.sort((a, b)=>Number(a.l1.blockNumber - b.l1.blockNumber));
43
- }
44
- /**
45
- * Processes newly received L2BlockProposed logs.
46
- * @param rollup - The rollup contract
47
- * @param publicClient - The viem public client to use for transaction retrieval.
48
- * @param logs - L2BlockProposed logs.
49
- * @returns - An array blocks.
50
- */ export async function processL2BlockProposedLogs(rollup, publicClient, blobSinkClient, logs, logger) {
51
- const retrievedBlocks = [];
52
- await asyncPool(10, logs, async (log)=>{
53
- const l2BlockNumber = log.args.blockNumber;
54
- const archive = log.args.archive;
55
- const archiveFromChain = await rollup.read.archiveAt([
56
- l2BlockNumber
57
- ]);
58
- const blobHashes = log.args.versionedBlobHashes.map((blobHash)=>Buffer.from(blobHash.slice(2), 'hex'));
59
- // The value from the event and contract will match only if the block is in the chain.
60
- if (archive === archiveFromChain) {
61
- const block = await getBlockFromRollupTx(publicClient, blobSinkClient, log.transactionHash, blobHashes, l2BlockNumber, rollup.address, logger);
62
- const l1 = {
63
- blockNumber: log.blockNumber,
64
- blockHash: log.blockHash,
65
- timestamp: await getL1BlockTime(publicClient, log.blockNumber)
66
- };
67
- retrievedBlocks.push({
68
- data: block,
69
- l1
70
- });
71
- } else {
72
- logger.warn(`Ignoring L2 block ${l2BlockNumber} due to archive root mismatch`, {
73
- actual: archive,
74
- expected: archiveFromChain
75
- });
76
- }
77
- });
78
- return retrievedBlocks;
79
- }
80
- export async function getL1BlockTime(publicClient, blockNumber) {
81
- const block = await publicClient.getBlock({
82
- blockNumber,
83
- includeTransactions: false
84
- });
85
- return block.timestamp;
86
- }
87
- /**
88
- * Extracts the first 'propose' method calldata from a forwarder transaction's data.
89
- * @param forwarderData - The forwarder transaction input data
90
- * @param rollupAddress - The address of the rollup contract
91
- * @returns The calldata for the first 'propose' method call to the rollup contract
92
- */ function extractRollupProposeCalldata(forwarderData, rollupAddress) {
93
- // TODO(#11451): custom forwarders
94
- const { functionName: forwarderFunctionName, args: forwarderArgs } = decodeFunctionData({
95
- abi: ForwarderAbi,
96
- data: forwarderData
97
- });
98
- if (forwarderFunctionName !== 'forward') {
99
- throw new Error(`Unexpected forwarder method called ${forwarderFunctionName}`);
100
- }
101
- if (forwarderArgs.length !== 2) {
102
- throw new Error(`Unexpected number of arguments for forwarder`);
103
- }
104
- const [to, data] = forwarderArgs;
105
- // Find all rollup calls
106
- const rollupAddressLower = rollupAddress.toLowerCase();
107
- for(let i = 0; i < to.length; i++){
108
- const addr = to[i];
109
- if (addr.toLowerCase() !== rollupAddressLower) {
110
- continue;
111
- }
112
- const callData = data[i];
113
- try {
114
- const { functionName: rollupFunctionName } = decodeFunctionData({
115
- abi: RollupAbi,
116
- data: callData
117
- });
118
- if (rollupFunctionName === 'propose') {
119
- return callData;
120
- }
121
- } catch (err) {
122
- continue;
123
- }
124
- }
125
- throw new Error(`Rollup address not found in forwarder args`);
126
- }
127
- /**
128
- * Gets block from the calldata of an L1 transaction.
129
- * Assumes that the block was published from an EOA.
130
- * TODO: Add retries and error management.
131
- * @param publicClient - The viem public client to use for transaction retrieval.
132
- * @param txHash - Hash of the tx that published it.
133
- * @param l2BlockNum - L2 block number.
134
- * @returns L2 block from the calldata, deserialized
135
- */ async function getBlockFromRollupTx(publicClient, blobSinkClient, txHash, blobHashes, l2BlockNum, rollupAddress, logger) {
136
- const { input: forwarderData, blockHash } = await publicClient.getTransaction({
137
- hash: txHash
138
- });
139
- const rollupData = extractRollupProposeCalldata(forwarderData, rollupAddress);
140
- const { functionName: rollupFunctionName, args: rollupArgs } = decodeFunctionData({
141
- abi: RollupAbi,
142
- data: rollupData
143
- });
144
- if (rollupFunctionName !== 'propose') {
145
- throw new Error(`Unexpected rollup method called ${rollupFunctionName}`);
146
- }
147
- const [decodedArgs] = rollupArgs;
148
- const header = BlockHeader.fromBuffer(Buffer.from(hexToBytes(decodedArgs.header)));
149
- const blobBodies = await blobSinkClient.getBlobSidecar(blockHash, blobHashes);
150
- if (blobBodies.length === 0) {
151
- throw new NoBlobBodiesFoundError(Number(l2BlockNum));
152
- }
153
- let blockFields;
154
- try {
155
- blockFields = Blob.toEncodedFields(blobBodies);
156
- } catch (err) {
157
- if (err instanceof BlobDeserializationError) {
158
- logger.fatal(err.message);
159
- } else {
160
- logger.fatal('Unable to sync: failed to decode fetched blob, this blob was likely not created by us');
161
- }
162
- throw err;
163
- }
164
- // The blob source gives us blockFields, and we must construct the body from them:
165
- const blockBody = Body.fromBlobFields(blockFields);
166
- const blockNumberFromHeader = header.globalVariables.blockNumber.toBigInt();
167
- if (blockNumberFromHeader !== l2BlockNum) {
168
- throw new Error(`Block number mismatch: expected ${l2BlockNum} but got ${blockNumberFromHeader}`);
169
- }
170
- const archive = AppendOnlyTreeSnapshot.fromBuffer(Buffer.concat([
171
- Buffer.from(hexToBytes(decodedArgs.archive)),
172
- numToUInt32BE(Number(l2BlockNum + 1n))
173
- ]));
174
- return new L2Block(archive, header, blockBody);
175
- }
176
- /**
177
- * Fetch L1 to L2 messages.
178
- * @param publicClient - The viem public client to use for transaction retrieval.
179
- * @param inboxAddress - The address of the inbox contract to fetch messages from.
180
- * @param blockUntilSynced - If true, blocks until the archiver has fully synced.
181
- * @param searchStartBlock - The block number to use for starting the search.
182
- * @param searchEndBlock - The highest block number that we should search up to.
183
- * @returns An array of InboxLeaf and next eth block to search from.
184
- */ export async function retrieveL1ToL2Messages(inbox, searchStartBlock, searchEndBlock) {
185
- const retrievedL1ToL2Messages = [];
186
- do {
187
- if (searchStartBlock > searchEndBlock) {
188
- break;
189
- }
190
- const messageSentLogs = (await inbox.getEvents.MessageSent({}, {
191
- fromBlock: searchStartBlock,
192
- toBlock: searchEndBlock
193
- })).filter((log)=>log.blockNumber >= searchStartBlock && log.blockNumber <= searchEndBlock);
194
- if (messageSentLogs.length === 0) {
195
- break;
196
- }
197
- for (const log of messageSentLogs){
198
- const { index, hash } = log.args;
199
- retrievedL1ToL2Messages.push(new InboxLeaf(index, Fr.fromHexString(hash)));
200
- }
201
- // handles the case when there are no new messages:
202
- searchStartBlock = (messageSentLogs.findLast((msgLog)=>!!msgLog)?.blockNumber || searchStartBlock) + 1n;
203
- }while (searchStartBlock <= searchEndBlock)
204
- return {
205
- lastProcessedL1BlockNumber: searchStartBlock - 1n,
206
- retrievedData: retrievedL1ToL2Messages
207
- };
208
- }
209
- /** Retrieves L2ProofVerified events from the rollup contract. */ export async function retrieveL2ProofVerifiedEvents(publicClient, rollupAddress, searchStartBlock, searchEndBlock) {
210
- const logs = await publicClient.getLogs({
211
- address: rollupAddress.toString(),
212
- fromBlock: searchStartBlock,
213
- toBlock: searchEndBlock ? searchEndBlock : undefined,
214
- strict: true,
215
- event: getAbiItem({
216
- abi: RollupAbi,
217
- name: 'L2ProofVerified'
218
- })
219
- });
220
- return logs.map((log)=>({
221
- l1BlockNumber: log.blockNumber,
222
- l2BlockNumber: log.args.blockNumber,
223
- proverId: Fr.fromHexString(log.args.proverId),
224
- txHash: log.transactionHash
225
- }));
226
- }
227
- /** Retrieve submitted proofs from the rollup contract */ export async function retrieveL2ProofsFromRollup(publicClient, rollupAddress, searchStartBlock, searchEndBlock) {
228
- const logs = await retrieveL2ProofVerifiedEvents(publicClient, rollupAddress, searchStartBlock, searchEndBlock);
229
- const retrievedData = [];
230
- const lastProcessedL1BlockNumber = logs.length > 0 ? logs.at(-1).l1BlockNumber : searchStartBlock - 1n;
231
- for (const { txHash, proverId, l2BlockNumber } of logs){
232
- const proofData = await getProofFromSubmitProofTx(publicClient, txHash, proverId);
233
- retrievedData.push({
234
- proof: proofData.proof,
235
- proverId: proofData.proverId,
236
- l2BlockNumber,
237
- txHash
238
- });
239
- }
240
- return {
241
- retrievedData,
242
- lastProcessedL1BlockNumber
243
- };
244
- }
245
- /**
246
- * Gets block metadata (header and archive snapshot) from the calldata of an L1 transaction.
247
- * Assumes that the block was published from an EOA.
248
- * TODO: Add retries and error management.
249
- * @param publicClient - The viem public client to use for transaction retrieval.
250
- * @param txHash - Hash of the tx that published it.
251
- * @param l2BlockNum - L2 block number.
252
- * @returns L2 block metadata (header and archive) from the calldata, deserialized
253
- */ export async function getProofFromSubmitProofTx(publicClient, txHash, expectedProverId) {
254
- const { input: data } = await publicClient.getTransaction({
255
- hash: txHash
256
- });
257
- const { functionName, args } = decodeFunctionData({
258
- abi: RollupAbi,
259
- data
260
- });
261
- let proverId;
262
- let archiveRoot;
263
- let aggregationObject;
264
- let proof;
265
- if (functionName === 'submitEpochRootProof') {
266
- const [decodedArgs] = args;
267
- aggregationObject = Buffer.from(hexToBytes(decodedArgs.aggregationObject));
268
- proverId = Fr.fromHexString(decodedArgs.args.proverId);
269
- archiveRoot = Fr.fromHexString(decodedArgs.args.endArchive);
270
- proof = Proof.fromBuffer(Buffer.from(hexToBytes(decodedArgs.proof)));
271
- } else {
272
- throw new Error(`Unexpected proof method called ${functionName}`);
273
- }
274
- if (!proverId.equals(expectedProverId)) {
275
- throw new Error(`Prover ID mismatch: expected ${expectedProverId} but got ${proverId}`);
276
- }
277
- return {
278
- proverId,
279
- aggregationObject,
280
- archiveRoot,
281
- proof
282
- };
283
- }
@@ -1,4 +0,0 @@
1
- export declare class NoBlobBodiesFoundError extends Error {
2
- constructor(l2BlockNum: number);
3
- }
4
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/archiver/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,UAAU,EAAE,MAAM;CAG/B"}
@@ -1,5 +0,0 @@
1
- export class NoBlobBodiesFoundError extends Error {
2
- constructor(l2BlockNum){
3
- super(`No blob bodies found for block ${l2BlockNum}`);
4
- }
5
- }
@@ -1,8 +0,0 @@
1
- export * from './archiver.js';
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';
5
- export type { ArchiverDataStore } from './archiver_store.js';
6
- export { KVArchiverDataStore } from './kv_archiver_store/kv_archiver_store.js';
7
- export { ContractInstanceStore } from './kv_archiver_store/contract_instance_store.js';
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/archiver/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAC;AACvF,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC"}
@@ -1,5 +0,0 @@
1
- export * from './archiver.js';
2
- export * from './config.js';
3
- export { MemoryArchiverStore } from './memory_archiver_store/memory_archiver_store.js';
4
- export { KVArchiverDataStore } from './kv_archiver_store/kv_archiver_store.js';
5
- export { ContractInstanceStore } from './kv_archiver_store/contract_instance_store.js';
@@ -1,29 +0,0 @@
1
- import type { L2Block } from '@aztec/stdlib/block';
2
- import { type LmdbStatsCallback, type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
3
- export declare class ArchiverInstrumentation {
4
- private telemetry;
5
- readonly tracer: Tracer;
6
- private blockHeight;
7
- private txCount;
8
- private syncDuration;
9
- private l1BlocksSynced;
10
- private l1BlockHeight;
11
- private proofsSubmittedDelay;
12
- private proofsSubmittedCount;
13
- private dbMetrics;
14
- private pruneCount;
15
- private log;
16
- private constructor();
17
- static new(telemetry: TelemetryClient, lmdbStats?: LmdbStatsCallback): Promise<ArchiverInstrumentation>;
18
- isEnabled(): boolean;
19
- processNewBlocks(syncTimePerBlock: number, blocks: L2Block[]): void;
20
- processPrune(): void;
21
- updateLastProvenBlock(blockNumber: number): void;
22
- processProofsVerified(logs: {
23
- proverId: string;
24
- l2BlockNumber: bigint;
25
- delay: bigint;
26
- }[]): void;
27
- updateL1BlockHeight(blockNumber: bigint): void;
28
- }
29
- //# sourceMappingURL=instrumentation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/archiver/instrumentation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAKL,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EACpB,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,uBAAuB;IAed,OAAO,CAAC,SAAS;IAdrC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,YAAY,CAAY;IAChC,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,oBAAoB,CAAY;IACxC,OAAO,CAAC,oBAAoB,CAAgB;IAC5C,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,UAAU,CAAgB;IAElC,OAAO,CAAC,GAAG,CAA4C;IAEvD,OAAO;WAsDa,GAAG,CAAC,SAAS,EAAE,eAAe,EAAE,SAAS,CAAC,EAAE,iBAAiB;IAU1E,SAAS,IAAI,OAAO;IAIpB,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;IAS5D,YAAY;IAIZ,qBAAqB,CAAC,WAAW,EAAE,MAAM;IAIzC,qBAAqB,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE;IAaxF,mBAAmB,CAAC,WAAW,EAAE,MAAM;CAG/C"}
@@ -1,99 +0,0 @@
1
- import { createLogger } from '@aztec/foundation/log';
2
- import { Attributes, LmdbMetrics, Metrics, ValueType } from '@aztec/telemetry-client';
3
- export class ArchiverInstrumentation {
4
- telemetry;
5
- tracer;
6
- blockHeight;
7
- txCount;
8
- syncDuration;
9
- l1BlocksSynced;
10
- l1BlockHeight;
11
- proofsSubmittedDelay;
12
- proofsSubmittedCount;
13
- dbMetrics;
14
- pruneCount;
15
- log;
16
- constructor(telemetry, lmdbStats){
17
- this.telemetry = telemetry;
18
- this.log = createLogger('archiver:instrumentation');
19
- this.tracer = telemetry.getTracer('Archiver');
20
- const meter = telemetry.getMeter('Archiver');
21
- this.blockHeight = meter.createGauge(Metrics.ARCHIVER_BLOCK_HEIGHT, {
22
- description: 'The height of the latest block processed by the archiver',
23
- valueType: ValueType.INT
24
- });
25
- this.txCount = meter.createUpDownCounter(Metrics.ARCHIVER_TX_COUNT, {
26
- description: 'The total number of transactions',
27
- valueType: ValueType.INT
28
- });
29
- this.syncDuration = meter.createHistogram(Metrics.ARCHIVER_SYNC_DURATION, {
30
- unit: 'ms',
31
- description: 'Duration to sync a block',
32
- valueType: ValueType.INT
33
- });
34
- this.proofsSubmittedCount = meter.createUpDownCounter(Metrics.ARCHIVER_ROLLUP_PROOF_COUNT, {
35
- description: 'Number of proofs submitted',
36
- valueType: ValueType.INT
37
- });
38
- this.proofsSubmittedDelay = meter.createHistogram(Metrics.ARCHIVER_ROLLUP_PROOF_DELAY, {
39
- unit: 'ms',
40
- description: 'Time after a block is submitted until its proof is published',
41
- valueType: ValueType.INT
42
- });
43
- this.l1BlocksSynced = meter.createUpDownCounter(Metrics.ARCHIVER_L1_BLOCKS_SYNCED, {
44
- description: 'Number of blocks synced from L1',
45
- valueType: ValueType.INT
46
- });
47
- this.l1BlockHeight = meter.createGauge(Metrics.ARCHIVER_L1_BLOCK_HEIGHT, {
48
- description: 'The height of the latest L1 block processed by the archiver',
49
- valueType: ValueType.INT
50
- });
51
- this.dbMetrics = new LmdbMetrics(meter, {
52
- [Attributes.DB_DATA_TYPE]: 'archiver'
53
- }, lmdbStats);
54
- this.pruneCount = meter.createUpDownCounter(Metrics.ARCHIVER_PRUNE_COUNT, {
55
- description: 'Number of prunes detected',
56
- valueType: ValueType.INT
57
- });
58
- }
59
- static async new(telemetry, lmdbStats) {
60
- const instance = new ArchiverInstrumentation(telemetry, lmdbStats);
61
- instance.l1BlocksSynced.add(0);
62
- await instance.telemetry.flush();
63
- return instance;
64
- }
65
- isEnabled() {
66
- return this.telemetry.isEnabled();
67
- }
68
- processNewBlocks(syncTimePerBlock, blocks) {
69
- this.syncDuration.record(Math.ceil(syncTimePerBlock));
70
- this.blockHeight.record(Math.max(...blocks.map((b)=>b.number)));
71
- this.l1BlocksSynced.add(blocks.length);
72
- for (const block of blocks){
73
- this.txCount.add(block.body.txEffects.length);
74
- }
75
- }
76
- processPrune() {
77
- this.pruneCount.add(1);
78
- }
79
- updateLastProvenBlock(blockNumber) {
80
- this.blockHeight.record(blockNumber, {
81
- [Attributes.STATUS]: 'proven'
82
- });
83
- }
84
- processProofsVerified(logs) {
85
- for (const log of logs){
86
- this.log.debug('Recording proof verified event', log);
87
- this.proofsSubmittedCount.add(1, {
88
- [Attributes.ROLLUP_PROVER_ID]: log.proverId,
89
- [Attributes.PROOF_TIMED_OUT]: log.delay > 20n * 60n * 1000n
90
- });
91
- this.proofsSubmittedDelay.record(Math.ceil(Number(log.delay)), {
92
- [Attributes.ROLLUP_PROVER_ID]: log.proverId
93
- });
94
- }
95
- }
96
- updateL1BlockHeight(blockNumber) {
97
- this.l1BlockHeight.record(Number(blockNumber));
98
- }
99
- }