@aztec/archiver 3.0.0-nightly.20251210 → 3.0.0-nightly.20251211
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/dest/archiver/archiver.d.ts +9 -6
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +28 -10
- package/dest/archiver/archiver_store.d.ts +3 -3
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/config.d.ts +3 -2
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +8 -1
- package/dest/archiver/instrumentation.d.ts +3 -1
- package/dest/archiver/instrumentation.d.ts.map +1 -1
- package/dest/archiver/instrumentation.js +11 -0
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +3 -3
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.d.ts +2 -2
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts +3 -0
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/archiver/l1/bin/retrieve-calldata.js +147 -0
- package/dest/archiver/l1/calldata_retriever.d.ts +98 -0
- package/dest/archiver/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/archiver/l1/calldata_retriever.js +403 -0
- package/dest/archiver/l1/data_retrieval.d.ts +87 -0
- package/dest/archiver/l1/data_retrieval.d.ts.map +1 -0
- package/dest/archiver/{data_retrieval.js → l1/data_retrieval.js} +19 -89
- package/dest/archiver/l1/debug_tx.d.ts +19 -0
- package/dest/archiver/l1/debug_tx.d.ts.map +1 -0
- package/dest/archiver/l1/debug_tx.js +73 -0
- package/dest/archiver/l1/spire_proposer.d.ts +70 -0
- package/dest/archiver/l1/spire_proposer.d.ts.map +1 -0
- package/dest/archiver/l1/spire_proposer.js +157 -0
- package/dest/archiver/l1/trace_tx.d.ts +97 -0
- package/dest/archiver/l1/trace_tx.d.ts.map +1 -0
- package/dest/archiver/l1/trace_tx.js +91 -0
- package/dest/archiver/l1/types.d.ts +12 -0
- package/dest/archiver/l1/types.d.ts.map +1 -0
- package/dest/archiver/l1/types.js +3 -0
- package/dest/archiver/l1/validate_trace.d.ts +29 -0
- package/dest/archiver/l1/validate_trace.d.ts.map +1 -0
- package/dest/archiver/l1/validate_trace.js +150 -0
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/test/mock_l2_block_source.js +1 -1
- package/package.json +15 -14
- package/src/archiver/archiver.ts +45 -20
- package/src/archiver/archiver_store.ts +2 -2
- package/src/archiver/config.ts +8 -7
- package/src/archiver/instrumentation.ts +14 -0
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +2 -2
- package/src/archiver/kv_archiver_store/message_store.ts +1 -1
- package/src/archiver/l1/README.md +98 -0
- package/src/archiver/l1/bin/retrieve-calldata.ts +182 -0
- package/src/archiver/l1/calldata_retriever.ts +531 -0
- package/src/archiver/{data_retrieval.ts → l1/data_retrieval.ts} +50 -137
- package/src/archiver/l1/debug_tx.ts +99 -0
- package/src/archiver/l1/spire_proposer.ts +160 -0
- package/src/archiver/l1/trace_tx.ts +128 -0
- package/src/archiver/l1/types.ts +13 -0
- package/src/archiver/l1/validate_trace.ts +211 -0
- package/src/index.ts +1 -1
- 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/mock_l2_block_source.ts +1 -1
- package/dest/archiver/data_retrieval.d.ts +0 -80
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhY2VfdHguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcmNoaXZlci9sMS90cmFjZV90eC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxxQkFBcUIsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25FLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUMzRCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUNwRCxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQVcsTUFBTSwyQkFBMkIsQ0FBQztBQUdqRSxPQUFPLEtBQUssRUFBRSxHQUFHLEVBQUUsTUFBTSxNQUFNLENBQUM7QUFDaEMsT0FBTyxFQUFFLENBQUMsRUFBRSxNQUFNLEtBQUssQ0FBQztBQUV4QixPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSxZQUFZLENBQUM7QUFrQjNDLDJEQUEyRDtBQUMzRCxlQUFPLE1BQU0sV0FBVzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7RUFPdEIsQ0FBQztBQUVILDBDQUEwQztBQUMxQyxLQUFLLGdCQUFnQixHQUFHLENBQUMsQ0FBQyxLQUFLLENBQUMsT0FBTyxXQUFXLENBQUMsQ0FBQztBQUVwRCwyRUFBMkU7QUFDM0UsZUFBTyxNQUFNLDhCQUE4QixFQUFFLE1BQU0sQ0FBQyxnQkFBZ0IsRUFBRSxDQUF3QixDQUFDO0FBRS9GOzs7Ozs7Ozs7R0FTRztBQUNILHdCQUFzQiwyQkFBMkIsQ0FDL0MsTUFBTSxFQUFFLHFCQUFxQixFQUM3QixNQUFNLEVBQUUsR0FBRyxFQUNYLGFBQWEsRUFBRSxVQUFVLEVBQ3pCLGdCQUFnQixFQUFFLE1BQU0sRUFDeEIsTUFBTSxDQUFDLEVBQUUsTUFBTSxHQUNkLE9BQU8sQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQW9FckIifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace_tx.d.ts","sourceRoot":"","sources":["../../../src/archiver/l1/trace_tx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcmNoaXZlci9sMS90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFFM0QsT0FBTyxLQUFLLEVBQUUsR0FBRyxFQUFFLE1BQU0sTUFBTSxDQUFDO0FBRWhDOztHQUVHO0FBQ0gsTUFBTSxXQUFXLFFBQVE7SUFDdkIsSUFBSSxFQUFFLFVBQVUsQ0FBQztJQUNqQixPQUFPLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDakIsS0FBSyxFQUFFLEdBQUcsQ0FBQztJQUNYLEtBQUssRUFBRSxNQUFNLENBQUM7Q0FDZiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/archiver/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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ViemPublicDebugClient } from '@aztec/ethereum/types';
|
|
2
|
+
/** Result of trace availability checks */
|
|
3
|
+
export interface TraceAvailability {
|
|
4
|
+
/** Whether debug_traceTransaction works for recent blocks */
|
|
5
|
+
debugTraceRecent: boolean;
|
|
6
|
+
/** Whether trace_transaction works for recent blocks */
|
|
7
|
+
traceTransactionRecent: boolean;
|
|
8
|
+
/** Whether debug_traceTransaction works for old blocks (512 blocks ago) */
|
|
9
|
+
debugTraceOld: boolean;
|
|
10
|
+
/** Whether trace_transaction works for old blocks (512 blocks ago) */
|
|
11
|
+
traceTransactionOld: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validates the availability of debug/trace methods on the Ethereum client.
|
|
15
|
+
*
|
|
16
|
+
* @param client - The Viem public debug client
|
|
17
|
+
* @returns Object indicating which trace methods are available for recent and old blocks
|
|
18
|
+
*/
|
|
19
|
+
export declare function validateTraceAvailability(client: ViemPublicDebugClient): Promise<TraceAvailability>;
|
|
20
|
+
/**
|
|
21
|
+
* Validates trace availability and logs appropriate messages based on the results.
|
|
22
|
+
* Optionally throws an error if no trace methods are available and ethereumAllowNoDebugHosts is false.
|
|
23
|
+
*
|
|
24
|
+
* @param client - The Viem public debug client
|
|
25
|
+
* @param ethereumAllowNoDebugHosts - If false, throws an error when no trace methods are available
|
|
26
|
+
* @throws Error if ethereumAllowNoDebugHosts is false and no trace methods are available
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateAndLogTraceAvailability(client: ViemPublicDebugClient, ethereumAllowNoDebugHosts: boolean): Promise<void>;
|
|
29
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGVfdHJhY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcmNoaXZlci9sMS92YWxpZGF0ZV90cmFjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxxQkFBcUIsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBNkNuRSwwQ0FBMEM7QUFDMUMsTUFBTSxXQUFXLGlCQUFpQjtJQUNoQyw2REFBNkQ7SUFDN0QsZ0JBQWdCLEVBQUUsT0FBTyxDQUFDO0lBQzFCLHdEQUF3RDtJQUN4RCxzQkFBc0IsRUFBRSxPQUFPLENBQUM7SUFDaEMsMkVBQTJFO0lBQzNFLGFBQWEsRUFBRSxPQUFPLENBQUM7SUFDdkIsc0VBQXNFO0lBQ3RFLG1CQUFtQixFQUFFLE9BQU8sQ0FBQztDQUM5QjtBQUVEOzs7OztHQUtHO0FBQ0gsd0JBQXNCLHlCQUF5QixDQUFDLE1BQU0sRUFBRSxxQkFBcUIsR0FBRyxPQUFPLENBQUMsaUJBQWlCLENBQUMsQ0FzRnpHO0FBTUQ7Ozs7Ozs7R0FPRztBQUNILHdCQUFzQiwrQkFBK0IsQ0FDbkQsTUFBTSxFQUFFLHFCQUFxQixFQUM3Qix5QkFBeUIsRUFBRSxPQUFPLEdBQ2pDLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0E0Q2YifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate_trace.d.ts","sourceRoot":"","sources":["../../../src/archiver/l1/validate_trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AA6CnE,0CAA0C;AAC1C,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,gBAAgB,EAAE,OAAO,CAAC;IAC1B,wDAAwD;IACxD,sBAAsB,EAAE,OAAO,CAAC;IAChC,2EAA2E;IAC3E,aAAa,EAAE,OAAO,CAAC;IACvB,sEAAsE;IACtE,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAsFzG;AAMD;;;;;;;GAOG;AACH,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,qBAAqB,EAC7B,yBAAyB,EAAE,OAAO,GACjC,OAAO,CAAC,IAAI,CAAC,CA4Cf"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { callTraceSchema } from './debug_tx.js';
|
|
3
|
+
import { traceTransactionResponseSchema } from './trace_tx.js';
|
|
4
|
+
const logger = createLogger('aztec:archiver:validate_trace');
|
|
5
|
+
/**
|
|
6
|
+
* Helper function to test a trace method with validation
|
|
7
|
+
*
|
|
8
|
+
* @param client - The Viem public debug client
|
|
9
|
+
* @param txHash - Transaction hash to trace
|
|
10
|
+
* @param schema - Zod schema to validate the response
|
|
11
|
+
* @param method - Name of the RPC method ('debug_traceTransaction' or 'trace_transaction')
|
|
12
|
+
* @param blockType - Type of block being tested ('recent' or 'old')
|
|
13
|
+
* @returns true if the method works and validation passes, false otherwise
|
|
14
|
+
*/ async function testTraceMethod(client, txHash, schema, method, blockType) {
|
|
15
|
+
try {
|
|
16
|
+
// Make request with appropriate params based on method name
|
|
17
|
+
const result = await client.request(method === 'debug_traceTransaction' ? {
|
|
18
|
+
method,
|
|
19
|
+
params: [
|
|
20
|
+
txHash,
|
|
21
|
+
{
|
|
22
|
+
tracer: 'callTracer'
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
} : {
|
|
26
|
+
method,
|
|
27
|
+
params: [
|
|
28
|
+
txHash
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
schema.parse(result);
|
|
32
|
+
logger.debug(`${method} works for ${blockType} blocks`);
|
|
33
|
+
return true;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
logger.warn(`${method} failed for ${blockType} blocks: ${error}`);
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Validates the availability of debug/trace methods on the Ethereum client.
|
|
41
|
+
*
|
|
42
|
+
* @param client - The Viem public debug client
|
|
43
|
+
* @returns Object indicating which trace methods are available for recent and old blocks
|
|
44
|
+
*/ export async function validateTraceAvailability(client) {
|
|
45
|
+
const result = {
|
|
46
|
+
debugTraceRecent: false,
|
|
47
|
+
traceTransactionRecent: false,
|
|
48
|
+
debugTraceOld: false,
|
|
49
|
+
traceTransactionOld: false
|
|
50
|
+
};
|
|
51
|
+
try {
|
|
52
|
+
// Get the latest block
|
|
53
|
+
let latestBlock = await client.getBlock({
|
|
54
|
+
blockTag: 'latest'
|
|
55
|
+
});
|
|
56
|
+
let attempts = 10;
|
|
57
|
+
// Loop back to find a block with transactions (handles dev/test scenarios)
|
|
58
|
+
while(!hasTxs(latestBlock) && latestBlock.number && latestBlock.number > 0n && --attempts > 0){
|
|
59
|
+
logger.debug(`Block ${latestBlock.number} has no transactions, checking previous block`);
|
|
60
|
+
latestBlock = await client.getBlock({
|
|
61
|
+
blockNumber: latestBlock.number - 1n
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (!hasTxs(latestBlock)) {
|
|
65
|
+
logger.warn('No blocks with transactions found from latest back to genesis, cannot validate trace availability');
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
// Get a transaction from the found block
|
|
69
|
+
const recentTxHash = latestBlock.transactions[0];
|
|
70
|
+
// Test debug_traceTransaction with recent block
|
|
71
|
+
result.debugTraceRecent = await testTraceMethod(client, recentTxHash, callTraceSchema, 'debug_traceTransaction', 'recent');
|
|
72
|
+
// Test trace_transaction with recent block
|
|
73
|
+
result.traceTransactionRecent = await testTraceMethod(client, recentTxHash, traceTransactionResponseSchema, 'trace_transaction', 'recent');
|
|
74
|
+
// Get a block from 512 blocks ago
|
|
75
|
+
const oldBlockNumber = latestBlock.number ? latestBlock.number - 512n : null;
|
|
76
|
+
if (!oldBlockNumber || oldBlockNumber < 0n) {
|
|
77
|
+
logger.debug('Cannot test old blocks, blockchain too short');
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
let oldBlock = await client.getBlock({
|
|
81
|
+
blockNumber: oldBlockNumber
|
|
82
|
+
});
|
|
83
|
+
attempts = 10;
|
|
84
|
+
// Loop back to find a block with transactions (handles dev/test scenarios)
|
|
85
|
+
while(!hasTxs(oldBlock) && oldBlock.number && oldBlock.number > 0n && --attempts > 0){
|
|
86
|
+
logger.debug(`Block ${oldBlock.number} has no transactions, checking previous block`);
|
|
87
|
+
oldBlock = await client.getBlock({
|
|
88
|
+
blockNumber: oldBlock.number - 1n
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (!hasTxs(oldBlock)) {
|
|
92
|
+
logger.debug('No blocks with transactions found from old block back to genesis, cannot validate trace availability for old blocks');
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
const oldTxHash = oldBlock.transactions[0];
|
|
96
|
+
// Test debug_traceTransaction with old block
|
|
97
|
+
result.debugTraceOld = await testTraceMethod(client, oldTxHash, callTraceSchema, 'debug_traceTransaction', 'old');
|
|
98
|
+
// Test trace_transaction with old block
|
|
99
|
+
result.traceTransactionOld = await testTraceMethod(client, oldTxHash, traceTransactionResponseSchema, 'trace_transaction', 'old');
|
|
100
|
+
} catch (error) {
|
|
101
|
+
logger.warn(`Error validating debug_traceTransaction and trace_transaction availability: ${error}`);
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
function hasTxs(block) {
|
|
106
|
+
return Array.isArray(block.transactions) && block.transactions.length > 0;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Validates trace availability and logs appropriate messages based on the results.
|
|
110
|
+
* Optionally throws an error if no trace methods are available and ethereumAllowNoDebugHosts is false.
|
|
111
|
+
*
|
|
112
|
+
* @param client - The Viem public debug client
|
|
113
|
+
* @param ethereumAllowNoDebugHosts - If false, throws an error when no trace methods are available
|
|
114
|
+
* @throws Error if ethereumAllowNoDebugHosts is false and no trace methods are available
|
|
115
|
+
*/ export async function validateAndLogTraceAvailability(client, ethereumAllowNoDebugHosts) {
|
|
116
|
+
logger.info('Validating trace/debug method availability...');
|
|
117
|
+
const availability = await validateTraceAvailability(client);
|
|
118
|
+
// Check if we have support for old blocks (either debug or trace)
|
|
119
|
+
const hasOldBlockSupport = availability.debugTraceOld || availability.traceTransactionOld;
|
|
120
|
+
if (hasOldBlockSupport) {
|
|
121
|
+
// Ideal case: we have trace support for old blocks
|
|
122
|
+
const methods = [];
|
|
123
|
+
if (availability.debugTraceOld) {
|
|
124
|
+
methods.push('debug_traceTransaction');
|
|
125
|
+
}
|
|
126
|
+
if (availability.traceTransactionOld) {
|
|
127
|
+
methods.push('trace_transaction');
|
|
128
|
+
}
|
|
129
|
+
logger.info(`Ethereum client supports trace methods for old blocks (${methods.join(', ')}). Archiver can retrieve historical transaction traces.`);
|
|
130
|
+
} else if (availability.debugTraceRecent || availability.traceTransactionRecent) {
|
|
131
|
+
// Warning case: only recent block support
|
|
132
|
+
const methods = [];
|
|
133
|
+
if (availability.debugTraceRecent) {
|
|
134
|
+
methods.push('debug_traceTransaction');
|
|
135
|
+
}
|
|
136
|
+
if (availability.traceTransactionRecent) {
|
|
137
|
+
methods.push('trace_transaction');
|
|
138
|
+
}
|
|
139
|
+
logger.warn(`Ethereum client only supports trace methods for recent blocks (${methods.join(', ')}). Historical transaction traces may not be available.`);
|
|
140
|
+
} else {
|
|
141
|
+
// Error case: no support at all
|
|
142
|
+
const errorMessage = 'Ethereum debug client does not support debug_traceTransaction or trace_transaction methods. Transaction tracing will not be available. This may impact archiver syncing.';
|
|
143
|
+
if (ethereumAllowNoDebugHosts) {
|
|
144
|
+
logger.warn(`${errorMessage} Continuing because ETHEREUM_ALLOW_NO_DEBUG_HOSTS is set to true.`);
|
|
145
|
+
} else {
|
|
146
|
+
logger.error(errorMessage);
|
|
147
|
+
throw new Error(`${errorMessage} Set ETHEREUM_ALLOW_NO_DEBUG_HOSTS=true to bypass this check.`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
package/dest/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './archiver/index.js';
|
|
2
2
|
export * from './factory.js';
|
|
3
3
|
export * from './rpc/index.js';
|
|
4
|
-
export { retrieveL2ProofVerifiedEvents } from './archiver/data_retrieval.js';
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
export { retrieveCheckpointsFromRollup, retrieveL2ProofVerifiedEvents } from './archiver/l1/data_retrieval.js';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHFCQUFxQixDQUFDO0FBQ3BDLGNBQWMsY0FBYyxDQUFDO0FBQzdCLGNBQWMsZ0JBQWdCLENBQUM7QUFFL0IsT0FBTyxFQUFFLDZCQUE2QixFQUFFLDZCQUE2QixFQUFFLE1BQU0saUNBQWlDLENBQUMifQ==
|
package/dest/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAE,6BAA6B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAE,6BAA6B,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC"}
|
package/dest/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './archiver/index.js';
|
|
2
2
|
export * from './factory.js';
|
|
3
3
|
export * from './rpc/index.js';
|
|
4
|
-
export { retrieveL2ProofVerifiedEvents } from './archiver/data_retrieval.js';
|
|
4
|
+
export { retrieveCheckpointsFromRollup, retrieveL2ProofVerifiedEvents } from './archiver/l1/data_retrieval.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
2
|
-
import { DefaultL1ContractsConfig } from '@aztec/ethereum';
|
|
2
|
+
import { DefaultL1ContractsConfig } from '@aztec/ethereum/config';
|
|
3
3
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
5
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/archiver",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251211",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -66,22 +66,23 @@
|
|
|
66
66
|
]
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@aztec/blob-lib": "3.0.0-nightly.
|
|
70
|
-
"@aztec/blob-sink": "3.0.0-nightly.
|
|
71
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
72
|
-
"@aztec/epoch-cache": "3.0.0-nightly.
|
|
73
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
74
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
75
|
-
"@aztec/kv-store": "3.0.0-nightly.
|
|
76
|
-
"@aztec/l1-artifacts": "3.0.0-nightly.
|
|
77
|
-
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.
|
|
78
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
79
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
80
|
-
"@aztec/telemetry-client": "3.0.0-nightly.
|
|
69
|
+
"@aztec/blob-lib": "3.0.0-nightly.20251211",
|
|
70
|
+
"@aztec/blob-sink": "3.0.0-nightly.20251211",
|
|
71
|
+
"@aztec/constants": "3.0.0-nightly.20251211",
|
|
72
|
+
"@aztec/epoch-cache": "3.0.0-nightly.20251211",
|
|
73
|
+
"@aztec/ethereum": "3.0.0-nightly.20251211",
|
|
74
|
+
"@aztec/foundation": "3.0.0-nightly.20251211",
|
|
75
|
+
"@aztec/kv-store": "3.0.0-nightly.20251211",
|
|
76
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20251211",
|
|
77
|
+
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251211",
|
|
78
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20251211",
|
|
79
|
+
"@aztec/stdlib": "3.0.0-nightly.20251211",
|
|
80
|
+
"@aztec/telemetry-client": "3.0.0-nightly.20251211",
|
|
81
81
|
"lodash.groupby": "^4.6.0",
|
|
82
82
|
"lodash.omit": "^4.5.0",
|
|
83
83
|
"tslib": "^2.5.0",
|
|
84
|
-
"viem": "npm:@aztec/viem@2.38.2"
|
|
84
|
+
"viem": "npm:@aztec/viem@2.38.2",
|
|
85
|
+
"zod": "^3.23.8"
|
|
85
86
|
},
|
|
86
87
|
"devDependencies": {
|
|
87
88
|
"@jest/globals": "^30.0.0",
|
package/src/archiver/archiver.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
|
|
2
2
|
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
3
3
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type ViemPublicClient,
|
|
10
|
-
createEthereumChain,
|
|
11
|
-
} from '@aztec/ethereum';
|
|
4
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
5
|
+
import { BlockTagTooOldError, InboxContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
6
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
7
|
+
import type { L1BlockId } from '@aztec/ethereum/l1-types';
|
|
8
|
+
import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
|
|
12
9
|
import { maxBigint } from '@aztec/foundation/bigint';
|
|
13
10
|
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
14
11
|
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
@@ -81,14 +78,15 @@ import { type GetContractReturnType, type Hex, createPublicClient, fallback, htt
|
|
|
81
78
|
|
|
82
79
|
import type { ArchiverDataStore, ArchiverL1SynchPoint } from './archiver_store.js';
|
|
83
80
|
import type { ArchiverConfig } from './config.js';
|
|
81
|
+
import { InitialBlockNumberNotSequentialError, NoBlobBodiesFoundError } from './errors.js';
|
|
82
|
+
import { ArchiverInstrumentation } from './instrumentation.js';
|
|
84
83
|
import {
|
|
85
84
|
retrieveCheckpointsFromRollup,
|
|
86
85
|
retrieveL1ToL2Message,
|
|
87
86
|
retrieveL1ToL2Messages,
|
|
88
87
|
retrievedToPublishedCheckpoint,
|
|
89
|
-
} from './data_retrieval.js';
|
|
90
|
-
import {
|
|
91
|
-
import { ArchiverInstrumentation } from './instrumentation.js';
|
|
88
|
+
} from './l1/data_retrieval.js';
|
|
89
|
+
import { validateAndLogTraceAvailability } from './l1/validate_trace.js';
|
|
92
90
|
import type { InboxMessage } from './structs/inbox_message.js';
|
|
93
91
|
import { type ValidateBlockResult, validateCheckpointAttestations } from './validation.js';
|
|
94
92
|
|
|
@@ -110,6 +108,7 @@ function mapArchiverConfig(config: Partial<ArchiverConfig>) {
|
|
|
110
108
|
batchSize: config.archiverBatchSize,
|
|
111
109
|
skipValidateBlockAttestations: config.skipValidateBlockAttestations,
|
|
112
110
|
maxAllowedEthClientDriftSeconds: config.maxAllowedEthClientDriftSeconds,
|
|
111
|
+
ethereumAllowNoDebugHosts: config.ethereumAllowNoDebugHosts,
|
|
113
112
|
};
|
|
114
113
|
}
|
|
115
114
|
|
|
@@ -147,6 +146,7 @@ export class Archiver extends (EventEmitter as new () => ArchiverEmitter) implem
|
|
|
147
146
|
/**
|
|
148
147
|
* Creates a new instance of the Archiver.
|
|
149
148
|
* @param publicClient - A client for interacting with the Ethereum node.
|
|
149
|
+
* @param debugClient - A client for interacting with the Ethereum node for debug/trace methods.
|
|
150
150
|
* @param rollupAddress - Ethereum address of the rollup contract.
|
|
151
151
|
* @param inboxAddress - Ethereum address of the inbox contract.
|
|
152
152
|
* @param registryAddress - Ethereum address of the registry contract.
|
|
@@ -156,13 +156,18 @@ export class Archiver extends (EventEmitter as new () => ArchiverEmitter) implem
|
|
|
156
156
|
*/
|
|
157
157
|
constructor(
|
|
158
158
|
private readonly publicClient: ViemPublicClient,
|
|
159
|
-
private readonly
|
|
159
|
+
private readonly debugClient: ViemPublicDebugClient,
|
|
160
|
+
private readonly l1Addresses: Pick<
|
|
161
|
+
L1ContractAddresses,
|
|
162
|
+
'rollupAddress' | 'inboxAddress' | 'registryAddress' | 'governanceProposerAddress' | 'slashFactoryAddress'
|
|
163
|
+
> & { slashingProposerAddress: EthAddress },
|
|
160
164
|
readonly dataStore: ArchiverDataStore,
|
|
161
165
|
private config: {
|
|
162
166
|
pollingIntervalMs: number;
|
|
163
167
|
batchSize: number;
|
|
164
168
|
skipValidateBlockAttestations?: boolean;
|
|
165
169
|
maxAllowedEthClientDriftSeconds: number;
|
|
170
|
+
ethereumAllowNoDebugHosts?: boolean;
|
|
166
171
|
},
|
|
167
172
|
private readonly blobSinkClient: BlobSinkClientInterface,
|
|
168
173
|
private readonly epochCache: EpochCache,
|
|
@@ -210,14 +215,24 @@ export class Archiver extends (EventEmitter as new () => ArchiverEmitter) implem
|
|
|
210
215
|
pollingInterval: config.viemPollingIntervalMS,
|
|
211
216
|
});
|
|
212
217
|
|
|
218
|
+
// Create debug client using debug RPC URLs if available, otherwise fall back to regular RPC URLs
|
|
219
|
+
const debugRpcUrls = config.l1DebugRpcUrls.length > 0 ? config.l1DebugRpcUrls : config.l1RpcUrls;
|
|
220
|
+
const debugClient = createPublicClient({
|
|
221
|
+
chain: chain.chainInfo,
|
|
222
|
+
transport: fallback(debugRpcUrls.map(url => http(url))),
|
|
223
|
+
pollingInterval: config.viemPollingIntervalMS,
|
|
224
|
+
}) as ViemPublicDebugClient;
|
|
225
|
+
|
|
213
226
|
const rollup = new RollupContract(publicClient, config.l1Contracts.rollupAddress);
|
|
214
227
|
|
|
215
|
-
const [l1StartBlock, l1GenesisTime, proofSubmissionEpochs, genesisArchiveRoot] =
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
228
|
+
const [l1StartBlock, l1GenesisTime, proofSubmissionEpochs, genesisArchiveRoot, slashingProposerAddress] =
|
|
229
|
+
await Promise.all([
|
|
230
|
+
rollup.getL1StartBlock(),
|
|
231
|
+
rollup.getL1GenesisTime(),
|
|
232
|
+
rollup.getProofSubmissionEpochs(),
|
|
233
|
+
rollup.getGenesisArchiveTreeRoot(),
|
|
234
|
+
rollup.getSlashingProposerAddress(),
|
|
235
|
+
] as const);
|
|
221
236
|
|
|
222
237
|
const l1StartBlockHash = await publicClient
|
|
223
238
|
.getBlock({ blockNumber: l1StartBlock, includeTransactions: false })
|
|
@@ -237,7 +252,12 @@ export class Archiver extends (EventEmitter as new () => ArchiverEmitter) implem
|
|
|
237
252
|
};
|
|
238
253
|
|
|
239
254
|
const opts = merge(
|
|
240
|
-
{
|
|
255
|
+
{
|
|
256
|
+
pollingIntervalMs: 10_000,
|
|
257
|
+
batchSize: 100,
|
|
258
|
+
maxAllowedEthClientDriftSeconds: 300,
|
|
259
|
+
ethereumAllowNoDebugHosts: false,
|
|
260
|
+
},
|
|
241
261
|
mapArchiverConfig(config),
|
|
242
262
|
);
|
|
243
263
|
|
|
@@ -246,7 +266,8 @@ export class Archiver extends (EventEmitter as new () => ArchiverEmitter) implem
|
|
|
246
266
|
|
|
247
267
|
const archiver = new Archiver(
|
|
248
268
|
publicClient,
|
|
249
|
-
|
|
269
|
+
debugClient,
|
|
270
|
+
{ ...config.l1Contracts, slashingProposerAddress },
|
|
250
271
|
archiverStore,
|
|
251
272
|
opts,
|
|
252
273
|
deps.blobSinkClient,
|
|
@@ -275,6 +296,7 @@ export class Archiver extends (EventEmitter as new () => ArchiverEmitter) implem
|
|
|
275
296
|
|
|
276
297
|
await this.blobSinkClient.testSources();
|
|
277
298
|
await this.testEthereumNodeSynced();
|
|
299
|
+
await validateAndLogTraceAvailability(this.debugClient, this.config.ethereumAllowNoDebugHosts ?? false);
|
|
278
300
|
|
|
279
301
|
// Log initial state for the archiver
|
|
280
302
|
const { l1StartBlock } = this.l1constants;
|
|
@@ -853,9 +875,12 @@ export class Archiver extends (EventEmitter as new () => ArchiverEmitter) implem
|
|
|
853
875
|
const retrievedCheckpoints = await retrieveCheckpointsFromRollup(
|
|
854
876
|
this.rollup.getContract() as GetContractReturnType<typeof RollupAbi, ViemPublicClient>,
|
|
855
877
|
this.publicClient,
|
|
878
|
+
this.debugClient,
|
|
856
879
|
this.blobSinkClient,
|
|
857
880
|
searchStartBlock, // TODO(palla/reorg): If the L2 reorg was due to an L1 reorg, we need to start search earlier
|
|
858
881
|
searchEndBlock,
|
|
882
|
+
this.l1Addresses,
|
|
883
|
+
this.instrumentation,
|
|
859
884
|
this.log,
|
|
860
885
|
);
|
|
861
886
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { L1BlockId } from '@aztec/ethereum';
|
|
2
|
-
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import type { L1BlockId } from '@aztec/ethereum/l1-types';
|
|
2
|
+
import type { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import type { CustomRange } from '@aztec/kv-store';
|
|
5
5
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|