@aztec/archiver 0.0.1-commit.96bb3f7 → 0.0.1-commit.96dac018d
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 +156 -22
- package/dest/archiver.d.ts +139 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +699 -0
- package/dest/{archiver/config.d.ts → config.d.ts} +9 -1
- package/dest/config.d.ts.map +1 -0
- package/dest/{archiver/config.js → config.js} +9 -0
- package/dest/errors.d.ts +41 -0
- package/dest/errors.d.ts.map +1 -0
- package/dest/{archiver/errors.js → errors.js} +8 -0
- package/dest/factory.d.ts +9 -7
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +91 -11
- package/dest/index.d.ts +11 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +9 -3
- package/dest/interfaces.d.ts +9 -0
- package/dest/interfaces.d.ts.map +1 -0
- package/dest/interfaces.js +3 -0
- package/dest/{archiver/l1 → l1}/bin/retrieve-calldata.d.ts +1 -1
- package/dest/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/bin/retrieve-calldata.js +35 -32
- package/dest/l1/calldata_retriever.d.ts +135 -0
- package/dest/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/l1/calldata_retriever.js +402 -0
- package/dest/l1/data_retrieval.d.ts +85 -0
- package/dest/l1/data_retrieval.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/data_retrieval.js +43 -66
- package/dest/{archiver/l1 → l1}/debug_tx.d.ts +1 -1
- package/dest/l1/debug_tx.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/spire_proposer.d.ts +5 -5
- package/dest/l1/spire_proposer.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/spire_proposer.js +9 -17
- package/dest/{archiver/l1 → l1}/trace_tx.d.ts +1 -1
- package/dest/l1/trace_tx.d.ts.map +1 -0
- package/dest/l1/types.d.ts +12 -0
- package/dest/l1/types.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/validate_trace.d.ts +6 -3
- package/dest/l1/validate_trace.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/validate_trace.js +13 -9
- package/dest/modules/data_source_base.d.ts +89 -0
- package/dest/modules/data_source_base.d.ts.map +1 -0
- package/dest/modules/data_source_base.js +216 -0
- package/dest/modules/data_store_updater.d.ts +80 -0
- package/dest/modules/data_store_updater.d.ts.map +1 -0
- package/dest/modules/data_store_updater.js +323 -0
- package/dest/modules/instrumentation.d.ts +50 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/{archiver → modules}/instrumentation.js +36 -12
- package/dest/modules/l1_synchronizer.d.ts +71 -0
- package/dest/modules/l1_synchronizer.d.ts.map +1 -0
- package/dest/modules/l1_synchronizer.js +1117 -0
- package/dest/{archiver → modules}/validation.d.ts +1 -1
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/{archiver → modules}/validation.js +6 -0
- package/dest/store/block_store.d.ts +196 -0
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/block_store.js +207 -60
- 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 +12 -8
- package/dest/store/contract_instance_store.d.ts +24 -0
- package/dest/store/contract_instance_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/contract_instance_store.js +1 -1
- package/dest/store/kv_archiver_store.d.ts +354 -0
- package/dest/store/kv_archiver_store.d.ts.map +1 -0
- package/dest/store/kv_archiver_store.js +464 -0
- package/dest/store/l2_tips_cache.d.ts +19 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +89 -0
- package/dest/store/log_store.d.ts +54 -0
- package/dest/store/log_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/log_store.js +146 -91
- package/dest/{archiver/kv_archiver_store → store}/message_store.d.ts +1 -1
- package/dest/store/message_store.d.ts.map +1 -0
- package/dest/{archiver/structs → structs}/data_retrieval.d.ts +1 -1
- 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/{archiver/structs → structs}/published.d.ts +1 -1
- package/dest/structs/published.d.ts.map +1 -0
- package/dest/test/fake_l1_state.d.ts +195 -0
- package/dest/test/fake_l1_state.d.ts.map +1 -0
- package/dest/test/fake_l1_state.js +421 -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 +2 -2
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +3 -3
- package/dest/test/mock_l2_block_source.d.ts +35 -17
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +177 -74
- package/dest/test/mock_structs.d.ts +78 -3
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +140 -7
- 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 +16 -17
- package/src/archiver.ts +443 -0
- package/src/{archiver/config.ts → config.ts} +11 -0
- package/src/{archiver/errors.ts → errors.ts} +12 -0
- package/src/factory.ts +139 -11
- package/src/index.ts +11 -3
- package/src/interfaces.ts +9 -0
- package/src/l1/README.md +55 -0
- package/src/{archiver/l1 → l1}/bin/retrieve-calldata.ts +45 -33
- package/src/l1/calldata_retriever.ts +511 -0
- package/src/{archiver/l1 → l1}/data_retrieval.ts +61 -88
- package/src/{archiver/l1 → l1}/spire_proposer.ts +7 -15
- package/src/{archiver/l1 → l1}/validate_trace.ts +24 -6
- package/src/modules/data_source_base.ts +328 -0
- package/src/modules/data_store_updater.ts +448 -0
- package/src/{archiver → modules}/instrumentation.ts +46 -14
- package/src/modules/l1_synchronizer.ts +933 -0
- package/src/{archiver → modules}/validation.ts +5 -0
- package/src/{archiver/kv_archiver_store → store}/block_store.ts +258 -93
- package/src/{archiver/kv_archiver_store → store}/contract_class_store.ts +12 -8
- package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +1 -1
- package/src/{archiver/kv_archiver_store → store}/kv_archiver_store.ts +267 -38
- package/src/store/l2_tips_cache.ts +89 -0
- package/src/{archiver/kv_archiver_store → store}/log_store.ts +242 -121
- package/src/test/fake_l1_state.ts +657 -0
- package/src/test/index.ts +4 -0
- package/src/test/mock_archiver.ts +4 -3
- package/src/test/mock_l2_block_source.ts +218 -90
- package/src/test/mock_structs.ts +269 -8
- package/src/test/noop_l1_archiver.ts +109 -0
- package/dest/archiver/archiver.d.ts +0 -307
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -2102
- package/dest/archiver/archiver_store.d.ts +0 -315
- 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 -2770
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/errors.d.ts +0 -36
- package/dest/archiver/errors.d.ts.map +0 -1
- package/dest/archiver/index.d.ts +0 -7
- package/dest/archiver/index.d.ts.map +0 -1
- package/dest/archiver/index.js +0 -4
- package/dest/archiver/instrumentation.d.ts +0 -37
- package/dest/archiver/instrumentation.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -164
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- 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 -24
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -159
- 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 -316
- package/dest/archiver/kv_archiver_store/log_store.d.ts +0 -45
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +0 -1
- package/dest/archiver/l1/calldata_retriever.d.ts +0 -112
- package/dest/archiver/l1/calldata_retriever.d.ts.map +0 -1
- package/dest/archiver/l1/calldata_retriever.js +0 -471
- package/dest/archiver/l1/data_retrieval.d.ts +0 -90
- package/dest/archiver/l1/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/l1/debug_tx.d.ts.map +0 -1
- package/dest/archiver/l1/spire_proposer.d.ts.map +0 -1
- package/dest/archiver/l1/trace_tx.d.ts.map +0 -1
- package/dest/archiver/l1/types.d.ts +0 -12
- package/dest/archiver/l1/types.d.ts.map +0 -1
- package/dest/archiver/l1/validate_trace.d.ts.map +0 -1
- package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/structs/inbox_message.d.ts +0 -15
- package/dest/archiver/structs/inbox_message.d.ts.map +0 -1
- package/dest/archiver/structs/published.d.ts.map +0 -1
- package/dest/archiver/validation.d.ts.map +0 -1
- package/dest/rpc/index.d.ts +0 -9
- package/dest/rpc/index.d.ts.map +0 -1
- package/dest/rpc/index.js +0 -15
- package/src/archiver/archiver.ts +0 -2265
- package/src/archiver/archiver_store.ts +0 -380
- package/src/archiver/archiver_store_test_suite.ts +0 -2842
- package/src/archiver/index.ts +0 -6
- package/src/archiver/l1/README.md +0 -98
- package/src/archiver/l1/calldata_retriever.ts +0 -641
- package/src/rpc/index.ts +0 -16
- /package/dest/{archiver/l1 → l1}/debug_tx.js +0 -0
- /package/dest/{archiver/l1 → l1}/trace_tx.js +0 -0
- /package/dest/{archiver/l1 → l1}/types.js +0 -0
- /package/dest/{archiver/kv_archiver_store → store}/message_store.js +0 -0
- /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
- /package/dest/{archiver/structs → structs}/inbox_message.js +0 -0
- /package/dest/{archiver/structs → structs}/published.js +0 -0
- /package/src/{archiver/l1 → l1}/debug_tx.ts +0 -0
- /package/src/{archiver/l1 → l1}/trace_tx.ts +0 -0
- /package/src/{archiver/l1 → l1}/types.ts +0 -0
- /package/src/{archiver/kv_archiver_store → store}/message_store.ts +0 -0
- /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
- /package/src/{archiver/structs → structs}/inbox_message.ts +0 -0
- /package/src/{archiver/structs → structs}/published.ts +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
2
|
+
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
3
|
+
import type { L2LogsSource } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Helper interface to combine all sources this archiver implementation provides.
|
|
8
|
+
*/
|
|
9
|
+
export type ArchiverDataSource = L2BlockSource & L2LogsSource & ContractDataSource & L1ToL2MessageSource;
|
package/src/l1/README.md
ADDED
|
@@ -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.
|
|
@@ -3,8 +3,9 @@ import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/ty
|
|
|
3
3
|
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
+
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
6
7
|
|
|
7
|
-
import { type Hex, createPublicClient, http } from 'viem';
|
|
8
|
+
import { type Hex, createPublicClient, decodeEventLog, getAbiItem, http, toEventSelector } from 'viem';
|
|
8
9
|
import { mainnet } from 'viem/chains';
|
|
9
10
|
|
|
10
11
|
import { CalldataRetriever } from '../calldata_retriever.js';
|
|
@@ -88,14 +89,6 @@ async function main() {
|
|
|
88
89
|
|
|
89
90
|
logger.info(`Transaction found in block ${tx.blockNumber}`);
|
|
90
91
|
|
|
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
92
|
// Create CalldataRetriever
|
|
100
93
|
const retriever = new CalldataRetriever(
|
|
101
94
|
publicClient as unknown as ViemPublicClient,
|
|
@@ -103,48 +96,67 @@ async function main() {
|
|
|
103
96
|
targetCommitteeSize,
|
|
104
97
|
undefined,
|
|
105
98
|
logger,
|
|
106
|
-
|
|
107
|
-
rollupAddress,
|
|
108
|
-
governanceProposerAddress,
|
|
109
|
-
slashingProposerAddress,
|
|
110
|
-
slashFactoryAddress,
|
|
111
|
-
},
|
|
99
|
+
rollupAddress,
|
|
112
100
|
);
|
|
113
101
|
|
|
114
|
-
// Extract
|
|
115
|
-
logger.info('Decoding transaction to extract
|
|
102
|
+
// Extract checkpoint number and hashes from transaction logs
|
|
103
|
+
logger.info('Decoding transaction to extract checkpoint number and hashes...');
|
|
116
104
|
const receipt = await publicClient.getTransactionReceipt({ hash: txHash });
|
|
117
|
-
|
|
105
|
+
|
|
106
|
+
// Look for CheckpointProposed event
|
|
107
|
+
const checkpointProposedEventAbi = getAbiItem({ abi: RollupAbi, name: 'CheckpointProposed' });
|
|
108
|
+
const checkpointProposedLog = receipt.logs.find(log => {
|
|
118
109
|
try {
|
|
119
|
-
// Try to match the L2BlockProposed event
|
|
120
110
|
return (
|
|
121
111
|
log.address.toLowerCase() === rollupAddress.toString().toLowerCase() &&
|
|
122
|
-
log.topics[0] ===
|
|
112
|
+
log.topics[0] === toEventSelector(checkpointProposedEventAbi)
|
|
123
113
|
);
|
|
124
114
|
} catch {
|
|
125
115
|
return false;
|
|
126
116
|
}
|
|
127
117
|
});
|
|
128
118
|
|
|
129
|
-
|
|
130
|
-
|
|
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);
|
|
119
|
+
if (!checkpointProposedLog || checkpointProposedLog.topics[1] === undefined) {
|
|
120
|
+
throw new Error(`Checkpoint proposed event not found`);
|
|
138
121
|
}
|
|
139
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
|
+
|
|
140
153
|
logger.info('');
|
|
141
|
-
logger.info('Retrieving
|
|
154
|
+
logger.info('Retrieving checkpoint from rollup transaction...');
|
|
142
155
|
logger.info('');
|
|
143
156
|
|
|
144
|
-
|
|
145
|
-
const result = await retriever.getCheckpointFromRollupTx(txHash, [], CheckpointNumber(l2BlockNumber), {});
|
|
157
|
+
const result = await retriever.getCheckpointFromRollupTx(txHash, [], checkpointNumber, expectedHashes);
|
|
146
158
|
|
|
147
|
-
logger.info('
|
|
159
|
+
logger.info(' Successfully retrieved block header!');
|
|
148
160
|
logger.info('');
|
|
149
161
|
logger.info('Block Header Details:');
|
|
150
162
|
logger.info('====================');
|