@aztec/archiver 0.0.1-commit.fcb71a6 → 0.0.1-commit.ff7989d6c
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} +11 -2
- 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 +94 -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 +17 -18
- package/dest/{archiver/l1 → l1}/calldata_retriever.d.ts +9 -3
- package/dest/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/calldata_retriever.js +19 -6
- package/dest/l1/data_retrieval.d.ts +89 -0
- package/dest/l1/data_retrieval.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/data_retrieval.js +39 -57
- 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 +1 -1
- package/dest/l1/spire_proposer.d.ts.map +1 -0
- 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 +14 -10
- 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 +39 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/{archiver → modules}/instrumentation.js +33 -67
- package/dest/modules/l1_synchronizer.d.ts +76 -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/{archiver → modules}/validation.js +7 -1
- 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 +228 -62
- 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 +193 -0
- package/dest/test/fake_l1_state.d.ts.map +1 -0
- package/dest/test/fake_l1_state.js +389 -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_l1_to_l2_message_source.d.ts +2 -2
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +12 -3
- package/dest/test/mock_l2_block_source.d.ts +39 -17
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +232 -83
- 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} +13 -2
- package/src/{archiver/errors.ts → errors.ts} +12 -0
- package/src/factory.ts +140 -11
- package/src/index.ts +11 -3
- package/src/interfaces.ts +9 -0
- package/src/{archiver/l1 → l1}/bin/retrieve-calldata.ts +16 -17
- package/src/{archiver/l1 → l1}/calldata_retriever.ts +28 -6
- package/src/{archiver/l1 → l1}/data_retrieval.ts +60 -74
- package/src/{archiver/l1 → l1}/validate_trace.ts +25 -7
- package/src/modules/data_source_base.ts +328 -0
- package/src/modules/data_store_updater.ts +448 -0
- package/src/{archiver → modules}/instrumentation.ts +33 -70
- package/src/modules/l1_synchronizer.ts +932 -0
- package/src/{archiver → modules}/validation.ts +11 -6
- package/src/{archiver/kv_archiver_store → store}/block_store.ts +293 -100
- 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 +273 -40
- 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 +607 -0
- package/src/test/index.ts +4 -0
- package/src/test/mock_archiver.ts +4 -3
- package/src/test/mock_l1_to_l2_message_source.ts +10 -4
- package/src/test/mock_l2_block_source.ts +276 -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 -304
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -1645
- package/dest/archiver/archiver_store.d.ts +0 -308
- 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 -157
- 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 -158
- 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 -313
- 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.map +0 -1
- 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 +0 -17
- 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 -2157
- package/src/archiver/archiver_store.ts +0 -372
- package/src/archiver/archiver_store_test_suite.ts +0 -2843
- package/src/archiver/index.ts +0 -6
- package/src/rpc/index.ts +0 -16
- /package/dest/{archiver/l1 → l1}/debug_tx.js +0 -0
- /package/dest/{archiver/l1 → l1}/spire_proposer.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}/README.md +0 -0
- /package/src/{archiver/l1 → l1}/debug_tx.ts +0 -0
- /package/src/{archiver/l1 → l1}/spire_proposer.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
package/src/index.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
export * from './archiver/index.js';
|
|
2
1
|
export * from './factory.js';
|
|
3
|
-
export * from './
|
|
2
|
+
export * from './interfaces.js';
|
|
3
|
+
export * from './archiver.js';
|
|
4
|
+
export * from './modules/data_source_base.js';
|
|
5
|
+
export * from './modules/data_store_updater.js';
|
|
6
|
+
export * from './config.js';
|
|
4
7
|
|
|
5
|
-
export {
|
|
8
|
+
export { type L1PublishedData } from './structs/published.js';
|
|
9
|
+
export { KVArchiverDataStore, ARCHIVER_DB_VERSION } from './store/kv_archiver_store.js';
|
|
10
|
+
export { ContractInstanceStore } from './store/contract_instance_store.js';
|
|
11
|
+
export { L2TipsCache } from './store/l2_tips_cache.js';
|
|
12
|
+
|
|
13
|
+
export { retrieveCheckpointsFromRollup, retrieveL2ProofVerifiedEvents } from './l1/data_retrieval.js';
|
|
@@ -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;
|
|
@@ -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, getAbiItem, http, toEventSelector } from 'viem';
|
|
8
9
|
import { mainnet } from 'viem/chains';
|
|
9
10
|
|
|
10
11
|
import { CalldataRetriever } from '../calldata_retriever.js';
|
|
@@ -111,38 +112,36 @@ async function main() {
|
|
|
111
112
|
},
|
|
112
113
|
);
|
|
113
114
|
|
|
114
|
-
// Extract
|
|
115
|
-
logger.info('Decoding transaction to extract
|
|
115
|
+
// Extract checkpoint number from transaction logs
|
|
116
|
+
logger.info('Decoding transaction to extract checkpoint number...');
|
|
116
117
|
const receipt = await publicClient.getTransactionReceipt({ hash: txHash });
|
|
117
|
-
|
|
118
|
+
|
|
119
|
+
// Look for CheckpointProposed event (emitted when a checkpoint is proposed to the rollup)
|
|
120
|
+
// Event signature: CheckpointProposed(uint256 indexed checkpointNumber, bytes32 indexed archive, bytes32[], bytes32, bytes32)
|
|
121
|
+
// Hash: keccak256("CheckpointProposed(uint256,bytes32,bytes32[],bytes32,bytes32)")
|
|
122
|
+
const checkpointProposedEvent = receipt.logs.find(log => {
|
|
118
123
|
try {
|
|
119
|
-
// Try to match the L2BlockProposed event
|
|
120
124
|
return (
|
|
121
125
|
log.address.toLowerCase() === rollupAddress.toString().toLowerCase() &&
|
|
122
|
-
log.topics[0] ===
|
|
126
|
+
log.topics[0] === toEventSelector(getAbiItem({ abi: RollupAbi, name: 'CheckpointProposed' }))
|
|
123
127
|
);
|
|
124
128
|
} catch {
|
|
125
129
|
return false;
|
|
126
130
|
}
|
|
127
131
|
});
|
|
128
132
|
|
|
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);
|
|
133
|
+
if (!checkpointProposedEvent || checkpointProposedEvent.topics[1] === undefined) {
|
|
134
|
+
throw new Error(`Checkpoint proposed event not found`);
|
|
138
135
|
}
|
|
139
136
|
|
|
137
|
+
const checkpointNumber = CheckpointNumber.fromBigInt(BigInt(checkpointProposedEvent.topics[1]));
|
|
138
|
+
|
|
140
139
|
logger.info('');
|
|
141
|
-
logger.info('Retrieving
|
|
140
|
+
logger.info('Retrieving checkpoint from rollup transaction...');
|
|
142
141
|
logger.info('');
|
|
143
142
|
|
|
144
143
|
// For this script, we don't have blob hashes or expected hashes, so pass empty arrays/objects
|
|
145
|
-
const result = await retriever.getCheckpointFromRollupTx(txHash, [],
|
|
144
|
+
const result = await retriever.getCheckpointFromRollupTx(txHash, [], checkpointNumber, {});
|
|
146
145
|
|
|
147
146
|
logger.info(' Successfully retrieved block header!');
|
|
148
147
|
logger.info('');
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
toFunctionSelector,
|
|
29
29
|
} from 'viem';
|
|
30
30
|
|
|
31
|
-
import type { ArchiverInstrumentation } from '../instrumentation.js';
|
|
31
|
+
import type { ArchiverInstrumentation } from '../modules/instrumentation.js';
|
|
32
32
|
import { getSuccessfulCallsFromDebug } from './debug_tx.js';
|
|
33
33
|
import { getCallFromSpireProposer } from './spire_proposer.js';
|
|
34
34
|
import { getSuccessfulCallsFromTrace } from './trace_tx.js';
|
|
@@ -39,6 +39,14 @@ import type { CallInfo } from './types.js';
|
|
|
39
39
|
* in order to reconstruct an L2 block header.
|
|
40
40
|
*/
|
|
41
41
|
export class CalldataRetriever {
|
|
42
|
+
/** Tx hashes we've already logged for trace+debug failure (log once per tx per process). */
|
|
43
|
+
private static readonly traceFailureWarnedTxHashes = new Set<string>();
|
|
44
|
+
|
|
45
|
+
/** Clears the trace-failure warned set. For testing only. */
|
|
46
|
+
static resetTraceFailureWarnedForTesting(): void {
|
|
47
|
+
CalldataRetriever.traceFailureWarnedTxHashes.clear();
|
|
48
|
+
}
|
|
49
|
+
|
|
42
50
|
/** Pre-computed valid contract calls for validation */
|
|
43
51
|
private readonly validContractCalls: ValidContractCall[];
|
|
44
52
|
|
|
@@ -72,7 +80,7 @@ export class CalldataRetriever {
|
|
|
72
80
|
*/
|
|
73
81
|
async getCheckpointFromRollupTx(
|
|
74
82
|
txHash: `0x${string}`,
|
|
75
|
-
|
|
83
|
+
_blobHashes: Buffer[],
|
|
76
84
|
checkpointNumber: CheckpointNumber,
|
|
77
85
|
expectedHashes: {
|
|
78
86
|
attestationsHash?: Hex;
|
|
@@ -84,6 +92,7 @@ export class CalldataRetriever {
|
|
|
84
92
|
header: CheckpointHeader;
|
|
85
93
|
attestations: CommitteeAttestation[];
|
|
86
94
|
blockHash: string;
|
|
95
|
+
feeAssetPriceModifier: bigint;
|
|
87
96
|
}> {
|
|
88
97
|
this.logger.trace(`Fetching checkpoint ${checkpointNumber} from rollup tx ${txHash}`, {
|
|
89
98
|
willValidateHashes: !!expectedHashes.attestationsHash || !!expectedHashes.payloadDigest,
|
|
@@ -313,7 +322,8 @@ export class CalldataRetriever {
|
|
|
313
322
|
this.logger.debug(`Successfully traced using trace_transaction, found ${calls.length} calls`);
|
|
314
323
|
} catch (err) {
|
|
315
324
|
const traceError = err instanceof Error ? err : new Error(String(err));
|
|
316
|
-
this.logger.verbose(`Failed trace_transaction for ${txHash}
|
|
325
|
+
this.logger.verbose(`Failed trace_transaction for ${txHash}: ${traceError.message}`);
|
|
326
|
+
this.logger.debug(`Trace failure details for ${txHash}`, { traceError });
|
|
317
327
|
|
|
318
328
|
try {
|
|
319
329
|
// Fall back to debug_traceTransaction (Geth RPC)
|
|
@@ -322,7 +332,16 @@ export class CalldataRetriever {
|
|
|
322
332
|
this.logger.debug(`Successfully traced using debug_traceTransaction, found ${calls.length} calls`);
|
|
323
333
|
} catch (debugErr) {
|
|
324
334
|
const debugError = debugErr instanceof Error ? debugErr : new Error(String(debugErr));
|
|
325
|
-
|
|
335
|
+
// Log once per tx so we don't spam on every sync cycle when sync point doesn't advance
|
|
336
|
+
if (!CalldataRetriever.traceFailureWarnedTxHashes.has(txHash)) {
|
|
337
|
+
CalldataRetriever.traceFailureWarnedTxHashes.add(txHash);
|
|
338
|
+
this.logger.warn(
|
|
339
|
+
`Cannot decode L1 tx ${txHash}: trace and debug RPC failed or unavailable. ` +
|
|
340
|
+
`trace_transaction: ${traceError.message}; debug_traceTransaction: ${debugError.message}`,
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
// Full error objects can be very long; keep at debug only
|
|
344
|
+
this.logger.debug(`Trace/debug failure details for tx ${txHash}`, {
|
|
326
345
|
traceError,
|
|
327
346
|
debugError,
|
|
328
347
|
txHash,
|
|
@@ -403,6 +422,7 @@ export class CalldataRetriever {
|
|
|
403
422
|
header: CheckpointHeader;
|
|
404
423
|
attestations: CommitteeAttestation[];
|
|
405
424
|
blockHash: string;
|
|
425
|
+
feeAssetPriceModifier: bigint;
|
|
406
426
|
} {
|
|
407
427
|
const { functionName: rollupFunctionName, args: rollupArgs } = decodeFunctionData({
|
|
408
428
|
abi: RollupAbi,
|
|
@@ -458,8 +478,9 @@ export class CalldataRetriever {
|
|
|
458
478
|
if (expectedHashes.payloadDigest) {
|
|
459
479
|
// Use ConsensusPayload to compute the digest - this ensures we match the exact logic
|
|
460
480
|
// used by the network for signing and verification
|
|
461
|
-
const
|
|
462
|
-
const
|
|
481
|
+
const feeAssetPriceModifier = decodedArgs.oracleInput.feeAssetPriceModifier;
|
|
482
|
+
const consensusPayload = new ConsensusPayload(header, archiveRoot, feeAssetPriceModifier);
|
|
483
|
+
const payloadToSign = consensusPayload.getPayloadToSign(SignatureDomainSeparator.checkpointAttestation);
|
|
463
484
|
const computedPayloadDigest = keccak256(payloadToSign);
|
|
464
485
|
|
|
465
486
|
// Compare as buffers to avoid case-sensitivity and string comparison issues
|
|
@@ -495,6 +516,7 @@ export class CalldataRetriever {
|
|
|
495
516
|
header,
|
|
496
517
|
attestations,
|
|
497
518
|
blockHash,
|
|
519
|
+
feeAssetPriceModifier: decodedArgs.oracleInput.feeAssetPriceModifier,
|
|
498
520
|
};
|
|
499
521
|
}
|
|
500
522
|
}
|
|
@@ -6,33 +6,31 @@ import {
|
|
|
6
6
|
decodeCheckpointBlobDataFromBlobs,
|
|
7
7
|
encodeBlockBlobData,
|
|
8
8
|
} from '@aztec/blob-lib';
|
|
9
|
-
import type {
|
|
10
|
-
|
|
9
|
+
import type {
|
|
10
|
+
CheckpointProposedLog,
|
|
11
|
+
EpochProofPublicInputArgs,
|
|
12
|
+
InboxContract,
|
|
13
|
+
MessageSentLog,
|
|
14
|
+
RollupContract,
|
|
15
|
+
} from '@aztec/ethereum/contracts';
|
|
16
|
+
import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
|
|
11
17
|
import { asyncPool } from '@aztec/foundation/async-pool';
|
|
12
|
-
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
13
|
-
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
18
|
+
import { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
14
19
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
15
20
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
16
21
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
17
|
-
import {
|
|
18
|
-
import { Body, CommitteeAttestation,
|
|
22
|
+
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
23
|
+
import { Body, CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
|
|
19
24
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
20
25
|
import { Proof } from '@aztec/stdlib/proofs';
|
|
21
26
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
22
27
|
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
23
28
|
import { BlockHeader, GlobalVariables, PartialStateReference, StateReference } from '@aztec/stdlib/tx';
|
|
24
29
|
|
|
25
|
-
import {
|
|
26
|
-
type GetContractEventsReturnType,
|
|
27
|
-
type GetContractReturnType,
|
|
28
|
-
type Hex,
|
|
29
|
-
decodeFunctionData,
|
|
30
|
-
getAbiItem,
|
|
31
|
-
hexToBytes,
|
|
32
|
-
} from 'viem';
|
|
30
|
+
import { type Hex, decodeFunctionData, getAbiItem, hexToBytes } from 'viem';
|
|
33
31
|
|
|
34
32
|
import { NoBlobBodiesFoundError } from '../errors.js';
|
|
35
|
-
import type { ArchiverInstrumentation } from '../instrumentation.js';
|
|
33
|
+
import type { ArchiverInstrumentation } from '../modules/instrumentation.js';
|
|
36
34
|
import type { DataRetrieval } from '../structs/data_retrieval.js';
|
|
37
35
|
import type { InboxMessage } from '../structs/inbox_message.js';
|
|
38
36
|
import { CalldataRetriever } from './calldata_retriever.js';
|
|
@@ -40,6 +38,7 @@ import { CalldataRetriever } from './calldata_retriever.js';
|
|
|
40
38
|
export type RetrievedCheckpoint = {
|
|
41
39
|
checkpointNumber: CheckpointNumber;
|
|
42
40
|
archiveRoot: Fr;
|
|
41
|
+
feeAssetPriceModifier: bigint;
|
|
43
42
|
header: CheckpointHeader;
|
|
44
43
|
checkpointBlobData: CheckpointBlobData;
|
|
45
44
|
l1: L1PublishedData;
|
|
@@ -51,6 +50,7 @@ export type RetrievedCheckpoint = {
|
|
|
51
50
|
export async function retrievedToPublishedCheckpoint({
|
|
52
51
|
checkpointNumber,
|
|
53
52
|
archiveRoot,
|
|
53
|
+
feeAssetPriceModifier,
|
|
54
54
|
header: checkpointHeader,
|
|
55
55
|
checkpointBlobData,
|
|
56
56
|
l1,
|
|
@@ -71,7 +71,7 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
71
71
|
const l1toL2MessageTreeRoot = blocksBlobData[0].l1ToL2MessageRoot!;
|
|
72
72
|
|
|
73
73
|
const spongeBlob = SpongeBlob.init();
|
|
74
|
-
const l2Blocks:
|
|
74
|
+
const l2Blocks: L2Block[] = [];
|
|
75
75
|
for (let i = 0; i < blocksBlobData.length; i++) {
|
|
76
76
|
const blockBlobData = blocksBlobData[i];
|
|
77
77
|
const { blockEndMarker, blockEndStateField, lastArchiveRoot, noteHashRoot, nullifierRoot, publicDataRoot } =
|
|
@@ -102,7 +102,7 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
102
102
|
}),
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
const body = Body.fromTxBlobData(
|
|
105
|
+
const body = Body.fromTxBlobData(blockBlobData.txs);
|
|
106
106
|
|
|
107
107
|
const blobFields = encodeBlockBlobData(blockBlobData);
|
|
108
108
|
await spongeBlob.absorb(blobFields);
|
|
@@ -121,7 +121,7 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
121
121
|
|
|
122
122
|
const newArchive = new AppendOnlyTreeSnapshot(newArchiveRoots[i], l2BlockNumber + 1);
|
|
123
123
|
|
|
124
|
-
l2Blocks.push(new
|
|
124
|
+
l2Blocks.push(new L2Block(newArchive, header, body, checkpointNumber, IndexWithinCheckpoint(i)));
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
const lastBlock = l2Blocks.at(-1)!;
|
|
@@ -130,6 +130,7 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
130
130
|
header: checkpointHeader,
|
|
131
131
|
blocks: l2Blocks,
|
|
132
132
|
number: checkpointNumber,
|
|
133
|
+
feeAssetPriceModifier: feeAssetPriceModifier,
|
|
133
134
|
});
|
|
134
135
|
|
|
135
136
|
return PublishedCheckpoint.from({ checkpoint, l1, attestations });
|
|
@@ -137,7 +138,7 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
137
138
|
|
|
138
139
|
/**
|
|
139
140
|
* Fetches new checkpoints.
|
|
140
|
-
* @param rollup - The rollup contract
|
|
141
|
+
* @param rollup - The rollup contract wrapper.
|
|
141
142
|
* @param publicClient - The viem public client to use for transaction retrieval.
|
|
142
143
|
* @param debugClient - The viem debug client to use for trace/debug RPC methods (optional).
|
|
143
144
|
* @param blobClient - The blob client client for fetching blob data.
|
|
@@ -150,7 +151,7 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
150
151
|
* @returns An array of retrieved checkpoints.
|
|
151
152
|
*/
|
|
152
153
|
export async function retrieveCheckpointsFromRollup(
|
|
153
|
-
rollup:
|
|
154
|
+
rollup: RollupContract,
|
|
154
155
|
publicClient: ViemPublicClient,
|
|
155
156
|
debugClient: ViemPublicDebugClient,
|
|
156
157
|
blobClient: BlobClientInterface,
|
|
@@ -173,15 +174,7 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
173
174
|
if (searchStartBlock > searchEndBlock) {
|
|
174
175
|
break;
|
|
175
176
|
}
|
|
176
|
-
const checkpointProposedLogs = (
|
|
177
|
-
await rollup.getEvents.CheckpointProposed(
|
|
178
|
-
{},
|
|
179
|
-
{
|
|
180
|
-
fromBlock: searchStartBlock,
|
|
181
|
-
toBlock: searchEndBlock,
|
|
182
|
-
},
|
|
183
|
-
)
|
|
184
|
-
).filter(log => log.blockNumber! >= searchStartBlock && log.blockNumber! <= searchEndBlock);
|
|
177
|
+
const checkpointProposedLogs = await rollup.getCheckpointProposedEvents(searchStartBlock, searchEndBlock);
|
|
185
178
|
|
|
186
179
|
if (checkpointProposedLogs.length === 0) {
|
|
187
180
|
break;
|
|
@@ -189,19 +182,19 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
189
182
|
|
|
190
183
|
const lastLog = checkpointProposedLogs.at(-1)!;
|
|
191
184
|
logger.debug(
|
|
192
|
-
`Got ${checkpointProposedLogs.length} processed logs for checkpoints
|
|
185
|
+
`Got ${checkpointProposedLogs.length} processed logs for checkpoints ${checkpointProposedLogs[0].args.checkpointNumber}-${lastLog.args.checkpointNumber} between L1 blocks ${searchStartBlock}-${searchEndBlock}`,
|
|
193
186
|
);
|
|
194
187
|
|
|
195
188
|
if (rollupConstants === undefined) {
|
|
196
189
|
const [chainId, version, targetCommitteeSize] = await Promise.all([
|
|
197
190
|
publicClient.getChainId(),
|
|
198
|
-
rollup.
|
|
199
|
-
rollup.
|
|
191
|
+
rollup.getVersion(),
|
|
192
|
+
rollup.getTargetCommitteeSize(),
|
|
200
193
|
]);
|
|
201
194
|
rollupConstants = {
|
|
202
195
|
chainId: new Fr(chainId),
|
|
203
196
|
version: new Fr(version),
|
|
204
|
-
targetCommitteeSize
|
|
197
|
+
targetCommitteeSize,
|
|
205
198
|
};
|
|
206
199
|
}
|
|
207
200
|
|
|
@@ -218,7 +211,7 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
218
211
|
isHistoricalSync,
|
|
219
212
|
);
|
|
220
213
|
retrievedCheckpoints.push(...newCheckpoints);
|
|
221
|
-
searchStartBlock = lastLog.
|
|
214
|
+
searchStartBlock = lastLog.l1BlockNumber + 1n;
|
|
222
215
|
} while (searchStartBlock <= searchEndBlock);
|
|
223
216
|
|
|
224
217
|
// The asyncPool from processCheckpointProposedLogs will not necessarily return the checkpoints in order, so we sort them before returning.
|
|
@@ -227,7 +220,7 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
227
220
|
|
|
228
221
|
/**
|
|
229
222
|
* Processes newly received CheckpointProposed logs.
|
|
230
|
-
* @param rollup - The rollup contract
|
|
223
|
+
* @param rollup - The rollup contract wrapper.
|
|
231
224
|
* @param publicClient - The viem public client to use for transaction retrieval.
|
|
232
225
|
* @param debugClient - The viem debug client to use for trace/debug RPC methods (optional).
|
|
233
226
|
* @param blobClient - The blob client client for fetching blob data.
|
|
@@ -240,11 +233,11 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
240
233
|
* @returns An array of retrieved checkpoints.
|
|
241
234
|
*/
|
|
242
235
|
async function processCheckpointProposedLogs(
|
|
243
|
-
rollup:
|
|
236
|
+
rollup: RollupContract,
|
|
244
237
|
publicClient: ViemPublicClient,
|
|
245
238
|
debugClient: ViemPublicDebugClient,
|
|
246
239
|
blobClient: BlobClientInterface,
|
|
247
|
-
logs:
|
|
240
|
+
logs: CheckpointProposedLog[],
|
|
248
241
|
{ chainId, version, targetCommitteeSize }: { chainId: Fr; version: Fr; targetCommitteeSize: number },
|
|
249
242
|
contractAddresses: {
|
|
250
243
|
governanceProposerAddress: EthAddress;
|
|
@@ -266,21 +259,21 @@ async function processCheckpointProposedLogs(
|
|
|
266
259
|
);
|
|
267
260
|
|
|
268
261
|
await asyncPool(10, logs, async log => {
|
|
269
|
-
const checkpointNumber =
|
|
270
|
-
const archive = log.args.archive
|
|
271
|
-
const archiveFromChain = await rollup.
|
|
272
|
-
const blobHashes = log.args.versionedBlobHashes
|
|
262
|
+
const checkpointNumber = log.args.checkpointNumber;
|
|
263
|
+
const archive = log.args.archive;
|
|
264
|
+
const archiveFromChain = await rollup.archiveAt(checkpointNumber);
|
|
265
|
+
const blobHashes = log.args.versionedBlobHashes;
|
|
273
266
|
|
|
274
267
|
// The value from the event and contract will match only if the checkpoint is in the chain.
|
|
275
|
-
if (archive
|
|
268
|
+
if (archive.equals(archiveFromChain)) {
|
|
276
269
|
// Build expected hashes object (fields may be undefined for backwards compatibility with older events)
|
|
277
270
|
const expectedHashes = {
|
|
278
|
-
attestationsHash: log.args.attestationsHash,
|
|
279
|
-
payloadDigest: log.args.payloadDigest,
|
|
271
|
+
attestationsHash: log.args.attestationsHash?.toString(),
|
|
272
|
+
payloadDigest: log.args.payloadDigest?.toString(),
|
|
280
273
|
};
|
|
281
274
|
|
|
282
275
|
const checkpoint = await calldataRetriever.getCheckpointFromRollupTx(
|
|
283
|
-
log.
|
|
276
|
+
log.l1TransactionHash,
|
|
284
277
|
blobHashes,
|
|
285
278
|
checkpointNumber,
|
|
286
279
|
expectedHashes,
|
|
@@ -295,22 +288,22 @@ async function processCheckpointProposedLogs(
|
|
|
295
288
|
);
|
|
296
289
|
|
|
297
290
|
const l1 = new L1PublishedData(
|
|
298
|
-
log.
|
|
299
|
-
await getL1BlockTime(publicClient, log.
|
|
300
|
-
log.
|
|
291
|
+
log.l1BlockNumber,
|
|
292
|
+
await getL1BlockTime(publicClient, log.l1BlockNumber),
|
|
293
|
+
log.l1BlockHash.toString(),
|
|
301
294
|
);
|
|
302
295
|
|
|
303
296
|
retrievedCheckpoints.push({ ...checkpoint, checkpointBlobData, l1, chainId, version });
|
|
304
|
-
logger.trace(`Retrieved checkpoint ${checkpointNumber} from L1 tx ${log.
|
|
305
|
-
l1BlockNumber: log.
|
|
297
|
+
logger.trace(`Retrieved checkpoint ${checkpointNumber} from L1 tx ${log.l1TransactionHash}`, {
|
|
298
|
+
l1BlockNumber: log.l1BlockNumber,
|
|
306
299
|
checkpointNumber,
|
|
307
300
|
archive: archive.toString(),
|
|
308
301
|
attestations: checkpoint.attestations,
|
|
309
302
|
});
|
|
310
303
|
} else {
|
|
311
304
|
logger.warn(`Ignoring checkpoint ${checkpointNumber} due to archive root mismatch`, {
|
|
312
|
-
actual: archive,
|
|
313
|
-
expected: archiveFromChain,
|
|
305
|
+
actual: archive.toString(),
|
|
306
|
+
expected: archiveFromChain.toString(),
|
|
314
307
|
});
|
|
315
308
|
}
|
|
316
309
|
});
|
|
@@ -355,12 +348,12 @@ export async function getCheckpointBlobDataFromBlobs(
|
|
|
355
348
|
|
|
356
349
|
/** Given an L1 to L2 message, retrieves its corresponding event from the Inbox within a specific block range. */
|
|
357
350
|
export async function retrieveL1ToL2Message(
|
|
358
|
-
inbox:
|
|
351
|
+
inbox: InboxContract,
|
|
359
352
|
leaf: Fr,
|
|
360
353
|
fromBlock: bigint,
|
|
361
354
|
toBlock: bigint,
|
|
362
355
|
): Promise<InboxMessage | undefined> {
|
|
363
|
-
const logs = await inbox.
|
|
356
|
+
const logs = await inbox.getMessageSentEventByHash(leaf.toString(), fromBlock, toBlock);
|
|
364
357
|
|
|
365
358
|
const messages = mapLogsInboxMessage(logs);
|
|
366
359
|
return messages.length > 0 ? messages[0] : undefined;
|
|
@@ -368,47 +361,40 @@ export async function retrieveL1ToL2Message(
|
|
|
368
361
|
|
|
369
362
|
/**
|
|
370
363
|
* Fetch L1 to L2 messages.
|
|
371
|
-
* @param
|
|
372
|
-
* @param inboxAddress - The address of the inbox contract to fetch messages from.
|
|
373
|
-
* @param blockUntilSynced - If true, blocks until the archiver has fully synced.
|
|
364
|
+
* @param inbox - The inbox contract wrapper.
|
|
374
365
|
* @param searchStartBlock - The block number to use for starting the search.
|
|
375
366
|
* @param searchEndBlock - The highest block number that we should search up to.
|
|
376
367
|
* @returns An array of InboxLeaf and next eth block to search from.
|
|
377
368
|
*/
|
|
378
369
|
export async function retrieveL1ToL2Messages(
|
|
379
|
-
inbox:
|
|
370
|
+
inbox: InboxContract,
|
|
380
371
|
searchStartBlock: bigint,
|
|
381
372
|
searchEndBlock: bigint,
|
|
382
373
|
): Promise<InboxMessage[]> {
|
|
383
374
|
const retrievedL1ToL2Messages: InboxMessage[] = [];
|
|
384
375
|
while (searchStartBlock <= searchEndBlock) {
|
|
385
|
-
const messageSentLogs = (
|
|
386
|
-
await inbox.getEvents.MessageSent({}, { fromBlock: searchStartBlock, toBlock: searchEndBlock })
|
|
387
|
-
).filter(log => log.blockNumber! >= searchStartBlock && log.blockNumber! <= searchEndBlock);
|
|
376
|
+
const messageSentLogs = await inbox.getMessageSentEvents(searchStartBlock, searchEndBlock);
|
|
388
377
|
|
|
389
378
|
if (messageSentLogs.length === 0) {
|
|
390
379
|
break;
|
|
391
380
|
}
|
|
392
381
|
|
|
393
382
|
retrievedL1ToL2Messages.push(...mapLogsInboxMessage(messageSentLogs));
|
|
394
|
-
searchStartBlock = messageSentLogs.at(-1)!.
|
|
383
|
+
searchStartBlock = messageSentLogs.at(-1)!.l1BlockNumber + 1n;
|
|
395
384
|
}
|
|
396
385
|
|
|
397
386
|
return retrievedL1ToL2Messages;
|
|
398
387
|
}
|
|
399
388
|
|
|
400
|
-
function mapLogsInboxMessage(logs:
|
|
401
|
-
return logs.map(log => {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
rollingHash: Buffer16.fromString(rollingHash!),
|
|
410
|
-
};
|
|
411
|
-
});
|
|
389
|
+
function mapLogsInboxMessage(logs: MessageSentLog[]): InboxMessage[] {
|
|
390
|
+
return logs.map(log => ({
|
|
391
|
+
index: log.args.index,
|
|
392
|
+
leaf: log.args.leaf,
|
|
393
|
+
l1BlockNumber: log.l1BlockNumber,
|
|
394
|
+
l1BlockHash: log.l1BlockHash,
|
|
395
|
+
checkpointNumber: log.args.checkpointNumber,
|
|
396
|
+
rollingHash: log.args.rollingHash,
|
|
397
|
+
}));
|
|
412
398
|
}
|
|
413
399
|
|
|
414
400
|
/** Retrieves L2ProofVerified events from the rollup contract. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ViemPublicDebugClient } from '@aztec/ethereum/types';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
|
|
4
4
|
import type { Hex } from 'viem';
|
|
5
5
|
import type { ZodSchema } from 'zod';
|
|
@@ -7,8 +7,6 @@ import type { ZodSchema } from 'zod';
|
|
|
7
7
|
import { callTraceSchema } from './debug_tx.js';
|
|
8
8
|
import { traceTransactionResponseSchema } from './trace_tx.js';
|
|
9
9
|
|
|
10
|
-
const logger = createLogger('aztec:archiver:validate_trace');
|
|
11
|
-
|
|
12
10
|
/**
|
|
13
11
|
* Helper function to test a trace method with validation
|
|
14
12
|
*
|
|
@@ -17,6 +15,7 @@ const logger = createLogger('aztec:archiver:validate_trace');
|
|
|
17
15
|
* @param schema - Zod schema to validate the response
|
|
18
16
|
* @param method - Name of the RPC method ('debug_traceTransaction' or 'trace_transaction')
|
|
19
17
|
* @param blockType - Type of block being tested ('recent' or 'old')
|
|
18
|
+
* @param logger - Logger instance
|
|
20
19
|
* @returns true if the method works and validation passes, false otherwise
|
|
21
20
|
*/
|
|
22
21
|
async function testTraceMethod(
|
|
@@ -25,6 +24,7 @@ async function testTraceMethod(
|
|
|
25
24
|
schema: ZodSchema,
|
|
26
25
|
method: 'debug_traceTransaction' | 'trace_transaction',
|
|
27
26
|
blockType: string,
|
|
27
|
+
logger: Logger,
|
|
28
28
|
): Promise<boolean> {
|
|
29
29
|
try {
|
|
30
30
|
// Make request with appropriate params based on method name
|
|
@@ -59,9 +59,14 @@ export interface TraceAvailability {
|
|
|
59
59
|
* Validates the availability of debug/trace methods on the Ethereum client.
|
|
60
60
|
*
|
|
61
61
|
* @param client - The Viem public debug client
|
|
62
|
+
* @param bindings - Optional logger bindings for context
|
|
62
63
|
* @returns Object indicating which trace methods are available for recent and old blocks
|
|
63
64
|
*/
|
|
64
|
-
export async function validateTraceAvailability(
|
|
65
|
+
export async function validateTraceAvailability(
|
|
66
|
+
client: ViemPublicDebugClient,
|
|
67
|
+
bindings?: LoggerBindings,
|
|
68
|
+
): Promise<TraceAvailability> {
|
|
69
|
+
const logger = createLogger('archiver:validate_trace', bindings);
|
|
65
70
|
const result: TraceAvailability = {
|
|
66
71
|
debugTraceRecent: false,
|
|
67
72
|
traceTransactionRecent: false,
|
|
@@ -95,6 +100,7 @@ export async function validateTraceAvailability(client: ViemPublicDebugClient):
|
|
|
95
100
|
callTraceSchema,
|
|
96
101
|
'debug_traceTransaction',
|
|
97
102
|
'recent',
|
|
103
|
+
logger,
|
|
98
104
|
);
|
|
99
105
|
|
|
100
106
|
// Test trace_transaction with recent block
|
|
@@ -104,6 +110,7 @@ export async function validateTraceAvailability(client: ViemPublicDebugClient):
|
|
|
104
110
|
traceTransactionResponseSchema,
|
|
105
111
|
'trace_transaction',
|
|
106
112
|
'recent',
|
|
113
|
+
logger,
|
|
107
114
|
);
|
|
108
115
|
|
|
109
116
|
// Get a block from 512 blocks ago
|
|
@@ -132,7 +139,14 @@ export async function validateTraceAvailability(client: ViemPublicDebugClient):
|
|
|
132
139
|
const oldTxHash = oldBlock.transactions[0] as Hex;
|
|
133
140
|
|
|
134
141
|
// Test debug_traceTransaction with old block
|
|
135
|
-
result.debugTraceOld = await testTraceMethod(
|
|
142
|
+
result.debugTraceOld = await testTraceMethod(
|
|
143
|
+
client,
|
|
144
|
+
oldTxHash,
|
|
145
|
+
callTraceSchema,
|
|
146
|
+
'debug_traceTransaction',
|
|
147
|
+
'old',
|
|
148
|
+
logger,
|
|
149
|
+
);
|
|
136
150
|
|
|
137
151
|
// Test trace_transaction with old block
|
|
138
152
|
result.traceTransactionOld = await testTraceMethod(
|
|
@@ -141,6 +155,7 @@ export async function validateTraceAvailability(client: ViemPublicDebugClient):
|
|
|
141
155
|
traceTransactionResponseSchema,
|
|
142
156
|
'trace_transaction',
|
|
143
157
|
'old',
|
|
158
|
+
logger,
|
|
144
159
|
);
|
|
145
160
|
} catch (error) {
|
|
146
161
|
logger.warn(`Error validating debug_traceTransaction and trace_transaction availability: ${error}`);
|
|
@@ -159,15 +174,18 @@ function hasTxs(block: { transactions?: Hex[] }): boolean {
|
|
|
159
174
|
*
|
|
160
175
|
* @param client - The Viem public debug client
|
|
161
176
|
* @param ethereumAllowNoDebugHosts - If false, throws an error when no trace methods are available
|
|
177
|
+
* @param bindings - Optional logger bindings for context
|
|
162
178
|
* @throws Error if ethereumAllowNoDebugHosts is false and no trace methods are available
|
|
163
179
|
*/
|
|
164
180
|
export async function validateAndLogTraceAvailability(
|
|
165
181
|
client: ViemPublicDebugClient,
|
|
166
182
|
ethereumAllowNoDebugHosts: boolean,
|
|
183
|
+
bindings?: LoggerBindings,
|
|
167
184
|
): Promise<void> {
|
|
168
|
-
logger
|
|
185
|
+
const logger = createLogger('archiver:validate_trace', bindings);
|
|
186
|
+
logger.debug('Validating trace/debug method availability...');
|
|
169
187
|
|
|
170
|
-
const availability = await validateTraceAvailability(client);
|
|
188
|
+
const availability = await validateTraceAvailability(client, bindings);
|
|
171
189
|
|
|
172
190
|
// Check if we have support for old blocks (either debug or trace)
|
|
173
191
|
const hasOldBlockSupport = availability.debugTraceOld || availability.traceTransactionOld;
|