@aztec/archiver 0.0.1-commit.ffe5b04ea → 0.0.1-commit.fff30aa
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.d.ts +3 -5
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +51 -17
- package/dest/errors.d.ts +7 -9
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +9 -14
- package/dest/factory.d.ts +4 -5
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +19 -16
- package/dest/l1/data_retrieval.d.ts +3 -6
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +6 -12
- package/dest/modules/data_source_base.d.ts +3 -3
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +1 -1
- package/dest/modules/data_store_updater.d.ts +10 -5
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +66 -22
- package/dest/modules/instrumentation.d.ts +1 -12
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +0 -10
- package/dest/modules/l1_synchronizer.d.ts +2 -2
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +31 -8
- package/dest/store/block_store.d.ts +13 -13
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +111 -66
- package/dest/store/contract_class_store.d.ts +1 -1
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +6 -2
- package/dest/store/contract_instance_store.d.ts +1 -1
- package/dest/store/contract_instance_store.d.ts.map +1 -1
- package/dest/store/contract_instance_store.js +6 -2
- package/dest/store/kv_archiver_store.d.ts +20 -12
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +24 -13
- package/dest/store/log_store.d.ts +1 -1
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +48 -10
- package/dest/test/fake_l1_state.d.ts +15 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +41 -2
- package/dest/test/mock_l2_block_source.d.ts +3 -3
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +4 -4
- package/dest/test/noop_l1_archiver.d.ts +4 -1
- package/dest/test/noop_l1_archiver.d.ts.map +1 -1
- package/dest/test/noop_l1_archiver.js +5 -1
- package/package.json +13 -13
- package/src/archiver.ts +53 -18
- package/src/errors.ts +10 -24
- package/src/factory.ts +20 -13
- package/src/l1/data_retrieval.ts +9 -17
- package/src/modules/data_source_base.ts +3 -3
- package/src/modules/data_store_updater.ts +75 -25
- package/src/modules/instrumentation.ts +0 -20
- package/src/modules/l1_synchronizer.ts +34 -10
- package/src/store/block_store.ts +134 -74
- package/src/store/contract_class_store.ts +7 -3
- package/src/store/contract_instance_store.ts +8 -5
- package/src/store/kv_archiver_store.ts +31 -17
- package/src/store/log_store.ts +66 -12
- package/src/test/fake_l1_state.ts +50 -4
- package/src/test/mock_l2_block_source.ts +9 -3
- package/src/test/noop_l1_archiver.ts +7 -1
|
@@ -150,8 +150,12 @@ export class FakeL1State {
|
|
|
150
150
|
// Computed from checkpoints based on L1 block visibility
|
|
151
151
|
private pendingCheckpointNumber: CheckpointNumber = CheckpointNumber(0);
|
|
152
152
|
|
|
153
|
+
// The L1 block number reported as "finalized" (defaults to the start block)
|
|
154
|
+
private finalizedL1BlockNumber: bigint;
|
|
155
|
+
|
|
153
156
|
constructor(private readonly config: FakeL1StateConfig) {
|
|
154
157
|
this.l1BlockNumber = config.l1StartBlock;
|
|
158
|
+
this.finalizedL1BlockNumber = config.l1StartBlock;
|
|
155
159
|
this.lastArchive = new AppendOnlyTreeSnapshot(config.genesisArchiveRoot, 1);
|
|
156
160
|
}
|
|
157
161
|
|
|
@@ -283,11 +287,30 @@ export class FakeL1State {
|
|
|
283
287
|
this.updatePendingCheckpointNumber();
|
|
284
288
|
}
|
|
285
289
|
|
|
290
|
+
/** Sets the L1 block number that will be reported as "finalized". */
|
|
291
|
+
setFinalizedL1BlockNumber(blockNumber: bigint): void {
|
|
292
|
+
this.finalizedL1BlockNumber = blockNumber;
|
|
293
|
+
}
|
|
294
|
+
|
|
286
295
|
/** Marks a checkpoint as proven. Updates provenCheckpointNumber. */
|
|
287
296
|
markCheckpointAsProven(checkpointNumber: CheckpointNumber): void {
|
|
288
297
|
this.provenCheckpointNumber = checkpointNumber;
|
|
289
298
|
}
|
|
290
299
|
|
|
300
|
+
/**
|
|
301
|
+
* Simulates what `rollup.getProvenCheckpointNumber({ blockNumber: atL1Block })` would return.
|
|
302
|
+
*/
|
|
303
|
+
getProvenCheckpointNumberAtL1Block(atL1Block: bigint): CheckpointNumber {
|
|
304
|
+
if (this.provenCheckpointNumber === 0) {
|
|
305
|
+
return CheckpointNumber(0);
|
|
306
|
+
}
|
|
307
|
+
const checkpoint = this.checkpoints.find(cp => cp.checkpointNumber === this.provenCheckpointNumber);
|
|
308
|
+
if (checkpoint && checkpoint.l1BlockNumber <= atL1Block) {
|
|
309
|
+
return this.provenCheckpointNumber;
|
|
310
|
+
}
|
|
311
|
+
return CheckpointNumber(0);
|
|
312
|
+
}
|
|
313
|
+
|
|
291
314
|
/** Sets the target committee size for attestation validation. */
|
|
292
315
|
setTargetCommitteeSize(size: number): void {
|
|
293
316
|
this.targetCommitteeSize = size;
|
|
@@ -308,6 +331,21 @@ export class FakeL1State {
|
|
|
308
331
|
this.updatePendingCheckpointNumber();
|
|
309
332
|
}
|
|
310
333
|
|
|
334
|
+
/**
|
|
335
|
+
* Moves a checkpoint to a different L1 block number (simulates L1 reorg that
|
|
336
|
+
* re-includes the same checkpoint transaction in a different block).
|
|
337
|
+
* The checkpoint content stays the same — only the L1 metadata changes.
|
|
338
|
+
* Auto-updates pending status.
|
|
339
|
+
*/
|
|
340
|
+
moveCheckpointToL1Block(checkpointNumber: CheckpointNumber, newL1BlockNumber: bigint): void {
|
|
341
|
+
for (const cpData of this.checkpoints) {
|
|
342
|
+
if (cpData.checkpointNumber === checkpointNumber) {
|
|
343
|
+
cpData.l1BlockNumber = newL1BlockNumber;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
this.updatePendingCheckpointNumber();
|
|
347
|
+
}
|
|
348
|
+
|
|
311
349
|
/**
|
|
312
350
|
* Removes messages after a given total index (simulates L1 reorg).
|
|
313
351
|
* Auto-updates rolling hash.
|
|
@@ -406,6 +444,11 @@ export class FakeL1State {
|
|
|
406
444
|
});
|
|
407
445
|
});
|
|
408
446
|
|
|
447
|
+
mockRollup.getProvenCheckpointNumber.mockImplementation((options?: { blockNumber?: bigint }) => {
|
|
448
|
+
const atBlock = options?.blockNumber ?? this.l1BlockNumber;
|
|
449
|
+
return Promise.resolve(this.getProvenCheckpointNumberAtL1Block(atBlock));
|
|
450
|
+
});
|
|
451
|
+
|
|
409
452
|
mockRollup.canPruneAtTime.mockImplementation(() => Promise.resolve(this.canPruneResult));
|
|
410
453
|
|
|
411
454
|
// Mock the wrapper method for fetching checkpoint events
|
|
@@ -449,10 +492,13 @@ export class FakeL1State {
|
|
|
449
492
|
publicClient.getChainId.mockResolvedValue(1);
|
|
450
493
|
publicClient.getBlockNumber.mockImplementation(() => Promise.resolve(this.l1BlockNumber));
|
|
451
494
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
495
|
+
publicClient.getBlock.mockImplementation((async (args: { blockNumber?: bigint; blockTag?: string } = {}) => {
|
|
496
|
+
let blockNum: bigint;
|
|
497
|
+
if (args.blockTag === 'finalized') {
|
|
498
|
+
blockNum = this.finalizedL1BlockNumber;
|
|
499
|
+
} else {
|
|
500
|
+
blockNum = args.blockNumber ?? (await publicClient.getBlockNumber());
|
|
501
|
+
}
|
|
456
502
|
return {
|
|
457
503
|
number: blockNum,
|
|
458
504
|
timestamp: BigInt(blockNum) * BigInt(this.config.ethereumSlotDuration) + this.config.l1GenesisTime,
|
|
@@ -18,7 +18,12 @@ import {
|
|
|
18
18
|
} from '@aztec/stdlib/block';
|
|
19
19
|
import { Checkpoint, type CheckpointData, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
20
20
|
import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
EmptyL1RollupConstants,
|
|
23
|
+
type L1RollupConstants,
|
|
24
|
+
getEpochAtSlot,
|
|
25
|
+
getSlotRangeForEpoch,
|
|
26
|
+
} from '@aztec/stdlib/epoch-helpers';
|
|
22
27
|
import { computeCheckpointOutHash } from '@aztec/stdlib/messaging';
|
|
23
28
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
24
29
|
import { type BlockHeader, TxExecutionResult, TxHash, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
@@ -394,6 +399,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
394
399
|
txEffect.transactionFee.toBigInt(),
|
|
395
400
|
await block.hash(),
|
|
396
401
|
block.number,
|
|
402
|
+
getEpochAtSlot(block.slot, EmptyL1RollupConstants),
|
|
397
403
|
);
|
|
398
404
|
}
|
|
399
405
|
}
|
|
@@ -447,11 +453,11 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
447
453
|
};
|
|
448
454
|
}
|
|
449
455
|
|
|
450
|
-
|
|
456
|
+
getSyncedL2EpochNumber(): Promise<EpochNumber> {
|
|
451
457
|
throw new Error('Method not implemented.');
|
|
452
458
|
}
|
|
453
459
|
|
|
454
|
-
|
|
460
|
+
getSyncedL2SlotNumber(): Promise<SlotNumber> {
|
|
455
461
|
throw new Error('Method not implemented.');
|
|
456
462
|
}
|
|
457
463
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
2
|
import type { RollupContract } from '@aztec/ethereum/contracts';
|
|
3
3
|
import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
|
|
4
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
5
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
5
6
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
7
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -30,7 +31,7 @@ class NoopL1Synchronizer implements FunctionsOf<ArchiverL1Synchronizer> {
|
|
|
30
31
|
return 0n;
|
|
31
32
|
}
|
|
32
33
|
getL1Timestamp(): bigint | undefined {
|
|
33
|
-
return
|
|
34
|
+
return undefined;
|
|
34
35
|
}
|
|
35
36
|
testEthereumNodeSynced(): Promise<void> {
|
|
36
37
|
return Promise.resolve();
|
|
@@ -96,6 +97,11 @@ export class NoopL1Archiver extends Archiver {
|
|
|
96
97
|
this.runningPromise.start();
|
|
97
98
|
return Promise.resolve();
|
|
98
99
|
}
|
|
100
|
+
|
|
101
|
+
/** Always reports as fully synced since there is no real L1 to sync from. */
|
|
102
|
+
public override getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
103
|
+
return Promise.resolve(SlotNumber(Number.MAX_SAFE_INTEGER));
|
|
104
|
+
}
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
/** Creates an archiver with mocked L1 connectivity for testing. */
|