@aztec/archiver 0.0.1-commit.7d4e6cd → 0.0.1-commit.9372f48
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 +136 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +781 -0
- package/dest/{archiver/config.d.ts → config.d.ts} +9 -1
- package/dest/config.d.ts.map +1 -0
- package/dest/{archiver/config.js → config.js} +9 -0
- package/dest/errors.d.ts +41 -0
- package/dest/errors.d.ts.map +1 -0
- package/dest/{archiver/errors.js → errors.js} +8 -0
- package/dest/factory.d.ts +9 -7
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +89 -11
- package/dest/index.d.ts +10 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +8 -3
- package/dest/interfaces.d.ts +9 -0
- package/dest/interfaces.d.ts.map +1 -0
- package/dest/interfaces.js +3 -0
- package/dest/{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 +2 -2
- package/dest/{archiver/l1 → l1}/calldata_retriever.d.ts +2 -2
- package/dest/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/l1/data_retrieval.d.ts +88 -0
- package/dest/l1/data_retrieval.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/data_retrieval.js +36 -55
- 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 +13 -9
- package/dest/modules/data_source_base.d.ts +84 -0
- package/dest/modules/data_source_base.d.ts.map +1 -0
- package/dest/modules/data_source_base.js +260 -0
- package/dest/modules/data_store_updater.d.ts +73 -0
- package/dest/modules/data_store_updater.d.ts.map +1 -0
- package/dest/modules/data_store_updater.js +302 -0
- package/dest/modules/instrumentation.d.ts +37 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/{archiver → modules}/instrumentation.js +17 -10
- package/dest/modules/l1_synchronizer.d.ts +75 -0
- package/dest/modules/l1_synchronizer.d.ts.map +1 -0
- package/dest/modules/l1_synchronizer.js +1112 -0
- package/dest/{archiver → modules}/validation.d.ts +1 -1
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/{archiver → modules}/validation.js +6 -0
- package/dest/store/block_store.d.ts +192 -0
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/block_store.js +142 -47
- 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 +340 -0
- package/dest/store/kv_archiver_store.d.ts.map +1 -0
- package/dest/store/kv_archiver_store.js +446 -0
- package/dest/store/log_store.d.ts +54 -0
- package/dest/store/log_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/log_store.js +91 -56
- 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 +190 -0
- package/dest/test/fake_l1_state.d.ts.map +1 -0
- package/dest/test/fake_l1_state.js +383 -0
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +4 -1
- package/dest/test/mock_archiver.d.ts +2 -2
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +1 -2
- package/dest/test/mock_l2_block_source.d.ts +20 -17
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +108 -48
- 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 +543 -0
- package/src/{archiver/config.ts → config.ts} +11 -0
- package/src/{archiver/errors.ts → errors.ts} +12 -0
- package/src/factory.ts +125 -11
- package/src/index.ts +10 -3
- package/src/interfaces.ts +9 -0
- package/src/{archiver/l1 → l1}/bin/retrieve-calldata.ts +7 -2
- package/src/{archiver/l1 → l1}/calldata_retriever.ts +1 -1
- package/src/{archiver/l1 → l1}/data_retrieval.ts +57 -74
- package/src/{archiver/l1 → l1}/validate_trace.ts +24 -6
- package/src/modules/data_source_base.ts +367 -0
- package/src/modules/data_store_updater.ts +423 -0
- package/src/{archiver → modules}/instrumentation.ts +17 -12
- package/src/modules/l1_synchronizer.ts +930 -0
- package/src/{archiver → modules}/validation.ts +5 -0
- package/src/{archiver/kv_archiver_store → store}/block_store.ts +179 -63
- 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 +234 -37
- package/src/{archiver/kv_archiver_store → store}/log_store.ts +149 -90
- package/src/test/fake_l1_state.ts +599 -0
- package/src/test/index.ts +4 -0
- package/src/test/mock_archiver.ts +2 -2
- package/src/test/mock_l2_block_source.ts +114 -66
- package/src/test/mock_structs.ts +269 -8
- package/src/test/noop_l1_archiver.ts +109 -0
- package/dest/archiver/archiver.d.ts +0 -307
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -2102
- package/dest/archiver/archiver_store.d.ts +0 -315
- package/dest/archiver/archiver_store.d.ts.map +0 -1
- package/dest/archiver/archiver_store.js +0 -4
- package/dest/archiver/archiver_store_test_suite.d.ts +0 -8
- package/dest/archiver/archiver_store_test_suite.d.ts.map +0 -1
- package/dest/archiver/archiver_store_test_suite.js +0 -2770
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/errors.d.ts +0 -36
- package/dest/archiver/errors.d.ts.map +0 -1
- package/dest/archiver/index.d.ts +0 -7
- package/dest/archiver/index.d.ts.map +0 -1
- package/dest/archiver/index.js +0 -4
- package/dest/archiver/instrumentation.d.ts +0 -37
- package/dest/archiver/instrumentation.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -164
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +0 -18
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -24
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -159
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +0 -316
- package/dest/archiver/kv_archiver_store/log_store.d.ts +0 -45
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +0 -1
- package/dest/archiver/l1/calldata_retriever.d.ts.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.map +0 -1
- package/dest/rpc/index.d.ts +0 -9
- package/dest/rpc/index.d.ts.map +0 -1
- package/dest/rpc/index.js +0 -15
- package/src/archiver/archiver.ts +0 -2265
- package/src/archiver/archiver_store.ts +0 -380
- package/src/archiver/archiver_store_test_suite.ts +0 -2842
- package/src/archiver/index.ts +0 -6
- package/src/rpc/index.ts +0 -16
- /package/dest/{archiver/l1 → l1}/calldata_retriever.js +0 -0
- /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
|
@@ -88,3 +88,15 @@ export class BlockNotFoundError extends Error {
|
|
|
88
88
|
super(`Failed to find expected block number ${blockNumber}`);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
+
|
|
92
|
+
export class CannotOverwriteCheckpointedBlockError extends Error {
|
|
93
|
+
constructor(
|
|
94
|
+
public readonly blockNumber: number,
|
|
95
|
+
public readonly lastCheckpointedBlock: number,
|
|
96
|
+
) {
|
|
97
|
+
super(
|
|
98
|
+
`Cannot add block ${blockNumber}: would overwrite checkpointed data (checkpointed up to block ${lastCheckpointedBlock})`,
|
|
99
|
+
);
|
|
100
|
+
this.name = 'CannotOverwriteCheckpointedBlockError';
|
|
101
|
+
}
|
|
102
|
+
}
|
package/src/factory.ts
CHANGED
|
@@ -1,36 +1,51 @@
|
|
|
1
|
+
import { EpochCache } from '@aztec/epoch-cache';
|
|
2
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
3
|
+
import { InboxContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
4
|
+
import type { ViemPublicDebugClient } from '@aztec/ethereum/types';
|
|
1
5
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import {
|
|
6
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
7
|
+
import { merge } from '@aztec/foundation/collection';
|
|
8
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
3
10
|
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
4
11
|
import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
5
12
|
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
6
13
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
7
14
|
import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
|
|
15
|
+
import type { ArchiverEmitter } from '@aztec/stdlib/block';
|
|
8
16
|
import { type ContractClassPublic, computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
|
|
17
|
+
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
18
|
+
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
9
19
|
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
|
|
20
|
+
import { EventEmitter } from 'events';
|
|
21
|
+
import { createPublicClient, fallback, http } from 'viem';
|
|
22
|
+
|
|
23
|
+
import { Archiver, type ArchiverDeps } from './archiver.js';
|
|
24
|
+
import { type ArchiverConfig, mapArchiverConfig } from './config.js';
|
|
25
|
+
import { ArchiverInstrumentation } from './modules/instrumentation.js';
|
|
26
|
+
import { ArchiverL1Synchronizer } from './modules/l1_synchronizer.js';
|
|
27
|
+
import { ARCHIVER_DB_VERSION, KVArchiverDataStore } from './store/kv_archiver_store.js';
|
|
13
28
|
|
|
14
29
|
export const ARCHIVER_STORE_NAME = 'archiver';
|
|
15
30
|
|
|
16
31
|
/** Creates an archiver store. */
|
|
17
32
|
export async function createArchiverStore(
|
|
18
33
|
userConfig: Pick<ArchiverConfig, 'archiverStoreMapSizeKb' | 'maxLogs'> & DataStoreConfig,
|
|
34
|
+
l1Constants: Pick<L1RollupConstants, 'epochDuration'>,
|
|
19
35
|
) {
|
|
20
36
|
const config = {
|
|
21
37
|
...userConfig,
|
|
22
38
|
dataStoreMapSizeKb: userConfig.archiverStoreMapSizeKb ?? userConfig.dataStoreMapSizeKb,
|
|
23
39
|
};
|
|
24
|
-
const store = await createStore(ARCHIVER_STORE_NAME, ARCHIVER_DB_VERSION, config
|
|
25
|
-
return new KVArchiverDataStore(store, config.maxLogs);
|
|
40
|
+
const store = await createStore(ARCHIVER_STORE_NAME, ARCHIVER_DB_VERSION, config);
|
|
41
|
+
return new KVArchiverDataStore(store, config.maxLogs, l1Constants);
|
|
26
42
|
}
|
|
27
43
|
|
|
28
44
|
/**
|
|
29
45
|
* Creates a local archiver.
|
|
30
46
|
* @param config - The archiver configuration.
|
|
31
|
-
* @param
|
|
47
|
+
* @param deps - The archiver dependencies (blobClient, epochCache, dateProvider, telemetry).
|
|
32
48
|
* @param opts - The options.
|
|
33
|
-
* @param telemetry - The telemetry client.
|
|
34
49
|
* @returns The local archiver.
|
|
35
50
|
*/
|
|
36
51
|
export async function createArchiver(
|
|
@@ -38,12 +53,111 @@ export async function createArchiver(
|
|
|
38
53
|
deps: ArchiverDeps,
|
|
39
54
|
opts: { blockUntilSync: boolean } = { blockUntilSync: true },
|
|
40
55
|
): Promise<Archiver> {
|
|
41
|
-
const archiverStore = await createArchiverStore(config);
|
|
56
|
+
const archiverStore = await createArchiverStore(config, { epochDuration: config.aztecEpochDuration });
|
|
42
57
|
await registerProtocolContracts(archiverStore);
|
|
43
|
-
|
|
58
|
+
|
|
59
|
+
// Create Ethereum clients
|
|
60
|
+
const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
61
|
+
const publicClient = createPublicClient({
|
|
62
|
+
chain: chain.chainInfo,
|
|
63
|
+
transport: fallback(config.l1RpcUrls.map(url => http(url, { batch: false }))),
|
|
64
|
+
pollingInterval: config.viemPollingIntervalMS,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Create debug client using debug RPC URLs if available, otherwise fall back to regular RPC URLs
|
|
68
|
+
const debugRpcUrls = config.l1DebugRpcUrls.length > 0 ? config.l1DebugRpcUrls : config.l1RpcUrls;
|
|
69
|
+
const debugClient = createPublicClient({
|
|
70
|
+
chain: chain.chainInfo,
|
|
71
|
+
transport: fallback(debugRpcUrls.map(url => http(url, { batch: false }))),
|
|
72
|
+
pollingInterval: config.viemPollingIntervalMS,
|
|
73
|
+
}) as ViemPublicDebugClient;
|
|
74
|
+
|
|
75
|
+
// Create L1 contract instances
|
|
76
|
+
const rollup = new RollupContract(publicClient, config.l1Contracts.rollupAddress);
|
|
77
|
+
const inbox = new InboxContract(publicClient, config.l1Contracts.inboxAddress);
|
|
78
|
+
|
|
79
|
+
// Fetch L1 constants from rollup contract
|
|
80
|
+
const [l1StartBlock, l1GenesisTime, proofSubmissionEpochs, genesisArchiveRoot, slashingProposerAddress] =
|
|
81
|
+
await Promise.all([
|
|
82
|
+
rollup.getL1StartBlock(),
|
|
83
|
+
rollup.getL1GenesisTime(),
|
|
84
|
+
rollup.getProofSubmissionEpochs(),
|
|
85
|
+
rollup.getGenesisArchiveTreeRoot(),
|
|
86
|
+
rollup.getSlashingProposerAddress(),
|
|
87
|
+
] as const);
|
|
88
|
+
|
|
89
|
+
const l1StartBlockHash = await publicClient
|
|
90
|
+
.getBlock({ blockNumber: l1StartBlock, includeTransactions: false })
|
|
91
|
+
.then(block => Buffer32.fromString(block.hash));
|
|
92
|
+
|
|
93
|
+
const { aztecEpochDuration: epochDuration, aztecSlotDuration: slotDuration, ethereumSlotDuration } = config;
|
|
94
|
+
|
|
95
|
+
const l1Constants = {
|
|
96
|
+
l1StartBlockHash,
|
|
97
|
+
l1StartBlock,
|
|
98
|
+
l1GenesisTime,
|
|
99
|
+
epochDuration,
|
|
100
|
+
slotDuration,
|
|
101
|
+
ethereumSlotDuration,
|
|
102
|
+
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
103
|
+
genesisArchiveRoot: Fr.fromString(genesisArchiveRoot.toString()),
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const archiverConfig = merge(
|
|
107
|
+
{
|
|
108
|
+
pollingIntervalMs: 10_000,
|
|
109
|
+
batchSize: 100,
|
|
110
|
+
maxAllowedEthClientDriftSeconds: 300,
|
|
111
|
+
ethereumAllowNoDebugHosts: false,
|
|
112
|
+
},
|
|
113
|
+
mapArchiverConfig(config),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const epochCache = deps.epochCache ?? (await EpochCache.create(config.l1Contracts.rollupAddress, config, deps));
|
|
117
|
+
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
118
|
+
const instrumentation = await ArchiverInstrumentation.new(telemetry, () => archiverStore.estimateSize());
|
|
119
|
+
|
|
120
|
+
// Create the event emitter that will be shared by archiver and synchronizer
|
|
121
|
+
const events = new EventEmitter() as ArchiverEmitter;
|
|
122
|
+
|
|
123
|
+
// Create the L1 synchronizer
|
|
124
|
+
const synchronizer = new ArchiverL1Synchronizer(
|
|
125
|
+
publicClient,
|
|
126
|
+
debugClient,
|
|
127
|
+
rollup,
|
|
128
|
+
inbox,
|
|
129
|
+
{ ...config.l1Contracts, slashingProposerAddress },
|
|
130
|
+
archiverStore,
|
|
131
|
+
archiverConfig,
|
|
132
|
+
deps.blobClient,
|
|
133
|
+
epochCache,
|
|
134
|
+
deps.dateProvider ?? new DateProvider(),
|
|
135
|
+
instrumentation,
|
|
136
|
+
l1Constants,
|
|
137
|
+
events,
|
|
138
|
+
instrumentation.tracer,
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const archiver = new Archiver(
|
|
142
|
+
publicClient,
|
|
143
|
+
debugClient,
|
|
144
|
+
rollup,
|
|
145
|
+
{ ...config.l1Contracts, slashingProposerAddress },
|
|
146
|
+
archiverStore,
|
|
147
|
+
archiverConfig,
|
|
148
|
+
deps.blobClient,
|
|
149
|
+
instrumentation,
|
|
150
|
+
l1Constants,
|
|
151
|
+
synchronizer,
|
|
152
|
+
events,
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
await archiver.start(opts.blockUntilSync);
|
|
156
|
+
return archiver;
|
|
44
157
|
}
|
|
45
158
|
|
|
46
|
-
|
|
159
|
+
/** Registers protocol contracts in the archiver store. */
|
|
160
|
+
export async function registerProtocolContracts(store: KVArchiverDataStore) {
|
|
47
161
|
const blockNumber = 0;
|
|
48
162
|
for (const name of protocolContractNames) {
|
|
49
163
|
const provider = new BundledProtocolContractsProvider();
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
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
|
+
|
|
12
|
+
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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
|
|
3
|
-
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
6
|
|
|
@@ -142,7 +142,12 @@ async function main() {
|
|
|
142
142
|
logger.info('');
|
|
143
143
|
|
|
144
144
|
// For this script, we don't have blob hashes or expected hashes, so pass empty arrays/objects
|
|
145
|
-
const result = await retriever.getCheckpointFromRollupTx(
|
|
145
|
+
const result = await retriever.getCheckpointFromRollupTx(
|
|
146
|
+
txHash,
|
|
147
|
+
[],
|
|
148
|
+
CheckpointNumber.fromBlockNumber(BlockNumber(l2BlockNumber)),
|
|
149
|
+
{},
|
|
150
|
+
);
|
|
146
151
|
|
|
147
152
|
logger.info(' Successfully retrieved block header!');
|
|
148
153
|
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';
|
|
@@ -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';
|
|
@@ -71,7 +69,7 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
71
69
|
const l1toL2MessageTreeRoot = blocksBlobData[0].l1ToL2MessageRoot!;
|
|
72
70
|
|
|
73
71
|
const spongeBlob = SpongeBlob.init();
|
|
74
|
-
const l2Blocks:
|
|
72
|
+
const l2Blocks: L2Block[] = [];
|
|
75
73
|
for (let i = 0; i < blocksBlobData.length; i++) {
|
|
76
74
|
const blockBlobData = blocksBlobData[i];
|
|
77
75
|
const { blockEndMarker, blockEndStateField, lastArchiveRoot, noteHashRoot, nullifierRoot, publicDataRoot } =
|
|
@@ -102,7 +100,7 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
102
100
|
}),
|
|
103
101
|
});
|
|
104
102
|
|
|
105
|
-
const body = Body.fromTxBlobData(
|
|
103
|
+
const body = Body.fromTxBlobData(blockBlobData.txs);
|
|
106
104
|
|
|
107
105
|
const blobFields = encodeBlockBlobData(blockBlobData);
|
|
108
106
|
await spongeBlob.absorb(blobFields);
|
|
@@ -121,7 +119,7 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
121
119
|
|
|
122
120
|
const newArchive = new AppendOnlyTreeSnapshot(newArchiveRoots[i], l2BlockNumber + 1);
|
|
123
121
|
|
|
124
|
-
l2Blocks.push(new
|
|
122
|
+
l2Blocks.push(new L2Block(newArchive, header, body, checkpointNumber, IndexWithinCheckpoint(i)));
|
|
125
123
|
}
|
|
126
124
|
|
|
127
125
|
const lastBlock = l2Blocks.at(-1)!;
|
|
@@ -137,7 +135,7 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
137
135
|
|
|
138
136
|
/**
|
|
139
137
|
* Fetches new checkpoints.
|
|
140
|
-
* @param rollup - The rollup contract
|
|
138
|
+
* @param rollup - The rollup contract wrapper.
|
|
141
139
|
* @param publicClient - The viem public client to use for transaction retrieval.
|
|
142
140
|
* @param debugClient - The viem debug client to use for trace/debug RPC methods (optional).
|
|
143
141
|
* @param blobClient - The blob client client for fetching blob data.
|
|
@@ -150,7 +148,7 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
150
148
|
* @returns An array of retrieved checkpoints.
|
|
151
149
|
*/
|
|
152
150
|
export async function retrieveCheckpointsFromRollup(
|
|
153
|
-
rollup:
|
|
151
|
+
rollup: RollupContract,
|
|
154
152
|
publicClient: ViemPublicClient,
|
|
155
153
|
debugClient: ViemPublicDebugClient,
|
|
156
154
|
blobClient: BlobClientInterface,
|
|
@@ -173,15 +171,7 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
173
171
|
if (searchStartBlock > searchEndBlock) {
|
|
174
172
|
break;
|
|
175
173
|
}
|
|
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);
|
|
174
|
+
const checkpointProposedLogs = await rollup.getCheckpointProposedEvents(searchStartBlock, searchEndBlock);
|
|
185
175
|
|
|
186
176
|
if (checkpointProposedLogs.length === 0) {
|
|
187
177
|
break;
|
|
@@ -189,19 +179,19 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
189
179
|
|
|
190
180
|
const lastLog = checkpointProposedLogs.at(-1)!;
|
|
191
181
|
logger.debug(
|
|
192
|
-
`Got ${checkpointProposedLogs.length} processed logs for checkpoints
|
|
182
|
+
`Got ${checkpointProposedLogs.length} processed logs for checkpoints ${checkpointProposedLogs[0].args.checkpointNumber}-${lastLog.args.checkpointNumber} between L1 blocks ${searchStartBlock}-${searchEndBlock}`,
|
|
193
183
|
);
|
|
194
184
|
|
|
195
185
|
if (rollupConstants === undefined) {
|
|
196
186
|
const [chainId, version, targetCommitteeSize] = await Promise.all([
|
|
197
187
|
publicClient.getChainId(),
|
|
198
|
-
rollup.
|
|
199
|
-
rollup.
|
|
188
|
+
rollup.getVersion(),
|
|
189
|
+
rollup.getTargetCommitteeSize(),
|
|
200
190
|
]);
|
|
201
191
|
rollupConstants = {
|
|
202
192
|
chainId: new Fr(chainId),
|
|
203
193
|
version: new Fr(version),
|
|
204
|
-
targetCommitteeSize
|
|
194
|
+
targetCommitteeSize,
|
|
205
195
|
};
|
|
206
196
|
}
|
|
207
197
|
|
|
@@ -218,7 +208,7 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
218
208
|
isHistoricalSync,
|
|
219
209
|
);
|
|
220
210
|
retrievedCheckpoints.push(...newCheckpoints);
|
|
221
|
-
searchStartBlock = lastLog.
|
|
211
|
+
searchStartBlock = lastLog.l1BlockNumber + 1n;
|
|
222
212
|
} while (searchStartBlock <= searchEndBlock);
|
|
223
213
|
|
|
224
214
|
// The asyncPool from processCheckpointProposedLogs will not necessarily return the checkpoints in order, so we sort them before returning.
|
|
@@ -227,7 +217,7 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
227
217
|
|
|
228
218
|
/**
|
|
229
219
|
* Processes newly received CheckpointProposed logs.
|
|
230
|
-
* @param rollup - The rollup contract
|
|
220
|
+
* @param rollup - The rollup contract wrapper.
|
|
231
221
|
* @param publicClient - The viem public client to use for transaction retrieval.
|
|
232
222
|
* @param debugClient - The viem debug client to use for trace/debug RPC methods (optional).
|
|
233
223
|
* @param blobClient - The blob client client for fetching blob data.
|
|
@@ -240,11 +230,11 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
240
230
|
* @returns An array of retrieved checkpoints.
|
|
241
231
|
*/
|
|
242
232
|
async function processCheckpointProposedLogs(
|
|
243
|
-
rollup:
|
|
233
|
+
rollup: RollupContract,
|
|
244
234
|
publicClient: ViemPublicClient,
|
|
245
235
|
debugClient: ViemPublicDebugClient,
|
|
246
236
|
blobClient: BlobClientInterface,
|
|
247
|
-
logs:
|
|
237
|
+
logs: CheckpointProposedLog[],
|
|
248
238
|
{ chainId, version, targetCommitteeSize }: { chainId: Fr; version: Fr; targetCommitteeSize: number },
|
|
249
239
|
contractAddresses: {
|
|
250
240
|
governanceProposerAddress: EthAddress;
|
|
@@ -266,21 +256,21 @@ async function processCheckpointProposedLogs(
|
|
|
266
256
|
);
|
|
267
257
|
|
|
268
258
|
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
|
|
259
|
+
const checkpointNumber = log.args.checkpointNumber;
|
|
260
|
+
const archive = log.args.archive;
|
|
261
|
+
const archiveFromChain = await rollup.archiveAt(checkpointNumber);
|
|
262
|
+
const blobHashes = log.args.versionedBlobHashes;
|
|
273
263
|
|
|
274
264
|
// The value from the event and contract will match only if the checkpoint is in the chain.
|
|
275
|
-
if (archive
|
|
265
|
+
if (archive.equals(archiveFromChain)) {
|
|
276
266
|
// Build expected hashes object (fields may be undefined for backwards compatibility with older events)
|
|
277
267
|
const expectedHashes = {
|
|
278
|
-
attestationsHash: log.args.attestationsHash,
|
|
279
|
-
payloadDigest: log.args.payloadDigest,
|
|
268
|
+
attestationsHash: log.args.attestationsHash?.toString(),
|
|
269
|
+
payloadDigest: log.args.payloadDigest?.toString(),
|
|
280
270
|
};
|
|
281
271
|
|
|
282
272
|
const checkpoint = await calldataRetriever.getCheckpointFromRollupTx(
|
|
283
|
-
log.
|
|
273
|
+
log.l1TransactionHash,
|
|
284
274
|
blobHashes,
|
|
285
275
|
checkpointNumber,
|
|
286
276
|
expectedHashes,
|
|
@@ -295,22 +285,22 @@ async function processCheckpointProposedLogs(
|
|
|
295
285
|
);
|
|
296
286
|
|
|
297
287
|
const l1 = new L1PublishedData(
|
|
298
|
-
log.
|
|
299
|
-
await getL1BlockTime(publicClient, log.
|
|
300
|
-
log.
|
|
288
|
+
log.l1BlockNumber,
|
|
289
|
+
await getL1BlockTime(publicClient, log.l1BlockNumber),
|
|
290
|
+
log.l1BlockHash.toString(),
|
|
301
291
|
);
|
|
302
292
|
|
|
303
293
|
retrievedCheckpoints.push({ ...checkpoint, checkpointBlobData, l1, chainId, version });
|
|
304
|
-
logger.trace(`Retrieved checkpoint ${checkpointNumber} from L1 tx ${log.
|
|
305
|
-
l1BlockNumber: log.
|
|
294
|
+
logger.trace(`Retrieved checkpoint ${checkpointNumber} from L1 tx ${log.l1TransactionHash}`, {
|
|
295
|
+
l1BlockNumber: log.l1BlockNumber,
|
|
306
296
|
checkpointNumber,
|
|
307
297
|
archive: archive.toString(),
|
|
308
298
|
attestations: checkpoint.attestations,
|
|
309
299
|
});
|
|
310
300
|
} else {
|
|
311
301
|
logger.warn(`Ignoring checkpoint ${checkpointNumber} due to archive root mismatch`, {
|
|
312
|
-
actual: archive,
|
|
313
|
-
expected: archiveFromChain,
|
|
302
|
+
actual: archive.toString(),
|
|
303
|
+
expected: archiveFromChain.toString(),
|
|
314
304
|
});
|
|
315
305
|
}
|
|
316
306
|
});
|
|
@@ -355,12 +345,12 @@ export async function getCheckpointBlobDataFromBlobs(
|
|
|
355
345
|
|
|
356
346
|
/** Given an L1 to L2 message, retrieves its corresponding event from the Inbox within a specific block range. */
|
|
357
347
|
export async function retrieveL1ToL2Message(
|
|
358
|
-
inbox:
|
|
348
|
+
inbox: InboxContract,
|
|
359
349
|
leaf: Fr,
|
|
360
350
|
fromBlock: bigint,
|
|
361
351
|
toBlock: bigint,
|
|
362
352
|
): Promise<InboxMessage | undefined> {
|
|
363
|
-
const logs = await inbox.
|
|
353
|
+
const logs = await inbox.getMessageSentEventByHash(leaf.toString(), fromBlock, toBlock);
|
|
364
354
|
|
|
365
355
|
const messages = mapLogsInboxMessage(logs);
|
|
366
356
|
return messages.length > 0 ? messages[0] : undefined;
|
|
@@ -368,47 +358,40 @@ export async function retrieveL1ToL2Message(
|
|
|
368
358
|
|
|
369
359
|
/**
|
|
370
360
|
* 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.
|
|
361
|
+
* @param inbox - The inbox contract wrapper.
|
|
374
362
|
* @param searchStartBlock - The block number to use for starting the search.
|
|
375
363
|
* @param searchEndBlock - The highest block number that we should search up to.
|
|
376
364
|
* @returns An array of InboxLeaf and next eth block to search from.
|
|
377
365
|
*/
|
|
378
366
|
export async function retrieveL1ToL2Messages(
|
|
379
|
-
inbox:
|
|
367
|
+
inbox: InboxContract,
|
|
380
368
|
searchStartBlock: bigint,
|
|
381
369
|
searchEndBlock: bigint,
|
|
382
370
|
): Promise<InboxMessage[]> {
|
|
383
371
|
const retrievedL1ToL2Messages: InboxMessage[] = [];
|
|
384
372
|
while (searchStartBlock <= searchEndBlock) {
|
|
385
|
-
const messageSentLogs = (
|
|
386
|
-
await inbox.getEvents.MessageSent({}, { fromBlock: searchStartBlock, toBlock: searchEndBlock })
|
|
387
|
-
).filter(log => log.blockNumber! >= searchStartBlock && log.blockNumber! <= searchEndBlock);
|
|
373
|
+
const messageSentLogs = await inbox.getMessageSentEvents(searchStartBlock, searchEndBlock);
|
|
388
374
|
|
|
389
375
|
if (messageSentLogs.length === 0) {
|
|
390
376
|
break;
|
|
391
377
|
}
|
|
392
378
|
|
|
393
379
|
retrievedL1ToL2Messages.push(...mapLogsInboxMessage(messageSentLogs));
|
|
394
|
-
searchStartBlock = messageSentLogs.at(-1)!.
|
|
380
|
+
searchStartBlock = messageSentLogs.at(-1)!.l1BlockNumber + 1n;
|
|
395
381
|
}
|
|
396
382
|
|
|
397
383
|
return retrievedL1ToL2Messages;
|
|
398
384
|
}
|
|
399
385
|
|
|
400
|
-
function mapLogsInboxMessage(logs:
|
|
401
|
-
return logs.map(log => {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
rollingHash: Buffer16.fromString(rollingHash!),
|
|
410
|
-
};
|
|
411
|
-
});
|
|
386
|
+
function mapLogsInboxMessage(logs: MessageSentLog[]): InboxMessage[] {
|
|
387
|
+
return logs.map(log => ({
|
|
388
|
+
index: log.args.index,
|
|
389
|
+
leaf: log.args.leaf,
|
|
390
|
+
l1BlockNumber: log.l1BlockNumber,
|
|
391
|
+
l1BlockHash: log.l1BlockHash,
|
|
392
|
+
checkpointNumber: log.args.checkpointNumber,
|
|
393
|
+
rollingHash: log.args.rollingHash,
|
|
394
|
+
}));
|
|
412
395
|
}
|
|
413
396
|
|
|
414
397
|
/** 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> {
|
|
185
|
+
const logger = createLogger('archiver:validate_trace', bindings);
|
|
168
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;
|