@aztec/archiver 4.0.0-nightly.20260112 → 4.0.0-nightly.20260114
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 +139 -22
- package/dest/archiver/archive_source_base.d.ts +75 -0
- package/dest/archiver/archive_source_base.d.ts.map +1 -0
- package/dest/archiver/archive_source_base.js +202 -0
- package/dest/archiver/archiver.d.ts +32 -168
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +123 -613
- package/dest/archiver/archiver_store_updates.d.ts +38 -0
- package/dest/archiver/archiver_store_updates.d.ts.map +1 -0
- package/dest/archiver/archiver_store_updates.js +212 -0
- package/dest/archiver/config.js +2 -2
- package/dest/archiver/index.d.ts +3 -2
- package/dest/archiver/index.d.ts.map +1 -1
- package/dest/archiver/index.js +2 -0
- package/dest/archiver/kv_archiver_store/block_store.d.ts +12 -5
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +23 -4
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +1 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +1 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +1 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.js +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +173 -12
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +159 -48
- package/dest/archiver/l1/calldata_retriever.d.ts +2 -2
- package/dest/archiver/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/archiver/l1/calldata_retriever.js +2 -2
- package/dest/archiver/l1/data_retrieval.d.ts +9 -11
- package/dest/archiver/l1/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/l1/data_retrieval.js +32 -51
- package/dest/archiver/l1/validate_trace.js +1 -1
- package/dest/archiver/test/fake_l1_state.d.ts +173 -0
- package/dest/archiver/test/fake_l1_state.d.ts.map +1 -0
- package/dest/archiver/test/fake_l1_state.js +364 -0
- package/dest/archiver/validation.d.ts +4 -4
- package/dest/archiver/validation.d.ts.map +1 -1
- package/dest/archiver/validation.js +1 -1
- package/dest/test/mock_l1_to_l2_message_source.d.ts +2 -2
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +12 -3
- package/dest/test/mock_l2_block_source.d.ts +8 -4
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +65 -19
- package/package.json +13 -13
- package/src/archiver/archive_source_base.ts +339 -0
- package/src/archiver/archiver.ts +166 -815
- package/src/archiver/archiver_store_updates.ts +321 -0
- package/src/archiver/config.ts +2 -2
- package/src/archiver/index.ts +2 -1
- package/src/archiver/kv_archiver_store/block_store.ts +36 -8
- package/src/archiver/kv_archiver_store/contract_class_store.ts +1 -1
- package/src/archiver/kv_archiver_store/contract_instance_store.ts +1 -1
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +177 -11
- package/src/archiver/l1/calldata_retriever.ts +2 -2
- package/src/archiver/l1/data_retrieval.ts +51 -68
- package/src/archiver/l1/validate_trace.ts +1 -1
- package/src/archiver/test/fake_l1_state.ts +561 -0
- package/src/archiver/validation.ts +6 -6
- package/src/test/mock_l1_to_l2_message_source.ts +10 -4
- package/src/test/mock_l2_block_source.ts +76 -18
- package/dest/archiver/archiver_store.d.ts +0 -308
- 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/src/archiver/archiver_store.ts +0 -372
- package/src/archiver/archiver_store_test_suite.ts +0 -2843
|
@@ -6,15 +6,20 @@ 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
18
|
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
13
|
-
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
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 {
|
|
22
|
+
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
18
23
|
import { Body, CommitteeAttestation, L2BlockNew } from '@aztec/stdlib/block';
|
|
19
24
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
20
25
|
import { Proof } from '@aztec/stdlib/proofs';
|
|
@@ -22,14 +27,7 @@ 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
33
|
import type { ArchiverInstrumentation } from '../instrumentation.js';
|
|
@@ -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. */
|
|
@@ -165,7 +165,7 @@ export async function validateAndLogTraceAvailability(
|
|
|
165
165
|
client: ViemPublicDebugClient,
|
|
166
166
|
ethereumAllowNoDebugHosts: boolean,
|
|
167
167
|
): Promise<void> {
|
|
168
|
-
logger.
|
|
168
|
+
logger.debug('Validating trace/debug method availability...');
|
|
169
169
|
|
|
170
170
|
const availability = await validateTraceAvailability(client);
|
|
171
171
|
|