@aztec/archiver 0.0.0-test.1 → 0.0.1-commit.017a351

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 (252) hide show
  1. package/README.md +172 -9
  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 +19 -17
  12. package/dest/factory.d.ts.map +1 -1
  13. package/dest/factory.js +125 -61
  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/store/contract_instance_store.js +112 -0
  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/store/message_store.js +230 -0
  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/structs/inbox_message.js +39 -0
  100. package/dest/structs/published.d.ts +2 -0
  101. package/dest/structs/published.d.ts.map +1 -0
  102. package/dest/structs/published.js +1 -0
  103. package/dest/test/fake_l1_state.d.ts +214 -0
  104. package/dest/test/fake_l1_state.d.ts.map +1 -0
  105. package/dest/test/fake_l1_state.js +517 -0
  106. package/dest/test/index.d.ts +2 -1
  107. package/dest/test/index.d.ts.map +1 -1
  108. package/dest/test/index.js +4 -1
  109. package/dest/test/mock_archiver.d.ts +16 -8
  110. package/dest/test/mock_archiver.d.ts.map +1 -1
  111. package/dest/test/mock_archiver.js +19 -14
  112. package/dest/test/mock_l1_to_l2_message_source.d.ts +9 -6
  113. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
  114. package/dest/test/mock_l1_to_l2_message_source.js +31 -7
  115. package/dest/test/mock_l2_block_source.d.ts +98 -35
  116. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  117. package/dest/test/mock_l2_block_source.js +416 -76
  118. package/dest/test/mock_structs.d.ts +88 -0
  119. package/dest/test/mock_structs.d.ts.map +1 -0
  120. package/dest/test/mock_structs.js +183 -0
  121. package/dest/test/noop_l1_archiver.d.ts +30 -0
  122. package/dest/test/noop_l1_archiver.d.ts.map +1 -0
  123. package/dest/test/noop_l1_archiver.js +85 -0
  124. package/package.json +31 -33
  125. package/src/archiver.ts +719 -0
  126. package/src/config.ts +108 -0
  127. package/src/errors.ts +203 -0
  128. package/src/factory.ts +190 -76
  129. package/src/index.ts +27 -3
  130. package/src/interfaces.ts +9 -0
  131. package/src/l1/README.md +55 -0
  132. package/src/l1/bin/retrieve-calldata.ts +194 -0
  133. package/src/l1/calldata_retriever.ts +522 -0
  134. package/src/l1/data_retrieval.ts +484 -0
  135. package/src/l1/debug_tx.ts +99 -0
  136. package/src/l1/spire_proposer.ts +152 -0
  137. package/src/l1/trace_tx.ts +128 -0
  138. package/src/l1/types.ts +13 -0
  139. package/src/l1/validate_historical_logs.ts +140 -0
  140. package/src/l1/validate_trace.ts +229 -0
  141. package/src/modules/contract_data_source_adapter.ts +55 -0
  142. package/src/modules/data_source_base.ts +495 -0
  143. package/src/modules/data_store_updater.ts +518 -0
  144. package/src/modules/instrumentation.ts +204 -0
  145. package/src/modules/l1_synchronizer.ts +1257 -0
  146. package/src/modules/outbox_trees_resolver.ts +199 -0
  147. package/src/modules/validation.ts +130 -0
  148. package/src/store/block_store.ts +1540 -0
  149. package/src/store/contract_class_store.ts +108 -0
  150. package/src/store/contract_instance_store.ts +161 -0
  151. package/src/store/data_stores.ts +104 -0
  152. package/src/store/function_names_cache.ts +37 -0
  153. package/src/store/l2_tips_cache.ts +35 -0
  154. package/src/store/log_store.ts +379 -0
  155. package/src/store/log_store_codec.ts +132 -0
  156. package/src/store/message_store.ts +311 -0
  157. package/src/structs/inbox_message.ts +41 -0
  158. package/src/structs/published.ts +1 -0
  159. package/src/test/fake_l1_state.ts +770 -0
  160. package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
  161. package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
  162. package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
  163. package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
  164. package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
  165. package/src/test/fixtures/trace_transaction-proxied.json +128 -0
  166. package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
  167. package/src/test/index.ts +4 -0
  168. package/src/test/mock_archiver.ts +23 -16
  169. package/src/test/mock_l1_to_l2_message_source.ts +27 -8
  170. package/src/test/mock_l2_block_source.ts +514 -84
  171. package/src/test/mock_structs.ts +325 -0
  172. package/src/test/noop_l1_archiver.ts +148 -0
  173. package/dest/archiver/archiver.d.ts +0 -197
  174. package/dest/archiver/archiver.d.ts.map +0 -1
  175. package/dest/archiver/archiver.js +0 -900
  176. package/dest/archiver/archiver_store.d.ts +0 -220
  177. package/dest/archiver/archiver_store.d.ts.map +0 -1
  178. package/dest/archiver/archiver_store.js +0 -4
  179. package/dest/archiver/archiver_store_test_suite.d.ts +0 -8
  180. package/dest/archiver/archiver_store_test_suite.d.ts.map +0 -1
  181. package/dest/archiver/archiver_store_test_suite.js +0 -794
  182. package/dest/archiver/config.d.ts +0 -37
  183. package/dest/archiver/config.d.ts.map +0 -1
  184. package/dest/archiver/config.js +0 -46
  185. package/dest/archiver/data_retrieval.d.ts +0 -74
  186. package/dest/archiver/data_retrieval.d.ts.map +0 -1
  187. package/dest/archiver/data_retrieval.js +0 -283
  188. package/dest/archiver/errors.d.ts +0 -4
  189. package/dest/archiver/errors.d.ts.map +0 -1
  190. package/dest/archiver/errors.js +0 -5
  191. package/dest/archiver/index.d.ts +0 -8
  192. package/dest/archiver/index.d.ts.map +0 -1
  193. package/dest/archiver/index.js +0 -5
  194. package/dest/archiver/instrumentation.d.ts +0 -29
  195. package/dest/archiver/instrumentation.d.ts.map +0 -1
  196. package/dest/archiver/instrumentation.js +0 -99
  197. package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -87
  198. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
  199. package/dest/archiver/kv_archiver_store/block_store.js +0 -217
  200. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +0 -18
  201. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +0 -1
  202. package/dest/archiver/kv_archiver_store/contract_class_store.js +0 -126
  203. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -21
  204. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
  205. package/dest/archiver/kv_archiver_store/contract_instance_store.js +0 -63
  206. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -153
  207. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +0 -1
  208. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +0 -254
  209. package/dest/archiver/kv_archiver_store/log_store.d.ts +0 -49
  210. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
  211. package/dest/archiver/kv_archiver_store/log_store.js +0 -364
  212. package/dest/archiver/kv_archiver_store/message_store.d.ts +0 -33
  213. package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
  214. package/dest/archiver/kv_archiver_store/message_store.js +0 -85
  215. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
  216. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
  217. package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
  218. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +0 -23
  219. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +0 -1
  220. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +0 -49
  221. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
  222. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
  223. package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -636
  224. package/dest/archiver/structs/data_retrieval.d.ts +0 -27
  225. package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
  226. package/dest/archiver/structs/published.d.ts +0 -11
  227. package/dest/archiver/structs/published.d.ts.map +0 -1
  228. package/dest/archiver/structs/published.js +0 -1
  229. package/dest/rpc/index.d.ts +0 -10
  230. package/dest/rpc/index.d.ts.map +0 -1
  231. package/dest/rpc/index.js +0 -18
  232. package/src/archiver/archiver.ts +0 -1181
  233. package/src/archiver/archiver_store.ts +0 -263
  234. package/src/archiver/archiver_store_test_suite.ts +0 -810
  235. package/src/archiver/config.ts +0 -92
  236. package/src/archiver/data_retrieval.ts +0 -422
  237. package/src/archiver/errors.ts +0 -5
  238. package/src/archiver/index.ts +0 -7
  239. package/src/archiver/instrumentation.ts +0 -132
  240. package/src/archiver/kv_archiver_store/block_store.ts +0 -283
  241. package/src/archiver/kv_archiver_store/contract_class_store.ts +0 -186
  242. package/src/archiver/kv_archiver_store/contract_instance_store.ts +0 -107
  243. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -358
  244. package/src/archiver/kv_archiver_store/log_store.ts +0 -444
  245. package/src/archiver/kv_archiver_store/message_store.ts +0 -102
  246. package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
  247. package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +0 -61
  248. package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
  249. package/src/archiver/structs/published.ts +0 -11
  250. package/src/rpc/index.ts +0 -20
  251. /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
  252. /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
@@ -0,0 +1,55 @@
1
+ # Archiver L1 Data Retrieval
2
+
3
+ Modules and classes to handle data retrieval from L1 for the archiver.
4
+
5
+ ## Calldata Retriever
6
+
7
+ The sequencer publisher bundles multiple operations into a single multicall3 transaction for gas
8
+ efficiency. The archiver needs to extract the `propose` calldata from these bundled transactions
9
+ to reconstruct L2 blocks.
10
+
11
+ The retriever uses hash matching against `attestationsHash` and `payloadDigest` from the
12
+ `CheckpointProposed` L1 event to verify it has found the correct propose calldata. These hashes
13
+ are always required.
14
+
15
+ ### Multicall3 Decoding with Hash Matching
16
+
17
+ First attempt to decode the transaction as a multicall3 `aggregate3` call:
18
+
19
+ - Check if transaction is to multicall3 address (`0xcA11bde05977b3631167028862bE2a173976CA11`)
20
+ - Decode as `aggregate3(Call3[] calldata calls)`
21
+ - Find all calls matching the rollup contract address and the `propose` function selector
22
+ - Verify each candidate by computing `attestationsHash` (keccak256 of ABI-encoded attestations)
23
+ and `payloadDigest` (keccak256 of the consensus payload signing hash) and comparing against
24
+ expected values from the `CheckpointProposed` event
25
+ - Return the verified candidate (if multiple verify, return the first with a warning)
26
+
27
+ This approach works regardless of what other calls are in the multicall3 bundle, because hash
28
+ matching identifies the correct propose call without needing an allowlist.
29
+
30
+ ### Direct Propose Call
31
+
32
+ Second attempt to decode the transaction as a direct `propose` call to the rollup contract:
33
+
34
+ - Check if transaction is to the rollup address
35
+ - Decode as `propose` function call
36
+ - Verify against expected hashes
37
+ - Return the transaction input as the propose calldata
38
+
39
+ ### Spire Proposer Call
40
+
41
+ Given existing attempts to route the call via the Spire proposer, we also check if the tx is
42
+ `to` the proposer known address. If so, we extract all wrapped calls and try each as either
43
+ a multicall3 or direct propose call, using hash matching to find and verify the correct one.
44
+
45
+ Since the Spire proposer is upgradeable, we check that the implementation has not changed in
46
+ order to decode. Any validation failure triggers fallback to the next step.
47
+
48
+ ### Debug and Trace Transaction Fallback
49
+
50
+ Last, we use L1 node's trace/debug RPC methods to definitively identify the one successful
51
+ `propose` call within the tx. We can then extract the exact calldata that hit the `propose`
52
+ function in the rollup contract.
53
+
54
+ This approach requires access to a debug-enabled L1 node, which may be more resource-intensive,
55
+ so we only use it as a fallback when earlier steps fail, which should be rare in practice.
@@ -0,0 +1,194 @@
1
+ #!/usr/bin/env node
2
+ import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
3
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
4
+ import { EthAddress } from '@aztec/foundation/eth-address';
5
+ import { createLogger } from '@aztec/foundation/log';
6
+ import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
7
+
8
+ import { type Hex, createPublicClient, decodeEventLog, getAbiItem, http, toEventSelector } from 'viem';
9
+ import { mainnet } from 'viem/chains';
10
+
11
+ import { CalldataRetriever } from '../calldata_retriever.js';
12
+
13
+ const logger = createLogger('archiver:calldata-test');
14
+
15
+ interface ScriptArgs {
16
+ rollupAddress: EthAddress;
17
+ txHash: Hex;
18
+ rpcUrl: string;
19
+ targetCommitteeSize: number;
20
+ }
21
+
22
+ function parseArgs(): ScriptArgs {
23
+ const args = process.argv.slice(2);
24
+
25
+ if (args.length < 2) {
26
+ // eslint-disable-next-line no-console
27
+ console.error('Usage: node index.js <rollup-address> <tx-hash> [target-committee-size]');
28
+ // eslint-disable-next-line no-console
29
+ console.error('');
30
+ // eslint-disable-next-line no-console
31
+ console.error('Environment variables:');
32
+ // eslint-disable-next-line no-console
33
+ console.error(' ETHEREUM_HOST or RPC_URL - Ethereum RPC endpoint');
34
+ // eslint-disable-next-line no-console
35
+ console.error('');
36
+ // eslint-disable-next-line no-console
37
+ console.error('Example:');
38
+ // eslint-disable-next-line no-console
39
+ console.error(' RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY \\');
40
+ // eslint-disable-next-line no-console
41
+ console.error(' node index.js 0x1234... 0xabcd... 32');
42
+ process.exit(1);
43
+ }
44
+
45
+ const rollupAddress = EthAddress.fromString(args[0]);
46
+ const txHash = args[1] as Hex;
47
+ const targetCommitteeSize = args[2] ? parseInt(args[2], 10) : 24;
48
+
49
+ const rpcUrl = process.env.ETHEREUM_HOST || process.env.RPC_URL;
50
+ if (!rpcUrl) {
51
+ // eslint-disable-next-line no-console
52
+ console.error('Error: ETHEREUM_HOST or RPC_URL environment variable must be set');
53
+ process.exit(1);
54
+ }
55
+
56
+ if (targetCommitteeSize <= 0 || targetCommitteeSize > 256) {
57
+ // eslint-disable-next-line no-console
58
+ console.error('Error: target-committee-size must be between 1 and 256');
59
+ process.exit(1);
60
+ }
61
+
62
+ return { rollupAddress, txHash, rpcUrl, targetCommitteeSize };
63
+ }
64
+
65
+ async function main() {
66
+ const { rollupAddress, txHash, rpcUrl, targetCommitteeSize } = parseArgs();
67
+
68
+ logger.info('Calldata Retriever Test Script');
69
+ logger.info('===============================');
70
+ logger.info(`Rollup Address: ${rollupAddress.toString()}`);
71
+ logger.info(`Transaction Hash: ${txHash}`);
72
+ logger.info(`RPC URL: ${rpcUrl}`);
73
+ logger.info(`Target Committee Size: ${targetCommitteeSize}`);
74
+ logger.info('');
75
+
76
+ try {
77
+ // Create viem public client
78
+ const publicClient = createPublicClient({
79
+ chain: mainnet,
80
+ transport: http(rpcUrl, { batch: false }),
81
+ });
82
+
83
+ logger.info('Fetching transaction...');
84
+ const tx = await publicClient.getTransaction({ hash: txHash });
85
+
86
+ if (!tx) {
87
+ throw new Error(`Transaction ${txHash} not found`);
88
+ }
89
+
90
+ logger.info(`Transaction found in block ${tx.blockNumber}`);
91
+
92
+ // Create CalldataRetriever
93
+ const retriever = new CalldataRetriever(
94
+ publicClient as unknown as ViemPublicClient,
95
+ publicClient as unknown as ViemPublicDebugClient,
96
+ targetCommitteeSize,
97
+ undefined,
98
+ logger,
99
+ rollupAddress,
100
+ );
101
+
102
+ // Extract checkpoint number and hashes from transaction logs
103
+ logger.info('Decoding transaction to extract checkpoint number and hashes...');
104
+ const receipt = await publicClient.getTransactionReceipt({ hash: txHash });
105
+
106
+ // Look for CheckpointProposed event
107
+ const checkpointProposedEventAbi = getAbiItem({ abi: RollupAbi, name: 'CheckpointProposed' });
108
+ const checkpointProposedLog = receipt.logs.find(log => {
109
+ try {
110
+ return (
111
+ log.address.toLowerCase() === rollupAddress.toString().toLowerCase() &&
112
+ log.topics[0] === toEventSelector(checkpointProposedEventAbi)
113
+ );
114
+ } catch {
115
+ return false;
116
+ }
117
+ });
118
+
119
+ if (!checkpointProposedLog || checkpointProposedLog.topics[1] === undefined) {
120
+ throw new Error(`Checkpoint proposed event not found`);
121
+ }
122
+
123
+ const checkpointNumber = CheckpointNumber.fromBigInt(BigInt(checkpointProposedLog.topics[1]));
124
+
125
+ // Decode the full event to extract attestationsHash and payloadDigest
126
+ const decodedEvent = decodeEventLog({
127
+ abi: RollupAbi,
128
+ data: checkpointProposedLog.data,
129
+ topics: checkpointProposedLog.topics,
130
+ });
131
+
132
+ const eventArgs = decodedEvent.args as {
133
+ checkpointNumber: bigint;
134
+ archive: Hex;
135
+ versionedBlobHashes: Hex[];
136
+ attestationsHash: Hex;
137
+ payloadDigest: Hex;
138
+ };
139
+
140
+ if (!eventArgs.attestationsHash || !eventArgs.payloadDigest) {
141
+ throw new Error(`CheckpointProposed event missing attestationsHash or payloadDigest`);
142
+ }
143
+
144
+ const expectedHashes = {
145
+ attestationsHash: eventArgs.attestationsHash,
146
+ payloadDigest: eventArgs.payloadDigest,
147
+ };
148
+
149
+ logger.info(`Checkpoint Number: ${checkpointNumber}`);
150
+ logger.info(`Attestations Hash: ${expectedHashes.attestationsHash}`);
151
+ logger.info(`Payload Digest: ${expectedHashes.payloadDigest}`);
152
+
153
+ logger.info('');
154
+ logger.info('Retrieving checkpoint from rollup transaction...');
155
+ logger.info('');
156
+
157
+ const result = await retriever.getCheckpointFromRollupTx(txHash, [], checkpointNumber, expectedHashes);
158
+
159
+ logger.info(' Successfully retrieved block header!');
160
+ logger.info('');
161
+ logger.info('Block Header Details:');
162
+ logger.info('====================');
163
+ logger.info(`Checkpoint Number: ${result.checkpointNumber}`);
164
+ logger.info(`Block Hash: ${result.blockHash}`);
165
+ logger.info(`Archive Root: ${result.archiveRoot.toString()}`);
166
+ logger.info('');
167
+ logger.info('Header:');
168
+ logger.info(` Slot Number: ${result.header.slotNumber.toString()}`);
169
+ logger.info(` Timestamp: ${result.header.timestamp.toString()}`);
170
+ logger.info(` Coinbase: ${result.header.coinbase.toString()}`);
171
+ logger.info(` Fee Recipient: ${result.header.feeRecipient.toString()}`);
172
+ logger.info(` Total Mana Used: ${result.header.totalManaUsed.toString()}`);
173
+ logger.info('');
174
+ logger.info('Attestations:');
175
+ logger.info(` Count: ${result.attestations.length}`);
176
+ logger.info(` Non-empty attestations: ${result.attestations.filter((a: any) => !a.signature.isEmpty()).length}`);
177
+
178
+ process.exit(0);
179
+ } catch (error) {
180
+ logger.error('Error retrieving block header:');
181
+ logger.error(error instanceof Error ? error.message : String(error));
182
+
183
+ if (error instanceof Error && error.stack) {
184
+ logger.debug(error.stack);
185
+ }
186
+
187
+ process.exit(1);
188
+ }
189
+ }
190
+
191
+ // Only run if this is the main module
192
+ if (import.meta.url === `file://${process.argv[1]}`) {
193
+ void main();
194
+ }