@aztec/archiver 0.0.1-commit.9b94fc1 → 0.0.1-commit.9ee6fcc6

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 (211) hide show
  1. package/README.md +156 -22
  2. package/dest/archiver.d.ts +138 -0
  3. package/dest/archiver.d.ts.map +1 -0
  4. package/dest/archiver.js +743 -0
  5. package/dest/config.d.ts +30 -0
  6. package/dest/config.d.ts.map +1 -0
  7. package/dest/{archiver/config.js → config.js} +23 -6
  8. package/dest/errors.d.ts +53 -0
  9. package/dest/errors.d.ts.map +1 -0
  10. package/dest/errors.js +75 -0
  11. package/dest/factory.d.ts +8 -7
  12. package/dest/factory.d.ts.map +1 -1
  13. package/dest/factory.js +99 -15
  14. package/dest/index.d.ts +11 -4
  15. package/dest/index.d.ts.map +1 -1
  16. package/dest/index.js +9 -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 +135 -0
  24. package/dest/l1/calldata_retriever.d.ts.map +1 -0
  25. package/dest/l1/calldata_retriever.js +402 -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/{archiver → l1}/data_retrieval.js +83 -155
  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 +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 +89 -0
  45. package/dest/modules/data_source_base.d.ts.map +1 -0
  46. package/dest/modules/data_source_base.js +216 -0
  47. package/dest/modules/data_store_updater.d.ts +85 -0
  48. package/dest/modules/data_store_updater.d.ts.map +1 -0
  49. package/dest/modules/data_store_updater.js +324 -0
  50. package/dest/modules/instrumentation.d.ts +50 -0
  51. package/dest/modules/instrumentation.d.ts.map +1 -0
  52. package/dest/{archiver → modules}/instrumentation.js +49 -62
  53. package/dest/modules/l1_synchronizer.d.ts +72 -0
  54. package/dest/modules/l1_synchronizer.d.ts.map +1 -0
  55. package/dest/modules/l1_synchronizer.js +1147 -0
  56. package/dest/modules/validation.d.ts +17 -0
  57. package/dest/modules/validation.d.ts.map +1 -0
  58. package/dest/{archiver → modules}/validation.js +7 -1
  59. package/dest/store/block_store.d.ts +195 -0
  60. package/dest/store/block_store.d.ts.map +1 -0
  61. package/dest/store/block_store.js +773 -0
  62. package/dest/store/contract_class_store.d.ts +17 -0
  63. package/dest/store/contract_class_store.d.ts.map +1 -0
  64. package/dest/store/contract_class_store.js +64 -0
  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/{archiver/kv_archiver_store → store}/contract_instance_store.js +7 -3
  68. package/dest/store/kv_archiver_store.d.ts +364 -0
  69. package/dest/store/kv_archiver_store.d.ts.map +1 -0
  70. package/dest/store/kv_archiver_store.js +477 -0
  71. package/dest/store/l2_tips_cache.d.ts +19 -0
  72. package/dest/store/l2_tips_cache.d.ts.map +1 -0
  73. package/dest/store/l2_tips_cache.js +89 -0
  74. package/dest/store/log_store.d.ts +57 -0
  75. package/dest/store/log_store.d.ts.map +1 -0
  76. package/dest/store/log_store.js +533 -0
  77. package/dest/store/message_store.d.ts +44 -0
  78. package/dest/store/message_store.d.ts.map +1 -0
  79. package/dest/{archiver/kv_archiver_store → store}/message_store.js +29 -15
  80. package/dest/{archiver/structs → structs}/data_retrieval.d.ts +1 -1
  81. package/dest/structs/data_retrieval.d.ts.map +1 -0
  82. package/dest/structs/inbox_message.d.ts +15 -0
  83. package/dest/structs/inbox_message.d.ts.map +1 -0
  84. package/dest/{archiver/structs → structs}/inbox_message.js +6 -5
  85. package/dest/structs/published.d.ts +2 -0
  86. package/dest/structs/published.d.ts.map +1 -0
  87. package/dest/test/fake_l1_state.d.ts +202 -0
  88. package/dest/test/fake_l1_state.d.ts.map +1 -0
  89. package/dest/test/fake_l1_state.js +455 -0
  90. package/dest/test/index.d.ts +2 -1
  91. package/dest/test/index.d.ts.map +1 -1
  92. package/dest/test/index.js +4 -1
  93. package/dest/test/mock_archiver.d.ts +16 -8
  94. package/dest/test/mock_archiver.d.ts.map +1 -1
  95. package/dest/test/mock_archiver.js +19 -14
  96. package/dest/test/mock_l1_to_l2_message_source.d.ts +7 -6
  97. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
  98. package/dest/test/mock_l1_to_l2_message_source.js +21 -11
  99. package/dest/test/mock_l2_block_source.d.ts +54 -20
  100. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  101. package/dest/test/mock_l2_block_source.js +251 -85
  102. package/dest/test/mock_structs.d.ts +83 -4
  103. package/dest/test/mock_structs.d.ts.map +1 -1
  104. package/dest/test/mock_structs.js +157 -11
  105. package/dest/test/noop_l1_archiver.d.ts +26 -0
  106. package/dest/test/noop_l1_archiver.d.ts.map +1 -0
  107. package/dest/test/noop_l1_archiver.js +72 -0
  108. package/package.json +20 -20
  109. package/src/archiver.ts +500 -0
  110. package/src/{archiver/config.ts → config.ts} +36 -13
  111. package/src/errors.ts +118 -0
  112. package/src/factory.ts +154 -17
  113. package/src/index.ts +11 -3
  114. package/src/interfaces.ts +9 -0
  115. package/src/l1/README.md +55 -0
  116. package/src/l1/bin/retrieve-calldata.ts +194 -0
  117. package/src/l1/calldata_retriever.ts +511 -0
  118. package/src/{archiver → l1}/data_retrieval.ts +143 -226
  119. package/src/l1/debug_tx.ts +99 -0
  120. package/src/l1/spire_proposer.ts +152 -0
  121. package/src/l1/trace_tx.ts +128 -0
  122. package/src/l1/types.ts +13 -0
  123. package/src/l1/validate_trace.ts +229 -0
  124. package/src/modules/data_source_base.ts +333 -0
  125. package/src/modules/data_store_updater.ts +424 -0
  126. package/src/{archiver → modules}/instrumentation.ts +63 -66
  127. package/src/modules/l1_synchronizer.ts +967 -0
  128. package/src/{archiver → modules}/validation.ts +11 -6
  129. package/src/store/block_store.ts +1018 -0
  130. package/src/store/contract_class_store.ts +82 -0
  131. package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +10 -7
  132. package/src/store/kv_archiver_store.ts +682 -0
  133. package/src/store/l2_tips_cache.ts +89 -0
  134. package/src/store/log_store.ts +736 -0
  135. package/src/{archiver/kv_archiver_store → store}/message_store.ts +41 -19
  136. package/src/{archiver/structs → structs}/inbox_message.ts +8 -8
  137. package/src/{archiver/structs → structs}/published.ts +0 -1
  138. package/src/test/fake_l1_state.ts +698 -0
  139. package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
  140. package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
  141. package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
  142. package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
  143. package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
  144. package/src/test/fixtures/trace_transaction-proxied.json +128 -0
  145. package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
  146. package/src/test/index.ts +4 -0
  147. package/src/test/mock_archiver.ts +23 -16
  148. package/src/test/mock_l1_to_l2_message_source.ts +18 -11
  149. package/src/test/mock_l2_block_source.ts +311 -93
  150. package/src/test/mock_structs.ts +289 -13
  151. package/src/test/noop_l1_archiver.ts +115 -0
  152. package/dest/archiver/archiver.d.ts +0 -287
  153. package/dest/archiver/archiver.d.ts.map +0 -1
  154. package/dest/archiver/archiver.js +0 -1408
  155. package/dest/archiver/archiver_store.d.ts +0 -255
  156. package/dest/archiver/archiver_store.d.ts.map +0 -1
  157. package/dest/archiver/archiver_store.js +0 -4
  158. package/dest/archiver/archiver_store_test_suite.d.ts +0 -8
  159. package/dest/archiver/archiver_store_test_suite.d.ts.map +0 -1
  160. package/dest/archiver/archiver_store_test_suite.js +0 -1289
  161. package/dest/archiver/config.d.ts +0 -21
  162. package/dest/archiver/config.d.ts.map +0 -1
  163. package/dest/archiver/data_retrieval.d.ts +0 -79
  164. package/dest/archiver/data_retrieval.d.ts.map +0 -1
  165. package/dest/archiver/errors.d.ts +0 -12
  166. package/dest/archiver/errors.d.ts.map +0 -1
  167. package/dest/archiver/errors.js +0 -17
  168. package/dest/archiver/index.d.ts +0 -7
  169. package/dest/archiver/index.d.ts.map +0 -1
  170. package/dest/archiver/index.js +0 -4
  171. package/dest/archiver/instrumentation.d.ts +0 -35
  172. package/dest/archiver/instrumentation.d.ts.map +0 -1
  173. package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -124
  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 -370
  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_class_store.js +0 -120
  179. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -24
  180. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
  181. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -168
  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 -296
  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 -336
  187. package/dest/archiver/kv_archiver_store/message_store.d.ts +0 -39
  188. package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
  189. package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
  190. package/dest/archiver/structs/inbox_message.d.ts +0 -15
  191. package/dest/archiver/structs/inbox_message.d.ts.map +0 -1
  192. package/dest/archiver/structs/published.d.ts +0 -3
  193. package/dest/archiver/structs/published.d.ts.map +0 -1
  194. package/dest/archiver/validation.d.ts +0 -17
  195. package/dest/archiver/validation.d.ts.map +0 -1
  196. package/dest/rpc/index.d.ts +0 -9
  197. package/dest/rpc/index.d.ts.map +0 -1
  198. package/dest/rpc/index.js +0 -15
  199. package/src/archiver/archiver.ts +0 -1858
  200. package/src/archiver/archiver_store.ts +0 -305
  201. package/src/archiver/archiver_store_test_suite.ts +0 -1264
  202. package/src/archiver/errors.ts +0 -26
  203. package/src/archiver/index.ts +0 -6
  204. package/src/archiver/kv_archiver_store/block_store.ts +0 -481
  205. package/src/archiver/kv_archiver_store/contract_class_store.ts +0 -176
  206. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -422
  207. package/src/archiver/kv_archiver_store/log_store.ts +0 -406
  208. package/src/rpc/index.ts +0 -16
  209. /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
  210. /package/dest/{archiver/structs → structs}/published.js +0 -0
  211. /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env node
2
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
3
+ import { EthAddress } from '@aztec/foundation/eth-address';
4
+ import { createLogger } from '@aztec/foundation/log';
5
+ import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
6
+ import { createPublicClient, decodeEventLog, getAbiItem, http, toEventSelector } from 'viem';
7
+ import { mainnet } from 'viem/chains';
8
+ import { CalldataRetriever } from '../calldata_retriever.js';
9
+ const logger = createLogger('archiver:calldata-test');
10
+ function parseArgs() {
11
+ const args = process.argv.slice(2);
12
+ if (args.length < 2) {
13
+ // eslint-disable-next-line no-console
14
+ console.error('Usage: node index.js <rollup-address> <tx-hash> [target-committee-size]');
15
+ // eslint-disable-next-line no-console
16
+ console.error('');
17
+ // eslint-disable-next-line no-console
18
+ console.error('Environment variables:');
19
+ // eslint-disable-next-line no-console
20
+ console.error(' ETHEREUM_HOST or RPC_URL - Ethereum RPC endpoint');
21
+ // eslint-disable-next-line no-console
22
+ console.error('');
23
+ // eslint-disable-next-line no-console
24
+ console.error('Example:');
25
+ // eslint-disable-next-line no-console
26
+ console.error(' RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY \\');
27
+ // eslint-disable-next-line no-console
28
+ console.error(' node index.js 0x1234... 0xabcd... 32');
29
+ process.exit(1);
30
+ }
31
+ const rollupAddress = EthAddress.fromString(args[0]);
32
+ const txHash = args[1];
33
+ const targetCommitteeSize = args[2] ? parseInt(args[2], 10) : 24;
34
+ const rpcUrl = process.env.ETHEREUM_HOST || process.env.RPC_URL;
35
+ if (!rpcUrl) {
36
+ // eslint-disable-next-line no-console
37
+ console.error('Error: ETHEREUM_HOST or RPC_URL environment variable must be set');
38
+ process.exit(1);
39
+ }
40
+ if (targetCommitteeSize <= 0 || targetCommitteeSize > 256) {
41
+ // eslint-disable-next-line no-console
42
+ console.error('Error: target-committee-size must be between 1 and 256');
43
+ process.exit(1);
44
+ }
45
+ return {
46
+ rollupAddress,
47
+ txHash,
48
+ rpcUrl,
49
+ targetCommitteeSize
50
+ };
51
+ }
52
+ async function main() {
53
+ const { rollupAddress, txHash, rpcUrl, targetCommitteeSize } = parseArgs();
54
+ logger.info('Calldata Retriever Test Script');
55
+ logger.info('===============================');
56
+ logger.info(`Rollup Address: ${rollupAddress.toString()}`);
57
+ logger.info(`Transaction Hash: ${txHash}`);
58
+ logger.info(`RPC URL: ${rpcUrl}`);
59
+ logger.info(`Target Committee Size: ${targetCommitteeSize}`);
60
+ logger.info('');
61
+ try {
62
+ // Create viem public client
63
+ const publicClient = createPublicClient({
64
+ chain: mainnet,
65
+ transport: http(rpcUrl, {
66
+ batch: false
67
+ })
68
+ });
69
+ logger.info('Fetching transaction...');
70
+ const tx = await publicClient.getTransaction({
71
+ hash: txHash
72
+ });
73
+ if (!tx) {
74
+ throw new Error(`Transaction ${txHash} not found`);
75
+ }
76
+ logger.info(`Transaction found in block ${tx.blockNumber}`);
77
+ // Create CalldataRetriever
78
+ const retriever = new CalldataRetriever(publicClient, publicClient, targetCommitteeSize, undefined, logger, rollupAddress);
79
+ // Extract checkpoint number and hashes from transaction logs
80
+ logger.info('Decoding transaction to extract checkpoint number and hashes...');
81
+ const receipt = await publicClient.getTransactionReceipt({
82
+ hash: txHash
83
+ });
84
+ // Look for CheckpointProposed event
85
+ const checkpointProposedEventAbi = getAbiItem({
86
+ abi: RollupAbi,
87
+ name: 'CheckpointProposed'
88
+ });
89
+ const checkpointProposedLog = receipt.logs.find((log)=>{
90
+ try {
91
+ return log.address.toLowerCase() === rollupAddress.toString().toLowerCase() && log.topics[0] === toEventSelector(checkpointProposedEventAbi);
92
+ } catch {
93
+ return false;
94
+ }
95
+ });
96
+ if (!checkpointProposedLog || checkpointProposedLog.topics[1] === undefined) {
97
+ throw new Error(`Checkpoint proposed event not found`);
98
+ }
99
+ const checkpointNumber = CheckpointNumber.fromBigInt(BigInt(checkpointProposedLog.topics[1]));
100
+ // Decode the full event to extract attestationsHash and payloadDigest
101
+ const decodedEvent = decodeEventLog({
102
+ abi: RollupAbi,
103
+ data: checkpointProposedLog.data,
104
+ topics: checkpointProposedLog.topics
105
+ });
106
+ const eventArgs = decodedEvent.args;
107
+ if (!eventArgs.attestationsHash || !eventArgs.payloadDigest) {
108
+ throw new Error(`CheckpointProposed event missing attestationsHash or payloadDigest`);
109
+ }
110
+ const expectedHashes = {
111
+ attestationsHash: eventArgs.attestationsHash,
112
+ payloadDigest: eventArgs.payloadDigest
113
+ };
114
+ logger.info(`Checkpoint Number: ${checkpointNumber}`);
115
+ logger.info(`Attestations Hash: ${expectedHashes.attestationsHash}`);
116
+ logger.info(`Payload Digest: ${expectedHashes.payloadDigest}`);
117
+ logger.info('');
118
+ logger.info('Retrieving checkpoint from rollup transaction...');
119
+ logger.info('');
120
+ const result = await retriever.getCheckpointFromRollupTx(txHash, [], checkpointNumber, expectedHashes);
121
+ logger.info(' Successfully retrieved block header!');
122
+ logger.info('');
123
+ logger.info('Block Header Details:');
124
+ logger.info('====================');
125
+ logger.info(`Checkpoint Number: ${result.checkpointNumber}`);
126
+ logger.info(`Block Hash: ${result.blockHash}`);
127
+ logger.info(`Archive Root: ${result.archiveRoot.toString()}`);
128
+ logger.info('');
129
+ logger.info('Header:');
130
+ logger.info(` Slot Number: ${result.header.slotNumber.toString()}`);
131
+ logger.info(` Timestamp: ${result.header.timestamp.toString()}`);
132
+ logger.info(` Coinbase: ${result.header.coinbase.toString()}`);
133
+ logger.info(` Fee Recipient: ${result.header.feeRecipient.toString()}`);
134
+ logger.info(` Total Mana Used: ${result.header.totalManaUsed.toString()}`);
135
+ logger.info('');
136
+ logger.info('Attestations:');
137
+ logger.info(` Count: ${result.attestations.length}`);
138
+ logger.info(` Non-empty attestations: ${result.attestations.filter((a)=>!a.signature.isEmpty()).length}`);
139
+ process.exit(0);
140
+ } catch (error) {
141
+ logger.error('Error retrieving block header:');
142
+ logger.error(error instanceof Error ? error.message : String(error));
143
+ if (error instanceof Error && error.stack) {
144
+ logger.debug(error.stack);
145
+ }
146
+ process.exit(1);
147
+ }
148
+ }
149
+ // Only run if this is the main module
150
+ if (import.meta.url === `file://${process.argv[1]}`) {
151
+ void main();
152
+ }
@@ -0,0 +1,135 @@
1
+ import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
2
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
4
+ import { EthAddress } from '@aztec/foundation/eth-address';
5
+ import type { Logger } from '@aztec/foundation/log';
6
+ import { CommitteeAttestation } from '@aztec/stdlib/block';
7
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
8
+ import { type Hex, type Transaction } from 'viem';
9
+ import type { ArchiverInstrumentation } from '../modules/instrumentation.js';
10
+ /** Decoded checkpoint data from a propose calldata. */
11
+ type CheckpointData = {
12
+ checkpointNumber: CheckpointNumber;
13
+ archiveRoot: Fr;
14
+ header: CheckpointHeader;
15
+ attestations: CommitteeAttestation[];
16
+ blockHash: string;
17
+ feeAssetPriceModifier: bigint;
18
+ };
19
+ /**
20
+ * Extracts calldata to the `propose` method of the rollup contract from an L1 transaction
21
+ * in order to reconstruct an L2 block header. Uses hash matching against expected hashes
22
+ * from the CheckpointProposed event to verify the correct propose calldata.
23
+ */
24
+ export declare class CalldataRetriever {
25
+ private readonly publicClient;
26
+ private readonly debugClient;
27
+ private readonly targetCommitteeSize;
28
+ private readonly instrumentation;
29
+ private readonly logger;
30
+ private readonly rollupAddress;
31
+ /** Tx hashes we've already logged for trace+debug failure (log once per tx per process). */
32
+ private static readonly traceFailureWarnedTxHashes;
33
+ /** Clears the trace-failure warned set. For testing only. */
34
+ static resetTraceFailureWarnedForTesting(): void;
35
+ constructor(publicClient: ViemPublicClient, debugClient: ViemPublicDebugClient, targetCommitteeSize: number, instrumentation: ArchiverInstrumentation | undefined, logger: Logger, rollupAddress: EthAddress);
36
+ /**
37
+ * Gets checkpoint header and metadata from the calldata of an L1 transaction.
38
+ * Tries multicall3 decoding, falls back to trace-based extraction.
39
+ * @param txHash - Hash of the tx that published it.
40
+ * @param blobHashes - Blob hashes for the checkpoint.
41
+ * @param checkpointNumber - Checkpoint number.
42
+ * @param expectedHashes - Expected hashes from the CheckpointProposed event for validation
43
+ * @returns Checkpoint header and metadata from the calldata, deserialized
44
+ */
45
+ getCheckpointFromRollupTx(txHash: `0x${string}`, _blobHashes: Buffer[], checkpointNumber: CheckpointNumber, expectedHashes: {
46
+ attestationsHash: Hex;
47
+ payloadDigest: Hex;
48
+ }): Promise<CheckpointData>;
49
+ /** Gets checkpoint data from a transaction by trying decode strategies then falling back to trace. */
50
+ protected getCheckpointFromTx(tx: Transaction, checkpointNumber: CheckpointNumber, expectedHashes: {
51
+ attestationsHash: Hex;
52
+ payloadDigest: Hex;
53
+ }): Promise<CheckpointData>;
54
+ /**
55
+ * Attempts to decode a transaction as a Spire Proposer multicall wrapper.
56
+ * If successful, iterates all wrapped calls and validates each as either multicall3
57
+ * or direct propose, verifying against expected hashes.
58
+ * @param tx - The transaction to decode
59
+ * @param expectedHashes - Expected hashes for hash-verified matching
60
+ * @param checkpointNumber - The checkpoint number
61
+ * @param blockHash - The L1 block hash
62
+ * @returns The checkpoint data if successfully decoded and validated, undefined otherwise
63
+ */
64
+ protected tryDecodeSpireProposer(tx: Transaction, expectedHashes: {
65
+ attestationsHash: Hex;
66
+ payloadDigest: Hex;
67
+ }, checkpointNumber: CheckpointNumber, blockHash: Hex): Promise<CheckpointData | undefined>;
68
+ /**
69
+ * Attempts to decode transaction input as multicall3 and extract propose calldata.
70
+ * Finds all calls matching the rollup address and propose selector, then decodes
71
+ * and verifies each candidate against expected hashes from the CheckpointProposed event.
72
+ * @param tx - The transaction-like object with to, input, and hash
73
+ * @param expectedHashes - Expected hashes from CheckpointProposed event
74
+ * @param checkpointNumber - The checkpoint number
75
+ * @param blockHash - The L1 block hash
76
+ * @returns The checkpoint data if successfully validated, undefined otherwise
77
+ */
78
+ protected tryDecodeMulticall3(tx: {
79
+ to: Hex | null | undefined;
80
+ input: Hex;
81
+ hash: Hex;
82
+ }, expectedHashes: {
83
+ attestationsHash: Hex;
84
+ payloadDigest: Hex;
85
+ }, checkpointNumber: CheckpointNumber, blockHash: Hex): CheckpointData | undefined;
86
+ /**
87
+ * Attempts to decode transaction as a direct propose call to the rollup contract.
88
+ * Decodes, verifies hashes, and builds checkpoint data in a single pass.
89
+ * @param tx - The transaction-like object with to, input, and hash
90
+ * @param expectedHashes - Expected hashes from CheckpointProposed event
91
+ * @param checkpointNumber - The checkpoint number
92
+ * @param blockHash - The L1 block hash
93
+ * @returns The checkpoint data if successfully validated, undefined otherwise
94
+ */
95
+ protected tryDecodeDirectPropose(tx: {
96
+ to: Hex | null | undefined;
97
+ input: Hex;
98
+ hash: Hex;
99
+ }, expectedHashes: {
100
+ attestationsHash: Hex;
101
+ payloadDigest: Hex;
102
+ }, checkpointNumber: CheckpointNumber, blockHash: Hex): CheckpointData | undefined;
103
+ /**
104
+ * Uses debug/trace RPC to extract the actual calldata from the successful propose call.
105
+ * This is the definitive fallback that works for any transaction pattern.
106
+ * Tries trace_transaction first, then falls back to debug_traceTransaction.
107
+ * @param txHash - The transaction hash to trace
108
+ * @returns The propose calldata from the successful call
109
+ */
110
+ protected extractCalldataViaTrace(txHash: Hex): Promise<Hex>;
111
+ /**
112
+ * Decodes propose calldata, verifies against expected hashes, and builds checkpoint data.
113
+ * Returns undefined on decode errors or hash mismatches (soft failure for try-based callers).
114
+ * @param proposeCalldata - The propose function calldata
115
+ * @param expectedHashes - Expected hashes from the CheckpointProposed event
116
+ * @param checkpointNumber - The checkpoint number
117
+ * @param blockHash - The L1 block hash
118
+ * @returns The decoded checkpoint data, or undefined on failure
119
+ */
120
+ protected tryDecodeAndVerifyPropose(proposeCalldata: Hex, expectedHashes: {
121
+ attestationsHash: Hex;
122
+ payloadDigest: Hex;
123
+ }, checkpointNumber: CheckpointNumber, blockHash: Hex): CheckpointData | undefined;
124
+ /** Computes the keccak256 hash of ABI-encoded CommitteeAttestations. */
125
+ private computeAttestationsHash;
126
+ /** Computes the keccak256 payload digest from the checkpoint header, archive root, and fee asset price modifier. */
127
+ private computePayloadDigest;
128
+ /**
129
+ * Extracts the CommitteeAttestations struct definition from RollupAbi.
130
+ * Finds the _attestations parameter by name in the propose function.
131
+ */
132
+ private getCommitteeAttestation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