@aztec/archiver 0.0.1-commit.5daedc8 → 0.0.1-commit.6201a7b05
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 +162 -22
- package/dest/archiver.d.ts +147 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +788 -0
- package/dest/config.d.ts +32 -0
- package/dest/config.d.ts.map +1 -0
- package/dest/config.js +83 -0
- package/dest/errors.d.ts +92 -0
- package/dest/errors.d.ts.map +1 -0
- package/dest/errors.js +136 -0
- package/dest/factory.d.ts +8 -7
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +100 -15
- package/dest/index.d.ts +12 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +10 -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 +152 -0
- package/dest/l1/calldata_retriever.d.ts +136 -0
- package/dest/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/l1/calldata_retriever.js +408 -0
- package/dest/l1/data_retrieval.d.ts +97 -0
- package/dest/l1/data_retrieval.d.ts.map +1 -0
- package/dest/{archiver → l1}/data_retrieval.js +86 -165
- 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 +149 -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_historical_logs.d.ts +23 -0
- package/dest/l1/validate_historical_logs.d.ts.map +1 -0
- package/dest/l1/validate_historical_logs.js +108 -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 +95 -0
- package/dest/modules/data_source_base.d.ts.map +1 -0
- package/dest/modules/data_source_base.js +234 -0
- package/dest/modules/data_store_updater.d.ts +93 -0
- package/dest/modules/data_store_updater.d.ts.map +1 -0
- package/dest/modules/data_store_updater.js +345 -0
- package/dest/modules/instrumentation.d.ts +55 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/modules/instrumentation.js +143 -0
- package/dest/modules/l1_synchronizer.d.ts +77 -0
- package/dest/modules/l1_synchronizer.d.ts.map +1 -0
- package/dest/modules/l1_synchronizer.js +1265 -0
- package/dest/modules/validation.d.ts +18 -0
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/{archiver → modules}/validation.js +13 -7
- package/dest/store/block_store.d.ts +262 -0
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/store/block_store.js +1048 -0
- package/dest/store/contract_class_store.d.ts +17 -0
- package/dest/store/contract_class_store.d.ts.map +1 -0
- package/dest/store/contract_class_store.js +64 -0
- 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 +7 -3
- package/dest/store/kv_archiver_store.d.ts +401 -0
- package/dest/store/kv_archiver_store.d.ts.map +1 -0
- package/dest/store/kv_archiver_store.js +525 -0
- package/dest/store/l2_tips_cache.d.ts +20 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +109 -0
- package/dest/store/log_store.d.ts +57 -0
- package/dest/store/log_store.d.ts.map +1 -0
- package/dest/store/log_store.js +531 -0
- package/dest/store/message_store.d.ts +44 -0
- package/dest/store/message_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/message_store.js +36 -23
- 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}/inbox_message.js +6 -5
- package/dest/structs/published.d.ts +2 -0
- package/dest/structs/published.d.ts.map +1 -0
- package/dest/test/fake_l1_state.d.ts +214 -0
- package/dest/test/fake_l1_state.d.ts.map +1 -0
- package/dest/test/fake_l1_state.js +517 -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 +19 -14
- package/dest/test/mock_l1_to_l2_message_source.d.ts +7 -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 +23 -12
- package/dest/test/mock_l2_block_source.d.ts +68 -20
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +298 -85
- package/dest/test/mock_structs.d.ts +83 -4
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +157 -11
- package/dest/test/noop_l1_archiver.d.ts +26 -0
- package/dest/test/noop_l1_archiver.d.ts.map +1 -0
- package/dest/test/noop_l1_archiver.js +74 -0
- package/package.json +20 -20
- package/src/archiver.ts +566 -0
- package/src/{archiver/config.ts → config.ts} +51 -14
- package/src/errors.ts +213 -0
- package/src/factory.ts +155 -17
- package/src/index.ts +12 -3
- package/src/interfaces.ts +9 -0
- package/src/l1/README.md +55 -0
- package/src/l1/bin/retrieve-calldata.ts +194 -0
- package/src/l1/calldata_retriever.ts +523 -0
- package/src/{archiver → l1}/data_retrieval.ts +155 -247
- package/src/l1/debug_tx.ts +99 -0
- package/src/l1/spire_proposer.ts +152 -0
- package/src/l1/trace_tx.ts +128 -0
- package/src/l1/types.ts +13 -0
- package/src/l1/validate_historical_logs.ts +140 -0
- package/src/l1/validate_trace.ts +229 -0
- package/src/modules/data_source_base.ts +364 -0
- package/src/modules/data_store_updater.ts +465 -0
- package/src/modules/instrumentation.ts +204 -0
- package/src/modules/l1_synchronizer.ts +1126 -0
- package/src/{archiver → modules}/validation.ts +21 -15
- package/src/store/block_store.ts +1361 -0
- package/src/store/contract_class_store.ts +82 -0
- package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +10 -7
- package/src/store/kv_archiver_store.ts +765 -0
- package/src/store/l2_tips_cache.ts +134 -0
- package/src/store/log_store.ts +733 -0
- package/src/{archiver/kv_archiver_store → store}/message_store.ts +48 -28
- package/src/{archiver/structs → structs}/inbox_message.ts +7 -7
- package/src/{archiver/structs → structs}/published.ts +0 -1
- package/src/test/fake_l1_state.ts +770 -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 +23 -16
- package/src/test/mock_l1_to_l2_message_source.ts +19 -11
- package/src/test/mock_l2_block_source.ts +367 -93
- package/src/test/mock_structs.ts +289 -13
- package/src/test/noop_l1_archiver.ts +117 -0
- package/dest/archiver/archiver.d.ts +0 -287
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -1408
- package/dest/archiver/archiver_store.d.ts +0 -255
- 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 -1289
- package/dest/archiver/config.d.ts +0 -21
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/config.js +0 -55
- package/dest/archiver/data_retrieval.d.ts +0 -79
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/errors.d.ts +0 -12
- package/dest/archiver/errors.d.ts.map +0 -1
- package/dest/archiver/errors.js +0 -17
- 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 -35
- package/dest/archiver/instrumentation.d.ts.map +0 -1
- package/dest/archiver/instrumentation.js +0 -140
- package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -124
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.js +0 -370
- 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_class_store.js +0 -120
- 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 -168
- 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 -296
- 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 -336
- package/dest/archiver/kv_archiver_store/message_store.d.ts +0 -39
- package/dest/archiver/kv_archiver_store/message_store.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 +0 -3
- 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 -1858
- package/src/archiver/archiver_store.ts +0 -305
- package/src/archiver/archiver_store_test_suite.ts +0 -1264
- package/src/archiver/errors.ts +0 -26
- package/src/archiver/index.ts +0 -6
- package/src/archiver/instrumentation.ts +0 -187
- package/src/archiver/kv_archiver_store/block_store.ts +0 -481
- package/src/archiver/kv_archiver_store/contract_class_store.ts +0 -176
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -422
- package/src/archiver/kv_archiver_store/log_store.ts +0 -406
- package/src/rpc/index.ts +0 -16
- /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
- /package/dest/{archiver/structs → structs}/published.js +0 -0
- /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { decodeFunctionData, getAddress, trim } from 'viem';
|
|
3
|
+
// Spire Proposer Multicall constants
|
|
4
|
+
export const SPIRE_PROPOSER_ADDRESS = '0x9ccc2f3ecde026230e11a5c8799ac7524f2bb294';
|
|
5
|
+
export const SPIRE_PROPOSER_EXPECTED_IMPLEMENTATION = '0x7d38d47e7c82195e6e607d3b0f1c20c615c7bf42';
|
|
6
|
+
// EIP-1967 storage slot for implementation address
|
|
7
|
+
// keccak256("eip1967.proxy.implementation") - 1 = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc
|
|
8
|
+
export const EIP1967_IMPLEMENTATION_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc';
|
|
9
|
+
// Spire Proposer Multicall ABI
|
|
10
|
+
export const SpireProposerAbi = [
|
|
11
|
+
{
|
|
12
|
+
inputs: [
|
|
13
|
+
{
|
|
14
|
+
components: [
|
|
15
|
+
{
|
|
16
|
+
internalType: 'address',
|
|
17
|
+
name: 'proposer',
|
|
18
|
+
type: 'address'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
internalType: 'address',
|
|
22
|
+
name: 'target',
|
|
23
|
+
type: 'address'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
internalType: 'bytes',
|
|
27
|
+
name: 'data',
|
|
28
|
+
type: 'bytes'
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
internalType: 'uint256',
|
|
32
|
+
name: 'value',
|
|
33
|
+
type: 'uint256'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
internalType: 'uint256',
|
|
37
|
+
name: 'gasLimit',
|
|
38
|
+
type: 'uint256'
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
internalType: 'struct IProposerMulticall.Call[]',
|
|
42
|
+
name: '_calls',
|
|
43
|
+
type: 'tuple[]'
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
name: 'multicall',
|
|
47
|
+
outputs: [],
|
|
48
|
+
stateMutability: 'nonpayable',
|
|
49
|
+
type: 'function'
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
/**
|
|
53
|
+
* Verifies that a proxy contract points to the expected implementation using EIP-1967.
|
|
54
|
+
* @param publicClient - The viem public client
|
|
55
|
+
* @param proxyAddress - The proxy contract address
|
|
56
|
+
* @param expectedImplementation - The expected implementation address
|
|
57
|
+
* @param logger - Logger instance
|
|
58
|
+
* @returns True if the proxy points to the expected implementation
|
|
59
|
+
*/ export async function verifyProxyImplementation(publicClient, proxyAddress, expectedImplementation, logger) {
|
|
60
|
+
try {
|
|
61
|
+
// Read the EIP-1967 implementation slot
|
|
62
|
+
const implementationData = await publicClient.getStorageAt({
|
|
63
|
+
address: proxyAddress,
|
|
64
|
+
slot: EIP1967_IMPLEMENTATION_SLOT
|
|
65
|
+
});
|
|
66
|
+
if (!implementationData) {
|
|
67
|
+
logger.warn(`No implementation found in EIP-1967 slot for proxy ${proxyAddress}`);
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
// The implementation address is stored in the last 20 bytes of the slot
|
|
71
|
+
// We need to extract and normalize it for comparison
|
|
72
|
+
const implementationAddress = getAddress(trim(implementationData));
|
|
73
|
+
const expectedAddress = getAddress(expectedImplementation);
|
|
74
|
+
const matches = implementationAddress.toLowerCase() === expectedAddress.toLowerCase();
|
|
75
|
+
if (!matches) {
|
|
76
|
+
logger.warn(`Proxy implementation mismatch: expected ${expectedAddress}, got ${implementationAddress}`, {
|
|
77
|
+
proxyAddress,
|
|
78
|
+
expectedImplementation,
|
|
79
|
+
actualImplementation: implementationAddress
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return matches;
|
|
83
|
+
} catch (err) {
|
|
84
|
+
logger.warn(`Failed to verify proxy implementation for ${proxyAddress}: ${err}`);
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Attempts to decode transaction as a Spire Proposer Multicall.
|
|
90
|
+
* Spire Proposer is a proxy contract that wraps multiple calls.
|
|
91
|
+
* Returns all wrapped calls if validation succeeds (caller handles hash matching to find the propose call).
|
|
92
|
+
* @param tx - The transaction to decode
|
|
93
|
+
* @param publicClient - The viem public client for proxy verification
|
|
94
|
+
* @param logger - Logger instance
|
|
95
|
+
* @returns Array of wrapped calls with 'to' and 'data', or undefined if not a valid Spire Proposer tx
|
|
96
|
+
*/ export async function getCallsFromSpireProposer(tx, publicClient, logger) {
|
|
97
|
+
const txHash = tx.hash;
|
|
98
|
+
try {
|
|
99
|
+
// Check if transaction is to the Spire Proposer address
|
|
100
|
+
if (!tx.to || !EthAddress.areEqual(tx.to, SPIRE_PROPOSER_ADDRESS)) {
|
|
101
|
+
logger.debug(`Transaction is not to Spire Proposer address (to: ${tx.to})`, {
|
|
102
|
+
txHash
|
|
103
|
+
});
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
// Verify the proxy points to the expected implementation
|
|
107
|
+
const isValidProxy = await verifyProxyImplementation(publicClient, tx.to, SPIRE_PROPOSER_EXPECTED_IMPLEMENTATION, logger);
|
|
108
|
+
if (!isValidProxy) {
|
|
109
|
+
logger.warn(`Spire Proposer proxy implementation verification failed`, {
|
|
110
|
+
txHash,
|
|
111
|
+
to: tx.to
|
|
112
|
+
});
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
// Try to decode as Spire Proposer multicall
|
|
116
|
+
const { functionName: spireFunctionName, args: spireArgs } = decodeFunctionData({
|
|
117
|
+
abi: SpireProposerAbi,
|
|
118
|
+
data: tx.input
|
|
119
|
+
});
|
|
120
|
+
// If not multicall, return undefined
|
|
121
|
+
if (spireFunctionName !== 'multicall') {
|
|
122
|
+
logger.warn(`Transaction to Spire Proposer is not multicall (got ${spireFunctionName})`, {
|
|
123
|
+
txHash
|
|
124
|
+
});
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
if (spireArgs.length !== 1) {
|
|
128
|
+
logger.warn(`Unexpected number of arguments for Spire Proposer multicall (got ${spireArgs.length})`, {
|
|
129
|
+
txHash
|
|
130
|
+
});
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
const [calls] = spireArgs;
|
|
134
|
+
// Return all wrapped calls (hash matching in the caller determines which is the propose call)
|
|
135
|
+
logger.trace(`Decoded Spire Proposer with ${calls.length} call(s)`, {
|
|
136
|
+
txHash
|
|
137
|
+
});
|
|
138
|
+
return calls.map((call)=>({
|
|
139
|
+
to: call.target,
|
|
140
|
+
data: call.data
|
|
141
|
+
}));
|
|
142
|
+
} catch (err) {
|
|
143
|
+
// Any decoding error triggers fallback to trace
|
|
144
|
+
logger.warn(`Failed to decode Spire Proposer: ${err}`, {
|
|
145
|
+
txHash
|
|
146
|
+
});
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ViemPublicDebugClient } from '@aztec/ethereum/types';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
4
|
+
import { type ZodFor } from '@aztec/foundation/schemas';
|
|
5
|
+
import type { Hex } from 'viem';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import type { CallInfo } from './types.js';
|
|
8
|
+
/** Zod schema for a single trace from trace_transaction */
|
|
9
|
+
export declare const traceSchema: z.ZodObject<{
|
|
10
|
+
action: z.ZodObject<{
|
|
11
|
+
from: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `0x${string}`, string>;
|
|
12
|
+
to: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `0x${string}`, string>>;
|
|
13
|
+
callType: z.ZodString;
|
|
14
|
+
gas: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `0x${string}`, string>>;
|
|
15
|
+
input: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `0x${string}`, string>>;
|
|
16
|
+
value: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `0x${string}`, string>>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
from: `0x${string}`;
|
|
19
|
+
to?: `0x${string}` | undefined;
|
|
20
|
+
callType: string;
|
|
21
|
+
gas?: `0x${string}` | undefined;
|
|
22
|
+
input?: `0x${string}` | undefined;
|
|
23
|
+
value?: `0x${string}` | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
from: string;
|
|
26
|
+
to?: string | undefined;
|
|
27
|
+
callType: string;
|
|
28
|
+
gas?: string | undefined;
|
|
29
|
+
input?: string | undefined;
|
|
30
|
+
value?: string | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
result: z.ZodOptional<z.ZodObject<{
|
|
33
|
+
gasUsed: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `0x${string}`, string>>;
|
|
34
|
+
output: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `0x${string}`, string>>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
gasUsed?: `0x${string}` | undefined;
|
|
37
|
+
output?: `0x${string}` | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
gasUsed?: string | undefined;
|
|
40
|
+
output?: string | undefined;
|
|
41
|
+
}>>;
|
|
42
|
+
error: z.ZodOptional<z.ZodString>;
|
|
43
|
+
subtraces: z.ZodNumber;
|
|
44
|
+
traceAddress: z.ZodArray<z.ZodNumber, "many">;
|
|
45
|
+
type: z.ZodString;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
action: {
|
|
48
|
+
from: `0x${string}`;
|
|
49
|
+
to?: `0x${string}` | undefined;
|
|
50
|
+
callType: string;
|
|
51
|
+
gas?: `0x${string}` | undefined;
|
|
52
|
+
input?: `0x${string}` | undefined;
|
|
53
|
+
value?: `0x${string}` | undefined;
|
|
54
|
+
};
|
|
55
|
+
result?: {
|
|
56
|
+
gasUsed?: `0x${string}` | undefined;
|
|
57
|
+
output?: `0x${string}` | undefined;
|
|
58
|
+
} | undefined;
|
|
59
|
+
error?: string | undefined;
|
|
60
|
+
subtraces: number;
|
|
61
|
+
traceAddress: number[];
|
|
62
|
+
type: string;
|
|
63
|
+
}, {
|
|
64
|
+
action: {
|
|
65
|
+
from: string;
|
|
66
|
+
to?: string | undefined;
|
|
67
|
+
callType: string;
|
|
68
|
+
gas?: string | undefined;
|
|
69
|
+
input?: string | undefined;
|
|
70
|
+
value?: string | undefined;
|
|
71
|
+
};
|
|
72
|
+
result?: {
|
|
73
|
+
gasUsed?: string | undefined;
|
|
74
|
+
output?: string | undefined;
|
|
75
|
+
} | undefined;
|
|
76
|
+
error?: string | undefined;
|
|
77
|
+
subtraces: number;
|
|
78
|
+
traceAddress: number[];
|
|
79
|
+
type: string;
|
|
80
|
+
}>;
|
|
81
|
+
/** Type for trace_transaction response */
|
|
82
|
+
type TraceTransaction = z.infer<typeof traceSchema>;
|
|
83
|
+
/** Zod schema for the full trace_transaction response (array of traces) */
|
|
84
|
+
export declare const traceTransactionResponseSchema: ZodFor<TraceTransaction[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Traces a transaction and extracts all CALL operations to a specific contract and function selector.
|
|
87
|
+
* Uses the trace_transaction RPC method which returns a flat array of traces.
|
|
88
|
+
*
|
|
89
|
+
* @param client - The Viem public debug client
|
|
90
|
+
* @param txHash - The transaction hash to trace
|
|
91
|
+
* @param targetAddress - The contract address to filter for
|
|
92
|
+
* @param functionSelector - The 4-byte function selector to filter for (with or without 0x prefix)
|
|
93
|
+
* @returns Array of CallInfo objects containing from, gasUsed, input, and value for matching calls
|
|
94
|
+
*/
|
|
95
|
+
export declare function getSuccessfulCallsFromTrace(client: ViemPublicDebugClient, txHash: Hex, targetAddress: EthAddress, functionSelector: string, logger?: Logger): Promise<CallInfo[]>;
|
|
96
|
+
export {};
|
|
97
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhY2VfdHguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sMS90cmFjZV90eC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxxQkFBcUIsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25FLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUMzRCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUNwRCxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQVcsTUFBTSwyQkFBMkIsQ0FBQztBQUdq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pD,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,2BAA2B,CAAC;AAGjE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAkB3C,2DAA2D;AAC3D,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOtB,CAAC;AAEH,0CAA0C;AAC1C,KAAK,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEpD,2EAA2E;AAC3E,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAwB,CAAC;AAE/F;;;;;;;;;GASG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,GAAG,EACX,aAAa,EAAE,UAAU,EACzB,gBAAgB,EAAE,MAAM,EACxB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,QAAQ,EAAE,CAAC,CAoErB"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { schemas } from '@aztec/foundation/schemas';
|
|
3
|
+
import { withHexPrefix } from '@aztec/foundation/string';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/** Zod schema for trace action from trace_transaction */ const traceActionSchema = z.object({
|
|
6
|
+
from: schemas.HexStringWith0x,
|
|
7
|
+
to: schemas.HexStringWith0x.optional(),
|
|
8
|
+
callType: z.string(),
|
|
9
|
+
gas: schemas.HexStringWith0x.optional(),
|
|
10
|
+
input: schemas.HexStringWith0x.optional(),
|
|
11
|
+
value: schemas.HexStringWith0x.optional()
|
|
12
|
+
});
|
|
13
|
+
/** Zod schema for trace result from trace_transaction */ const traceResultSchema = z.object({
|
|
14
|
+
gasUsed: schemas.HexStringWith0x.optional(),
|
|
15
|
+
output: schemas.HexStringWith0x.optional()
|
|
16
|
+
});
|
|
17
|
+
/** Zod schema for a single trace from trace_transaction */ export const traceSchema = z.object({
|
|
18
|
+
action: traceActionSchema,
|
|
19
|
+
result: traceResultSchema.optional(),
|
|
20
|
+
error: z.string().optional(),
|
|
21
|
+
subtraces: z.number(),
|
|
22
|
+
traceAddress: z.array(z.number()),
|
|
23
|
+
type: z.string()
|
|
24
|
+
});
|
|
25
|
+
/** Zod schema for the full trace_transaction response (array of traces) */ export const traceTransactionResponseSchema = z.array(traceSchema);
|
|
26
|
+
/**
|
|
27
|
+
* Traces a transaction and extracts all CALL operations to a specific contract and function selector.
|
|
28
|
+
* Uses the trace_transaction RPC method which returns a flat array of traces.
|
|
29
|
+
*
|
|
30
|
+
* @param client - The Viem public debug client
|
|
31
|
+
* @param txHash - The transaction hash to trace
|
|
32
|
+
* @param targetAddress - The contract address to filter for
|
|
33
|
+
* @param functionSelector - The 4-byte function selector to filter for (with or without 0x prefix)
|
|
34
|
+
* @returns Array of CallInfo objects containing from, gasUsed, input, and value for matching calls
|
|
35
|
+
*/ export async function getSuccessfulCallsFromTrace(client, txHash, targetAddress, functionSelector, logger) {
|
|
36
|
+
// Normalize inputs for comparison
|
|
37
|
+
const normalizedTarget = targetAddress.toString().toLowerCase();
|
|
38
|
+
const normalizedSelector = withHexPrefix(functionSelector.toLowerCase());
|
|
39
|
+
// Call trace_transaction (no options needed)
|
|
40
|
+
const rawTrace = await client.request({
|
|
41
|
+
method: 'trace_transaction',
|
|
42
|
+
params: [
|
|
43
|
+
txHash
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
if (rawTrace === null || rawTrace === undefined) {
|
|
47
|
+
throw new Error(`Failed to retrieve trace_transaction for ${txHash}`);
|
|
48
|
+
}
|
|
49
|
+
logger?.trace(`Retrieved trace_transaction for ${txHash}`, {
|
|
50
|
+
trace: rawTrace
|
|
51
|
+
});
|
|
52
|
+
// Validate the response with zod
|
|
53
|
+
const traces = traceTransactionResponseSchema.parse(rawTrace);
|
|
54
|
+
const results = [];
|
|
55
|
+
// Build a set of trace addresses that errored - we should skip their descendants
|
|
56
|
+
// A trace address is the path in the trace tree, represented as an array of indices
|
|
57
|
+
const erroredTraceAddresses = new Set();
|
|
58
|
+
for (const trace of traces){
|
|
59
|
+
if (trace.error) {
|
|
60
|
+
erroredTraceAddresses.add(JSON.stringify(trace.traceAddress));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Helper to check if a trace is a descendant of an errored trace
|
|
64
|
+
function isDescendantOfError(traceAddress) {
|
|
65
|
+
// Check all possible ancestor paths
|
|
66
|
+
for(let i = 1; i < traceAddress.length; i++){
|
|
67
|
+
const ancestorAddress = traceAddress.slice(0, i);
|
|
68
|
+
if (erroredTraceAddresses.has(JSON.stringify(ancestorAddress))) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
// Process each trace
|
|
75
|
+
for (const trace of traces){
|
|
76
|
+
// Skip if this has an error or is a descendant of an errored trace
|
|
77
|
+
if (trace.error || isDescendantOfError(trace.traceAddress)) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
// Check if this is a CALL type trace to the target address with matching selector and result
|
|
81
|
+
if (trace.type === 'call' && trace.action.callType.toLowerCase() === 'call' && trace.action.to?.toLowerCase() === normalizedTarget && trace.action.input?.toLowerCase().startsWith(normalizedSelector) && trace.result) {
|
|
82
|
+
results.push({
|
|
83
|
+
from: EthAddress.fromString(trace.action.from),
|
|
84
|
+
gasUsed: trace.result.gasUsed === undefined ? undefined : BigInt(trace.result.gasUsed),
|
|
85
|
+
input: trace.action.input,
|
|
86
|
+
value: trace.action.value ? BigInt(trace.action.value) : 0n
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return results;
|
|
91
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import type { Hex } from 'viem';
|
|
3
|
+
/**
|
|
4
|
+
* Information about a matching CALL
|
|
5
|
+
*/
|
|
6
|
+
export interface CallInfo {
|
|
7
|
+
from: EthAddress;
|
|
8
|
+
gasUsed?: bigint;
|
|
9
|
+
input: Hex;
|
|
10
|
+
value: bigint;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sMS90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFFM0QsT0FBTyxLQUFLLEVBQUUsR0FBRyxFQUFFLE1BQU0sTUFBTSxDQUFDO0FBRWhDOztHQUVHO0FBQ0gsTUFBTSxXQUFXLFFBQVE7SUFDdkIsSUFBSSxFQUFFLFVBQVUsQ0FBQztJQUNqQixPQUFPLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDakIsS0FBSyxFQUFFLEdBQUcsQ0FBQztJQUNYLEtBQUssRUFBRSxNQUFNLENBQUM7Q0FDZiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/l1/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf"}
|
package/dest/l1/types.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
2
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
3
|
+
import { type LoggerBindings } from '@aztec/foundation/log';
|
|
4
|
+
/** Subset of L1 contract addresses whose historical logs the Aztec node relies on. */
|
|
5
|
+
export type HistoricalLogsContractAddresses = Pick<L1ContractAddresses, 'rollupAddress' | 'inboxAddress' | 'registryAddress' | 'governanceProposerAddress'>;
|
|
6
|
+
/**
|
|
7
|
+
* Validates that every configured L1 RPC URL returns historical logs for the Rollup contract.
|
|
8
|
+
*
|
|
9
|
+
* Some RPC providers prune old logs, which would cause L1 syncing to silently fail. To detect this,
|
|
10
|
+
* we query for the `OwnershipTransferred` event which every Rollup emits in its constructor (via
|
|
11
|
+
* Ownable) on the block it was deployed (`l1StartBlock`). The `client` is typically a viem fallback
|
|
12
|
+
* transport over several user-configured RPC URLs — checking only the first URL would miss a bad
|
|
13
|
+
* secondary, so we probe each URL independently. The first URL that fails aborts startup, unless
|
|
14
|
+
* the operator has explicitly opted out.
|
|
15
|
+
*
|
|
16
|
+
* @param client - The L1 public client built from the user-configured RPC URLs.
|
|
17
|
+
* @param addresses - The subset of L1 contract addresses we rely on for historical log retrieval.
|
|
18
|
+
* @param skipCheck - If true, log warnings instead of throwing.
|
|
19
|
+
* @param bindings - Optional logger bindings for context.
|
|
20
|
+
* @throws Error if any URL fails the probe and skipCheck is false.
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateAndLogHistoricalLogsAvailability(client: ViemPublicClient, addresses: HistoricalLogsContractAddresses, skipCheck: boolean, bindings?: LoggerBindings): Promise<void>;
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGVfaGlzdG9yaWNhbF9sb2dzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6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F;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,wCAAwC,CAC5D,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,+BAA+B,EAC1C,SAAS,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,IAAI,CAAC,CAmCf"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { getPublicClient, getRpcUrlsFromClient } from '@aztec/ethereum/client';
|
|
2
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
/**
|
|
5
|
+
* Validates that every configured L1 RPC URL returns historical logs for the Rollup contract.
|
|
6
|
+
*
|
|
7
|
+
* Some RPC providers prune old logs, which would cause L1 syncing to silently fail. To detect this,
|
|
8
|
+
* we query for the `OwnershipTransferred` event which every Rollup emits in its constructor (via
|
|
9
|
+
* Ownable) on the block it was deployed (`l1StartBlock`). The `client` is typically a viem fallback
|
|
10
|
+
* transport over several user-configured RPC URLs — checking only the first URL would miss a bad
|
|
11
|
+
* secondary, so we probe each URL independently. The first URL that fails aborts startup, unless
|
|
12
|
+
* the operator has explicitly opted out.
|
|
13
|
+
*
|
|
14
|
+
* @param client - The L1 public client built from the user-configured RPC URLs.
|
|
15
|
+
* @param addresses - The subset of L1 contract addresses we rely on for historical log retrieval.
|
|
16
|
+
* @param skipCheck - If true, log warnings instead of throwing.
|
|
17
|
+
* @param bindings - Optional logger bindings for context.
|
|
18
|
+
* @throws Error if any URL fails the probe and skipCheck is false.
|
|
19
|
+
*/ export async function validateAndLogHistoricalLogsAvailability(client, addresses, skipCheck, bindings) {
|
|
20
|
+
const logger = createLogger('archiver:validate_historical_logs', bindings);
|
|
21
|
+
logger.debug('Validating historical log availability on L1 RPCs');
|
|
22
|
+
const urls = getRpcUrlsFromClient(client);
|
|
23
|
+
if (urls.length === 0) {
|
|
24
|
+
logger.warn('Could not determine L1 RPC URLs from the public client; skipping historical logs check.');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const chainId = client.chain?.id;
|
|
28
|
+
if (chainId === undefined) {
|
|
29
|
+
logger.warn('Could not determine L1 chain ID from the public client; skipping historical logs check.');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
for (const url of urls){
|
|
33
|
+
const probeClient = getPublicClient({
|
|
34
|
+
l1RpcUrls: [
|
|
35
|
+
url
|
|
36
|
+
],
|
|
37
|
+
l1ChainId: chainId
|
|
38
|
+
});
|
|
39
|
+
const rollup = new RollupContract(probeClient, addresses.rollupAddress.toString());
|
|
40
|
+
const result = await probeRpcUrl(rollup, probeClient, logger);
|
|
41
|
+
if (result.ok) {
|
|
42
|
+
logger.debug(`L1 RPC ${url} returned historical OwnershipTransferred log for the Rollup contract.`);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const errorMessage = buildErrorMessage(url, result, addresses);
|
|
46
|
+
if (skipCheck) {
|
|
47
|
+
logger.warn(`${errorMessage}\nContinuing because ARCHIVER_SKIP_HISTORICAL_LOGS_CHECK is true.`);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
logger.error(errorMessage);
|
|
51
|
+
throw new Error(errorMessage);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Runs the OwnershipTransferred probe against a single RPC and queries its client version. */ async function probeRpcUrl(rollup, client, logger) {
|
|
55
|
+
let queryError;
|
|
56
|
+
try {
|
|
57
|
+
const logs = await rollup.getOwnershipTransferredEventsAtDeploy();
|
|
58
|
+
if (logs.length > 0) {
|
|
59
|
+
return {
|
|
60
|
+
ok: true
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
} catch (err) {
|
|
64
|
+
queryError = err;
|
|
65
|
+
}
|
|
66
|
+
const clientVersion = await getClientVersion(client, logger);
|
|
67
|
+
let reason;
|
|
68
|
+
if (queryError instanceof Error) {
|
|
69
|
+
reason = `Query for historical logs failed: ${queryError.message}`;
|
|
70
|
+
} else if (queryError !== undefined) {
|
|
71
|
+
reason = 'Query for historical logs failed with a non-Error value.';
|
|
72
|
+
} else {
|
|
73
|
+
reason = 'No OwnershipTransferred event was returned by the L1 RPC for the Rollup deploy block.';
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
ok: false,
|
|
77
|
+
reason,
|
|
78
|
+
clientVersion
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** Builds the operator-facing error message for a failing RPC URL. */ function buildErrorMessage(url, result, addresses) {
|
|
82
|
+
return [
|
|
83
|
+
`L1 RPC at ${url} does not return historical logs for the Rollup contract. ${result.reason}`,
|
|
84
|
+
`This likely means this Ethereum RPC node prunes old logs, which would cause the archiver ` + `to silently miss data during L1 sync.`,
|
|
85
|
+
result.clientVersion ? `Detected L1 client version for ${url}: ${result.clientVersion}.` : `Could not determine L1 client version for ${url}.`,
|
|
86
|
+
`The following L1 contract addresses must have their historical logs retained by the RPC node:`,
|
|
87
|
+
` - Rollup: ${addresses.rollupAddress.toString()}`,
|
|
88
|
+
` - Inbox: ${addresses.inboxAddress.toString()}`,
|
|
89
|
+
` - Registry: ${addresses.registryAddress.toString()}`,
|
|
90
|
+
` - GovernanceProposer: ${addresses.governanceProposerAddress.toString()}`,
|
|
91
|
+
isReth(result.clientVersion) ? `To retain logs for these contracts, configure reth with a ` + `prune.segments.receipts_log_filter entry for each address above ` + `so reth does not prune their receipts/logs. See https://reth.rs/run/pruning.html for details.` : `Point this RPC endpoint at a node that retains full log history for the addresses above.`,
|
|
92
|
+
`Set ARCHIVER_SKIP_HISTORICAL_LOGS_CHECK=true to bypass this check at your own risk.`
|
|
93
|
+
].join('\n');
|
|
94
|
+
}
|
|
95
|
+
/** Queries `web3_clientVersion` on the L1 RPC. Returns undefined if the call fails or returns a non-string. */ async function getClientVersion(client, logger) {
|
|
96
|
+
try {
|
|
97
|
+
const result = await client.request({
|
|
98
|
+
method: 'web3_clientVersion'
|
|
99
|
+
});
|
|
100
|
+
return typeof result === 'string' ? result : undefined;
|
|
101
|
+
} catch (err) {
|
|
102
|
+
logger.debug(`Failed to query web3_clientVersion: ${err instanceof Error ? err.message : err}`);
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** Heuristic check for reth based on the web3_clientVersion string (reth returns e.g. "reth/v1.0.0-..."). */ function isReth(clientVersion) {
|
|
107
|
+
return !!clientVersion && /reth/i.test(clientVersion);
|
|
108
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ViemPublicDebugClient } from '@aztec/ethereum/types';
|
|
2
|
+
import { type LoggerBindings } from '@aztec/foundation/log';
|
|
3
|
+
/** Result of trace availability checks */
|
|
4
|
+
export interface TraceAvailability {
|
|
5
|
+
/** Whether debug_traceTransaction works for recent blocks */
|
|
6
|
+
debugTraceRecent: boolean;
|
|
7
|
+
/** Whether trace_transaction works for recent blocks */
|
|
8
|
+
traceTransactionRecent: boolean;
|
|
9
|
+
/** Whether debug_traceTransaction works for old blocks (512 blocks ago) */
|
|
10
|
+
debugTraceOld: boolean;
|
|
11
|
+
/** Whether trace_transaction works for old blocks (512 blocks ago) */
|
|
12
|
+
traceTransactionOld: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Validates the availability of debug/trace methods on the Ethereum client.
|
|
16
|
+
*
|
|
17
|
+
* @param client - The Viem public debug client
|
|
18
|
+
* @param bindings - Optional logger bindings for context
|
|
19
|
+
* @returns Object indicating which trace methods are available for recent and old blocks
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateTraceAvailability(client: ViemPublicDebugClient, bindings?: LoggerBindings): Promise<TraceAvailability>;
|
|
22
|
+
/**
|
|
23
|
+
* Validates trace availability and logs appropriate messages based on the results.
|
|
24
|
+
* Optionally throws an error if no trace methods are available and ethereumAllowNoDebugHosts is false.
|
|
25
|
+
*
|
|
26
|
+
* @param client - The Viem public debug client
|
|
27
|
+
* @param ethereumAllowNoDebugHosts - If false, throws an error when no trace methods are available
|
|
28
|
+
* @param bindings - Optional logger bindings for context
|
|
29
|
+
* @throws Error if ethereumAllowNoDebugHosts is false and no trace methods are available
|
|
30
|
+
*/
|
|
31
|
+
export declare function validateAndLogTraceAvailability(client: ViemPublicDebugClient, ethereumAllowNoDebugHosts: boolean, bindings?: LoggerBindings): Promise<void>;
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGVfdHJhY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sMS92YWxpZGF0ZV90cmFjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxxQkFBcUIsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25FLE9BQU8sRUFBZSxLQUFLLGNBQWMsRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQTRDdkYsMENBQTBDO0FBQzFDLE1BQU0sV0FBVyxpQkFBaUI7SUFDaEMsNkRBQTZEO0lBQzdELGdCQUFnQixFQUFFLE9BQU8sQ0FBQztJQUMxQix3REFBd0Q7SUFDeEQsc0JBQXNCLEVBQUUsT0FBTyxDQUFDO0lBQ2hDLDJFQUEyRTtJQUMzRSxhQUFhLEVBQUUsT0FBTyxDQUFDO0lBQ3ZCLHNFQUFzRTtJQUN0RSxtQkFBbUIsRUFBRSxPQUFPLENBQUM7Q0FDOUI7QUFFRDs7Ozs7O0dBTUc7QUFDSCx3QkFBc0IseUJBQXlCLENBQzdDLE1BQU0sRUFBRSxxQkFBcUIsRUFDN0IsUUFBUSxDQUFDLEVBQUUsY0FBYyxHQUN4QixPQUFPLENBQUMsaUJBQWlCLENBQUMsQ0FpRzVCO0FBTUQ7Ozs7Ozs7O0dBUUc7QUFDSCx3QkFBc0IsK0JBQStCLENBQ25ELE1BQU0sRUFBRSxxQkFBcUIsRUFDN0IseUJBQXlCLEVBQUUsT0FBT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