@aztec/archiver 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107

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 (133) hide show
  1. package/README.md +27 -6
  2. package/dest/archiver/archiver.d.ts +127 -84
  3. package/dest/archiver/archiver.d.ts.map +1 -1
  4. package/dest/archiver/archiver.js +1128 -380
  5. package/dest/archiver/archiver_store.d.ts +122 -45
  6. package/dest/archiver/archiver_store.d.ts.map +1 -1
  7. package/dest/archiver/archiver_store_test_suite.d.ts +1 -1
  8. package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
  9. package/dest/archiver/archiver_store_test_suite.js +2013 -343
  10. package/dest/archiver/config.d.ts +7 -20
  11. package/dest/archiver/config.d.ts.map +1 -1
  12. package/dest/archiver/config.js +21 -5
  13. package/dest/archiver/errors.d.ts +25 -1
  14. package/dest/archiver/errors.d.ts.map +1 -1
  15. package/dest/archiver/errors.js +37 -0
  16. package/dest/archiver/index.d.ts +2 -2
  17. package/dest/archiver/index.d.ts.map +1 -1
  18. package/dest/archiver/instrumentation.d.ts +5 -3
  19. package/dest/archiver/instrumentation.d.ts.map +1 -1
  20. package/dest/archiver/instrumentation.js +14 -0
  21. package/dest/archiver/kv_archiver_store/block_store.d.ts +83 -15
  22. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
  23. package/dest/archiver/kv_archiver_store/block_store.js +396 -73
  24. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +2 -2
  25. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
  26. package/dest/archiver/kv_archiver_store/contract_class_store.js +1 -1
  27. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +2 -2
  28. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
  29. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +51 -55
  30. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
  31. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +82 -46
  32. package/dest/archiver/kv_archiver_store/log_store.d.ts +12 -16
  33. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
  34. package/dest/archiver/kv_archiver_store/log_store.js +149 -84
  35. package/dest/archiver/kv_archiver_store/message_store.d.ts +6 -5
  36. package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
  37. package/dest/archiver/kv_archiver_store/message_store.js +15 -14
  38. package/dest/archiver/l1/bin/retrieve-calldata.d.ts +3 -0
  39. package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +1 -0
  40. package/dest/archiver/l1/bin/retrieve-calldata.js +149 -0
  41. package/dest/archiver/l1/calldata_retriever.d.ts +112 -0
  42. package/dest/archiver/l1/calldata_retriever.d.ts.map +1 -0
  43. package/dest/archiver/l1/calldata_retriever.js +471 -0
  44. package/dest/archiver/l1/data_retrieval.d.ts +90 -0
  45. package/dest/archiver/l1/data_retrieval.d.ts.map +1 -0
  46. package/dest/archiver/l1/data_retrieval.js +331 -0
  47. package/dest/archiver/l1/debug_tx.d.ts +19 -0
  48. package/dest/archiver/l1/debug_tx.d.ts.map +1 -0
  49. package/dest/archiver/l1/debug_tx.js +73 -0
  50. package/dest/archiver/l1/spire_proposer.d.ts +70 -0
  51. package/dest/archiver/l1/spire_proposer.d.ts.map +1 -0
  52. package/dest/archiver/l1/spire_proposer.js +157 -0
  53. package/dest/archiver/l1/trace_tx.d.ts +97 -0
  54. package/dest/archiver/l1/trace_tx.d.ts.map +1 -0
  55. package/dest/archiver/l1/trace_tx.js +91 -0
  56. package/dest/archiver/l1/types.d.ts +12 -0
  57. package/dest/archiver/l1/types.d.ts.map +1 -0
  58. package/dest/archiver/l1/types.js +3 -0
  59. package/dest/archiver/l1/validate_trace.d.ts +29 -0
  60. package/dest/archiver/l1/validate_trace.d.ts.map +1 -0
  61. package/dest/archiver/l1/validate_trace.js +150 -0
  62. package/dest/archiver/structs/data_retrieval.d.ts +1 -1
  63. package/dest/archiver/structs/inbox_message.d.ts +4 -4
  64. package/dest/archiver/structs/inbox_message.d.ts.map +1 -1
  65. package/dest/archiver/structs/inbox_message.js +6 -5
  66. package/dest/archiver/structs/published.d.ts +2 -2
  67. package/dest/archiver/structs/published.d.ts.map +1 -1
  68. package/dest/archiver/validation.d.ts +10 -4
  69. package/dest/archiver/validation.d.ts.map +1 -1
  70. package/dest/archiver/validation.js +66 -44
  71. package/dest/factory.d.ts +4 -6
  72. package/dest/factory.d.ts.map +1 -1
  73. package/dest/factory.js +5 -4
  74. package/dest/index.d.ts +2 -2
  75. package/dest/index.d.ts.map +1 -1
  76. package/dest/index.js +1 -1
  77. package/dest/rpc/index.d.ts +2 -2
  78. package/dest/test/index.d.ts +1 -1
  79. package/dest/test/mock_archiver.d.ts +16 -8
  80. package/dest/test/mock_archiver.d.ts.map +1 -1
  81. package/dest/test/mock_archiver.js +19 -14
  82. package/dest/test/mock_l1_to_l2_message_source.d.ts +7 -6
  83. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
  84. package/dest/test/mock_l1_to_l2_message_source.js +10 -9
  85. package/dest/test/mock_l2_block_source.d.ts +31 -20
  86. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  87. package/dest/test/mock_l2_block_source.js +85 -18
  88. package/dest/test/mock_structs.d.ts +3 -2
  89. package/dest/test/mock_structs.d.ts.map +1 -1
  90. package/dest/test/mock_structs.js +9 -8
  91. package/package.json +18 -17
  92. package/src/archiver/archiver.ts +971 -475
  93. package/src/archiver/archiver_store.ts +141 -44
  94. package/src/archiver/archiver_store_test_suite.ts +2114 -331
  95. package/src/archiver/config.ts +30 -35
  96. package/src/archiver/errors.ts +64 -0
  97. package/src/archiver/index.ts +1 -1
  98. package/src/archiver/instrumentation.ts +19 -2
  99. package/src/archiver/kv_archiver_store/block_store.ts +541 -83
  100. package/src/archiver/kv_archiver_store/contract_class_store.ts +1 -1
  101. package/src/archiver/kv_archiver_store/contract_instance_store.ts +1 -1
  102. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +107 -67
  103. package/src/archiver/kv_archiver_store/log_store.ts +209 -99
  104. package/src/archiver/kv_archiver_store/message_store.ts +21 -18
  105. package/src/archiver/l1/README.md +98 -0
  106. package/src/archiver/l1/bin/retrieve-calldata.ts +182 -0
  107. package/src/archiver/l1/calldata_retriever.ts +641 -0
  108. package/src/archiver/l1/data_retrieval.ts +512 -0
  109. package/src/archiver/l1/debug_tx.ts +99 -0
  110. package/src/archiver/l1/spire_proposer.ts +160 -0
  111. package/src/archiver/l1/trace_tx.ts +128 -0
  112. package/src/archiver/l1/types.ts +13 -0
  113. package/src/archiver/l1/validate_trace.ts +211 -0
  114. package/src/archiver/structs/inbox_message.ts +8 -8
  115. package/src/archiver/structs/published.ts +1 -1
  116. package/src/archiver/validation.ts +86 -32
  117. package/src/factory.ts +6 -7
  118. package/src/index.ts +1 -1
  119. package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
  120. package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
  121. package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
  122. package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
  123. package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
  124. package/src/test/fixtures/trace_transaction-proxied.json +128 -0
  125. package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
  126. package/src/test/mock_archiver.ts +22 -16
  127. package/src/test/mock_l1_to_l2_message_source.ts +10 -9
  128. package/src/test/mock_l2_block_source.ts +114 -27
  129. package/src/test/mock_structs.ts +10 -9
  130. package/dest/archiver/data_retrieval.d.ts +0 -78
  131. package/dest/archiver/data_retrieval.d.ts.map +0 -1
  132. package/dest/archiver/data_retrieval.js +0 -354
  133. package/src/archiver/data_retrieval.ts +0 -535
@@ -0,0 +1,182 @@
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
+
7
+ import { type Hex, createPublicClient, http } from 'viem';
8
+ import { mainnet } from 'viem/chains';
9
+
10
+ import { CalldataRetriever } from '../calldata_retriever.js';
11
+
12
+ const logger = createLogger('archiver:calldata-test');
13
+
14
+ interface ScriptArgs {
15
+ rollupAddress: EthAddress;
16
+ txHash: Hex;
17
+ rpcUrl: string;
18
+ targetCommitteeSize: number;
19
+ }
20
+
21
+ function parseArgs(): ScriptArgs {
22
+ const args = process.argv.slice(2);
23
+
24
+ if (args.length < 2) {
25
+ // eslint-disable-next-line no-console
26
+ console.error('Usage: node index.js <rollup-address> <tx-hash> [target-committee-size]');
27
+ // eslint-disable-next-line no-console
28
+ console.error('');
29
+ // eslint-disable-next-line no-console
30
+ console.error('Environment variables:');
31
+ // eslint-disable-next-line no-console
32
+ console.error(' ETHEREUM_HOST or RPC_URL - Ethereum RPC endpoint');
33
+ // eslint-disable-next-line no-console
34
+ console.error('');
35
+ // eslint-disable-next-line no-console
36
+ console.error('Example:');
37
+ // eslint-disable-next-line no-console
38
+ console.error(' RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY \\');
39
+ // eslint-disable-next-line no-console
40
+ console.error(' node index.js 0x1234... 0xabcd... 32');
41
+ process.exit(1);
42
+ }
43
+
44
+ const rollupAddress = EthAddress.fromString(args[0]);
45
+ const txHash = args[1] as Hex;
46
+ const targetCommitteeSize = args[2] ? parseInt(args[2], 10) : 24;
47
+
48
+ const rpcUrl = process.env.ETHEREUM_HOST || process.env.RPC_URL;
49
+ if (!rpcUrl) {
50
+ // eslint-disable-next-line no-console
51
+ console.error('Error: ETHEREUM_HOST or RPC_URL environment variable must be set');
52
+ process.exit(1);
53
+ }
54
+
55
+ if (targetCommitteeSize <= 0 || targetCommitteeSize > 256) {
56
+ // eslint-disable-next-line no-console
57
+ console.error('Error: target-committee-size must be between 1 and 256');
58
+ process.exit(1);
59
+ }
60
+
61
+ return { rollupAddress, txHash, rpcUrl, targetCommitteeSize };
62
+ }
63
+
64
+ async function main() {
65
+ const { rollupAddress, txHash, rpcUrl, targetCommitteeSize } = parseArgs();
66
+
67
+ logger.info('Calldata Retriever Test Script');
68
+ logger.info('===============================');
69
+ logger.info(`Rollup Address: ${rollupAddress.toString()}`);
70
+ logger.info(`Transaction Hash: ${txHash}`);
71
+ logger.info(`RPC URL: ${rpcUrl}`);
72
+ logger.info(`Target Committee Size: ${targetCommitteeSize}`);
73
+ logger.info('');
74
+
75
+ try {
76
+ // Create viem public client
77
+ const publicClient = createPublicClient({
78
+ chain: mainnet,
79
+ transport: http(rpcUrl, { batch: false }),
80
+ });
81
+
82
+ logger.info('Fetching transaction...');
83
+ const tx = await publicClient.getTransaction({ hash: txHash });
84
+
85
+ if (!tx) {
86
+ throw new Error(`Transaction ${txHash} not found`);
87
+ }
88
+
89
+ logger.info(`Transaction found in block ${tx.blockNumber}`);
90
+
91
+ // For simplicity, use zero addresses for optional contract addresses
92
+ // In production, these would be fetched from the rollup contract or configuration
93
+ const slashingProposerAddress = EthAddress.ZERO;
94
+ const governanceProposerAddress = EthAddress.ZERO;
95
+ const slashFactoryAddress = undefined;
96
+
97
+ logger.info('Using zero addresses for governance/slashing (can be configured if needed)');
98
+
99
+ // Create CalldataRetriever
100
+ const retriever = new CalldataRetriever(
101
+ publicClient as unknown as ViemPublicClient,
102
+ publicClient as unknown as ViemPublicDebugClient,
103
+ targetCommitteeSize,
104
+ undefined,
105
+ logger,
106
+ {
107
+ rollupAddress,
108
+ governanceProposerAddress,
109
+ slashingProposerAddress,
110
+ slashFactoryAddress,
111
+ },
112
+ );
113
+
114
+ // Extract L2 block number from transaction logs
115
+ logger.info('Decoding transaction to extract L2 block number...');
116
+ const receipt = await publicClient.getTransactionReceipt({ hash: txHash });
117
+ const l2BlockProposedEvent = receipt.logs.find(log => {
118
+ try {
119
+ // Try to match the L2BlockProposed event
120
+ return (
121
+ log.address.toLowerCase() === rollupAddress.toString().toLowerCase() &&
122
+ log.topics[0] === '0x2f1d0e696fa5186494a2f2f89a0e0bcbb15d607f6c5eac4637e07e1e5e7d3c00' // L2BlockProposed event signature
123
+ );
124
+ } catch {
125
+ return false;
126
+ }
127
+ });
128
+
129
+ let l2BlockNumber: number;
130
+ if (l2BlockProposedEvent && l2BlockProposedEvent.topics[1]) {
131
+ // L2 block number is typically the first indexed parameter
132
+ l2BlockNumber = Number(BigInt(l2BlockProposedEvent.topics[1]));
133
+ logger.info(`L2 Block Number (from event): ${l2BlockNumber}`);
134
+ } else {
135
+ // Fallback: try to extract from transaction data or use a default
136
+ logger.warn('Could not extract L2 block number from event, using block number as fallback');
137
+ l2BlockNumber = Number(tx.blockNumber);
138
+ }
139
+
140
+ logger.info('');
141
+ logger.info('Retrieving block header from rollup transaction...');
142
+ logger.info('');
143
+
144
+ // For this script, we don't have blob hashes or expected hashes, so pass empty arrays/objects
145
+ const result = await retriever.getCheckpointFromRollupTx(txHash, [], CheckpointNumber(l2BlockNumber), {});
146
+
147
+ logger.info(' Successfully retrieved block header!');
148
+ logger.info('');
149
+ logger.info('Block Header Details:');
150
+ logger.info('====================');
151
+ logger.info(`Checkpoint Number: ${result.checkpointNumber}`);
152
+ logger.info(`Block Hash: ${result.blockHash}`);
153
+ logger.info(`Archive Root: ${result.archiveRoot.toString()}`);
154
+ logger.info('');
155
+ logger.info('Header:');
156
+ logger.info(` Slot Number: ${result.header.slotNumber.toString()}`);
157
+ logger.info(` Timestamp: ${result.header.timestamp.toString()}`);
158
+ logger.info(` Coinbase: ${result.header.coinbase.toString()}`);
159
+ logger.info(` Fee Recipient: ${result.header.feeRecipient.toString()}`);
160
+ logger.info(` Total Mana Used: ${result.header.totalManaUsed.toString()}`);
161
+ logger.info('');
162
+ logger.info('Attestations:');
163
+ logger.info(` Count: ${result.attestations.length}`);
164
+ logger.info(` Non-empty attestations: ${result.attestations.filter((a: any) => !a.signature.isEmpty()).length}`);
165
+
166
+ process.exit(0);
167
+ } catch (error) {
168
+ logger.error('Error retrieving block header:');
169
+ logger.error(error instanceof Error ? error.message : String(error));
170
+
171
+ if (error instanceof Error && error.stack) {
172
+ logger.debug(error.stack);
173
+ }
174
+
175
+ process.exit(1);
176
+ }
177
+ }
178
+
179
+ // Only run if this is the main module
180
+ if (import.meta.url === `file://${process.argv[1]}`) {
181
+ void main();
182
+ }