@aztec/archiver 3.0.0-nightly.20251216 → 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 +1624 -251
- 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 +29 -27
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +50 -26
- package/dest/archiver/kv_archiver_store/log_store.d.ts +4 -4
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- 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 +25 -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 +1626 -232
- 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 +62 -38
- package/src/archiver/kv_archiver_store/log_store.ts +4 -4
- package/src/archiver/l1/data_retrieval.ts +27 -13
- package/src/archiver/structs/published.ts +0 -1
- package/src/test/mock_l2_block_source.ts +9 -16
|
@@ -6,7 +6,8 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
6
6
|
import type { AztecAsyncKVStore, CustomRange, StoreSize } from '@aztec/kv-store';
|
|
7
7
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
8
8
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
-
import {
|
|
9
|
+
import { CheckpointedL2Block, L2BlockHash, L2BlockNew, type ValidateBlockResult } from '@aztec/stdlib/block';
|
|
10
|
+
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
10
11
|
import type {
|
|
11
12
|
ContractClassPublic,
|
|
12
13
|
ContractDataSource,
|
|
@@ -24,8 +25,7 @@ import { join } from 'path';
|
|
|
24
25
|
|
|
25
26
|
import type { ArchiverDataStore, ArchiverL1SynchPoint } from '../archiver_store.js';
|
|
26
27
|
import type { InboxMessage } from '../structs/inbox_message.js';
|
|
27
|
-
import type
|
|
28
|
-
import { BlockStore } from './block_store.js';
|
|
28
|
+
import { BlockStore, type CheckpointData } from './block_store.js';
|
|
29
29
|
import { ContractClassStore } from './contract_class_store.js';
|
|
30
30
|
import { ContractInstanceStore } from './contract_instance_store.js';
|
|
31
31
|
import { LogStore } from './log_store.js';
|
|
@@ -67,7 +67,7 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
public getBlockNumber(): Promise<BlockNumber> {
|
|
70
|
-
return this.
|
|
70
|
+
return this.#blockStore.getLatestL2BlockNumber();
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
public async getContract(
|
|
@@ -186,42 +186,52 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
186
186
|
* @param blocks - The L2 blocks to be added to the store and the last processed L1 block.
|
|
187
187
|
* @returns True if the operation is successful.
|
|
188
188
|
*/
|
|
189
|
-
addBlocks(blocks:
|
|
189
|
+
addBlocks(blocks: L2BlockNew[], opts: { force?: boolean; checkpointNumber?: number } = {}): Promise<boolean> {
|
|
190
190
|
return this.#blockStore.addBlocks(blocks, opts);
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
getRangeOfCheckpoints(from: CheckpointNumber, limit: number): Promise<CheckpointData[]> {
|
|
194
|
+
return this.#blockStore.getRangeOfCheckpoints(from, limit);
|
|
195
|
+
}
|
|
196
|
+
getLatestBlockNumber(): Promise<BlockNumber> {
|
|
197
|
+
return this.#blockStore.getLatestBlockNumber();
|
|
198
|
+
}
|
|
199
|
+
|
|
193
200
|
/**
|
|
194
|
-
* Unwinds
|
|
201
|
+
* Unwinds checkpoints from the database
|
|
195
202
|
* @param from - The tip of the chain, passed for verification purposes,
|
|
196
203
|
* ensuring that we don't end up deleting something we did not intend
|
|
197
|
-
* @param
|
|
204
|
+
* @param checkpointsToUnwind - The number of checkpoints we are to unwind
|
|
198
205
|
* @returns True if the operation is successful
|
|
199
206
|
*/
|
|
200
|
-
|
|
201
|
-
return this.#blockStore.
|
|
207
|
+
unwindCheckpoints(from: CheckpointNumber, checkpointsToUnwind: number): Promise<boolean> {
|
|
208
|
+
return this.#blockStore.unwindCheckpoints(from, checkpointsToUnwind);
|
|
202
209
|
}
|
|
203
210
|
|
|
204
|
-
|
|
205
|
-
return this.#blockStore.
|
|
211
|
+
addCheckpoints(checkpoints: PublishedCheckpoint[]): Promise<boolean> {
|
|
212
|
+
return this.#blockStore.addCheckpoints(checkpoints);
|
|
206
213
|
}
|
|
207
214
|
|
|
208
|
-
|
|
215
|
+
getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined> {
|
|
216
|
+
return this.#blockStore.getCheckpointedBlock(number);
|
|
217
|
+
}
|
|
218
|
+
getCheckpointedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined> {
|
|
219
|
+
return this.#blockStore.getCheckpointedBlockByHash(blockHash);
|
|
220
|
+
}
|
|
221
|
+
getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined> {
|
|
222
|
+
return this.#blockStore.getCheckpointedBlockByArchive(archive);
|
|
223
|
+
}
|
|
224
|
+
getBlock(number: BlockNumber): Promise<L2BlockNew | undefined> {
|
|
225
|
+
return this.#blockStore.getBlock(number);
|
|
226
|
+
}
|
|
227
|
+
getBlockByHash(blockHash: Fr): Promise<L2BlockNew | undefined> {
|
|
209
228
|
return this.#blockStore.getBlockByHash(L2BlockHash.fromField(blockHash));
|
|
210
229
|
}
|
|
211
|
-
|
|
212
|
-
getPublishedBlockByArchive(archive: Fr): Promise<PublishedL2Block | undefined> {
|
|
230
|
+
getBlockByArchive(archive: Fr): Promise<L2BlockNew | undefined> {
|
|
213
231
|
return this.#blockStore.getBlockByArchive(archive);
|
|
214
232
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
* Gets up to `limit` amount of L2 blocks starting from `from`.
|
|
218
|
-
*
|
|
219
|
-
* @param start - Number of the first block to return (inclusive).
|
|
220
|
-
* @param limit - The number of blocks to return.
|
|
221
|
-
* @returns The requested L2 blocks
|
|
222
|
-
*/
|
|
223
|
-
getPublishedBlocks(start: BlockNumber, limit: number): Promise<PublishedL2Block[]> {
|
|
224
|
-
return toArray(this.#blockStore.getBlocks(start, limit));
|
|
233
|
+
getBlocks(from: BlockNumber, limit: BlockNumber): Promise<L2BlockNew[]> {
|
|
234
|
+
return toArray(this.#blockStore.getBlocks(from, limit));
|
|
225
235
|
}
|
|
226
236
|
|
|
227
237
|
/**
|
|
@@ -266,11 +276,11 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
266
276
|
* @param blocks - The blocks for which to add the logs.
|
|
267
277
|
* @returns True if the operation is successful.
|
|
268
278
|
*/
|
|
269
|
-
addLogs(blocks:
|
|
279
|
+
addLogs(blocks: L2BlockNew[]): Promise<boolean> {
|
|
270
280
|
return this.#logStore.addLogs(blocks);
|
|
271
281
|
}
|
|
272
282
|
|
|
273
|
-
deleteLogs(blocks:
|
|
283
|
+
deleteLogs(blocks: L2BlockNew[]): Promise<boolean> {
|
|
274
284
|
return this.#logStore.deleteLogs(blocks);
|
|
275
285
|
}
|
|
276
286
|
|
|
@@ -349,20 +359,12 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
349
359
|
}
|
|
350
360
|
}
|
|
351
361
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
* @returns The number of the latest L2 block processed.
|
|
355
|
-
*/
|
|
356
|
-
getSynchedL2BlockNumber(): Promise<BlockNumber> {
|
|
357
|
-
return this.#blockStore.getSynchedL2BlockNumber();
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
getProvenL2BlockNumber(): Promise<BlockNumber> {
|
|
361
|
-
return this.#blockStore.getProvenL2BlockNumber();
|
|
362
|
+
getProvenCheckpointNumber(): Promise<CheckpointNumber> {
|
|
363
|
+
return this.#blockStore.getProvenCheckpointNumber();
|
|
362
364
|
}
|
|
363
365
|
|
|
364
|
-
async
|
|
365
|
-
await this.#blockStore.
|
|
366
|
+
async setProvenCheckpointNumber(checkpointNumber: CheckpointNumber) {
|
|
367
|
+
await this.#blockStore.setProvenCheckpointNumber(checkpointNumber);
|
|
366
368
|
}
|
|
367
369
|
|
|
368
370
|
async setBlockSynchedL1BlockNumber(l1BlockNumber: bigint) {
|
|
@@ -373,6 +375,10 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
373
375
|
await this.#messageStore.setSynchedL1Block(l1Block);
|
|
374
376
|
}
|
|
375
377
|
|
|
378
|
+
getProvenBlockNumber(): Promise<BlockNumber> {
|
|
379
|
+
return this.#blockStore.getProvenBlockNumber();
|
|
380
|
+
}
|
|
381
|
+
|
|
376
382
|
/**
|
|
377
383
|
* Gets the last L1 block number processed by the archiver
|
|
378
384
|
*/
|
|
@@ -410,4 +416,22 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
410
416
|
public setPendingChainValidationStatus(status: ValidateBlockResult | undefined): Promise<void> {
|
|
411
417
|
return this.#blockStore.setPendingChainValidationStatus(status);
|
|
412
418
|
}
|
|
419
|
+
|
|
420
|
+
public getCheckpointedL2BlockNumber(): Promise<BlockNumber> {
|
|
421
|
+
return this.#blockStore.getCheckpointedL2BlockNumber();
|
|
422
|
+
}
|
|
423
|
+
public getSynchedCheckpointNumber(): Promise<CheckpointNumber> {
|
|
424
|
+
return this.#blockStore.getLatestCheckpointNumber();
|
|
425
|
+
}
|
|
426
|
+
async setCheckpointSynchedL1BlockNumber(l1BlockNumber: bigint): Promise<void> {
|
|
427
|
+
await this.#blockStore.setSynchedL1BlockNumber(l1BlockNumber);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
getBlocksForCheckpoint(checkpointNumber: CheckpointNumber): Promise<L2BlockNew[] | undefined> {
|
|
431
|
+
return this.#blockStore.getBlocksForCheckpoint(checkpointNumber);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
getCheckpointData(checkpointNumber: CheckpointNumber): Promise<CheckpointData | undefined> {
|
|
435
|
+
return this.#blockStore.getCheckpointData(checkpointNumber);
|
|
436
|
+
}
|
|
413
437
|
}
|
|
@@ -4,7 +4,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { BufferReader, numToUInt32BE } from '@aztec/foundation/serialize';
|
|
6
6
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
7
|
-
import {
|
|
7
|
+
import { L2BlockHash, L2BlockNew } from '@aztec/stdlib/block';
|
|
8
8
|
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
9
9
|
import {
|
|
10
10
|
ContractClassLog,
|
|
@@ -42,7 +42,7 @@ export class LogStore {
|
|
|
42
42
|
this.#logsMaxPageSize = logsMaxPageSize;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
async #extractTaggedLogs(block:
|
|
45
|
+
async #extractTaggedLogs(block: L2BlockNew) {
|
|
46
46
|
const blockHash = L2BlockHash.fromField(await block.hash());
|
|
47
47
|
const taggedLogs = new Map<string, Buffer[]>();
|
|
48
48
|
const dataStartIndexForBlock =
|
|
@@ -82,7 +82,7 @@ export class LogStore {
|
|
|
82
82
|
* @param blocks - The blocks for which to add the logs.
|
|
83
83
|
* @returns True if the operation is successful.
|
|
84
84
|
*/
|
|
85
|
-
async addLogs(blocks:
|
|
85
|
+
async addLogs(blocks: L2BlockNew[]): Promise<boolean> {
|
|
86
86
|
const taggedLogsInBlocks = await Promise.all(blocks.map(block => this.#extractTaggedLogs(block)));
|
|
87
87
|
const taggedLogsToAdd = taggedLogsInBlocks.reduce((acc, taggedLogs) => {
|
|
88
88
|
for (const [tag, logs] of taggedLogs.entries()) {
|
|
@@ -160,7 +160,7 @@ export class LogStore {
|
|
|
160
160
|
return L2BlockHash.fromField(blockHash);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
deleteLogs(blocks:
|
|
163
|
+
deleteLogs(blocks: L2BlockNew[]): Promise<boolean> {
|
|
164
164
|
return this.db.transactionAsync(async () => {
|
|
165
165
|
const tagsToDelete = (
|
|
166
166
|
await Promise.all(
|
|
@@ -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(
|
|
@@ -279,13 +291,14 @@ async function processCheckpointProposedLogs(
|
|
|
279
291
|
blobHashes,
|
|
280
292
|
checkpointNumber,
|
|
281
293
|
logger,
|
|
294
|
+
isHistoricalSync,
|
|
282
295
|
);
|
|
283
296
|
|
|
284
|
-
const l1
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
297
|
+
const l1 = new L1PublishedData(
|
|
298
|
+
log.blockNumber,
|
|
299
|
+
await getL1BlockTime(publicClient, log.blockNumber),
|
|
300
|
+
log.blockHash,
|
|
301
|
+
);
|
|
289
302
|
|
|
290
303
|
retrievedCheckpoints.push({ ...checkpoint, checkpointBlobData, l1, chainId, version });
|
|
291
304
|
logger.trace(`Retrieved checkpoint ${checkpointNumber} from L1 tx ${log.transactionHash}`, {
|
|
@@ -316,8 +329,9 @@ export async function getCheckpointBlobDataFromBlobs(
|
|
|
316
329
|
blobHashes: Buffer<ArrayBufferLike>[],
|
|
317
330
|
checkpointNumber: CheckpointNumber,
|
|
318
331
|
logger: Logger,
|
|
332
|
+
isHistoricalSync: boolean,
|
|
319
333
|
): Promise<CheckpointBlobData> {
|
|
320
|
-
const blobBodies = await blobSinkClient.getBlobSidecar(blockHash, blobHashes);
|
|
334
|
+
const blobBodies = await blobSinkClient.getBlobSidecar(blockHash, blobHashes, undefined, { isHistoricalSync });
|
|
321
335
|
if (blobBodies.length === 0) {
|
|
322
336
|
throw new NoBlobBodiesFoundError(checkpointNumber);
|
|
323
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
|
);
|