@aztec/archiver 0.0.1-commit.b655e406 → 0.0.1-commit.b9865e97

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 (241) hide show
  1. package/README.md +164 -22
  2. package/dest/archiver.d.ts +176 -0
  3. package/dest/archiver.d.ts.map +1 -0
  4. package/dest/archiver.js +905 -0
  5. package/dest/config.d.ts +33 -0
  6. package/dest/config.d.ts.map +1 -0
  7. package/dest/config.js +78 -0
  8. package/dest/errors.d.ts +87 -0
  9. package/dest/errors.d.ts.map +1 -0
  10. package/dest/errors.js +129 -0
  11. package/dest/factory.d.ts +17 -10
  12. package/dest/factory.d.ts.map +1 -1
  13. package/dest/factory.js +117 -22
  14. package/dest/index.d.ts +19 -4
  15. package/dest/index.d.ts.map +1 -1
  16. package/dest/index.js +17 -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 +152 -0
  23. package/dest/l1/calldata_retriever.d.ts +136 -0
  24. package/dest/l1/calldata_retriever.d.ts.map +1 -0
  25. package/dest/l1/calldata_retriever.js +412 -0
  26. package/dest/l1/data_retrieval.d.ts +97 -0
  27. package/dest/l1/data_retrieval.d.ts.map +1 -0
  28. package/dest/l1/data_retrieval.js +307 -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 +149 -0
  35. package/dest/l1/trace_tx.d.ts +43 -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_historical_logs.d.ts +23 -0
  42. package/dest/l1/validate_historical_logs.d.ts.map +1 -0
  43. package/dest/l1/validate_historical_logs.js +108 -0
  44. package/dest/l1/validate_trace.d.ts +32 -0
  45. package/dest/l1/validate_trace.d.ts.map +1 -0
  46. package/dest/l1/validate_trace.js +154 -0
  47. package/dest/modules/contract_data_source_adapter.d.ts +25 -0
  48. package/dest/modules/contract_data_source_adapter.d.ts.map +1 -0
  49. package/dest/modules/contract_data_source_adapter.js +40 -0
  50. package/dest/modules/data_source_base.d.ts +113 -0
  51. package/dest/modules/data_source_base.d.ts.map +1 -0
  52. package/dest/modules/data_source_base.js +348 -0
  53. package/dest/modules/data_store_updater.d.ts +105 -0
  54. package/dest/modules/data_store_updater.d.ts.map +1 -0
  55. package/dest/modules/data_store_updater.js +392 -0
  56. package/dest/modules/instrumentation.d.ts +55 -0
  57. package/dest/modules/instrumentation.d.ts.map +1 -0
  58. package/dest/modules/instrumentation.js +145 -0
  59. package/dest/modules/l1_synchronizer.d.ts +77 -0
  60. package/dest/modules/l1_synchronizer.d.ts.map +1 -0
  61. package/dest/modules/l1_synchronizer.js +1344 -0
  62. package/dest/modules/outbox_trees_resolver.d.ts +62 -0
  63. package/dest/modules/outbox_trees_resolver.d.ts.map +1 -0
  64. package/dest/modules/outbox_trees_resolver.js +162 -0
  65. package/dest/modules/validation.d.ts +18 -0
  66. package/dest/modules/validation.d.ts.map +1 -0
  67. package/dest/modules/validation.js +104 -0
  68. package/dest/store/block_store.d.ts +294 -0
  69. package/dest/store/block_store.d.ts.map +1 -0
  70. package/dest/store/block_store.js +1188 -0
  71. package/dest/store/contract_class_store.d.ts +31 -0
  72. package/dest/store/contract_class_store.d.ts.map +1 -0
  73. package/dest/store/contract_class_store.js +80 -0
  74. package/dest/store/contract_instance_store.d.ts +51 -0
  75. package/dest/store/contract_instance_store.d.ts.map +1 -0
  76. package/dest/{archiver/kv_archiver_store → store}/contract_instance_store.js +38 -3
  77. package/dest/store/data_stores.d.ts +68 -0
  78. package/dest/store/data_stores.d.ts.map +1 -0
  79. package/dest/store/data_stores.js +54 -0
  80. package/dest/store/function_names_cache.d.ts +17 -0
  81. package/dest/store/function_names_cache.d.ts.map +1 -0
  82. package/dest/store/function_names_cache.js +30 -0
  83. package/dest/store/l2_tips_cache.d.ts +25 -0
  84. package/dest/store/l2_tips_cache.d.ts.map +1 -0
  85. package/dest/store/l2_tips_cache.js +26 -0
  86. package/dest/store/log_store.d.ts +59 -0
  87. package/dest/store/log_store.d.ts.map +1 -0
  88. package/dest/store/log_store.js +310 -0
  89. package/dest/store/log_store_codec.d.ts +70 -0
  90. package/dest/store/log_store_codec.d.ts.map +1 -0
  91. package/dest/store/log_store_codec.js +101 -0
  92. package/dest/store/message_store.d.ts +50 -0
  93. package/dest/store/message_store.d.ts.map +1 -0
  94. package/dest/{archiver/kv_archiver_store → store}/message_store.js +66 -23
  95. package/dest/structs/data_retrieval.d.ts +27 -0
  96. package/dest/structs/data_retrieval.d.ts.map +1 -0
  97. package/dest/structs/inbox_message.d.ts +15 -0
  98. package/dest/structs/inbox_message.d.ts.map +1 -0
  99. package/dest/{archiver/structs → structs}/inbox_message.js +6 -5
  100. package/dest/structs/published.d.ts +2 -0
  101. package/dest/structs/published.d.ts.map +1 -0
  102. package/dest/test/fake_l1_state.d.ts +214 -0
  103. package/dest/test/fake_l1_state.d.ts.map +1 -0
  104. package/dest/test/fake_l1_state.js +517 -0
  105. package/dest/test/index.d.ts +2 -1
  106. package/dest/test/index.d.ts.map +1 -1
  107. package/dest/test/index.js +4 -1
  108. package/dest/test/mock_archiver.d.ts +16 -8
  109. package/dest/test/mock_archiver.d.ts.map +1 -1
  110. package/dest/test/mock_archiver.js +19 -14
  111. package/dest/test/mock_l1_to_l2_message_source.d.ts +7 -6
  112. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
  113. package/dest/test/mock_l1_to_l2_message_source.js +23 -12
  114. package/dest/test/mock_l2_block_source.d.ts +76 -40
  115. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  116. package/dest/test/mock_l2_block_source.js +362 -133
  117. package/dest/test/mock_structs.d.ts +83 -4
  118. package/dest/test/mock_structs.d.ts.map +1 -1
  119. package/dest/test/mock_structs.js +157 -11
  120. package/dest/test/noop_l1_archiver.d.ts +30 -0
  121. package/dest/test/noop_l1_archiver.d.ts.map +1 -0
  122. package/dest/test/noop_l1_archiver.js +85 -0
  123. package/package.json +20 -20
  124. package/src/archiver.ts +719 -0
  125. package/src/config.ts +108 -0
  126. package/src/errors.ts +203 -0
  127. package/src/factory.ts +179 -23
  128. package/src/index.ts +27 -3
  129. package/src/interfaces.ts +9 -0
  130. package/src/l1/README.md +55 -0
  131. package/src/l1/bin/retrieve-calldata.ts +194 -0
  132. package/src/l1/calldata_retriever.ts +522 -0
  133. package/src/l1/data_retrieval.ts +484 -0
  134. package/src/l1/debug_tx.ts +99 -0
  135. package/src/l1/spire_proposer.ts +152 -0
  136. package/src/l1/trace_tx.ts +128 -0
  137. package/src/l1/types.ts +13 -0
  138. package/src/l1/validate_historical_logs.ts +140 -0
  139. package/src/l1/validate_trace.ts +229 -0
  140. package/src/modules/contract_data_source_adapter.ts +55 -0
  141. package/src/modules/data_source_base.ts +495 -0
  142. package/src/modules/data_store_updater.ts +518 -0
  143. package/src/modules/instrumentation.ts +204 -0
  144. package/src/modules/l1_synchronizer.ts +1257 -0
  145. package/src/modules/outbox_trees_resolver.ts +199 -0
  146. package/src/modules/validation.ts +130 -0
  147. package/src/store/block_store.ts +1540 -0
  148. package/src/store/contract_class_store.ts +108 -0
  149. package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +53 -7
  150. package/src/store/data_stores.ts +104 -0
  151. package/src/store/function_names_cache.ts +37 -0
  152. package/src/store/l2_tips_cache.ts +35 -0
  153. package/src/store/log_store.ts +379 -0
  154. package/src/store/log_store_codec.ts +132 -0
  155. package/src/{archiver/kv_archiver_store → store}/message_store.ts +81 -28
  156. package/src/{archiver/structs → structs}/inbox_message.ts +7 -7
  157. package/src/structs/published.ts +1 -0
  158. package/src/test/fake_l1_state.ts +770 -0
  159. package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
  160. package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
  161. package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
  162. package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
  163. package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
  164. package/src/test/fixtures/trace_transaction-proxied.json +128 -0
  165. package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
  166. package/src/test/index.ts +4 -0
  167. package/src/test/mock_archiver.ts +23 -16
  168. package/src/test/mock_l1_to_l2_message_source.ts +19 -11
  169. package/src/test/mock_l2_block_source.ts +431 -145
  170. package/src/test/mock_structs.ts +289 -13
  171. package/src/test/noop_l1_archiver.ts +148 -0
  172. package/dest/archiver/archiver.d.ts +0 -277
  173. package/dest/archiver/archiver.d.ts.map +0 -1
  174. package/dest/archiver/archiver.js +0 -1322
  175. package/dest/archiver/archiver_store.d.ts +0 -255
  176. package/dest/archiver/archiver_store.d.ts.map +0 -1
  177. package/dest/archiver/archiver_store.js +0 -4
  178. package/dest/archiver/archiver_store_test_suite.d.ts +0 -8
  179. package/dest/archiver/archiver_store_test_suite.d.ts.map +0 -1
  180. package/dest/archiver/archiver_store_test_suite.js +0 -1288
  181. package/dest/archiver/config.d.ts +0 -21
  182. package/dest/archiver/config.d.ts.map +0 -1
  183. package/dest/archiver/config.js +0 -50
  184. package/dest/archiver/data_retrieval.d.ts +0 -79
  185. package/dest/archiver/data_retrieval.d.ts.map +0 -1
  186. package/dest/archiver/data_retrieval.js +0 -362
  187. package/dest/archiver/errors.d.ts +0 -12
  188. package/dest/archiver/errors.d.ts.map +0 -1
  189. package/dest/archiver/errors.js +0 -17
  190. package/dest/archiver/index.d.ts +0 -7
  191. package/dest/archiver/index.d.ts.map +0 -1
  192. package/dest/archiver/index.js +0 -4
  193. package/dest/archiver/instrumentation.d.ts +0 -35
  194. package/dest/archiver/instrumentation.d.ts.map +0 -1
  195. package/dest/archiver/instrumentation.js +0 -140
  196. package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -124
  197. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
  198. package/dest/archiver/kv_archiver_store/block_store.js +0 -370
  199. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +0 -18
  200. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +0 -1
  201. package/dest/archiver/kv_archiver_store/contract_class_store.js +0 -120
  202. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -24
  203. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
  204. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -168
  205. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +0 -1
  206. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +0 -296
  207. package/dest/archiver/kv_archiver_store/log_store.d.ts +0 -49
  208. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
  209. package/dest/archiver/kv_archiver_store/log_store.js +0 -336
  210. package/dest/archiver/kv_archiver_store/message_store.d.ts +0 -39
  211. package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
  212. package/dest/archiver/structs/data_retrieval.d.ts +0 -27
  213. package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
  214. package/dest/archiver/structs/inbox_message.d.ts +0 -15
  215. package/dest/archiver/structs/inbox_message.d.ts.map +0 -1
  216. package/dest/archiver/structs/published.d.ts +0 -2
  217. package/dest/archiver/structs/published.d.ts.map +0 -1
  218. package/dest/archiver/validation.d.ts +0 -11
  219. package/dest/archiver/validation.d.ts.map +0 -1
  220. package/dest/archiver/validation.js +0 -90
  221. package/dest/rpc/index.d.ts +0 -9
  222. package/dest/rpc/index.d.ts.map +0 -1
  223. package/dest/rpc/index.js +0 -15
  224. package/src/archiver/archiver.ts +0 -1722
  225. package/src/archiver/archiver_store.ts +0 -305
  226. package/src/archiver/archiver_store_test_suite.ts +0 -1263
  227. package/src/archiver/config.ts +0 -74
  228. package/src/archiver/data_retrieval.ts +0 -545
  229. package/src/archiver/errors.ts +0 -26
  230. package/src/archiver/index.ts +0 -6
  231. package/src/archiver/instrumentation.ts +0 -187
  232. package/src/archiver/kv_archiver_store/block_store.ts +0 -481
  233. package/src/archiver/kv_archiver_store/contract_class_store.ts +0 -176
  234. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -422
  235. package/src/archiver/kv_archiver_store/log_store.ts +0 -406
  236. package/src/archiver/structs/published.ts +0 -1
  237. package/src/archiver/validation.ts +0 -99
  238. package/src/rpc/index.ts +0 -16
  239. /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
  240. /package/dest/{archiver/structs → structs}/published.js +0 -0
  241. /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
@@ -0,0 +1,43 @@
1
+ import type { ViemPublicDebugClient } from '@aztec/ethereum/types';
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
3
+ import type { Logger } from '@aztec/foundation/log';
4
+ import { type ZodFor } from '@aztec/foundation/schemas';
5
+ import type { Hex } from 'viem';
6
+ import { z } from 'zod';
7
+ import type { CallInfo } from './types.js';
8
+ /** Zod schema for a single trace from trace_transaction */
9
+ export declare const traceSchema: z.ZodObject<{
10
+ action: z.ZodObject<{
11
+ from: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
12
+ to: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
13
+ callType: z.ZodString;
14
+ gas: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
15
+ input: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
16
+ value: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
17
+ }, z.core.$strip>;
18
+ result: z.ZodOptional<z.ZodObject<{
19
+ gasUsed: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
20
+ output: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
21
+ }, z.core.$strip>>;
22
+ error: z.ZodOptional<z.ZodString>;
23
+ subtraces: z.ZodNumber;
24
+ traceAddress: z.ZodArray<z.ZodNumber>;
25
+ type: z.ZodString;
26
+ }, z.core.$strip>;
27
+ /** Type for trace_transaction response */
28
+ type TraceTransaction = z.infer<typeof traceSchema>;
29
+ /** Zod schema for the full trace_transaction response (array of traces) */
30
+ export declare const traceTransactionResponseSchema: ZodFor<TraceTransaction[]>;
31
+ /**
32
+ * Traces a transaction and extracts all CALL operations to a specific contract and function selector.
33
+ * Uses the trace_transaction RPC method which returns a flat array of traces.
34
+ *
35
+ * @param client - The Viem public debug client
36
+ * @param txHash - The transaction hash to trace
37
+ * @param targetAddress - The contract address to filter for
38
+ * @param functionSelector - The 4-byte function selector to filter for (with or without 0x prefix)
39
+ * @returns Array of CallInfo objects containing from, gasUsed, input, and value for matching calls
40
+ */
41
+ export declare function getSuccessfulCallsFromTrace(client: ViemPublicDebugClient, txHash: Hex, targetAddress: EthAddress, functionSelector: string, logger?: Logger): Promise<CallInfo[]>;
42
+ export {};
43
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhY2VfdHguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sMS90cmFjZV90eC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxxQkFBcUIsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25FLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwrQk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;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,2BAA2B,CAAC;AAGjE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAkB3C,2DAA2D;AAC3D,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;iBAOtB,CAAC;AAEH,0CAA0C;AAC1C,KAAK,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEpD,2EAA2E;AAC3E,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAwB,CAAC;AAE/F;;;;;;;;;GASG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,GAAG,EACX,aAAa,EAAE,UAAU,EACzB,gBAAgB,EAAE,MAAM,EACxB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,QAAQ,EAAE,CAAC,CAoErB"}
@@ -0,0 +1,91 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import { schemas } from '@aztec/foundation/schemas';
3
+ import { withHexPrefix } from '@aztec/foundation/string';
4
+ import { z } from 'zod';
5
+ /** Zod schema for trace action from trace_transaction */ const traceActionSchema = z.object({
6
+ from: schemas.HexStringWith0x,
7
+ to: schemas.HexStringWith0x.optional(),
8
+ callType: z.string(),
9
+ gas: schemas.HexStringWith0x.optional(),
10
+ input: schemas.HexStringWith0x.optional(),
11
+ value: schemas.HexStringWith0x.optional()
12
+ });
13
+ /** Zod schema for trace result from trace_transaction */ const traceResultSchema = z.object({
14
+ gasUsed: schemas.HexStringWith0x.optional(),
15
+ output: schemas.HexStringWith0x.optional()
16
+ });
17
+ /** Zod schema for a single trace from trace_transaction */ export const traceSchema = z.object({
18
+ action: traceActionSchema,
19
+ result: traceResultSchema.optional(),
20
+ error: z.string().optional(),
21
+ subtraces: z.number(),
22
+ traceAddress: z.array(z.number()),
23
+ type: z.string()
24
+ });
25
+ /** Zod schema for the full trace_transaction response (array of traces) */ export const traceTransactionResponseSchema = z.array(traceSchema);
26
+ /**
27
+ * Traces a transaction and extracts all CALL operations to a specific contract and function selector.
28
+ * Uses the trace_transaction RPC method which returns a flat array of traces.
29
+ *
30
+ * @param client - The Viem public debug client
31
+ * @param txHash - The transaction hash to trace
32
+ * @param targetAddress - The contract address to filter for
33
+ * @param functionSelector - The 4-byte function selector to filter for (with or without 0x prefix)
34
+ * @returns Array of CallInfo objects containing from, gasUsed, input, and value for matching calls
35
+ */ export async function getSuccessfulCallsFromTrace(client, txHash, targetAddress, functionSelector, logger) {
36
+ // Normalize inputs for comparison
37
+ const normalizedTarget = targetAddress.toString().toLowerCase();
38
+ const normalizedSelector = withHexPrefix(functionSelector.toLowerCase());
39
+ // Call trace_transaction (no options needed)
40
+ const rawTrace = await client.request({
41
+ method: 'trace_transaction',
42
+ params: [
43
+ txHash
44
+ ]
45
+ });
46
+ if (rawTrace === null || rawTrace === undefined) {
47
+ throw new Error(`Failed to retrieve trace_transaction for ${txHash}`);
48
+ }
49
+ logger?.trace(`Retrieved trace_transaction for ${txHash}`, {
50
+ trace: rawTrace
51
+ });
52
+ // Validate the response with zod
53
+ const traces = traceTransactionResponseSchema.parse(rawTrace);
54
+ const results = [];
55
+ // Build a set of trace addresses that errored - we should skip their descendants
56
+ // A trace address is the path in the trace tree, represented as an array of indices
57
+ const erroredTraceAddresses = new Set();
58
+ for (const trace of traces){
59
+ if (trace.error) {
60
+ erroredTraceAddresses.add(JSON.stringify(trace.traceAddress));
61
+ }
62
+ }
63
+ // Helper to check if a trace is a descendant of an errored trace
64
+ function isDescendantOfError(traceAddress) {
65
+ // Check all possible ancestor paths
66
+ for(let i = 1; i < traceAddress.length; i++){
67
+ const ancestorAddress = traceAddress.slice(0, i);
68
+ if (erroredTraceAddresses.has(JSON.stringify(ancestorAddress))) {
69
+ return true;
70
+ }
71
+ }
72
+ return false;
73
+ }
74
+ // Process each trace
75
+ for (const trace of traces){
76
+ // Skip if this has an error or is a descendant of an errored trace
77
+ if (trace.error || isDescendantOfError(trace.traceAddress)) {
78
+ continue;
79
+ }
80
+ // Check if this is a CALL type trace to the target address with matching selector and result
81
+ if (trace.type === 'call' && trace.action.callType.toLowerCase() === 'call' && trace.action.to?.toLowerCase() === normalizedTarget && trace.action.input?.toLowerCase().startsWith(normalizedSelector) && trace.result) {
82
+ results.push({
83
+ from: EthAddress.fromString(trace.action.from),
84
+ gasUsed: trace.result.gasUsed === undefined ? undefined : BigInt(trace.result.gasUsed),
85
+ input: trace.action.input,
86
+ value: trace.action.value ? BigInt(trace.action.value) : 0n
87
+ });
88
+ }
89
+ }
90
+ return results;
91
+ }
@@ -0,0 +1,12 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import type { Hex } from 'viem';
3
+ /**
4
+ * Information about a matching CALL
5
+ */
6
+ export interface CallInfo {
7
+ from: EthAddress;
8
+ gasUsed?: bigint;
9
+ input: Hex;
10
+ value: bigint;
11
+ }
12
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sMS90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFFM0QsT0FBTyxLQUFLLEVBQUUsR0FBRyxFQUFFLE1BQU0sTUFBTSxDQUFDO0FBRWhDOztHQUVHO0FBQ0gsTUFBTSxXQUFXLFFBQVE7SUFDdkIsSUFBSSxFQUFFLFVBQVUsQ0FBQztJQUNqQixPQUFPLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDakIsS0FBSyxFQUFFLEdBQUcsQ0FBQztJQUNYLEtBQUssRUFBRSxNQUFNLENBQUM7Q0FDZiJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/l1/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,3 @@
1
+ /**
2
+ * Information about a matching CALL
3
+ */ export { };
@@ -0,0 +1,23 @@
1
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
2
+ import type { ViemPublicClient } from '@aztec/ethereum/types';
3
+ import { type LoggerBindings } from '@aztec/foundation/log';
4
+ /** Subset of L1 contract addresses whose historical logs the Aztec node relies on. */
5
+ export type HistoricalLogsContractAddresses = Pick<L1ContractAddresses, 'rollupAddress' | 'inboxAddress' | 'registryAddress' | 'governanceProposerAddress'>;
6
+ /**
7
+ * Validates that every configured L1 RPC URL returns historical logs for the Rollup contract.
8
+ *
9
+ * Some RPC providers prune old logs, which would cause L1 syncing to silently fail. To detect this,
10
+ * we query for the `OwnershipTransferred` event which every Rollup emits in its constructor (via
11
+ * Ownable) on the block it was deployed (`l1StartBlock`). The `client` is typically a viem fallback
12
+ * transport over several user-configured RPC URLs — checking only the first URL would miss a bad
13
+ * secondary, so we probe each URL independently. The first URL that fails aborts startup, unless
14
+ * the operator has explicitly opted out.
15
+ *
16
+ * @param client - The L1 public client built from the user-configured RPC URLs.
17
+ * @param addresses - The subset of L1 contract addresses we rely on for historical log retrieval.
18
+ * @param skipCheck - If true, log warnings instead of throwing.
19
+ * @param bindings - Optional logger bindings for context.
20
+ * @throws Error if any URL fails the probe and skipCheck is false.
21
+ */
22
+ export declare function validateAndLogHistoricalLogsAvailability(client: ViemPublicClient, addresses: HistoricalLogsContractAddresses, skipCheck: boolean, bindings?: LoggerBindings): Promise<void>;
23
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGVfaGlzdG9yaWNhbF9sb2dzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbDEvdmFsaWRhdGVfaGlzdG9yaWNhbF9sb2dzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sdUNBQXVDLENBQUM7QUFDakYsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUM5RCxPQUFPLEVBQWUsS0FBSyxjQUFjLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFFdkYsc0ZBQXNGO0FBQ3RGLE1BQU0sTUFBTSwrQkFBK0IsR0FBRyxJQUFJLENBQ2hELG1CQUFtQixFQUNuQixlQUFlLEdBQUcsY0FBYyxHQUFHLGlCQUFpQixHQUFHLDJCQUEyQixDQUNuRixDQUFDO0FBS0Y7Ozs7Ozs7Ozs7Ozs7OztHQWVHO0FBQ0gsd0JBQXNCLHdDQUF3QyxDQUM1RCxNQUFNLEVBQUUsZ0JBQWdCLEVBQ3hCLFNBQVMsRUFBRSwrQkFBK0IsRUFDMUMsU0FBUyxFQUFFLE9BQU8sRUFDbEIsUUFBUSxDQUFDLEVBQUUsY0FBYyxHQUN4QixPQUFPLENBQUMsSUFBSSxDQUFDLENBbUNmIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate_historical_logs.d.ts","sourceRoot":"","sources":["../../src/l1/validate_historical_logs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAEvF,sFAAsF;AACtF,MAAM,MAAM,+BAA+B,GAAG,IAAI,CAChD,mBAAmB,EACnB,eAAe,GAAG,cAAc,GAAG,iBAAiB,GAAG,2BAA2B,CACnF,CAAC;AAKF;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,wCAAwC,CAC5D,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,+BAA+B,EAC1C,SAAS,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,IAAI,CAAC,CAmCf"}
@@ -0,0 +1,108 @@
1
+ import { getPublicClient, getRpcUrlsFromClient } from '@aztec/ethereum/client';
2
+ import { RollupContract } from '@aztec/ethereum/contracts';
3
+ import { createLogger } from '@aztec/foundation/log';
4
+ /**
5
+ * Validates that every configured L1 RPC URL returns historical logs for the Rollup contract.
6
+ *
7
+ * Some RPC providers prune old logs, which would cause L1 syncing to silently fail. To detect this,
8
+ * we query for the `OwnershipTransferred` event which every Rollup emits in its constructor (via
9
+ * Ownable) on the block it was deployed (`l1StartBlock`). The `client` is typically a viem fallback
10
+ * transport over several user-configured RPC URLs — checking only the first URL would miss a bad
11
+ * secondary, so we probe each URL independently. The first URL that fails aborts startup, unless
12
+ * the operator has explicitly opted out.
13
+ *
14
+ * @param client - The L1 public client built from the user-configured RPC URLs.
15
+ * @param addresses - The subset of L1 contract addresses we rely on for historical log retrieval.
16
+ * @param skipCheck - If true, log warnings instead of throwing.
17
+ * @param bindings - Optional logger bindings for context.
18
+ * @throws Error if any URL fails the probe and skipCheck is false.
19
+ */ export async function validateAndLogHistoricalLogsAvailability(client, addresses, skipCheck, bindings) {
20
+ const logger = createLogger('archiver:validate_historical_logs', bindings);
21
+ logger.debug('Validating historical log availability on L1 RPCs');
22
+ const urls = getRpcUrlsFromClient(client);
23
+ if (urls.length === 0) {
24
+ logger.warn('Could not determine L1 RPC URLs from the public client; skipping historical logs check.');
25
+ return;
26
+ }
27
+ const chainId = client.chain?.id;
28
+ if (chainId === undefined) {
29
+ logger.warn('Could not determine L1 chain ID from the public client; skipping historical logs check.');
30
+ return;
31
+ }
32
+ for (const url of urls){
33
+ const probeClient = getPublicClient({
34
+ l1RpcUrls: [
35
+ url
36
+ ],
37
+ l1ChainId: chainId
38
+ });
39
+ const rollup = new RollupContract(probeClient, addresses.rollupAddress.toString());
40
+ const result = await probeRpcUrl(rollup, probeClient, logger);
41
+ if (result.ok) {
42
+ logger.debug(`L1 RPC ${url} returned historical OwnershipTransferred log for the Rollup contract.`);
43
+ continue;
44
+ }
45
+ const errorMessage = buildErrorMessage(url, result, addresses);
46
+ if (skipCheck) {
47
+ logger.warn(`${errorMessage}\nContinuing because ARCHIVER_SKIP_HISTORICAL_LOGS_CHECK is true.`);
48
+ continue;
49
+ }
50
+ logger.error(errorMessage);
51
+ throw new Error(errorMessage);
52
+ }
53
+ }
54
+ /** Runs the OwnershipTransferred probe against a single RPC and queries its client version. */ async function probeRpcUrl(rollup, client, logger) {
55
+ let queryError;
56
+ try {
57
+ const logs = await rollup.getOwnershipTransferredEventsAtDeploy();
58
+ if (logs.length > 0) {
59
+ return {
60
+ ok: true
61
+ };
62
+ }
63
+ } catch (err) {
64
+ queryError = err;
65
+ }
66
+ const clientVersion = await getClientVersion(client, logger);
67
+ let reason;
68
+ if (queryError instanceof Error) {
69
+ reason = `Query for historical logs failed: ${queryError.message}`;
70
+ } else if (queryError !== undefined) {
71
+ reason = 'Query for historical logs failed with a non-Error value.';
72
+ } else {
73
+ reason = 'No OwnershipTransferred event was returned by the L1 RPC for the Rollup deploy block.';
74
+ }
75
+ return {
76
+ ok: false,
77
+ reason,
78
+ clientVersion
79
+ };
80
+ }
81
+ /** Builds the operator-facing error message for a failing RPC URL. */ function buildErrorMessage(url, result, addresses) {
82
+ return [
83
+ `L1 RPC at ${url} does not return historical logs for the Rollup contract. ${result.reason}`,
84
+ `This likely means this Ethereum RPC node prunes old logs, which would cause the archiver ` + `to silently miss data during L1 sync.`,
85
+ result.clientVersion ? `Detected L1 client version for ${url}: ${result.clientVersion}.` : `Could not determine L1 client version for ${url}.`,
86
+ `The following L1 contract addresses must have their historical logs retained by the RPC node:`,
87
+ ` - Rollup: ${addresses.rollupAddress.toString()}`,
88
+ ` - Inbox: ${addresses.inboxAddress.toString()}`,
89
+ ` - Registry: ${addresses.registryAddress.toString()}`,
90
+ ` - GovernanceProposer: ${addresses.governanceProposerAddress.toString()}`,
91
+ isReth(result.clientVersion) ? `To retain logs for these contracts, configure reth with a ` + `prune.segments.receipts_log_filter entry for each address above ` + `so reth does not prune their receipts/logs. See https://reth.rs/run/pruning.html for details.` : `Point this RPC endpoint at a node that retains full log history for the addresses above.`,
92
+ `Set ARCHIVER_SKIP_HISTORICAL_LOGS_CHECK=true to bypass this check at your own risk.`
93
+ ].join('\n');
94
+ }
95
+ /** Queries `web3_clientVersion` on the L1 RPC. Returns undefined if the call fails or returns a non-string. */ async function getClientVersion(client, logger) {
96
+ try {
97
+ const result = await client.request({
98
+ method: 'web3_clientVersion'
99
+ });
100
+ return typeof result === 'string' ? result : undefined;
101
+ } catch (err) {
102
+ logger.debug(`Failed to query web3_clientVersion: ${err instanceof Error ? err.message : err}`);
103
+ return undefined;
104
+ }
105
+ }
106
+ /** Heuristic check for reth based on the web3_clientVersion string (reth returns e.g. "reth/v1.0.0-..."). */ function isReth(clientVersion) {
107
+ return !!clientVersion && /reth/i.test(clientVersion);
108
+ }
@@ -0,0 +1,32 @@
1
+ import type { ViemPublicDebugClient } from '@aztec/ethereum/types';
2
+ import { type LoggerBindings } from '@aztec/foundation/log';
3
+ /** Result of trace availability checks */
4
+ export interface TraceAvailability {
5
+ /** Whether debug_traceTransaction works for recent blocks */
6
+ debugTraceRecent: boolean;
7
+ /** Whether trace_transaction works for recent blocks */
8
+ traceTransactionRecent: boolean;
9
+ /** Whether debug_traceTransaction works for old blocks (512 blocks ago) */
10
+ debugTraceOld: boolean;
11
+ /** Whether trace_transaction works for old blocks (512 blocks ago) */
12
+ traceTransactionOld: boolean;
13
+ }
14
+ /**
15
+ * Validates the availability of debug/trace methods on the Ethereum client.
16
+ *
17
+ * @param client - The Viem public debug client
18
+ * @param bindings - Optional logger bindings for context
19
+ * @returns Object indicating which trace methods are available for recent and old blocks
20
+ */
21
+ export declare function validateTraceAvailability(client: ViemPublicDebugClient, bindings?: LoggerBindings): Promise<TraceAvailability>;
22
+ /**
23
+ * Validates trace availability and logs appropriate messages based on the results.
24
+ * Optionally throws an error if no trace methods are available and ethereumAllowNoDebugHosts is false.
25
+ *
26
+ * @param client - The Viem public debug client
27
+ * @param ethereumAllowNoDebugHosts - If false, throws an error when no trace methods are available
28
+ * @param bindings - Optional logger bindings for context
29
+ * @throws Error if ethereumAllowNoDebugHosts is false and no trace methods are available
30
+ */
31
+ export declare function validateAndLogTraceAvailability(client: ViemPublicDebugClient, ethereumAllowNoDebugHosts: boolean, bindings?: LoggerBindings): Promise<void>;
32
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGVfdHJhY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sMS92YWxpZGF0ZV90cmFjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxxQkFBcUIsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25FLE9BQU8sRUFBZSxLQUFLLGNBQWMsRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQTRDdkYsMENBQTBDO0FBQzFDLE1BQU0sV0FBVyxpQkFBaUI7SUFDaEMsNkRBQTZEO0lBQzdELGdCQUFnQixFQUFFLE9BQU8sQ0FBQztJQUMx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ACH,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,qBAAqB,EAC7B,yBAAyB,EAAE,OAAO,EAClC,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,IAAI,CAAC,CA6Cf"}
@@ -0,0 +1,154 @@
1
+ import { createLogger } from '@aztec/foundation/log';
2
+ import { callTraceSchema } from './debug_tx.js';
3
+ import { traceTransactionResponseSchema } from './trace_tx.js';
4
+ /**
5
+ * Helper function to test a trace method with validation
6
+ *
7
+ * @param client - The Viem public debug client
8
+ * @param txHash - Transaction hash to trace
9
+ * @param schema - Zod schema to validate the response
10
+ * @param method - Name of the RPC method ('debug_traceTransaction' or 'trace_transaction')
11
+ * @param blockType - Type of block being tested ('recent' or 'old')
12
+ * @param logger - Logger instance
13
+ * @returns true if the method works and validation passes, false otherwise
14
+ */ async function testTraceMethod(client, txHash, schema, method, blockType, logger) {
15
+ try {
16
+ // Make request with appropriate params based on method name
17
+ const result = await client.request(method === 'debug_traceTransaction' ? {
18
+ method,
19
+ params: [
20
+ txHash,
21
+ {
22
+ tracer: 'callTracer'
23
+ }
24
+ ]
25
+ } : {
26
+ method,
27
+ params: [
28
+ txHash
29
+ ]
30
+ });
31
+ schema.parse(result);
32
+ logger.debug(`${method} works for ${blockType} blocks`);
33
+ return true;
34
+ } catch (error) {
35
+ logger.warn(`${method} failed for ${blockType} blocks: ${error}`);
36
+ return false;
37
+ }
38
+ }
39
+ /**
40
+ * Validates the availability of debug/trace methods on the Ethereum client.
41
+ *
42
+ * @param client - The Viem public debug client
43
+ * @param bindings - Optional logger bindings for context
44
+ * @returns Object indicating which trace methods are available for recent and old blocks
45
+ */ export async function validateTraceAvailability(client, bindings) {
46
+ const logger = createLogger('archiver:validate_trace', bindings);
47
+ const result = {
48
+ debugTraceRecent: false,
49
+ traceTransactionRecent: false,
50
+ debugTraceOld: false,
51
+ traceTransactionOld: false
52
+ };
53
+ try {
54
+ // Get the latest block
55
+ let latestBlock = await client.getBlock({
56
+ blockTag: 'latest'
57
+ });
58
+ let attempts = 10;
59
+ // Loop back to find a block with transactions (handles dev/test scenarios)
60
+ while(!hasTxs(latestBlock) && latestBlock.number && latestBlock.number > 0n && --attempts > 0){
61
+ logger.debug(`Block ${latestBlock.number} has no transactions, checking previous block`);
62
+ latestBlock = await client.getBlock({
63
+ blockNumber: latestBlock.number - 1n
64
+ });
65
+ }
66
+ if (!hasTxs(latestBlock)) {
67
+ logger.warn('No blocks with transactions found from latest back to genesis, cannot validate trace availability');
68
+ return result;
69
+ }
70
+ // Get a transaction from the found block
71
+ const recentTxHash = latestBlock.transactions[0];
72
+ // Test debug_traceTransaction with recent block
73
+ result.debugTraceRecent = await testTraceMethod(client, recentTxHash, callTraceSchema, 'debug_traceTransaction', 'recent', logger);
74
+ // Test trace_transaction with recent block
75
+ result.traceTransactionRecent = await testTraceMethod(client, recentTxHash, traceTransactionResponseSchema, 'trace_transaction', 'recent', logger);
76
+ // Get a block from 512 blocks ago
77
+ const oldBlockNumber = latestBlock.number ? latestBlock.number - 512n : null;
78
+ if (!oldBlockNumber || oldBlockNumber < 0n) {
79
+ logger.debug('Cannot test old blocks, blockchain too short');
80
+ return result;
81
+ }
82
+ let oldBlock = await client.getBlock({
83
+ blockNumber: oldBlockNumber
84
+ });
85
+ attempts = 10;
86
+ // Loop back to find a block with transactions (handles dev/test scenarios)
87
+ while(!hasTxs(oldBlock) && oldBlock.number && oldBlock.number > 0n && --attempts > 0){
88
+ logger.debug(`Block ${oldBlock.number} has no transactions, checking previous block`);
89
+ oldBlock = await client.getBlock({
90
+ blockNumber: oldBlock.number - 1n
91
+ });
92
+ }
93
+ if (!hasTxs(oldBlock)) {
94
+ logger.debug('No blocks with transactions found from old block back to genesis, cannot validate trace availability for old blocks');
95
+ return result;
96
+ }
97
+ const oldTxHash = oldBlock.transactions[0];
98
+ // Test debug_traceTransaction with old block
99
+ result.debugTraceOld = await testTraceMethod(client, oldTxHash, callTraceSchema, 'debug_traceTransaction', 'old', logger);
100
+ // Test trace_transaction with old block
101
+ result.traceTransactionOld = await testTraceMethod(client, oldTxHash, traceTransactionResponseSchema, 'trace_transaction', 'old', logger);
102
+ } catch (error) {
103
+ logger.warn(`Error validating debug_traceTransaction and trace_transaction availability: ${error}`);
104
+ }
105
+ return result;
106
+ }
107
+ function hasTxs(block) {
108
+ return Array.isArray(block.transactions) && block.transactions.length > 0;
109
+ }
110
+ /**
111
+ * Validates trace availability and logs appropriate messages based on the results.
112
+ * Optionally throws an error if no trace methods are available and ethereumAllowNoDebugHosts is false.
113
+ *
114
+ * @param client - The Viem public debug client
115
+ * @param ethereumAllowNoDebugHosts - If false, throws an error when no trace methods are available
116
+ * @param bindings - Optional logger bindings for context
117
+ * @throws Error if ethereumAllowNoDebugHosts is false and no trace methods are available
118
+ */ export async function validateAndLogTraceAvailability(client, ethereumAllowNoDebugHosts, bindings) {
119
+ const logger = createLogger('archiver:validate_trace', bindings);
120
+ logger.debug('Validating trace/debug method availability...');
121
+ const availability = await validateTraceAvailability(client, bindings);
122
+ // Check if we have support for old blocks (either debug or trace)
123
+ const hasOldBlockSupport = availability.debugTraceOld || availability.traceTransactionOld;
124
+ if (hasOldBlockSupport) {
125
+ // Ideal case: we have trace support for old blocks
126
+ const methods = [];
127
+ if (availability.debugTraceOld) {
128
+ methods.push('debug_traceTransaction');
129
+ }
130
+ if (availability.traceTransactionOld) {
131
+ methods.push('trace_transaction');
132
+ }
133
+ logger.info(`Ethereum client supports trace methods for old blocks (${methods.join(', ')}). Archiver can retrieve historical transaction traces.`);
134
+ } else if (availability.debugTraceRecent || availability.traceTransactionRecent) {
135
+ // Warning case: only recent block support
136
+ const methods = [];
137
+ if (availability.debugTraceRecent) {
138
+ methods.push('debug_traceTransaction');
139
+ }
140
+ if (availability.traceTransactionRecent) {
141
+ methods.push('trace_transaction');
142
+ }
143
+ logger.warn(`Ethereum client only supports trace methods for recent blocks (${methods.join(', ')}). Historical transaction traces may not be available.`);
144
+ } else {
145
+ // Error case: no support at all
146
+ const errorMessage = 'Ethereum debug client does not support debug_traceTransaction or trace_transaction methods. Transaction tracing will not be available. This may impact archiver syncing.';
147
+ if (ethereumAllowNoDebugHosts) {
148
+ logger.warn(`${errorMessage} Continuing because ETHEREUM_ALLOW_NO_DEBUG_HOSTS is set to true.`);
149
+ } else {
150
+ logger.error(errorMessage);
151
+ throw new Error(`${errorMessage} Set ETHEREUM_ALLOW_NO_DEBUG_HOSTS=true to bypass this check.`);
152
+ }
153
+ }
154
+ }
@@ -0,0 +1,25 @@
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { FunctionSelector } from '@aztec/stdlib/abi';
4
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+ import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
6
+ import type { UInt64 } from '@aztec/stdlib/types';
7
+ import type { ArchiverDataStores } from '../store/data_stores.js';
8
+ /**
9
+ * Thin {@link ContractDataSource} adapter over {@link ArchiverDataStores}.
10
+ *
11
+ * Used by contexts (e.g. offline epoch re-prover tools) that need a ContractDataSource
12
+ * but do not need a full archiver instance.
13
+ */
14
+ export declare class ArchiverContractDataSourceAdapter implements ContractDataSource {
15
+ private readonly stores;
16
+ constructor(stores: ArchiverDataStores);
17
+ getBlockNumber(): Promise<BlockNumber>;
18
+ getContractClass(id: Fr): Promise<ContractClassPublic | undefined>;
19
+ getBytecodeCommitment(id: Fr): Promise<Fr | undefined>;
20
+ getContract(address: AztecAddress, maybeTimestamp?: UInt64): Promise<ContractInstanceWithAddress | undefined>;
21
+ getContractClassIds(): Promise<Fr[]>;
22
+ getDebugFunctionName(_address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
23
+ registerContractFunctionSignatures(signatures: string[]): Promise<void>;
24
+ }
25
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfZGF0YV9zb3VyY2VfYWRhc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E,EAAE,EAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAExE;IAEM,qBAAqB,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAE5D;IAEY,WAAW,CACtB,OAAO,EAAE,YAAY,EACrB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAQlD;IAEM,mBAAmB,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC,CAE1C;IAEM,oBAAoB,CAAC,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE3G;IAEM,kCAAkC,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7E;CACF"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Thin {@link ContractDataSource} adapter over {@link ArchiverDataStores}.
3
+ *
4
+ * Used by contexts (e.g. offline epoch re-prover tools) that need a ContractDataSource
5
+ * but do not need a full archiver instance.
6
+ */ export class ArchiverContractDataSourceAdapter {
7
+ stores;
8
+ constructor(stores){
9
+ this.stores = stores;
10
+ }
11
+ getBlockNumber() {
12
+ return this.stores.blocks.getLatestL2BlockNumber();
13
+ }
14
+ getContractClass(id) {
15
+ return this.stores.contractClasses.getContractClass(id);
16
+ }
17
+ getBytecodeCommitment(id) {
18
+ return this.stores.contractClasses.getBytecodeCommitment(id);
19
+ }
20
+ async getContract(address, maybeTimestamp) {
21
+ let timestamp = maybeTimestamp;
22
+ if (timestamp === undefined) {
23
+ const latest = await this.stores.blocks.getLatestL2BlockNumber();
24
+ const blockData = latest > 0 ? await this.stores.blocks.getBlockData({
25
+ number: latest
26
+ }) : undefined;
27
+ timestamp = blockData ? blockData.header.globalVariables.timestamp : 0n;
28
+ }
29
+ return this.stores.contractInstances.getContractInstance(address, timestamp);
30
+ }
31
+ getContractClassIds() {
32
+ return this.stores.contractClasses.getContractClassIds();
33
+ }
34
+ getDebugFunctionName(_address, selector) {
35
+ return Promise.resolve(this.stores.functionNames.get(selector));
36
+ }
37
+ registerContractFunctionSignatures(signatures) {
38
+ return this.stores.functionNames.register(signatures);
39
+ }
40
+ }