@aztec/archiver 3.0.0-nightly.20251214 → 3.0.0-nightly.20251217
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/archiver/archiver.d.ts +60 -36
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +366 -180
- package/dest/archiver/archiver_store.d.ts +79 -23
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.js +1666 -244
- package/dest/archiver/errors.d.ts +25 -1
- package/dest/archiver/errors.d.ts.map +1 -1
- package/dest/archiver/errors.js +37 -0
- package/dest/archiver/index.d.ts +2 -2
- package/dest/archiver/index.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.d.ts +49 -17
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +320 -83
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +30 -28
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +51 -27
- package/dest/archiver/kv_archiver_store/log_store.d.ts +5 -5
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +39 -15
- package/dest/archiver/l1/bin/retrieve-calldata.js +2 -2
- package/dest/archiver/l1/calldata_retriever.d.ts +17 -3
- package/dest/archiver/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/archiver/l1/calldata_retriever.js +75 -7
- package/dest/archiver/l1/data_retrieval.d.ts +11 -8
- package/dest/archiver/l1/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/l1/data_retrieval.js +30 -17
- package/dest/archiver/structs/published.d.ts +1 -2
- package/dest/archiver/structs/published.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.d.ts +3 -2
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +8 -15
- package/package.json +13 -13
- package/src/archiver/archiver.ts +464 -222
- package/src/archiver/archiver_store.ts +88 -22
- package/src/archiver/archiver_store_test_suite.ts +1689 -226
- package/src/archiver/errors.ts +64 -0
- package/src/archiver/index.ts +1 -1
- package/src/archiver/kv_archiver_store/block_store.ts +435 -94
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +63 -39
- package/src/archiver/kv_archiver_store/log_store.ts +62 -25
- package/src/archiver/l1/bin/retrieve-calldata.ts +2 -2
- package/src/archiver/l1/calldata_retriever.ts +116 -6
- package/src/archiver/l1/data_retrieval.ts +34 -13
- package/src/archiver/structs/published.ts +0 -1
- package/src/test/mock_l2_block_source.ts +9 -16
|
@@ -16,7 +16,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
16
16
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
17
17
|
import { type InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
18
18
|
import { Body, CommitteeAttestation, L2BlockNew } from '@aztec/stdlib/block';
|
|
19
|
-
import { Checkpoint, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
19
|
+
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
20
20
|
import { Proof } from '@aztec/stdlib/proofs';
|
|
21
21
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
22
22
|
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
@@ -35,7 +35,6 @@ import { NoBlobBodiesFoundError } from '../errors.js';
|
|
|
35
35
|
import type { ArchiverInstrumentation } from '../instrumentation.js';
|
|
36
36
|
import type { DataRetrieval } from '../structs/data_retrieval.js';
|
|
37
37
|
import type { InboxMessage } from '../structs/inbox_message.js';
|
|
38
|
-
import type { L1PublishedData } from '../structs/published.js';
|
|
39
38
|
import { CalldataRetriever } from './calldata_retriever.js';
|
|
40
39
|
|
|
41
40
|
export type RetrievedCheckpoint = {
|
|
@@ -138,13 +137,17 @@ export async function retrievedToPublishedCheckpoint({
|
|
|
138
137
|
|
|
139
138
|
/**
|
|
140
139
|
* Fetches new checkpoints.
|
|
140
|
+
* @param rollup - The rollup contract instance.
|
|
141
141
|
* @param publicClient - The viem public client to use for transaction retrieval.
|
|
142
142
|
* @param debugClient - The viem debug client to use for trace/debug RPC methods (optional).
|
|
143
|
-
* @param
|
|
143
|
+
* @param blobSinkClient - The blob sink client for fetching blob data.
|
|
144
144
|
* @param searchStartBlock - The block number to use for starting the search.
|
|
145
145
|
* @param searchEndBlock - The highest block number that we should search up to.
|
|
146
|
-
* @param
|
|
147
|
-
* @
|
|
146
|
+
* @param contractAddresses - The contract addresses (governanceProposerAddress, slashFactoryAddress, slashingProposerAddress).
|
|
147
|
+
* @param instrumentation - The archiver instrumentation instance.
|
|
148
|
+
* @param logger - The logger instance.
|
|
149
|
+
* @param isHistoricalSync - Whether this is a historical sync.
|
|
150
|
+
* @returns An array of retrieved checkpoints.
|
|
148
151
|
*/
|
|
149
152
|
export async function retrieveCheckpointsFromRollup(
|
|
150
153
|
rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>,
|
|
@@ -160,6 +163,7 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
160
163
|
},
|
|
161
164
|
instrumentation: ArchiverInstrumentation,
|
|
162
165
|
logger: Logger = createLogger('archiver'),
|
|
166
|
+
isHistoricalSync: boolean = false,
|
|
163
167
|
): Promise<RetrievedCheckpoint[]> {
|
|
164
168
|
const retrievedCheckpoints: RetrievedCheckpoint[] = [];
|
|
165
169
|
|
|
@@ -211,6 +215,7 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
211
215
|
contractAddresses,
|
|
212
216
|
instrumentation,
|
|
213
217
|
logger,
|
|
218
|
+
isHistoricalSync,
|
|
214
219
|
);
|
|
215
220
|
retrievedCheckpoints.push(...newCheckpoints);
|
|
216
221
|
searchStartBlock = lastLog.blockNumber! + 1n;
|
|
@@ -222,11 +227,17 @@ export async function retrieveCheckpointsFromRollup(
|
|
|
222
227
|
|
|
223
228
|
/**
|
|
224
229
|
* Processes newly received CheckpointProposed logs.
|
|
225
|
-
* @param rollup - The rollup contract
|
|
230
|
+
* @param rollup - The rollup contract instance.
|
|
226
231
|
* @param publicClient - The viem public client to use for transaction retrieval.
|
|
227
232
|
* @param debugClient - The viem debug client to use for trace/debug RPC methods (optional).
|
|
233
|
+
* @param blobSinkClient - The blob sink client for fetching blob data.
|
|
228
234
|
* @param logs - CheckpointProposed logs.
|
|
229
|
-
* @
|
|
235
|
+
* @param rollupConstants - The rollup constants (chainId, version, targetCommitteeSize).
|
|
236
|
+
* @param contractAddresses - The contract addresses (governanceProposerAddress, slashFactoryAddress, slashingProposerAddress).
|
|
237
|
+
* @param instrumentation - The archiver instrumentation instance.
|
|
238
|
+
* @param logger - The logger instance.
|
|
239
|
+
* @param isHistoricalSync - Whether this is a historical sync.
|
|
240
|
+
* @returns An array of retrieved checkpoints.
|
|
230
241
|
*/
|
|
231
242
|
async function processCheckpointProposedLogs(
|
|
232
243
|
rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>,
|
|
@@ -242,6 +253,7 @@ async function processCheckpointProposedLogs(
|
|
|
242
253
|
},
|
|
243
254
|
instrumentation: ArchiverInstrumentation,
|
|
244
255
|
logger: Logger,
|
|
256
|
+
isHistoricalSync: boolean,
|
|
245
257
|
): Promise<RetrievedCheckpoint[]> {
|
|
246
258
|
const retrievedCheckpoints: RetrievedCheckpoint[] = [];
|
|
247
259
|
const calldataRetriever = new CalldataRetriever(
|
|
@@ -261,10 +273,17 @@ async function processCheckpointProposedLogs(
|
|
|
261
273
|
|
|
262
274
|
// The value from the event and contract will match only if the checkpoint is in the chain.
|
|
263
275
|
if (archive === archiveFromChain) {
|
|
276
|
+
// Build expected hashes object (fields may be undefined for backwards compatibility with older events)
|
|
277
|
+
const expectedHashes = {
|
|
278
|
+
attestationsHash: log.args.attestationsHash,
|
|
279
|
+
payloadDigest: log.args.payloadDigest,
|
|
280
|
+
};
|
|
281
|
+
|
|
264
282
|
const checkpoint = await calldataRetriever.getCheckpointFromRollupTx(
|
|
265
283
|
log.transactionHash!,
|
|
266
284
|
blobHashes,
|
|
267
285
|
checkpointNumber,
|
|
286
|
+
expectedHashes,
|
|
268
287
|
);
|
|
269
288
|
const checkpointBlobData = await getCheckpointBlobDataFromBlobs(
|
|
270
289
|
blobSinkClient,
|
|
@@ -272,13 +291,14 @@ async function processCheckpointProposedLogs(
|
|
|
272
291
|
blobHashes,
|
|
273
292
|
checkpointNumber,
|
|
274
293
|
logger,
|
|
294
|
+
isHistoricalSync,
|
|
275
295
|
);
|
|
276
296
|
|
|
277
|
-
const l1
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
297
|
+
const l1 = new L1PublishedData(
|
|
298
|
+
log.blockNumber,
|
|
299
|
+
await getL1BlockTime(publicClient, log.blockNumber),
|
|
300
|
+
log.blockHash,
|
|
301
|
+
);
|
|
282
302
|
|
|
283
303
|
retrievedCheckpoints.push({ ...checkpoint, checkpointBlobData, l1, chainId, version });
|
|
284
304
|
logger.trace(`Retrieved checkpoint ${checkpointNumber} from L1 tx ${log.transactionHash}`, {
|
|
@@ -309,8 +329,9 @@ export async function getCheckpointBlobDataFromBlobs(
|
|
|
309
329
|
blobHashes: Buffer<ArrayBufferLike>[],
|
|
310
330
|
checkpointNumber: CheckpointNumber,
|
|
311
331
|
logger: Logger,
|
|
332
|
+
isHistoricalSync: boolean,
|
|
312
333
|
): Promise<CheckpointBlobData> {
|
|
313
|
-
const blobBodies = await blobSinkClient.getBlobSidecar(blockHash, blobHashes);
|
|
334
|
+
const blobBodies = await blobSinkClient.getBlobSidecar(blockHash, blobHashes, undefined, { isHistoricalSync });
|
|
314
335
|
if (blobBodies.length === 0) {
|
|
315
336
|
throw new NoBlobBodiesFoundError(checkpointNumber);
|
|
316
337
|
}
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
PublishedL2Block,
|
|
16
16
|
type ValidateBlockResult,
|
|
17
17
|
} from '@aztec/stdlib/block';
|
|
18
|
-
import type
|
|
18
|
+
import { type Checkpoint, L1PublishedData } from '@aztec/stdlib/checkpoint';
|
|
19
19
|
import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
20
20
|
import { EmptyL1RollupConstants, type L1RollupConstants, getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
21
21
|
import { type BlockHeader, TxHash, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
@@ -91,6 +91,11 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
91
91
|
return Promise.resolve(BlockNumber(this.provenBlockNumber));
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
public getCheckpointedBlock(_number: BlockNumber) {
|
|
95
|
+
// In this mock, we don't track checkpointed blocks separately
|
|
96
|
+
return Promise.resolve(undefined);
|
|
97
|
+
}
|
|
98
|
+
|
|
94
99
|
/**
|
|
95
100
|
* Gets an l2 block.
|
|
96
101
|
* @param number - The block number to return (inclusive).
|
|
@@ -129,11 +134,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
129
134
|
return blocks.map(block =>
|
|
130
135
|
PublishedL2Block.fromFields({
|
|
131
136
|
block,
|
|
132
|
-
l1:
|
|
133
|
-
blockNumber: BigInt(block.number),
|
|
134
|
-
blockHash: Buffer32.random().toString(),
|
|
135
|
-
timestamp: BigInt(block.number),
|
|
136
|
-
},
|
|
137
|
+
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
137
138
|
attestations: [],
|
|
138
139
|
}),
|
|
139
140
|
);
|
|
@@ -145,11 +146,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
145
146
|
if (hash.equals(blockHash)) {
|
|
146
147
|
return PublishedL2Block.fromFields({
|
|
147
148
|
block,
|
|
148
|
-
l1:
|
|
149
|
-
blockNumber: BigInt(block.number),
|
|
150
|
-
blockHash: Buffer32.random().toString(),
|
|
151
|
-
timestamp: BigInt(block.number),
|
|
152
|
-
},
|
|
149
|
+
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
153
150
|
attestations: [],
|
|
154
151
|
});
|
|
155
152
|
}
|
|
@@ -165,11 +162,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
165
162
|
return Promise.resolve(
|
|
166
163
|
PublishedL2Block.fromFields({
|
|
167
164
|
block,
|
|
168
|
-
l1:
|
|
169
|
-
blockNumber: BigInt(block.number),
|
|
170
|
-
blockHash: Buffer32.random().toString(),
|
|
171
|
-
timestamp: BigInt(block.number),
|
|
172
|
-
},
|
|
165
|
+
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
173
166
|
attestations: [],
|
|
174
167
|
}),
|
|
175
168
|
);
|