@aztec/archiver 0.0.1-commit.6d3c34e → 0.0.1-commit.7ac86ea28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +156 -22
- package/dest/archiver.d.ts +139 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +699 -0
- package/dest/{archiver/config.d.ts → config.d.ts} +9 -1
- package/dest/config.d.ts.map +1 -0
- package/dest/{archiver/config.js → config.js} +9 -0
- package/dest/errors.d.ts +41 -0
- package/dest/errors.d.ts.map +1 -0
- package/dest/{archiver/errors.js → errors.js} +8 -0
- package/dest/factory.d.ts +9 -7
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +94 -11
- package/dest/index.d.ts +11 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +9 -3
- package/dest/interfaces.d.ts +9 -0
- package/dest/interfaces.d.ts.map +1 -0
- package/dest/interfaces.js +3 -0
- package/dest/{archiver/l1 → l1}/bin/retrieve-calldata.d.ts +1 -1
- package/dest/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/bin/retrieve-calldata.js +17 -18
- package/dest/{archiver/l1 → l1}/calldata_retriever.d.ts +8 -2
- package/dest/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/calldata_retriever.js +17 -4
- package/dest/l1/data_retrieval.d.ts +89 -0
- package/dest/l1/data_retrieval.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/data_retrieval.js +39 -57
- package/dest/{archiver/l1 → l1}/debug_tx.d.ts +1 -1
- package/dest/l1/debug_tx.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/spire_proposer.d.ts +1 -1
- package/dest/l1/spire_proposer.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/trace_tx.d.ts +1 -1
- package/dest/l1/trace_tx.d.ts.map +1 -0
- package/dest/l1/types.d.ts +12 -0
- package/dest/l1/types.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/validate_trace.d.ts +6 -3
- package/dest/l1/validate_trace.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/validate_trace.js +13 -9
- package/dest/modules/data_source_base.d.ts +89 -0
- package/dest/modules/data_source_base.d.ts.map +1 -0
- package/dest/modules/data_source_base.js +216 -0
- package/dest/modules/data_store_updater.d.ts +80 -0
- package/dest/modules/data_store_updater.d.ts.map +1 -0
- package/dest/modules/data_store_updater.js +323 -0
- package/dest/modules/instrumentation.d.ts +39 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/{archiver → modules}/instrumentation.js +26 -12
- package/dest/modules/l1_synchronizer.d.ts +76 -0
- package/dest/modules/l1_synchronizer.d.ts.map +1 -0
- package/dest/modules/l1_synchronizer.js +1112 -0
- package/dest/{archiver → modules}/validation.d.ts +1 -1
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/{archiver → modules}/validation.js +6 -0
- package/dest/store/block_store.d.ts +196 -0
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/block_store.js +207 -60
- package/dest/store/contract_class_store.d.ts +18 -0
- package/dest/store/contract_class_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/contract_class_store.js +12 -8
- package/dest/store/contract_instance_store.d.ts +24 -0
- package/dest/store/contract_instance_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/contract_instance_store.js +1 -1
- package/dest/store/kv_archiver_store.d.ts +354 -0
- package/dest/store/kv_archiver_store.d.ts.map +1 -0
- package/dest/store/kv_archiver_store.js +464 -0
- package/dest/store/l2_tips_cache.d.ts +19 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +89 -0
- package/dest/store/log_store.d.ts +54 -0
- package/dest/store/log_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/log_store.js +146 -91
- package/dest/{archiver/kv_archiver_store → store}/message_store.d.ts +1 -1
- package/dest/store/message_store.d.ts.map +1 -0
- package/dest/{archiver/structs → structs}/data_retrieval.d.ts +1 -1
- package/dest/structs/data_retrieval.d.ts.map +1 -0
- package/dest/structs/inbox_message.d.ts +15 -0
- package/dest/structs/inbox_message.d.ts.map +1 -0
- package/dest/{archiver/structs → structs}/published.d.ts +1 -1
- package/dest/structs/published.d.ts.map +1 -0
- package/dest/test/fake_l1_state.d.ts +193 -0
- package/dest/test/fake_l1_state.d.ts.map +1 -0
- package/dest/test/fake_l1_state.js +389 -0
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +4 -1
- package/dest/test/mock_archiver.d.ts +2 -2
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +3 -3
- package/dest/test/mock_l2_block_source.d.ts +35 -17
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +177 -74
- package/dest/test/mock_structs.d.ts +78 -3
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +140 -7
- package/dest/test/noop_l1_archiver.d.ts +23 -0
- package/dest/test/noop_l1_archiver.d.ts.map +1 -0
- package/dest/test/noop_l1_archiver.js +68 -0
- package/package.json +16 -17
- package/src/archiver.ts +443 -0
- package/src/{archiver/config.ts → config.ts} +11 -0
- package/src/{archiver/errors.ts → errors.ts} +12 -0
- package/src/factory.ts +140 -11
- package/src/index.ts +11 -3
- package/src/interfaces.ts +9 -0
- package/src/{archiver/l1 → l1}/bin/retrieve-calldata.ts +16 -17
- package/src/{archiver/l1 → l1}/calldata_retriever.ts +26 -4
- package/src/{archiver/l1 → l1}/data_retrieval.ts +60 -74
- package/src/{archiver/l1 → l1}/validate_trace.ts +24 -6
- package/src/modules/data_source_base.ts +328 -0
- package/src/modules/data_store_updater.ts +448 -0
- package/src/{archiver → modules}/instrumentation.ts +26 -14
- package/src/modules/l1_synchronizer.ts +932 -0
- package/src/{archiver → modules}/validation.ts +5 -0
- package/src/{archiver/kv_archiver_store → store}/block_store.ts +258 -93
- package/src/{archiver/kv_archiver_store → store}/contract_class_store.ts +12 -8
- package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +1 -1
- package/src/{archiver/kv_archiver_store → store}/kv_archiver_store.ts +267 -38
- package/src/store/l2_tips_cache.ts +89 -0
- package/src/{archiver/kv_archiver_store → store}/log_store.ts +242 -121
- package/src/test/fake_l1_state.ts +607 -0
- package/src/test/index.ts +4 -0
- package/src/test/mock_archiver.ts +4 -3
- package/src/test/mock_l2_block_source.ts +218 -90
- package/src/test/mock_structs.ts +269 -8
- package/src/test/noop_l1_archiver.ts +109 -0
- package/dest/archiver/archiver.d.ts +0 -307
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -2102
- package/dest/archiver/archiver_store.d.ts +0 -315
- package/dest/archiver/archiver_store.d.ts.map +0 -1
- package/dest/archiver/archiver_store.js +0 -4
- package/dest/archiver/archiver_store_test_suite.d.ts +0 -8
- package/dest/archiver/archiver_store_test_suite.d.ts.map +0 -1
- package/dest/archiver/archiver_store_test_suite.js +0 -2770
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/errors.d.ts +0 -36
- package/dest/archiver/errors.d.ts.map +0 -1
- package/dest/archiver/index.d.ts +0 -7
- package/dest/archiver/index.d.ts.map +0 -1
- package/dest/archiver/index.js +0 -4
- package/dest/archiver/instrumentation.d.ts +0 -37
- package/dest/archiver/instrumentation.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -164
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +0 -18
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -24
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -159
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +0 -316
- package/dest/archiver/kv_archiver_store/log_store.d.ts +0 -45
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +0 -1
- package/dest/archiver/l1/calldata_retriever.d.ts.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}/debug_tx.js +0 -0
- /package/dest/{archiver/l1 → l1}/spire_proposer.js +0 -0
- /package/dest/{archiver/l1 → l1}/trace_tx.js +0 -0
- /package/dest/{archiver/l1 → l1}/types.js +0 -0
- /package/dest/{archiver/kv_archiver_store → store}/message_store.js +0 -0
- /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
- /package/dest/{archiver/structs → structs}/inbox_message.js +0 -0
- /package/dest/{archiver/structs → structs}/published.js +0 -0
- /package/src/{archiver/l1 → l1}/README.md +0 -0
- /package/src/{archiver/l1 → l1}/debug_tx.ts +0 -0
- /package/src/{archiver/l1 → l1}/spire_proposer.ts +0 -0
- /package/src/{archiver/l1 → l1}/trace_tx.ts +0 -0
- /package/src/{archiver/l1 → l1}/types.ts +0 -0
- /package/src/{archiver/kv_archiver_store → store}/message_store.ts +0 -0
- /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
- /package/src/{archiver/structs → structs}/inbox_message.ts +0 -0
- /package/src/{archiver/structs → structs}/published.ts +0 -0
package/src/factory.ts
CHANGED
|
@@ -1,36 +1,52 @@
|
|
|
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';
|
|
28
|
+
import { L2TipsCache } from './store/l2_tips_cache.js';
|
|
13
29
|
|
|
14
30
|
export const ARCHIVER_STORE_NAME = 'archiver';
|
|
15
31
|
|
|
16
32
|
/** Creates an archiver store. */
|
|
17
33
|
export async function createArchiverStore(
|
|
18
34
|
userConfig: Pick<ArchiverConfig, 'archiverStoreMapSizeKb' | 'maxLogs'> & DataStoreConfig,
|
|
35
|
+
l1Constants: Pick<L1RollupConstants, 'epochDuration'>,
|
|
19
36
|
) {
|
|
20
37
|
const config = {
|
|
21
38
|
...userConfig,
|
|
22
39
|
dataStoreMapSizeKb: userConfig.archiverStoreMapSizeKb ?? userConfig.dataStoreMapSizeKb,
|
|
23
40
|
};
|
|
24
|
-
const store = await createStore(ARCHIVER_STORE_NAME, ARCHIVER_DB_VERSION, config
|
|
25
|
-
return new KVArchiverDataStore(store, config.maxLogs);
|
|
41
|
+
const store = await createStore(ARCHIVER_STORE_NAME, ARCHIVER_DB_VERSION, config);
|
|
42
|
+
return new KVArchiverDataStore(store, config.maxLogs, l1Constants);
|
|
26
43
|
}
|
|
27
44
|
|
|
28
45
|
/**
|
|
29
46
|
* Creates a local archiver.
|
|
30
47
|
* @param config - The archiver configuration.
|
|
31
|
-
* @param
|
|
48
|
+
* @param deps - The archiver dependencies (blobClient, epochCache, dateProvider, telemetry).
|
|
32
49
|
* @param opts - The options.
|
|
33
|
-
* @param telemetry - The telemetry client.
|
|
34
50
|
* @returns The local archiver.
|
|
35
51
|
*/
|
|
36
52
|
export async function createArchiver(
|
|
@@ -38,12 +54,125 @@ export async function createArchiver(
|
|
|
38
54
|
deps: ArchiverDeps,
|
|
39
55
|
opts: { blockUntilSync: boolean } = { blockUntilSync: true },
|
|
40
56
|
): Promise<Archiver> {
|
|
41
|
-
const archiverStore = await createArchiverStore(config);
|
|
57
|
+
const archiverStore = await createArchiverStore(config, { epochDuration: config.aztecEpochDuration });
|
|
42
58
|
await registerProtocolContracts(archiverStore);
|
|
43
|
-
|
|
59
|
+
|
|
60
|
+
// Create Ethereum clients
|
|
61
|
+
const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
62
|
+
const publicClient = createPublicClient({
|
|
63
|
+
chain: chain.chainInfo,
|
|
64
|
+
transport: fallback(config.l1RpcUrls.map(url => http(url, { batch: false }))),
|
|
65
|
+
pollingInterval: config.viemPollingIntervalMS,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Create debug client using debug RPC URLs if available, otherwise fall back to regular RPC URLs
|
|
69
|
+
const debugRpcUrls = config.l1DebugRpcUrls.length > 0 ? config.l1DebugRpcUrls : config.l1RpcUrls;
|
|
70
|
+
const debugClient = createPublicClient({
|
|
71
|
+
chain: chain.chainInfo,
|
|
72
|
+
transport: fallback(debugRpcUrls.map(url => http(url, { batch: false }))),
|
|
73
|
+
pollingInterval: config.viemPollingIntervalMS,
|
|
74
|
+
}) as ViemPublicDebugClient;
|
|
75
|
+
|
|
76
|
+
// Create L1 contract instances
|
|
77
|
+
const rollup = new RollupContract(publicClient, config.l1Contracts.rollupAddress);
|
|
78
|
+
const inbox = new InboxContract(publicClient, config.l1Contracts.inboxAddress);
|
|
79
|
+
|
|
80
|
+
// Fetch L1 constants from rollup contract
|
|
81
|
+
const [
|
|
82
|
+
l1StartBlock,
|
|
83
|
+
l1GenesisTime,
|
|
84
|
+
proofSubmissionEpochs,
|
|
85
|
+
genesisArchiveRoot,
|
|
86
|
+
slashingProposerAddress,
|
|
87
|
+
targetCommitteeSize,
|
|
88
|
+
] = await Promise.all([
|
|
89
|
+
rollup.getL1StartBlock(),
|
|
90
|
+
rollup.getL1GenesisTime(),
|
|
91
|
+
rollup.getProofSubmissionEpochs(),
|
|
92
|
+
rollup.getGenesisArchiveTreeRoot(),
|
|
93
|
+
rollup.getSlashingProposerAddress(),
|
|
94
|
+
rollup.getTargetCommitteeSize(),
|
|
95
|
+
] as const);
|
|
96
|
+
|
|
97
|
+
const l1StartBlockHash = await publicClient
|
|
98
|
+
.getBlock({ blockNumber: l1StartBlock, includeTransactions: false })
|
|
99
|
+
.then(block => Buffer32.fromString(block.hash));
|
|
100
|
+
|
|
101
|
+
const { aztecEpochDuration: epochDuration, aztecSlotDuration: slotDuration, ethereumSlotDuration } = config;
|
|
102
|
+
|
|
103
|
+
const l1Constants = {
|
|
104
|
+
l1StartBlockHash,
|
|
105
|
+
l1StartBlock,
|
|
106
|
+
l1GenesisTime,
|
|
107
|
+
epochDuration,
|
|
108
|
+
slotDuration,
|
|
109
|
+
ethereumSlotDuration,
|
|
110
|
+
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
111
|
+
targetCommitteeSize,
|
|
112
|
+
genesisArchiveRoot: Fr.fromString(genesisArchiveRoot.toString()),
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const archiverConfig = merge(
|
|
116
|
+
{
|
|
117
|
+
pollingIntervalMs: 10_000,
|
|
118
|
+
batchSize: 100,
|
|
119
|
+
maxAllowedEthClientDriftSeconds: 300,
|
|
120
|
+
ethereumAllowNoDebugHosts: false,
|
|
121
|
+
},
|
|
122
|
+
mapArchiverConfig(config),
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const epochCache = deps.epochCache ?? (await EpochCache.create(config.l1Contracts.rollupAddress, config, deps));
|
|
126
|
+
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
127
|
+
const instrumentation = await ArchiverInstrumentation.new(telemetry, () => archiverStore.estimateSize());
|
|
128
|
+
|
|
129
|
+
// Create the event emitter that will be shared by archiver and synchronizer
|
|
130
|
+
const events = new EventEmitter() as ArchiverEmitter;
|
|
131
|
+
|
|
132
|
+
// Create L2 tips cache shared by archiver and synchronizer
|
|
133
|
+
const l2TipsCache = new L2TipsCache(archiverStore.blockStore);
|
|
134
|
+
|
|
135
|
+
// Create the L1 synchronizer
|
|
136
|
+
const synchronizer = new ArchiverL1Synchronizer(
|
|
137
|
+
publicClient,
|
|
138
|
+
debugClient,
|
|
139
|
+
rollup,
|
|
140
|
+
inbox,
|
|
141
|
+
{ ...config.l1Contracts, slashingProposerAddress },
|
|
142
|
+
archiverStore,
|
|
143
|
+
archiverConfig,
|
|
144
|
+
deps.blobClient,
|
|
145
|
+
epochCache,
|
|
146
|
+
deps.dateProvider ?? new DateProvider(),
|
|
147
|
+
instrumentation,
|
|
148
|
+
l1Constants,
|
|
149
|
+
events,
|
|
150
|
+
instrumentation.tracer,
|
|
151
|
+
l2TipsCache,
|
|
152
|
+
undefined, // log (use default)
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
const archiver = new Archiver(
|
|
156
|
+
publicClient,
|
|
157
|
+
debugClient,
|
|
158
|
+
rollup,
|
|
159
|
+
{ ...config.l1Contracts, slashingProposerAddress },
|
|
160
|
+
archiverStore,
|
|
161
|
+
archiverConfig,
|
|
162
|
+
deps.blobClient,
|
|
163
|
+
instrumentation,
|
|
164
|
+
l1Constants,
|
|
165
|
+
synchronizer,
|
|
166
|
+
events,
|
|
167
|
+
l2TipsCache,
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
await archiver.start(opts.blockUntilSync);
|
|
171
|
+
return archiver;
|
|
44
172
|
}
|
|
45
173
|
|
|
46
|
-
|
|
174
|
+
/** Registers protocol contracts in the archiver store. */
|
|
175
|
+
export async function registerProtocolContracts(store: KVArchiverDataStore) {
|
|
47
176
|
const blockNumber = 0;
|
|
48
177
|
for (const name of protocolContractNames) {
|
|
49
178
|
const provider = new BundledProtocolContractsProvider();
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
export * from './archiver/index.js';
|
|
2
1
|
export * from './factory.js';
|
|
3
|
-
export * from './
|
|
2
|
+
export * from './interfaces.js';
|
|
3
|
+
export * from './archiver.js';
|
|
4
|
+
export * from './modules/data_source_base.js';
|
|
5
|
+
export * from './modules/data_store_updater.js';
|
|
6
|
+
export * from './config.js';
|
|
4
7
|
|
|
5
|
-
export {
|
|
8
|
+
export { type L1PublishedData } from './structs/published.js';
|
|
9
|
+
export { KVArchiverDataStore, ARCHIVER_DB_VERSION } from './store/kv_archiver_store.js';
|
|
10
|
+
export { ContractInstanceStore } from './store/contract_instance_store.js';
|
|
11
|
+
export { L2TipsCache } from './store/l2_tips_cache.js';
|
|
12
|
+
|
|
13
|
+
export { retrieveCheckpointsFromRollup, retrieveL2ProofVerifiedEvents } from './l1/data_retrieval.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
2
|
+
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
3
|
+
import type { L2LogsSource } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Helper interface to combine all sources this archiver implementation provides.
|
|
8
|
+
*/
|
|
9
|
+
export type ArchiverDataSource = L2BlockSource & L2LogsSource & ContractDataSource & L1ToL2MessageSource;
|
|
@@ -3,8 +3,9 @@ import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/ty
|
|
|
3
3
|
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
+
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
6
7
|
|
|
7
|
-
import { type Hex, createPublicClient, http } from 'viem';
|
|
8
|
+
import { type Hex, createPublicClient, getAbiItem, http, toEventSelector } from 'viem';
|
|
8
9
|
import { mainnet } from 'viem/chains';
|
|
9
10
|
|
|
10
11
|
import { CalldataRetriever } from '../calldata_retriever.js';
|
|
@@ -111,38 +112,36 @@ async function main() {
|
|
|
111
112
|
},
|
|
112
113
|
);
|
|
113
114
|
|
|
114
|
-
// Extract
|
|
115
|
-
logger.info('Decoding transaction to extract
|
|
115
|
+
// Extract checkpoint number from transaction logs
|
|
116
|
+
logger.info('Decoding transaction to extract checkpoint number...');
|
|
116
117
|
const receipt = await publicClient.getTransactionReceipt({ hash: txHash });
|
|
117
|
-
|
|
118
|
+
|
|
119
|
+
// Look for CheckpointProposed event (emitted when a checkpoint is proposed to the rollup)
|
|
120
|
+
// Event signature: CheckpointProposed(uint256 indexed checkpointNumber, bytes32 indexed archive, bytes32[], bytes32, bytes32)
|
|
121
|
+
// Hash: keccak256("CheckpointProposed(uint256,bytes32,bytes32[],bytes32,bytes32)")
|
|
122
|
+
const checkpointProposedEvent = receipt.logs.find(log => {
|
|
118
123
|
try {
|
|
119
|
-
// Try to match the L2BlockProposed event
|
|
120
124
|
return (
|
|
121
125
|
log.address.toLowerCase() === rollupAddress.toString().toLowerCase() &&
|
|
122
|
-
log.topics[0] ===
|
|
126
|
+
log.topics[0] === toEventSelector(getAbiItem({ abi: RollupAbi, name: 'CheckpointProposed' }))
|
|
123
127
|
);
|
|
124
128
|
} catch {
|
|
125
129
|
return false;
|
|
126
130
|
}
|
|
127
131
|
});
|
|
128
132
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// L2 block number is typically the first indexed parameter
|
|
132
|
-
l2BlockNumber = Number(BigInt(l2BlockProposedEvent.topics[1]));
|
|
133
|
-
logger.info(`L2 Block Number (from event): ${l2BlockNumber}`);
|
|
134
|
-
} else {
|
|
135
|
-
// Fallback: try to extract from transaction data or use a default
|
|
136
|
-
logger.warn('Could not extract L2 block number from event, using block number as fallback');
|
|
137
|
-
l2BlockNumber = Number(tx.blockNumber);
|
|
133
|
+
if (!checkpointProposedEvent || checkpointProposedEvent.topics[1] === undefined) {
|
|
134
|
+
throw new Error(`Checkpoint proposed event not found`);
|
|
138
135
|
}
|
|
139
136
|
|
|
137
|
+
const checkpointNumber = CheckpointNumber.fromBigInt(BigInt(checkpointProposedEvent.topics[1]));
|
|
138
|
+
|
|
140
139
|
logger.info('');
|
|
141
|
-
logger.info('Retrieving
|
|
140
|
+
logger.info('Retrieving checkpoint from rollup transaction...');
|
|
142
141
|
logger.info('');
|
|
143
142
|
|
|
144
143
|
// For this script, we don't have blob hashes or expected hashes, so pass empty arrays/objects
|
|
145
|
-
const result = await retriever.getCheckpointFromRollupTx(txHash, [],
|
|
144
|
+
const result = await retriever.getCheckpointFromRollupTx(txHash, [], checkpointNumber, {});
|
|
146
145
|
|
|
147
146
|
logger.info(' Successfully retrieved block header!');
|
|
148
147
|
logger.info('');
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
toFunctionSelector,
|
|
29
29
|
} from 'viem';
|
|
30
30
|
|
|
31
|
-
import type { ArchiverInstrumentation } from '../instrumentation.js';
|
|
31
|
+
import type { ArchiverInstrumentation } from '../modules/instrumentation.js';
|
|
32
32
|
import { getSuccessfulCallsFromDebug } from './debug_tx.js';
|
|
33
33
|
import { getCallFromSpireProposer } from './spire_proposer.js';
|
|
34
34
|
import { getSuccessfulCallsFromTrace } from './trace_tx.js';
|
|
@@ -39,6 +39,14 @@ import type { CallInfo } from './types.js';
|
|
|
39
39
|
* in order to reconstruct an L2 block header.
|
|
40
40
|
*/
|
|
41
41
|
export class CalldataRetriever {
|
|
42
|
+
/** Tx hashes we've already logged for trace+debug failure (log once per tx per process). */
|
|
43
|
+
private static readonly traceFailureWarnedTxHashes = new Set<string>();
|
|
44
|
+
|
|
45
|
+
/** Clears the trace-failure warned set. For testing only. */
|
|
46
|
+
static resetTraceFailureWarnedForTesting(): void {
|
|
47
|
+
CalldataRetriever.traceFailureWarnedTxHashes.clear();
|
|
48
|
+
}
|
|
49
|
+
|
|
42
50
|
/** Pre-computed valid contract calls for validation */
|
|
43
51
|
private readonly validContractCalls: ValidContractCall[];
|
|
44
52
|
|
|
@@ -84,6 +92,7 @@ export class CalldataRetriever {
|
|
|
84
92
|
header: CheckpointHeader;
|
|
85
93
|
attestations: CommitteeAttestation[];
|
|
86
94
|
blockHash: string;
|
|
95
|
+
feeAssetPriceModifier: bigint;
|
|
87
96
|
}> {
|
|
88
97
|
this.logger.trace(`Fetching checkpoint ${checkpointNumber} from rollup tx ${txHash}`, {
|
|
89
98
|
willValidateHashes: !!expectedHashes.attestationsHash || !!expectedHashes.payloadDigest,
|
|
@@ -313,7 +322,8 @@ export class CalldataRetriever {
|
|
|
313
322
|
this.logger.debug(`Successfully traced using trace_transaction, found ${calls.length} calls`);
|
|
314
323
|
} catch (err) {
|
|
315
324
|
const traceError = err instanceof Error ? err : new Error(String(err));
|
|
316
|
-
this.logger.verbose(`Failed trace_transaction for ${txHash}
|
|
325
|
+
this.logger.verbose(`Failed trace_transaction for ${txHash}: ${traceError.message}`);
|
|
326
|
+
this.logger.debug(`Trace failure details for ${txHash}`, { traceError });
|
|
317
327
|
|
|
318
328
|
try {
|
|
319
329
|
// Fall back to debug_traceTransaction (Geth RPC)
|
|
@@ -322,7 +332,16 @@ export class CalldataRetriever {
|
|
|
322
332
|
this.logger.debug(`Successfully traced using debug_traceTransaction, found ${calls.length} calls`);
|
|
323
333
|
} catch (debugErr) {
|
|
324
334
|
const debugError = debugErr instanceof Error ? debugErr : new Error(String(debugErr));
|
|
325
|
-
|
|
335
|
+
// Log once per tx so we don't spam on every sync cycle when sync point doesn't advance
|
|
336
|
+
if (!CalldataRetriever.traceFailureWarnedTxHashes.has(txHash)) {
|
|
337
|
+
CalldataRetriever.traceFailureWarnedTxHashes.add(txHash);
|
|
338
|
+
this.logger.warn(
|
|
339
|
+
`Cannot decode L1 tx ${txHash}: trace and debug RPC failed or unavailable. ` +
|
|
340
|
+
`trace_transaction: ${traceError.message}; debug_traceTransaction: ${debugError.message}`,
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
// Full error objects can be very long; keep at debug only
|
|
344
|
+
this.logger.debug(`Trace/debug failure details for tx ${txHash}`, {
|
|
326
345
|
traceError,
|
|
327
346
|
debugError,
|
|
328
347
|
txHash,
|
|
@@ -403,6 +422,7 @@ export class CalldataRetriever {
|
|
|
403
422
|
header: CheckpointHeader;
|
|
404
423
|
attestations: CommitteeAttestation[];
|
|
405
424
|
blockHash: string;
|
|
425
|
+
feeAssetPriceModifier: bigint;
|
|
406
426
|
} {
|
|
407
427
|
const { functionName: rollupFunctionName, args: rollupArgs } = decodeFunctionData({
|
|
408
428
|
abi: RollupAbi,
|
|
@@ -458,7 +478,8 @@ export class CalldataRetriever {
|
|
|
458
478
|
if (expectedHashes.payloadDigest) {
|
|
459
479
|
// Use ConsensusPayload to compute the digest - this ensures we match the exact logic
|
|
460
480
|
// used by the network for signing and verification
|
|
461
|
-
const
|
|
481
|
+
const feeAssetPriceModifier = decodedArgs.oracleInput.feeAssetPriceModifier;
|
|
482
|
+
const consensusPayload = new ConsensusPayload(header, archiveRoot, feeAssetPriceModifier);
|
|
462
483
|
const payloadToSign = consensusPayload.getPayloadToSign(SignatureDomainSeparator.checkpointAttestation);
|
|
463
484
|
const computedPayloadDigest = keccak256(payloadToSign);
|
|
464
485
|
|
|
@@ -495,6 +516,7 @@ export class CalldataRetriever {
|
|
|
495
516
|
header,
|
|
496
517
|
attestations,
|
|
497
518
|
blockHash,
|
|
519
|
+
feeAssetPriceModifier: decodedArgs.oracleInput.feeAssetPriceModifier,
|
|
498
520
|
};
|
|
499
521
|
}
|
|
500
522
|
}
|