@aztec/archiver 0.0.1-commit.db765a8 → 0.0.1-commit.ddcf04837
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 +12 -6
- package/dest/archiver.d.ts +8 -7
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +64 -22
- package/dest/config.d.ts +3 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +3 -2
- package/dest/errors.d.ts +34 -10
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +45 -16
- package/dest/factory.d.ts +4 -5
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +24 -21
- package/dest/l1/calldata_retriever.d.ts +1 -1
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +2 -1
- package/dest/l1/data_retrieval.d.ts +3 -3
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +14 -15
- package/dest/modules/data_source_base.d.ts +8 -6
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +11 -5
- package/dest/modules/data_store_updater.d.ts +18 -12
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +87 -77
- package/dest/modules/instrumentation.d.ts +4 -2
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +17 -6
- package/dest/modules/l1_synchronizer.d.ts +4 -2
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +166 -129
- package/dest/modules/validation.d.ts +1 -1
- package/dest/modules/validation.d.ts.map +1 -1
- package/dest/modules/validation.js +2 -2
- package/dest/store/block_store.d.ts +50 -16
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +290 -121
- package/dest/store/contract_class_store.d.ts +2 -3
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +7 -67
- 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 +45 -22
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +57 -27
- package/dest/store/l2_tips_cache.d.ts +2 -1
- package/dest/store/l2_tips_cache.d.ts.map +1 -1
- package/dest/store/l2_tips_cache.js +27 -7
- package/dest/store/log_store.d.ts +6 -3
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +95 -20
- package/dest/store/message_store.d.ts +5 -1
- package/dest/store/message_store.d.ts.map +1 -1
- package/dest/store/message_store.js +21 -9
- package/dest/test/fake_l1_state.d.ts +16 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +77 -8
- 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 +10 -4
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +35 -7
- package/dest/test/mock_structs.d.ts +4 -1
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +13 -1
- 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 -2
- package/package.json +13 -13
- package/src/archiver.ts +78 -28
- package/src/config.ts +9 -2
- package/src/errors.ts +70 -26
- package/src/factory.ts +23 -15
- package/src/l1/calldata_retriever.ts +2 -1
- package/src/l1/data_retrieval.ts +8 -12
- package/src/modules/data_source_base.ts +26 -7
- package/src/modules/data_store_updater.ts +96 -107
- package/src/modules/instrumentation.ts +19 -7
- package/src/modules/l1_synchronizer.ts +189 -161
- package/src/modules/validation.ts +2 -2
- package/src/store/block_store.ts +371 -141
- package/src/store/contract_class_store.ts +8 -106
- package/src/store/contract_instance_store.ts +8 -5
- package/src/store/kv_archiver_store.ts +81 -39
- package/src/store/l2_tips_cache.ts +58 -13
- package/src/store/log_store.ts +128 -32
- package/src/store/message_store.ts +27 -10
- package/src/structs/inbox_message.ts +1 -1
- package/src/test/fake_l1_state.ts +103 -13
- package/src/test/mock_l1_to_l2_message_source.ts +1 -0
- package/src/test/mock_l2_block_source.ts +52 -5
- package/src/test/mock_structs.ts +20 -6
- package/src/test/noop_l1_archiver.ts +7 -2
|
@@ -16,9 +16,20 @@ import {
|
|
|
16
16
|
type L2Tips,
|
|
17
17
|
type ValidateCheckpointResult,
|
|
18
18
|
} from '@aztec/stdlib/block';
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
Checkpoint,
|
|
21
|
+
type CheckpointData,
|
|
22
|
+
L1PublishedData,
|
|
23
|
+
type ProposedCheckpointData,
|
|
24
|
+
PublishedCheckpoint,
|
|
25
|
+
} from '@aztec/stdlib/checkpoint';
|
|
20
26
|
import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
21
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
EmptyL1RollupConstants,
|
|
29
|
+
type L1RollupConstants,
|
|
30
|
+
getEpochAtSlot,
|
|
31
|
+
getSlotRangeForEpoch,
|
|
32
|
+
} from '@aztec/stdlib/epoch-helpers';
|
|
22
33
|
import { computeCheckpointOutHash } from '@aztec/stdlib/messaging';
|
|
23
34
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
24
35
|
import { type BlockHeader, TxExecutionResult, TxHash, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
@@ -34,6 +45,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
34
45
|
private provenBlockNumber: number = 0;
|
|
35
46
|
private finalizedBlockNumber: number = 0;
|
|
36
47
|
private checkpointedBlockNumber: number = 0;
|
|
48
|
+
private proposedCheckpointBlockNumber: number = 0;
|
|
37
49
|
|
|
38
50
|
private log = createLogger('archiver:mock_l2_block_source');
|
|
39
51
|
|
|
@@ -42,6 +54,12 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
42
54
|
await this.createCheckpoints(numBlocks, 1);
|
|
43
55
|
}
|
|
44
56
|
|
|
57
|
+
public getCheckpointNumber(): Promise<CheckpointNumber> {
|
|
58
|
+
return Promise.resolve(
|
|
59
|
+
this.checkpointList.length === 0 ? CheckpointNumber.ZERO : CheckpointNumber(this.checkpointList.length),
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
45
63
|
/** Creates checkpoints, each containing `blocksPerCheckpoint` blocks. */
|
|
46
64
|
public async createCheckpoints(numCheckpoints: number, blocksPerCheckpoint: number = 1) {
|
|
47
65
|
for (let c = 0; c < numCheckpoints; c++) {
|
|
@@ -78,6 +96,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
78
96
|
});
|
|
79
97
|
// Keep tip numbers consistent with remaining blocks.
|
|
80
98
|
this.checkpointedBlockNumber = Math.min(this.checkpointedBlockNumber, maxBlockNum);
|
|
99
|
+
this.proposedCheckpointBlockNumber = Math.min(this.proposedCheckpointBlockNumber, maxBlockNum);
|
|
81
100
|
this.provenBlockNumber = Math.min(this.provenBlockNumber, maxBlockNum);
|
|
82
101
|
this.finalizedBlockNumber = Math.min(this.finalizedBlockNumber, maxBlockNum);
|
|
83
102
|
this.log.verbose(`Removed ${numBlocks} blocks from the mock L2 block source`);
|
|
@@ -94,9 +113,17 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
94
113
|
this.finalizedBlockNumber = finalizedBlockNumber;
|
|
95
114
|
}
|
|
96
115
|
|
|
116
|
+
public setProposedCheckpointBlockNumber(blockNumber: number) {
|
|
117
|
+
this.proposedCheckpointBlockNumber = blockNumber;
|
|
118
|
+
}
|
|
119
|
+
|
|
97
120
|
public setCheckpointedBlockNumber(checkpointedBlockNumber: number) {
|
|
98
121
|
const prevCheckpointed = this.checkpointedBlockNumber;
|
|
99
122
|
this.checkpointedBlockNumber = checkpointedBlockNumber;
|
|
123
|
+
// Proposed checkpoint is always at least as advanced as checkpointed
|
|
124
|
+
if (this.proposedCheckpointBlockNumber < checkpointedBlockNumber) {
|
|
125
|
+
this.proposedCheckpointBlockNumber = checkpointedBlockNumber;
|
|
126
|
+
}
|
|
100
127
|
// Auto-create single-block checkpoints for newly checkpointed blocks that don't have one yet.
|
|
101
128
|
// This handles blocks added via addProposedBlocks that are now being marked as checkpointed.
|
|
102
129
|
const newCheckpoints: Checkpoint[] = [];
|
|
@@ -160,6 +187,10 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
160
187
|
return Promise.resolve(BlockNumber(this.finalizedBlockNumber));
|
|
161
188
|
}
|
|
162
189
|
|
|
190
|
+
public getProposedCheckpointL2BlockNumber() {
|
|
191
|
+
return Promise.resolve(BlockNumber(this.proposedCheckpointBlockNumber));
|
|
192
|
+
}
|
|
193
|
+
|
|
163
194
|
public getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined> {
|
|
164
195
|
if (number > this.checkpointedBlockNumber) {
|
|
165
196
|
return Promise.resolve(undefined);
|
|
@@ -388,6 +419,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
388
419
|
txEffect.transactionFee.toBigInt(),
|
|
389
420
|
await block.hash(),
|
|
390
421
|
block.number,
|
|
422
|
+
getEpochAtSlot(block.slot, EmptyL1RollupConstants),
|
|
391
423
|
);
|
|
392
424
|
}
|
|
393
425
|
}
|
|
@@ -396,17 +428,19 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
396
428
|
}
|
|
397
429
|
|
|
398
430
|
async getL2Tips(): Promise<L2Tips> {
|
|
399
|
-
const [latest, proven, finalized, checkpointed] = [
|
|
431
|
+
const [latest, proven, finalized, checkpointed, proposedCheckpoint] = [
|
|
400
432
|
await this.getBlockNumber(),
|
|
401
433
|
await this.getProvenBlockNumber(),
|
|
402
434
|
this.finalizedBlockNumber,
|
|
403
435
|
this.checkpointedBlockNumber,
|
|
436
|
+
await this.getProposedCheckpointL2BlockNumber(),
|
|
404
437
|
] as const;
|
|
405
438
|
|
|
406
439
|
const latestBlock = this.l2Blocks[latest - 1];
|
|
407
440
|
const provenBlock = this.l2Blocks[proven - 1];
|
|
408
441
|
const finalizedBlock = this.l2Blocks[finalized - 1];
|
|
409
442
|
const checkpointedBlock = this.l2Blocks[checkpointed - 1];
|
|
443
|
+
const proposedCheckpointBlock = this.l2Blocks[proposedCheckpoint - 1];
|
|
410
444
|
|
|
411
445
|
const latestBlockId = {
|
|
412
446
|
number: BlockNumber(latest),
|
|
@@ -424,6 +458,10 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
424
458
|
number: BlockNumber(checkpointed),
|
|
425
459
|
hash: (await checkpointedBlock?.hash())?.toString(),
|
|
426
460
|
};
|
|
461
|
+
const proposedCheckpointBlockId = {
|
|
462
|
+
number: BlockNumber(proposedCheckpoint),
|
|
463
|
+
hash: (await proposedCheckpointBlock?.hash())?.toString(),
|
|
464
|
+
};
|
|
427
465
|
|
|
428
466
|
const makeTipId = (blockId: typeof latestBlockId) => ({
|
|
429
467
|
block: blockId,
|
|
@@ -438,14 +476,15 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
438
476
|
checkpointed: makeTipId(checkpointedBlockId),
|
|
439
477
|
proven: makeTipId(provenBlockId),
|
|
440
478
|
finalized: makeTipId(finalizedBlockId),
|
|
479
|
+
proposedCheckpoint: makeTipId(proposedCheckpointBlockId),
|
|
441
480
|
};
|
|
442
481
|
}
|
|
443
482
|
|
|
444
|
-
|
|
483
|
+
getSyncedL2EpochNumber(): Promise<EpochNumber> {
|
|
445
484
|
throw new Error('Method not implemented.');
|
|
446
485
|
}
|
|
447
486
|
|
|
448
|
-
|
|
487
|
+
getSyncedL2SlotNumber(): Promise<SlotNumber> {
|
|
449
488
|
throw new Error('Method not implemented.');
|
|
450
489
|
}
|
|
451
490
|
|
|
@@ -519,6 +558,14 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
519
558
|
return Promise.resolve({ valid: true });
|
|
520
559
|
}
|
|
521
560
|
|
|
561
|
+
getProposedCheckpoint(): Promise<ProposedCheckpointData | undefined> {
|
|
562
|
+
return Promise.resolve(undefined);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
getProposedCheckpointOnly(): Promise<ProposedCheckpointData | undefined> {
|
|
566
|
+
return Promise.resolve(undefined);
|
|
567
|
+
}
|
|
568
|
+
|
|
522
569
|
/** Returns checkpoints whose slot falls within the given epoch. */
|
|
523
570
|
private getCheckpointsInEpoch(epochNumber: EpochNumber): Checkpoint[] {
|
|
524
571
|
const epochDuration = DefaultL1ContractsConfig.aztecEpochDuration;
|
package/src/test/mock_structs.ts
CHANGED
|
@@ -127,6 +127,25 @@ export function makeL1PublishedData(l1BlockNumber: number): L1PublishedData {
|
|
|
127
127
|
return new L1PublishedData(BigInt(l1BlockNumber), BigInt(l1BlockNumber * 1000), makeBlockHash(l1BlockNumber));
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
/** Creates a Checkpoint from a list of blocks with a header that matches the blocks' structure. */
|
|
131
|
+
export function makeCheckpoint(blocks: L2Block[], checkpointNumber = CheckpointNumber(1)): Checkpoint {
|
|
132
|
+
const firstBlock = blocks[0];
|
|
133
|
+
const { slotNumber, timestamp, coinbase, feeRecipient, gasFees } = firstBlock.header.globalVariables;
|
|
134
|
+
return new Checkpoint(
|
|
135
|
+
blocks.at(-1)!.archive,
|
|
136
|
+
CheckpointHeader.random({
|
|
137
|
+
lastArchiveRoot: firstBlock.header.lastArchive.root,
|
|
138
|
+
slotNumber,
|
|
139
|
+
timestamp,
|
|
140
|
+
coinbase,
|
|
141
|
+
feeRecipient,
|
|
142
|
+
gasFees,
|
|
143
|
+
}),
|
|
144
|
+
blocks,
|
|
145
|
+
checkpointNumber,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
130
149
|
/** Wraps a Checkpoint with L1 published data and random attestations. */
|
|
131
150
|
export function makePublishedCheckpoint(
|
|
132
151
|
checkpoint: Checkpoint,
|
|
@@ -301,11 +320,6 @@ export async function makeCheckpointWithLogs(
|
|
|
301
320
|
return txEffect;
|
|
302
321
|
});
|
|
303
322
|
|
|
304
|
-
const checkpoint =
|
|
305
|
-
AppendOnlyTreeSnapshot.random(),
|
|
306
|
-
CheckpointHeader.random(),
|
|
307
|
-
[block],
|
|
308
|
-
CheckpointNumber.fromBlockNumber(BlockNumber(blockNumber)),
|
|
309
|
-
);
|
|
323
|
+
const checkpoint = makeCheckpoint([block], CheckpointNumber.fromBlockNumber(BlockNumber(blockNumber)));
|
|
310
324
|
return makePublishedCheckpoint(checkpoint, blockNumber);
|
|
311
325
|
}
|
|
@@ -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();
|
|
@@ -71,7 +72,6 @@ export class NoopL1Archiver extends Archiver {
|
|
|
71
72
|
{
|
|
72
73
|
registryAddress: EthAddress.ZERO,
|
|
73
74
|
governanceProposerAddress: EthAddress.ZERO,
|
|
74
|
-
slashFactoryAddress: EthAddress.ZERO,
|
|
75
75
|
slashingProposerAddress: EthAddress.ZERO,
|
|
76
76
|
},
|
|
77
77
|
dataStore,
|
|
@@ -96,6 +96,11 @@ export class NoopL1Archiver extends Archiver {
|
|
|
96
96
|
this.runningPromise.start();
|
|
97
97
|
return Promise.resolve();
|
|
98
98
|
}
|
|
99
|
+
|
|
100
|
+
/** Always reports as fully synced since there is no real L1 to sync from. */
|
|
101
|
+
public override getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
102
|
+
return Promise.resolve(SlotNumber(Number.MAX_SAFE_INTEGER));
|
|
103
|
+
}
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
/** Creates an archiver with mocked L1 connectivity for testing. */
|