@aztec/archiver 0.0.1-commit.96bb3f7 → 0.0.1-commit.993d240
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 +164 -22
- package/dest/archiver.d.ts +158 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +881 -0
- package/dest/config.d.ts +33 -0
- package/dest/config.d.ts.map +1 -0
- package/dest/{archiver/config.js → config.js} +31 -14
- package/dest/errors.d.ts +87 -0
- package/dest/errors.d.ts.map +1 -0
- package/dest/errors.js +129 -0
- package/dest/factory.d.ts +16 -10
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +112 -20
- package/dest/index.d.ts +19 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +17 -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 +35 -32
- package/dest/l1/calldata_retriever.d.ts +136 -0
- package/dest/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/l1/calldata_retriever.js +412 -0
- package/dest/l1/data_retrieval.d.ts +97 -0
- package/dest/l1/data_retrieval.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/data_retrieval.js +65 -89
- 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 +5 -5
- package/dest/l1/spire_proposer.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/spire_proposer.js +9 -17
- package/dest/l1/trace_tx.d.ts +43 -0
- 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/l1/validate_historical_logs.d.ts +23 -0
- package/dest/l1/validate_historical_logs.d.ts.map +1 -0
- package/dest/l1/validate_historical_logs.js +108 -0
- package/dest/{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/contract_data_source_adapter.d.ts +25 -0
- package/dest/modules/contract_data_source_adapter.d.ts.map +1 -0
- package/dest/modules/contract_data_source_adapter.js +40 -0
- package/dest/modules/data_source_base.d.ts +113 -0
- package/dest/modules/data_source_base.d.ts.map +1 -0
- package/dest/modules/data_source_base.js +351 -0
- package/dest/modules/data_store_updater.d.ts +105 -0
- package/dest/modules/data_store_updater.d.ts.map +1 -0
- package/dest/modules/data_store_updater.js +392 -0
- package/dest/modules/instrumentation.d.ts +55 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/{archiver → modules}/instrumentation.js +61 -19
- package/dest/modules/l1_synchronizer.d.ts +77 -0
- package/dest/modules/l1_synchronizer.d.ts.map +1 -0
- package/dest/modules/l1_synchronizer.js +1344 -0
- package/dest/modules/validation.d.ts +18 -0
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/{archiver → modules}/validation.js +12 -6
- package/dest/store/block_store.d.ts +300 -0
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/store/block_store.js +1219 -0
- package/dest/store/contract_class_store.d.ts +31 -0
- package/dest/store/contract_class_store.d.ts.map +1 -0
- package/dest/store/contract_class_store.js +80 -0
- package/dest/store/contract_instance_store.d.ts +51 -0
- package/dest/store/contract_instance_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/contract_instance_store.js +38 -3
- package/dest/store/data_stores.d.ts +68 -0
- package/dest/store/data_stores.d.ts.map +1 -0
- package/dest/store/data_stores.js +54 -0
- package/dest/store/function_names_cache.d.ts +17 -0
- package/dest/store/function_names_cache.d.ts.map +1 -0
- package/dest/store/function_names_cache.js +30 -0
- package/dest/store/l2_tips_cache.d.ts +25 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +26 -0
- package/dest/store/log_store.d.ts +59 -0
- package/dest/store/log_store.d.ts.map +1 -0
- package/dest/store/log_store.js +310 -0
- package/dest/store/log_store_codec.d.ts +70 -0
- package/dest/store/log_store_codec.d.ts.map +1 -0
- package/dest/store/log_store_codec.js +101 -0
- package/dest/store/message_store.d.ts +50 -0
- package/dest/store/message_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/message_store.js +51 -9
- 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 +214 -0
- package/dest/test/fake_l1_state.d.ts.map +1 -0
- package/dest/test/fake_l1_state.js +517 -0
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +4 -1
- package/dest/test/mock_archiver.d.ts +2 -2
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +3 -3
- package/dest/test/mock_l1_to_l2_message_source.d.ts +1 -1
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +2 -1
- package/dest/test/mock_l2_block_source.d.ts +65 -41
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +330 -151
- package/dest/test/mock_structs.d.ts +81 -3
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +152 -7
- package/dest/test/noop_l1_archiver.d.ts +29 -0
- package/dest/test/noop_l1_archiver.d.ts.map +1 -0
- package/dest/test/noop_l1_archiver.js +85 -0
- package/package.json +17 -18
- package/src/archiver.ts +681 -0
- package/src/{archiver/config.ts → config.ts} +43 -12
- package/src/errors.ts +203 -0
- package/src/factory.ts +175 -22
- package/src/index.ts +27 -3
- package/src/interfaces.ts +9 -0
- package/src/l1/README.md +55 -0
- package/src/{archiver/l1 → l1}/bin/retrieve-calldata.ts +45 -33
- package/src/l1/calldata_retriever.ts +522 -0
- package/src/{archiver/l1 → l1}/data_retrieval.ts +106 -134
- package/src/{archiver/l1 → l1}/spire_proposer.ts +7 -15
- package/src/l1/validate_historical_logs.ts +140 -0
- package/src/{archiver/l1 → l1}/validate_trace.ts +24 -6
- package/src/modules/contract_data_source_adapter.ts +55 -0
- package/src/modules/data_source_base.ts +493 -0
- package/src/modules/data_store_updater.ts +518 -0
- package/src/{archiver → modules}/instrumentation.ts +72 -20
- package/src/modules/l1_synchronizer.ts +1257 -0
- package/src/{archiver → modules}/validation.ts +15 -9
- package/src/store/block_store.ts +1590 -0
- package/src/store/contract_class_store.ts +108 -0
- package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +52 -6
- package/src/store/data_stores.ts +104 -0
- package/src/store/function_names_cache.ts +37 -0
- package/src/store/l2_tips_cache.ts +35 -0
- package/src/store/log_store.ts +379 -0
- package/src/store/log_store_codec.ts +132 -0
- package/src/{archiver/kv_archiver_store → store}/message_store.ts +60 -10
- package/src/{archiver/structs → structs}/inbox_message.ts +1 -1
- package/src/test/fake_l1_state.ts +770 -0
- package/src/test/index.ts +4 -0
- package/src/test/mock_archiver.ts +4 -3
- package/src/test/mock_l1_to_l2_message_source.ts +1 -0
- package/src/test/mock_l2_block_source.ts +403 -171
- package/src/test/mock_structs.ts +283 -8
- package/src/test/noop_l1_archiver.ts +139 -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 +0 -22
- 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/errors.js +0 -54
- 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/block_store.js +0 -626
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +0 -18
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +0 -120
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -24
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -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/log_store.js +0 -401
- package/dest/archiver/kv_archiver_store/message_store.d.ts +0 -40
- 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 +0 -112
- package/dest/archiver/l1/calldata_retriever.d.ts.map +0 -1
- package/dest/archiver/l1/calldata_retriever.js +0 -471
- 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 +0 -97
- package/dest/archiver/l1/trace_tx.d.ts.map +0 -1
- package/dest/archiver/l1/types.d.ts +0 -12
- package/dest/archiver/l1/types.d.ts.map +0 -1
- package/dest/archiver/l1/validate_trace.d.ts.map +0 -1
- package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/structs/inbox_message.d.ts +0 -15
- package/dest/archiver/structs/inbox_message.d.ts.map +0 -1
- package/dest/archiver/structs/published.d.ts.map +0 -1
- package/dest/archiver/validation.d.ts +0 -17
- package/dest/archiver/validation.d.ts.map +0 -1
- package/dest/rpc/index.d.ts +0 -9
- package/dest/rpc/index.d.ts.map +0 -1
- package/dest/rpc/index.js +0 -15
- package/src/archiver/archiver.ts +0 -2265
- package/src/archiver/archiver_store.ts +0 -380
- package/src/archiver/archiver_store_test_suite.ts +0 -2842
- package/src/archiver/errors.ts +0 -90
- package/src/archiver/index.ts +0 -6
- package/src/archiver/kv_archiver_store/block_store.ts +0 -850
- package/src/archiver/kv_archiver_store/contract_class_store.ts +0 -176
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -442
- package/src/archiver/kv_archiver_store/log_store.ts +0 -516
- package/src/archiver/l1/README.md +0 -98
- package/src/archiver/l1/calldata_retriever.ts +0 -641
- package/src/rpc/index.ts +0 -16
- /package/dest/{archiver/l1 → l1}/debug_tx.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/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}/debug_tx.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/structs → structs}/data_retrieval.ts +0 -0
- /package/src/{archiver/structs → structs}/published.ts +0 -0
|
@@ -6,51 +6,61 @@ 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';
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
type RetrievedCheckpointBase = {
|
|
41
39
|
checkpointNumber: CheckpointNumber;
|
|
42
40
|
archiveRoot: Fr;
|
|
41
|
+
feeAssetPriceModifier: bigint;
|
|
43
42
|
header: CheckpointHeader;
|
|
44
|
-
checkpointBlobData: CheckpointBlobData;
|
|
45
43
|
l1: L1PublishedData;
|
|
46
44
|
chainId: Fr;
|
|
47
45
|
version: Fr;
|
|
48
46
|
attestations: CommitteeAttestation[];
|
|
49
47
|
};
|
|
50
48
|
|
|
49
|
+
/** Checkpoint data as retrieved from L1 calldata and blob data. */
|
|
50
|
+
export type RetrievedCheckpoint = RetrievedCheckpointBase & { checkpointBlobData: CheckpointBlobData };
|
|
51
|
+
|
|
52
|
+
/** Checkpoint data retrieved from L1 calldata only, without blob data. */
|
|
53
|
+
export type RetrievedCheckpointFromCalldata = RetrievedCheckpointBase & {
|
|
54
|
+
/** Versioned blob hashes from the checkpoint proposed event. */
|
|
55
|
+
blobHashes: Buffer[];
|
|
56
|
+
/** Parent beacon block root from the L1 block, used for blob fetching. */
|
|
57
|
+
parentBeaconBlockRoot: string | undefined;
|
|
58
|
+
};
|
|
59
|
+
|
|
51
60
|
export async function retrievedToPublishedCheckpoint({
|
|
52
61
|
checkpointNumber,
|
|
53
62
|
archiveRoot,
|
|
63
|
+
feeAssetPriceModifier,
|
|
54
64
|
header: checkpointHeader,
|
|
55
65
|
checkpointBlobData,
|
|
56
66
|
l1,
|
|
@@ -71,7 +81,7 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
71
81
|
const l1toL2MessageTreeRoot = blocksBlobData[0].l1ToL2MessageRoot!;
|
|
72
82
|
|
|
73
83
|
const spongeBlob = SpongeBlob.init();
|
|
74
|
-
const l2Blocks:
|
|
84
|
+
const l2Blocks: L2Block[] = [];
|
|
75
85
|
for (let i = 0; i < blocksBlobData.length; i++) {
|
|
76
86
|
const blockBlobData = blocksBlobData[i];
|
|
77
87
|
const { blockEndMarker, blockEndStateField, lastArchiveRoot, noteHashRoot, nullifierRoot, publicDataRoot } =
|
|
@@ -102,7 +112,7 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
102
112
|
}),
|
|
103
113
|
});
|
|
104
114
|
|
|
105
|
-
const body = Body.fromTxBlobData(
|
|
115
|
+
const body = Body.fromTxBlobData(blockBlobData.txs);
|
|
106
116
|
|
|
107
117
|
const blobFields = encodeBlockBlobData(blockBlobData);
|
|
108
118
|
await spongeBlob.absorb(blobFields);
|
|
@@ -121,7 +131,7 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
121
131
|
|
|
122
132
|
const newArchive = new AppendOnlyTreeSnapshot(newArchiveRoots[i], l2BlockNumber + 1);
|
|
123
133
|
|
|
124
|
-
l2Blocks.push(new
|
|
134
|
+
l2Blocks.push(new L2Block(newArchive, header, body, checkpointNumber, IndexWithinCheckpoint(i)));
|
|
125
135
|
}
|
|
126
136
|
|
|
127
137
|
const lastBlock = l2Blocks.at(-1)!;
|
|
@@ -130,42 +140,34 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
130
140
|
header: checkpointHeader,
|
|
131
141
|
blocks: l2Blocks,
|
|
132
142
|
number: checkpointNumber,
|
|
143
|
+
feeAssetPriceModifier: feeAssetPriceModifier,
|
|
133
144
|
});
|
|
134
145
|
|
|
135
146
|
return PublishedCheckpoint.from({ checkpoint, l1, attestations });
|
|
136
147
|
}
|
|
137
148
|
|
|
138
149
|
/**
|
|
139
|
-
* Fetches
|
|
140
|
-
*
|
|
150
|
+
* Fetches checkpoint calldata from the rollup contract without fetching blob data.
|
|
151
|
+
* Returns RetrievedCheckpointFromCalldata objects that preserve the information needed for deferred blob fetching.
|
|
152
|
+
* @param rollup - The rollup contract wrapper.
|
|
141
153
|
* @param publicClient - The viem public client to use for transaction retrieval.
|
|
142
154
|
* @param debugClient - The viem debug client to use for trace/debug RPC methods (optional).
|
|
143
|
-
* @param blobClient - The blob client client for fetching blob data.
|
|
144
155
|
* @param searchStartBlock - The block number to use for starting the search.
|
|
145
156
|
* @param searchEndBlock - The highest block number that we should search up to.
|
|
146
|
-
* @param contractAddresses - The contract addresses (governanceProposerAddress, slashFactoryAddress, slashingProposerAddress).
|
|
147
157
|
* @param instrumentation - The archiver instrumentation instance.
|
|
148
158
|
* @param logger - The logger instance.
|
|
149
|
-
* @
|
|
150
|
-
* @returns An array of retrieved checkpoints.
|
|
159
|
+
* @returns An array of calldata-only checkpoints.
|
|
151
160
|
*/
|
|
152
|
-
export async function
|
|
153
|
-
rollup:
|
|
161
|
+
export async function retrieveCheckpointCalldataFromRollup(
|
|
162
|
+
rollup: RollupContract,
|
|
154
163
|
publicClient: ViemPublicClient,
|
|
155
164
|
debugClient: ViemPublicDebugClient,
|
|
156
|
-
blobClient: BlobClientInterface,
|
|
157
165
|
searchStartBlock: bigint,
|
|
158
166
|
searchEndBlock: bigint,
|
|
159
|
-
contractAddresses: {
|
|
160
|
-
governanceProposerAddress: EthAddress;
|
|
161
|
-
slashFactoryAddress?: EthAddress;
|
|
162
|
-
slashingProposerAddress: EthAddress;
|
|
163
|
-
},
|
|
164
167
|
instrumentation: ArchiverInstrumentation,
|
|
165
168
|
logger: Logger = createLogger('archiver'),
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const retrievedCheckpoints: RetrievedCheckpoint[] = [];
|
|
169
|
+
): Promise<RetrievedCheckpointFromCalldata[]> {
|
|
170
|
+
const retrievedCheckpoints: RetrievedCheckpointFromCalldata[] = [];
|
|
169
171
|
|
|
170
172
|
let rollupConstants: { chainId: Fr; version: Fr; targetCommitteeSize: number } | undefined;
|
|
171
173
|
|
|
@@ -173,15 +175,7 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
173
175
|
if (searchStartBlock > searchEndBlock) {
|
|
174
176
|
break;
|
|
175
177
|
}
|
|
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);
|
|
178
|
+
const checkpointProposedLogs = await rollup.getCheckpointProposedEvents(searchStartBlock, searchEndBlock);
|
|
185
179
|
|
|
186
180
|
if (checkpointProposedLogs.length === 0) {
|
|
187
181
|
break;
|
|
@@ -189,19 +183,19 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
189
183
|
|
|
190
184
|
const lastLog = checkpointProposedLogs.at(-1)!;
|
|
191
185
|
logger.debug(
|
|
192
|
-
`Got ${checkpointProposedLogs.length} processed logs for checkpoints
|
|
186
|
+
`Got ${checkpointProposedLogs.length} processed logs for checkpoints ${checkpointProposedLogs[0].args.checkpointNumber}-${lastLog.args.checkpointNumber} between L1 blocks ${searchStartBlock}-${searchEndBlock}`,
|
|
193
187
|
);
|
|
194
188
|
|
|
195
189
|
if (rollupConstants === undefined) {
|
|
196
190
|
const [chainId, version, targetCommitteeSize] = await Promise.all([
|
|
197
191
|
publicClient.getChainId(),
|
|
198
|
-
rollup.
|
|
199
|
-
rollup.
|
|
192
|
+
rollup.getVersion(),
|
|
193
|
+
rollup.getTargetCommitteeSize(),
|
|
200
194
|
]);
|
|
201
195
|
rollupConstants = {
|
|
202
196
|
chainId: new Fr(chainId),
|
|
203
197
|
version: new Fr(version),
|
|
204
|
-
targetCommitteeSize
|
|
198
|
+
targetCommitteeSize,
|
|
205
199
|
};
|
|
206
200
|
}
|
|
207
201
|
|
|
@@ -209,108 +203,88 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
209
203
|
rollup,
|
|
210
204
|
publicClient,
|
|
211
205
|
debugClient,
|
|
212
|
-
blobClient,
|
|
213
206
|
checkpointProposedLogs,
|
|
214
207
|
rollupConstants,
|
|
215
|
-
contractAddresses,
|
|
216
208
|
instrumentation,
|
|
217
209
|
logger,
|
|
218
|
-
isHistoricalSync,
|
|
219
210
|
);
|
|
220
211
|
retrievedCheckpoints.push(...newCheckpoints);
|
|
221
|
-
searchStartBlock = lastLog.
|
|
212
|
+
searchStartBlock = lastLog.l1BlockNumber + 1n;
|
|
222
213
|
} while (searchStartBlock <= searchEndBlock);
|
|
223
214
|
|
|
224
|
-
// The asyncPool from processCheckpointProposedLogs will not necessarily return the checkpoints in order, so we sort them before returning.
|
|
225
215
|
return retrievedCheckpoints.sort((a, b) => Number(a.l1.blockNumber - b.l1.blockNumber));
|
|
226
216
|
}
|
|
227
217
|
|
|
228
218
|
/**
|
|
229
|
-
* Processes
|
|
230
|
-
* @param rollup - The rollup contract
|
|
219
|
+
* Processes CheckpointProposed logs, fetching only calldata (no blobs).
|
|
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
|
-
* @param blobClient - The blob client client for fetching blob data.
|
|
234
223
|
* @param logs - CheckpointProposed logs.
|
|
235
224
|
* @param rollupConstants - The rollup constants (chainId, version, targetCommitteeSize).
|
|
236
|
-
* @param contractAddresses - The contract addresses (governanceProposerAddress, slashFactoryAddress, slashingProposerAddress).
|
|
237
225
|
* @param instrumentation - The archiver instrumentation instance.
|
|
238
226
|
* @param logger - The logger instance.
|
|
239
|
-
* @
|
|
240
|
-
* @returns An array of retrieved checkpoints.
|
|
227
|
+
* @returns An array of calldata-only checkpoints.
|
|
241
228
|
*/
|
|
242
229
|
async function processCheckpointProposedLogs(
|
|
243
|
-
rollup:
|
|
230
|
+
rollup: RollupContract,
|
|
244
231
|
publicClient: ViemPublicClient,
|
|
245
232
|
debugClient: ViemPublicDebugClient,
|
|
246
|
-
|
|
247
|
-
logs: GetContractEventsReturnType<typeof RollupAbi, 'CheckpointProposed'>,
|
|
233
|
+
logs: CheckpointProposedLog[],
|
|
248
234
|
{ chainId, version, targetCommitteeSize }: { chainId: Fr; version: Fr; targetCommitteeSize: number },
|
|
249
|
-
contractAddresses: {
|
|
250
|
-
governanceProposerAddress: EthAddress;
|
|
251
|
-
slashFactoryAddress?: EthAddress;
|
|
252
|
-
slashingProposerAddress: EthAddress;
|
|
253
|
-
},
|
|
254
235
|
instrumentation: ArchiverInstrumentation,
|
|
255
236
|
logger: Logger,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const retrievedCheckpoints: RetrievedCheckpoint[] = [];
|
|
237
|
+
): Promise<RetrievedCheckpointFromCalldata[]> {
|
|
238
|
+
const retrievedCheckpoints: RetrievedCheckpointFromCalldata[] = [];
|
|
259
239
|
const calldataRetriever = new CalldataRetriever(
|
|
260
240
|
publicClient,
|
|
261
241
|
debugClient,
|
|
262
242
|
targetCommitteeSize,
|
|
263
243
|
instrumentation,
|
|
264
244
|
logger,
|
|
265
|
-
|
|
245
|
+
EthAddress.fromString(rollup.address),
|
|
266
246
|
);
|
|
267
247
|
|
|
268
248
|
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
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if (archive === archiveFromChain) {
|
|
276
|
-
// Build expected hashes object (fields may be undefined for backwards compatibility with older events)
|
|
249
|
+
const checkpointNumber = log.args.checkpointNumber;
|
|
250
|
+
const archive = log.args.archive;
|
|
251
|
+
const archiveFromChain = await rollup.archiveAt(checkpointNumber);
|
|
252
|
+
const blobHashes = log.args.versionedBlobHashes;
|
|
253
|
+
|
|
254
|
+
if (archive.equals(archiveFromChain)) {
|
|
277
255
|
const expectedHashes = {
|
|
278
|
-
attestationsHash: log.args.attestationsHash,
|
|
279
|
-
payloadDigest: log.args.payloadDigest,
|
|
256
|
+
attestationsHash: log.args.attestationsHash.toString() as Hex,
|
|
257
|
+
payloadDigest: log.args.payloadDigest.toString() as Hex,
|
|
280
258
|
};
|
|
281
259
|
|
|
282
260
|
const checkpoint = await calldataRetriever.getCheckpointFromRollupTx(
|
|
283
|
-
log.
|
|
261
|
+
log.l1TransactionHash,
|
|
284
262
|
blobHashes,
|
|
285
263
|
checkpointNumber,
|
|
286
264
|
expectedHashes,
|
|
287
265
|
);
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
266
|
+
const { timestamp, parentBeaconBlockRoot } = await getL1Block(publicClient, log.l1BlockNumber);
|
|
267
|
+
const l1 = new L1PublishedData(log.l1BlockNumber, timestamp, log.l1BlockHash.toString());
|
|
268
|
+
|
|
269
|
+
retrievedCheckpoints.push({
|
|
270
|
+
...checkpoint,
|
|
271
|
+
l1,
|
|
272
|
+
chainId,
|
|
273
|
+
version,
|
|
291
274
|
blobHashes,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
isHistoricalSync,
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
const l1 = new L1PublishedData(
|
|
298
|
-
log.blockNumber,
|
|
299
|
-
await getL1BlockTime(publicClient, log.blockNumber),
|
|
300
|
-
log.blockHash,
|
|
301
|
-
);
|
|
275
|
+
parentBeaconBlockRoot,
|
|
276
|
+
});
|
|
302
277
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
l1BlockNumber: log.blockNumber,
|
|
278
|
+
logger.trace(`Retrieved checkpoint calldata ${checkpointNumber} from L1 tx ${log.l1TransactionHash}`, {
|
|
279
|
+
l1BlockNumber: log.l1BlockNumber,
|
|
306
280
|
checkpointNumber,
|
|
307
281
|
archive: archive.toString(),
|
|
308
282
|
attestations: checkpoint.attestations,
|
|
309
283
|
});
|
|
310
284
|
} else {
|
|
311
285
|
logger.warn(`Ignoring checkpoint ${checkpointNumber} due to archive root mismatch`, {
|
|
312
|
-
actual: archive,
|
|
313
|
-
expected: archiveFromChain,
|
|
286
|
+
actual: archive.toString(),
|
|
287
|
+
expected: archiveFromChain.toString(),
|
|
314
288
|
});
|
|
315
289
|
}
|
|
316
290
|
});
|
|
@@ -318,9 +292,12 @@ async function processCheckpointProposedLogs(
|
|
|
318
292
|
return retrievedCheckpoints;
|
|
319
293
|
}
|
|
320
294
|
|
|
321
|
-
export async function
|
|
295
|
+
export async function getL1Block(
|
|
296
|
+
publicClient: ViemPublicClient,
|
|
297
|
+
blockNumber: bigint,
|
|
298
|
+
): Promise<{ timestamp: bigint; parentBeaconBlockRoot: string | undefined }> {
|
|
322
299
|
const block = await publicClient.getBlock({ blockNumber, includeTransactions: false });
|
|
323
|
-
return block.timestamp;
|
|
300
|
+
return { timestamp: block.timestamp, parentBeaconBlockRoot: block.parentBeaconBlockRoot };
|
|
324
301
|
}
|
|
325
302
|
|
|
326
303
|
export async function getCheckpointBlobDataFromBlobs(
|
|
@@ -330,8 +307,14 @@ export async function getCheckpointBlobDataFromBlobs(
|
|
|
330
307
|
checkpointNumber: CheckpointNumber,
|
|
331
308
|
logger: Logger,
|
|
332
309
|
isHistoricalSync: boolean,
|
|
310
|
+
parentBeaconBlockRoot?: string,
|
|
311
|
+
l1BlockTimestamp?: bigint,
|
|
333
312
|
): Promise<CheckpointBlobData> {
|
|
334
|
-
const blobBodies = await blobClient.getBlobSidecar(blockHash, blobHashes, {
|
|
313
|
+
const blobBodies = await blobClient.getBlobSidecar(blockHash, blobHashes, {
|
|
314
|
+
isHistoricalSync,
|
|
315
|
+
parentBeaconBlockRoot,
|
|
316
|
+
l1BlockTimestamp,
|
|
317
|
+
});
|
|
335
318
|
if (blobBodies.length === 0) {
|
|
336
319
|
throw new NoBlobBodiesFoundError(checkpointNumber);
|
|
337
320
|
}
|
|
@@ -355,60 +338,49 @@ export async function getCheckpointBlobDataFromBlobs(
|
|
|
355
338
|
|
|
356
339
|
/** Given an L1 to L2 message, retrieves its corresponding event from the Inbox within a specific block range. */
|
|
357
340
|
export async function retrieveL1ToL2Message(
|
|
358
|
-
inbox:
|
|
359
|
-
|
|
360
|
-
fromBlock: bigint,
|
|
361
|
-
toBlock: bigint,
|
|
341
|
+
inbox: InboxContract,
|
|
342
|
+
message: InboxMessage,
|
|
362
343
|
): Promise<InboxMessage | undefined> {
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
const messages = mapLogsInboxMessage(logs);
|
|
366
|
-
return messages.length > 0 ? messages[0] : undefined;
|
|
344
|
+
const log = await inbox.getMessageSentEventByHash(message.leaf.toString(), message.l1BlockNumber);
|
|
345
|
+
return log && mapLogInboxMessage(log);
|
|
367
346
|
}
|
|
368
347
|
|
|
369
348
|
/**
|
|
370
349
|
* 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.
|
|
350
|
+
* @param inbox - The inbox contract wrapper.
|
|
374
351
|
* @param searchStartBlock - The block number to use for starting the search.
|
|
375
352
|
* @param searchEndBlock - The highest block number that we should search up to.
|
|
376
353
|
* @returns An array of InboxLeaf and next eth block to search from.
|
|
377
354
|
*/
|
|
378
355
|
export async function retrieveL1ToL2Messages(
|
|
379
|
-
inbox:
|
|
356
|
+
inbox: InboxContract,
|
|
380
357
|
searchStartBlock: bigint,
|
|
381
358
|
searchEndBlock: bigint,
|
|
382
359
|
): Promise<InboxMessage[]> {
|
|
383
360
|
const retrievedL1ToL2Messages: InboxMessage[] = [];
|
|
384
361
|
while (searchStartBlock <= searchEndBlock) {
|
|
385
|
-
const messageSentLogs = (
|
|
386
|
-
await inbox.getEvents.MessageSent({}, { fromBlock: searchStartBlock, toBlock: searchEndBlock })
|
|
387
|
-
).filter(log => log.blockNumber! >= searchStartBlock && log.blockNumber! <= searchEndBlock);
|
|
362
|
+
const messageSentLogs = await inbox.getMessageSentEvents(searchStartBlock, searchEndBlock);
|
|
388
363
|
|
|
389
364
|
if (messageSentLogs.length === 0) {
|
|
390
365
|
break;
|
|
391
366
|
}
|
|
392
367
|
|
|
393
|
-
retrievedL1ToL2Messages.push(...
|
|
394
|
-
searchStartBlock = messageSentLogs.at(-1)!.
|
|
368
|
+
retrievedL1ToL2Messages.push(...messageSentLogs.map(mapLogInboxMessage));
|
|
369
|
+
searchStartBlock = messageSentLogs.at(-1)!.l1BlockNumber + 1n;
|
|
395
370
|
}
|
|
396
371
|
|
|
397
372
|
return retrievedL1ToL2Messages;
|
|
398
373
|
}
|
|
399
374
|
|
|
400
|
-
function
|
|
401
|
-
return
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
rollingHash: Buffer16.fromString(rollingHash!),
|
|
410
|
-
};
|
|
411
|
-
});
|
|
375
|
+
function mapLogInboxMessage(log: MessageSentLog): InboxMessage {
|
|
376
|
+
return {
|
|
377
|
+
index: log.args.index,
|
|
378
|
+
leaf: log.args.leaf,
|
|
379
|
+
l1BlockNumber: log.l1BlockNumber,
|
|
380
|
+
l1BlockHash: log.l1BlockHash,
|
|
381
|
+
checkpointNumber: log.args.checkpointNumber,
|
|
382
|
+
rollingHash: log.args.rollingHash,
|
|
383
|
+
};
|
|
412
384
|
}
|
|
413
385
|
|
|
414
386
|
/** Retrieves L2ProofVerified events from the rollup contract. */
|
|
@@ -87,17 +87,17 @@ export async function verifyProxyImplementation(
|
|
|
87
87
|
/**
|
|
88
88
|
* Attempts to decode transaction as a Spire Proposer Multicall.
|
|
89
89
|
* Spire Proposer is a proxy contract that wraps multiple calls.
|
|
90
|
-
* Returns
|
|
90
|
+
* Returns all wrapped calls if validation succeeds (caller handles hash matching to find the propose call).
|
|
91
91
|
* @param tx - The transaction to decode
|
|
92
92
|
* @param publicClient - The viem public client for proxy verification
|
|
93
93
|
* @param logger - Logger instance
|
|
94
|
-
* @returns
|
|
94
|
+
* @returns Array of wrapped calls with 'to' and 'data', or undefined if not a valid Spire Proposer tx
|
|
95
95
|
*/
|
|
96
|
-
export async function
|
|
96
|
+
export async function getCallsFromSpireProposer(
|
|
97
97
|
tx: Transaction,
|
|
98
98
|
publicClient: { getStorageAt: (params: { address: Hex; slot: Hex }) => Promise<Hex | undefined> },
|
|
99
99
|
logger: Logger,
|
|
100
|
-
): Promise<{ to: Hex; data: Hex } | undefined> {
|
|
100
|
+
): Promise<{ to: Hex; data: Hex }[] | undefined> {
|
|
101
101
|
const txHash = tx.hash;
|
|
102
102
|
|
|
103
103
|
try {
|
|
@@ -141,17 +141,9 @@ export async function getCallFromSpireProposer(
|
|
|
141
141
|
|
|
142
142
|
const [calls] = spireArgs;
|
|
143
143
|
|
|
144
|
-
//
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const call = calls[0];
|
|
151
|
-
|
|
152
|
-
// Successfully extracted the single wrapped call
|
|
153
|
-
logger.trace(`Decoded Spire Proposer with single call to ${call.target}`, { txHash });
|
|
154
|
-
return { to: call.target, data: call.data };
|
|
144
|
+
// Return all wrapped calls (hash matching in the caller determines which is the propose call)
|
|
145
|
+
logger.trace(`Decoded Spire Proposer with ${calls.length} call(s)`, { txHash });
|
|
146
|
+
return calls.map(call => ({ to: call.target, data: call.data }));
|
|
155
147
|
} catch (err) {
|
|
156
148
|
// Any decoding error triggers fallback to trace
|
|
157
149
|
logger.warn(`Failed to decode Spire Proposer: ${err}`, { txHash });
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { getPublicClient, getRpcUrlsFromClient } from '@aztec/ethereum/client';
|
|
2
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
3
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
4
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
5
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
6
|
+
|
|
7
|
+
/** Subset of L1 contract addresses whose historical logs the Aztec node relies on. */
|
|
8
|
+
export type HistoricalLogsContractAddresses = Pick<
|
|
9
|
+
L1ContractAddresses,
|
|
10
|
+
'rollupAddress' | 'inboxAddress' | 'registryAddress' | 'governanceProposerAddress'
|
|
11
|
+
>;
|
|
12
|
+
|
|
13
|
+
/** Result of probing a single RPC URL. */
|
|
14
|
+
type ProbeResult = { ok: true } | { ok: false; reason: string; clientVersion: string | undefined };
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Validates that every configured L1 RPC URL returns historical logs for the Rollup contract.
|
|
18
|
+
*
|
|
19
|
+
* Some RPC providers prune old logs, which would cause L1 syncing to silently fail. To detect this,
|
|
20
|
+
* we query for the `OwnershipTransferred` event which every Rollup emits in its constructor (via
|
|
21
|
+
* Ownable) on the block it was deployed (`l1StartBlock`). The `client` is typically a viem fallback
|
|
22
|
+
* transport over several user-configured RPC URLs — checking only the first URL would miss a bad
|
|
23
|
+
* secondary, so we probe each URL independently. The first URL that fails aborts startup, unless
|
|
24
|
+
* the operator has explicitly opted out.
|
|
25
|
+
*
|
|
26
|
+
* @param client - The L1 public client built from the user-configured RPC URLs.
|
|
27
|
+
* @param addresses - The subset of L1 contract addresses we rely on for historical log retrieval.
|
|
28
|
+
* @param skipCheck - If true, log warnings instead of throwing.
|
|
29
|
+
* @param bindings - Optional logger bindings for context.
|
|
30
|
+
* @throws Error if any URL fails the probe and skipCheck is false.
|
|
31
|
+
*/
|
|
32
|
+
export async function validateAndLogHistoricalLogsAvailability(
|
|
33
|
+
client: ViemPublicClient,
|
|
34
|
+
addresses: HistoricalLogsContractAddresses,
|
|
35
|
+
skipCheck: boolean,
|
|
36
|
+
bindings?: LoggerBindings,
|
|
37
|
+
): Promise<void> {
|
|
38
|
+
const logger = createLogger('archiver:validate_historical_logs', bindings);
|
|
39
|
+
logger.debug('Validating historical log availability on L1 RPCs');
|
|
40
|
+
|
|
41
|
+
const urls = getRpcUrlsFromClient(client);
|
|
42
|
+
if (urls.length === 0) {
|
|
43
|
+
logger.warn('Could not determine L1 RPC URLs from the public client; skipping historical logs check.');
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const chainId = client.chain?.id;
|
|
48
|
+
if (chainId === undefined) {
|
|
49
|
+
logger.warn('Could not determine L1 chain ID from the public client; skipping historical logs check.');
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
for (const url of urls) {
|
|
54
|
+
const probeClient = getPublicClient({ l1RpcUrls: [url], l1ChainId: chainId });
|
|
55
|
+
const rollup = new RollupContract(probeClient, addresses.rollupAddress.toString());
|
|
56
|
+
const result = await probeRpcUrl(rollup, probeClient, logger);
|
|
57
|
+
|
|
58
|
+
if (result.ok) {
|
|
59
|
+
logger.debug(`L1 RPC ${url} returned historical OwnershipTransferred log for the Rollup contract.`);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const errorMessage = buildErrorMessage(url, result, addresses);
|
|
64
|
+
if (skipCheck) {
|
|
65
|
+
logger.warn(`${errorMessage}\nContinuing because ARCHIVER_SKIP_HISTORICAL_LOGS_CHECK is true.`);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
logger.error(errorMessage);
|
|
70
|
+
throw new Error(errorMessage);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Runs the OwnershipTransferred probe against a single RPC and queries its client version. */
|
|
75
|
+
async function probeRpcUrl(rollup: RollupContract, client: ViemPublicClient, logger: Logger): Promise<ProbeResult> {
|
|
76
|
+
let queryError: unknown;
|
|
77
|
+
try {
|
|
78
|
+
const logs = await rollup.getOwnershipTransferredEventsAtDeploy();
|
|
79
|
+
if (logs.length > 0) {
|
|
80
|
+
return { ok: true };
|
|
81
|
+
}
|
|
82
|
+
} catch (err) {
|
|
83
|
+
queryError = err;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const clientVersion = await getClientVersion(client, logger);
|
|
87
|
+
|
|
88
|
+
let reason: string;
|
|
89
|
+
if (queryError instanceof Error) {
|
|
90
|
+
reason = `Query for historical logs failed: ${queryError.message}`;
|
|
91
|
+
} else if (queryError !== undefined) {
|
|
92
|
+
reason = 'Query for historical logs failed with a non-Error value.';
|
|
93
|
+
} else {
|
|
94
|
+
reason = 'No OwnershipTransferred event was returned by the L1 RPC for the Rollup deploy block.';
|
|
95
|
+
}
|
|
96
|
+
return { ok: false, reason, clientVersion };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Builds the operator-facing error message for a failing RPC URL. */
|
|
100
|
+
function buildErrorMessage(
|
|
101
|
+
url: string,
|
|
102
|
+
result: Extract<ProbeResult, { ok: false }>,
|
|
103
|
+
addresses: HistoricalLogsContractAddresses,
|
|
104
|
+
): string {
|
|
105
|
+
return [
|
|
106
|
+
`L1 RPC at ${url} does not return historical logs for the Rollup contract. ${result.reason}`,
|
|
107
|
+
`This likely means this Ethereum RPC node prunes old logs, which would cause the archiver ` +
|
|
108
|
+
`to silently miss data during L1 sync.`,
|
|
109
|
+
result.clientVersion
|
|
110
|
+
? `Detected L1 client version for ${url}: ${result.clientVersion}.`
|
|
111
|
+
: `Could not determine L1 client version for ${url}.`,
|
|
112
|
+
`The following L1 contract addresses must have their historical logs retained by the RPC node:`,
|
|
113
|
+
` - Rollup: ${addresses.rollupAddress.toString()}`,
|
|
114
|
+
` - Inbox: ${addresses.inboxAddress.toString()}`,
|
|
115
|
+
` - Registry: ${addresses.registryAddress.toString()}`,
|
|
116
|
+
` - GovernanceProposer: ${addresses.governanceProposerAddress.toString()}`,
|
|
117
|
+
isReth(result.clientVersion)
|
|
118
|
+
? `To retain logs for these contracts, configure reth with a ` +
|
|
119
|
+
`prune.segments.receipts_log_filter entry for each address above ` +
|
|
120
|
+
`so reth does not prune their receipts/logs. See https://reth.rs/run/pruning.html for details.`
|
|
121
|
+
: `Point this RPC endpoint at a node that retains full log history for the addresses above.`,
|
|
122
|
+
`Set ARCHIVER_SKIP_HISTORICAL_LOGS_CHECK=true to bypass this check at your own risk.`,
|
|
123
|
+
].join('\n');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Queries `web3_clientVersion` on the L1 RPC. Returns undefined if the call fails or returns a non-string. */
|
|
127
|
+
async function getClientVersion(client: ViemPublicClient, logger: Logger): Promise<string | undefined> {
|
|
128
|
+
try {
|
|
129
|
+
const result = await client.request({ method: 'web3_clientVersion' });
|
|
130
|
+
return typeof result === 'string' ? result : undefined;
|
|
131
|
+
} catch (err) {
|
|
132
|
+
logger.debug(`Failed to query web3_clientVersion: ${err instanceof Error ? err.message : err}`);
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Heuristic check for reth based on the web3_clientVersion string (reth returns e.g. "reth/v1.0.0-..."). */
|
|
138
|
+
function isReth(clientVersion: string | undefined): boolean {
|
|
139
|
+
return !!clientVersion && /reth/i.test(clientVersion);
|
|
140
|
+
}
|