@aztec/archiver 0.0.0-test.1 → 0.0.1-commit.0208eb9
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.
- package/README.md +164 -9
- package/dest/archiver.d.ts +136 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +781 -0
- package/dest/config.d.ts +30 -0
- package/dest/config.d.ts.map +1 -0
- package/dest/config.js +71 -0
- package/dest/errors.d.ts +41 -0
- package/dest/errors.d.ts.map +1 -0
- package/dest/errors.js +62 -0
- package/dest/factory.d.ts +13 -16
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +103 -55
- package/dest/index.d.ts +10 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +8 -3
- package/dest/interfaces.d.ts +9 -0
- package/dest/interfaces.d.ts.map +1 -0
- package/dest/interfaces.js +3 -0
- package/dest/l1/bin/retrieve-calldata.d.ts +3 -0
- package/dest/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/l1/bin/retrieve-calldata.js +149 -0
- package/dest/l1/calldata_retriever.d.ts +112 -0
- package/dest/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/l1/calldata_retriever.js +471 -0
- package/dest/l1/data_retrieval.d.ts +88 -0
- package/dest/l1/data_retrieval.d.ts.map +1 -0
- package/dest/l1/data_retrieval.js +312 -0
- package/dest/l1/debug_tx.d.ts +19 -0
- package/dest/l1/debug_tx.d.ts.map +1 -0
- package/dest/l1/debug_tx.js +73 -0
- package/dest/l1/spire_proposer.d.ts +70 -0
- package/dest/l1/spire_proposer.d.ts.map +1 -0
- package/dest/l1/spire_proposer.js +157 -0
- package/dest/l1/trace_tx.d.ts +97 -0
- package/dest/l1/trace_tx.d.ts.map +1 -0
- package/dest/l1/trace_tx.js +91 -0
- package/dest/l1/types.d.ts +12 -0
- package/dest/l1/types.d.ts.map +1 -0
- package/dest/l1/types.js +3 -0
- package/dest/l1/validate_trace.d.ts +32 -0
- package/dest/l1/validate_trace.d.ts.map +1 -0
- package/dest/l1/validate_trace.js +154 -0
- package/dest/modules/data_source_base.d.ts +84 -0
- package/dest/modules/data_source_base.d.ts.map +1 -0
- package/dest/modules/data_source_base.js +260 -0
- package/dest/modules/data_store_updater.d.ts +73 -0
- package/dest/modules/data_store_updater.d.ts.map +1 -0
- package/dest/modules/data_store_updater.js +302 -0
- package/dest/modules/instrumentation.d.ts +37 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/modules/instrumentation.js +110 -0
- package/dest/modules/l1_synchronizer.d.ts +75 -0
- package/dest/modules/l1_synchronizer.d.ts.map +1 -0
- package/dest/modules/l1_synchronizer.js +1112 -0
- package/dest/modules/validation.d.ts +17 -0
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/modules/validation.js +104 -0
- package/dest/store/block_store.d.ts +192 -0
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/store/block_store.js +721 -0
- package/dest/store/contract_class_store.d.ts +18 -0
- package/dest/store/contract_class_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/contract_class_store.js +25 -27
- package/dest/store/contract_instance_store.d.ts +24 -0
- package/dest/store/contract_instance_store.d.ts.map +1 -0
- package/dest/store/contract_instance_store.js +77 -0
- package/dest/store/kv_archiver_store.d.ts +340 -0
- package/dest/store/kv_archiver_store.d.ts.map +1 -0
- package/dest/store/kv_archiver_store.js +446 -0
- package/dest/store/log_store.d.ts +54 -0
- package/dest/store/log_store.d.ts.map +1 -0
- package/dest/store/log_store.js +436 -0
- package/dest/store/message_store.d.ts +40 -0
- package/dest/store/message_store.d.ts.map +1 -0
- package/dest/store/message_store.js +188 -0
- package/dest/structs/data_retrieval.d.ts +27 -0
- package/dest/structs/data_retrieval.d.ts.map +1 -0
- package/dest/structs/inbox_message.d.ts +15 -0
- package/dest/structs/inbox_message.d.ts.map +1 -0
- package/dest/structs/inbox_message.js +39 -0
- package/dest/structs/published.d.ts +2 -0
- package/dest/structs/published.d.ts.map +1 -0
- package/dest/structs/published.js +1 -0
- package/dest/test/fake_l1_state.d.ts +190 -0
- package/dest/test/fake_l1_state.d.ts.map +1 -0
- package/dest/test/fake_l1_state.js +383 -0
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +4 -1
- package/dest/test/mock_archiver.d.ts +16 -8
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +18 -14
- package/dest/test/mock_l1_to_l2_message_source.d.ts +9 -6
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +30 -7
- package/dest/test/mock_l2_block_source.d.ts +62 -16
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +263 -32
- package/dest/test/mock_structs.d.ts +85 -0
- package/dest/test/mock_structs.d.ts.map +1 -0
- package/dest/test/mock_structs.js +171 -0
- package/dest/test/noop_l1_archiver.d.ts +23 -0
- package/dest/test/noop_l1_archiver.d.ts.map +1 -0
- package/dest/test/noop_l1_archiver.js +68 -0
- package/package.json +31 -33
- package/src/archiver.ts +543 -0
- package/src/config.ts +95 -0
- package/src/errors.ts +102 -0
- package/src/factory.ts +144 -71
- package/src/index.ts +10 -3
- package/src/interfaces.ts +9 -0
- package/src/l1/README.md +98 -0
- package/src/l1/bin/retrieve-calldata.ts +187 -0
- package/src/l1/calldata_retriever.ts +641 -0
- package/src/l1/data_retrieval.ts +495 -0
- package/src/l1/debug_tx.ts +99 -0
- package/src/l1/spire_proposer.ts +160 -0
- package/src/l1/trace_tx.ts +128 -0
- package/src/l1/types.ts +13 -0
- package/src/l1/validate_trace.ts +229 -0
- package/src/modules/data_source_base.ts +367 -0
- package/src/modules/data_store_updater.ts +423 -0
- package/src/modules/instrumentation.ts +157 -0
- package/src/modules/l1_synchronizer.ts +930 -0
- package/src/modules/validation.ts +129 -0
- package/src/store/block_store.ts +966 -0
- package/src/{archiver/kv_archiver_store → store}/contract_class_store.ts +26 -32
- package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +37 -29
- package/src/store/kv_archiver_store.ts +639 -0
- package/src/store/log_store.ts +575 -0
- package/src/store/message_store.ts +261 -0
- package/src/structs/inbox_message.ts +41 -0
- package/src/structs/published.ts +1 -0
- package/src/test/fake_l1_state.ts +599 -0
- package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
- package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
- package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
- package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
- package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
- package/src/test/fixtures/trace_transaction-proxied.json +128 -0
- package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
- package/src/test/index.ts +4 -0
- package/src/test/mock_archiver.ts +22 -16
- package/src/test/mock_l1_to_l2_message_source.ts +26 -8
- package/src/test/mock_l2_block_source.ts +313 -42
- package/src/test/mock_structs.ts +311 -0
- package/src/test/noop_l1_archiver.ts +109 -0
- package/dest/archiver/archiver.d.ts +0 -197
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -900
- package/dest/archiver/archiver_store.d.ts +0 -220
- package/dest/archiver/archiver_store.d.ts.map +0 -1
- package/dest/archiver/archiver_store.js +0 -4
- package/dest/archiver/archiver_store_test_suite.d.ts +0 -8
- package/dest/archiver/archiver_store_test_suite.d.ts.map +0 -1
- package/dest/archiver/archiver_store_test_suite.js +0 -794
- package/dest/archiver/config.d.ts +0 -37
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/config.js +0 -46
- package/dest/archiver/data_retrieval.d.ts +0 -74
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/data_retrieval.js +0 -283
- package/dest/archiver/errors.d.ts +0 -4
- package/dest/archiver/errors.d.ts.map +0 -1
- package/dest/archiver/errors.js +0 -5
- package/dest/archiver/index.d.ts +0 -8
- package/dest/archiver/index.d.ts.map +0 -1
- package/dest/archiver/index.js +0 -5
- package/dest/archiver/instrumentation.d.ts +0 -29
- package/dest/archiver/instrumentation.d.ts.map +0 -1
- package/dest/archiver/instrumentation.js +0 -99
- package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -87
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.js +0 -217
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +0 -18
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -21
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.js +0 -63
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -153
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +0 -254
- package/dest/archiver/kv_archiver_store/log_store.d.ts +0 -49
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/log_store.js +0 -364
- package/dest/archiver/kv_archiver_store/message_store.d.ts +0 -33
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/message_store.js +0 -85
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +0 -23
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +0 -49
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -636
- package/dest/archiver/structs/data_retrieval.d.ts +0 -27
- package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/structs/published.d.ts +0 -11
- package/dest/archiver/structs/published.d.ts.map +0 -1
- package/dest/archiver/structs/published.js +0 -1
- package/dest/rpc/index.d.ts +0 -10
- package/dest/rpc/index.d.ts.map +0 -1
- package/dest/rpc/index.js +0 -18
- package/src/archiver/archiver.ts +0 -1181
- package/src/archiver/archiver_store.ts +0 -263
- package/src/archiver/archiver_store_test_suite.ts +0 -810
- package/src/archiver/config.ts +0 -92
- package/src/archiver/data_retrieval.ts +0 -422
- package/src/archiver/errors.ts +0 -5
- package/src/archiver/index.ts +0 -7
- package/src/archiver/instrumentation.ts +0 -132
- package/src/archiver/kv_archiver_store/block_store.ts +0 -283
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -358
- package/src/archiver/kv_archiver_store/log_store.ts +0 -444
- package/src/archiver/kv_archiver_store/message_store.ts +0 -102
- package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
- package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +0 -61
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
- package/src/archiver/structs/published.ts +0 -11
- package/src/rpc/index.ts +0 -20
- /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
- /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { createPublicClient, http } from 'viem';
|
|
6
|
+
import { mainnet } from 'viem/chains';
|
|
7
|
+
import { CalldataRetriever } from '../calldata_retriever.js';
|
|
8
|
+
const logger = createLogger('archiver:calldata-test');
|
|
9
|
+
function parseArgs() {
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
if (args.length < 2) {
|
|
12
|
+
// eslint-disable-next-line no-console
|
|
13
|
+
console.error('Usage: node index.js <rollup-address> <tx-hash> [target-committee-size]');
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.error('');
|
|
16
|
+
// eslint-disable-next-line no-console
|
|
17
|
+
console.error('Environment variables:');
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.error(' ETHEREUM_HOST or RPC_URL - Ethereum RPC endpoint');
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.error('');
|
|
22
|
+
// eslint-disable-next-line no-console
|
|
23
|
+
console.error('Example:');
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.error(' RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY \\');
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.error(' node index.js 0x1234... 0xabcd... 32');
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
const rollupAddress = EthAddress.fromString(args[0]);
|
|
31
|
+
const txHash = args[1];
|
|
32
|
+
const targetCommitteeSize = args[2] ? parseInt(args[2], 10) : 24;
|
|
33
|
+
const rpcUrl = process.env.ETHEREUM_HOST || process.env.RPC_URL;
|
|
34
|
+
if (!rpcUrl) {
|
|
35
|
+
// eslint-disable-next-line no-console
|
|
36
|
+
console.error('Error: ETHEREUM_HOST or RPC_URL environment variable must be set');
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
if (targetCommitteeSize <= 0 || targetCommitteeSize > 256) {
|
|
40
|
+
// eslint-disable-next-line no-console
|
|
41
|
+
console.error('Error: target-committee-size must be between 1 and 256');
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
rollupAddress,
|
|
46
|
+
txHash,
|
|
47
|
+
rpcUrl,
|
|
48
|
+
targetCommitteeSize
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
async function main() {
|
|
52
|
+
const { rollupAddress, txHash, rpcUrl, targetCommitteeSize } = parseArgs();
|
|
53
|
+
logger.info('Calldata Retriever Test Script');
|
|
54
|
+
logger.info('===============================');
|
|
55
|
+
logger.info(`Rollup Address: ${rollupAddress.toString()}`);
|
|
56
|
+
logger.info(`Transaction Hash: ${txHash}`);
|
|
57
|
+
logger.info(`RPC URL: ${rpcUrl}`);
|
|
58
|
+
logger.info(`Target Committee Size: ${targetCommitteeSize}`);
|
|
59
|
+
logger.info('');
|
|
60
|
+
try {
|
|
61
|
+
// Create viem public client
|
|
62
|
+
const publicClient = createPublicClient({
|
|
63
|
+
chain: mainnet,
|
|
64
|
+
transport: http(rpcUrl, {
|
|
65
|
+
batch: false
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
logger.info('Fetching transaction...');
|
|
69
|
+
const tx = await publicClient.getTransaction({
|
|
70
|
+
hash: txHash
|
|
71
|
+
});
|
|
72
|
+
if (!tx) {
|
|
73
|
+
throw new Error(`Transaction ${txHash} not found`);
|
|
74
|
+
}
|
|
75
|
+
logger.info(`Transaction found in block ${tx.blockNumber}`);
|
|
76
|
+
// For simplicity, use zero addresses for optional contract addresses
|
|
77
|
+
// In production, these would be fetched from the rollup contract or configuration
|
|
78
|
+
const slashingProposerAddress = EthAddress.ZERO;
|
|
79
|
+
const governanceProposerAddress = EthAddress.ZERO;
|
|
80
|
+
const slashFactoryAddress = undefined;
|
|
81
|
+
logger.info('Using zero addresses for governance/slashing (can be configured if needed)');
|
|
82
|
+
// Create CalldataRetriever
|
|
83
|
+
const retriever = new CalldataRetriever(publicClient, publicClient, targetCommitteeSize, undefined, logger, {
|
|
84
|
+
rollupAddress,
|
|
85
|
+
governanceProposerAddress,
|
|
86
|
+
slashingProposerAddress,
|
|
87
|
+
slashFactoryAddress
|
|
88
|
+
});
|
|
89
|
+
// Extract L2 block number from transaction logs
|
|
90
|
+
logger.info('Decoding transaction to extract L2 block number...');
|
|
91
|
+
const receipt = await publicClient.getTransactionReceipt({
|
|
92
|
+
hash: txHash
|
|
93
|
+
});
|
|
94
|
+
const l2BlockProposedEvent = receipt.logs.find((log)=>{
|
|
95
|
+
try {
|
|
96
|
+
// Try to match the L2BlockProposed event
|
|
97
|
+
return log.address.toLowerCase() === rollupAddress.toString().toLowerCase() && log.topics[0] === '0x2f1d0e696fa5186494a2f2f89a0e0bcbb15d607f6c5eac4637e07e1e5e7d3c00' // L2BlockProposed event signature
|
|
98
|
+
;
|
|
99
|
+
} catch {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
let l2BlockNumber;
|
|
104
|
+
if (l2BlockProposedEvent && l2BlockProposedEvent.topics[1]) {
|
|
105
|
+
// L2 block number is typically the first indexed parameter
|
|
106
|
+
l2BlockNumber = Number(BigInt(l2BlockProposedEvent.topics[1]));
|
|
107
|
+
logger.info(`L2 Block Number (from event): ${l2BlockNumber}`);
|
|
108
|
+
} else {
|
|
109
|
+
// Fallback: try to extract from transaction data or use a default
|
|
110
|
+
logger.warn('Could not extract L2 block number from event, using block number as fallback');
|
|
111
|
+
l2BlockNumber = Number(tx.blockNumber);
|
|
112
|
+
}
|
|
113
|
+
logger.info('');
|
|
114
|
+
logger.info('Retrieving block header from rollup transaction...');
|
|
115
|
+
logger.info('');
|
|
116
|
+
// For this script, we don't have blob hashes or expected hashes, so pass empty arrays/objects
|
|
117
|
+
const result = await retriever.getCheckpointFromRollupTx(txHash, [], CheckpointNumber.fromBlockNumber(BlockNumber(l2BlockNumber)), {});
|
|
118
|
+
logger.info(' Successfully retrieved block header!');
|
|
119
|
+
logger.info('');
|
|
120
|
+
logger.info('Block Header Details:');
|
|
121
|
+
logger.info('====================');
|
|
122
|
+
logger.info(`Checkpoint Number: ${result.checkpointNumber}`);
|
|
123
|
+
logger.info(`Block Hash: ${result.blockHash}`);
|
|
124
|
+
logger.info(`Archive Root: ${result.archiveRoot.toString()}`);
|
|
125
|
+
logger.info('');
|
|
126
|
+
logger.info('Header:');
|
|
127
|
+
logger.info(` Slot Number: ${result.header.slotNumber.toString()}`);
|
|
128
|
+
logger.info(` Timestamp: ${result.header.timestamp.toString()}`);
|
|
129
|
+
logger.info(` Coinbase: ${result.header.coinbase.toString()}`);
|
|
130
|
+
logger.info(` Fee Recipient: ${result.header.feeRecipient.toString()}`);
|
|
131
|
+
logger.info(` Total Mana Used: ${result.header.totalManaUsed.toString()}`);
|
|
132
|
+
logger.info('');
|
|
133
|
+
logger.info('Attestations:');
|
|
134
|
+
logger.info(` Count: ${result.attestations.length}`);
|
|
135
|
+
logger.info(` Non-empty attestations: ${result.attestations.filter((a)=>!a.signature.isEmpty()).length}`);
|
|
136
|
+
process.exit(0);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
logger.error('Error retrieving block header:');
|
|
139
|
+
logger.error(error instanceof Error ? error.message : String(error));
|
|
140
|
+
if (error instanceof Error && error.stack) {
|
|
141
|
+
logger.debug(error.stack);
|
|
142
|
+
}
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Only run if this is the main module
|
|
147
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
148
|
+
void main();
|
|
149
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* Extracts calldata to the `propose` method of the rollup contract from an L1 transaction
|
|
12
|
+
* in order to reconstruct an L2 block header.
|
|
13
|
+
*/
|
|
14
|
+
export declare class CalldataRetriever {
|
|
15
|
+
private readonly publicClient;
|
|
16
|
+
private readonly debugClient;
|
|
17
|
+
private readonly targetCommitteeSize;
|
|
18
|
+
private readonly instrumentation;
|
|
19
|
+
private readonly logger;
|
|
20
|
+
/** Pre-computed valid contract calls for validation */
|
|
21
|
+
private readonly validContractCalls;
|
|
22
|
+
private readonly rollupAddress;
|
|
23
|
+
constructor(publicClient: ViemPublicClient, debugClient: ViemPublicDebugClient, targetCommitteeSize: number, instrumentation: ArchiverInstrumentation | undefined, logger: Logger, contractAddresses: {
|
|
24
|
+
rollupAddress: EthAddress;
|
|
25
|
+
governanceProposerAddress: EthAddress;
|
|
26
|
+
slashingProposerAddress: EthAddress;
|
|
27
|
+
slashFactoryAddress?: EthAddress;
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Gets checkpoint header and metadata from the calldata of an L1 transaction.
|
|
31
|
+
* Tries multicall3 decoding, falls back to trace-based extraction.
|
|
32
|
+
* @param txHash - Hash of the tx that published it.
|
|
33
|
+
* @param blobHashes - Blob hashes for the checkpoint.
|
|
34
|
+
* @param checkpointNumber - Checkpoint number.
|
|
35
|
+
* @param expectedHashes - Optional expected hashes from the CheckpointProposed event for validation
|
|
36
|
+
* @returns Checkpoint header and metadata from the calldata, deserialized
|
|
37
|
+
*/
|
|
38
|
+
getCheckpointFromRollupTx(txHash: `0x${string}`, _blobHashes: Buffer[], checkpointNumber: CheckpointNumber, expectedHashes: {
|
|
39
|
+
attestationsHash?: Hex;
|
|
40
|
+
payloadDigest?: Hex;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
checkpointNumber: CheckpointNumber;
|
|
43
|
+
archiveRoot: Fr;
|
|
44
|
+
header: CheckpointHeader;
|
|
45
|
+
attestations: CommitteeAttestation[];
|
|
46
|
+
blockHash: string;
|
|
47
|
+
}>;
|
|
48
|
+
/** Gets rollup propose calldata from a transaction */
|
|
49
|
+
protected getProposeCallData(tx: Transaction, checkpointNumber: CheckpointNumber): Promise<Hex>;
|
|
50
|
+
/**
|
|
51
|
+
* Attempts to decode a transaction as a Spire Proposer multicall wrapper.
|
|
52
|
+
* If successful, extracts the wrapped call and validates it as either multicall3 or direct propose.
|
|
53
|
+
* @param tx - The transaction to decode
|
|
54
|
+
* @returns The propose calldata if successfully decoded and validated, undefined otherwise
|
|
55
|
+
*/
|
|
56
|
+
protected tryDecodeSpireProposer(tx: Transaction): Promise<Hex | undefined>;
|
|
57
|
+
/**
|
|
58
|
+
* Attempts to decode transaction input as multicall3 and extract propose calldata.
|
|
59
|
+
* Returns undefined if validation fails.
|
|
60
|
+
* @param tx - The transaction-like object with to, input, and hash
|
|
61
|
+
* @returns The propose calldata if successfully validated, undefined otherwise
|
|
62
|
+
*/
|
|
63
|
+
protected tryDecodeMulticall3(tx: {
|
|
64
|
+
to: Hex | null | undefined;
|
|
65
|
+
input: Hex;
|
|
66
|
+
hash: Hex;
|
|
67
|
+
}): Hex | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Attempts to decode transaction as a direct propose call to the rollup contract.
|
|
70
|
+
* Returns undefined if validation fails.
|
|
71
|
+
* @param tx - The transaction-like object with to, input, and hash
|
|
72
|
+
* @returns The propose calldata if successfully validated, undefined otherwise
|
|
73
|
+
*/
|
|
74
|
+
protected tryDecodeDirectPropose(tx: {
|
|
75
|
+
to: Hex | null | undefined;
|
|
76
|
+
input: Hex;
|
|
77
|
+
hash: Hex;
|
|
78
|
+
}): Hex | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Uses debug/trace RPC to extract the actual calldata from the successful propose call.
|
|
81
|
+
* This is the definitive fallback that works for any transaction pattern.
|
|
82
|
+
* Tries trace_transaction first, then falls back to debug_traceTransaction.
|
|
83
|
+
* @param txHash - The transaction hash to trace
|
|
84
|
+
* @returns The propose calldata from the successful call
|
|
85
|
+
*/
|
|
86
|
+
protected extractCalldataViaTrace(txHash: Hex): Promise<Hex>;
|
|
87
|
+
/**
|
|
88
|
+
* Extracts the CommitteeAttestations struct definition from RollupAbi.
|
|
89
|
+
* Finds the _attestations parameter by name in the propose function.
|
|
90
|
+
* Lazy-loaded to avoid issues during module initialization.
|
|
91
|
+
*/
|
|
92
|
+
private getCommitteeAttestationsStructDef;
|
|
93
|
+
/**
|
|
94
|
+
* Decodes propose calldata and builds the checkpoint header structure.
|
|
95
|
+
* @param proposeCalldata - The propose function calldata
|
|
96
|
+
* @param blockHash - The L1 block hash containing this transaction
|
|
97
|
+
* @param checkpointNumber - The checkpoint number
|
|
98
|
+
* @param expectedHashes - Optional expected hashes from the CheckpointProposed event for validation
|
|
99
|
+
* @returns The decoded checkpoint header and metadata
|
|
100
|
+
*/
|
|
101
|
+
protected decodeAndBuildCheckpoint(proposeCalldata: Hex, blockHash: Hex, checkpointNumber: CheckpointNumber, expectedHashes: {
|
|
102
|
+
attestationsHash?: Hex;
|
|
103
|
+
payloadDigest?: Hex;
|
|
104
|
+
}): {
|
|
105
|
+
checkpointNumber: CheckpointNumber;
|
|
106
|
+
archiveRoot: Fr;
|
|
107
|
+
header: CheckpointHeader;
|
|
108
|
+
attestations: CommitteeAttestation[];
|
|
109
|
+
blockHash: string;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FsbGRhdGFfcmV0cmlldmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbDEvY2FsbGRhdGFfcmV0cmlldmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLHFCQUFxQixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDckYsT0FBTyxFQUFFLGdCQUFnQixFQUFF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