@aztec/archiver 0.0.1-commit.8c0b8ff → 0.0.1-commit.8cb2d04d8
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 +6 -5
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +11 -5
- 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 +28 -2
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +36 -2
- package/dest/factory.d.ts +2 -2
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +1 -3
- 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 +8 -5
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +26 -21
- package/dest/modules/data_source_base.d.ts +6 -4
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +10 -4
- package/dest/modules/data_store_updater.d.ts +5 -7
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +14 -56
- package/dest/modules/instrumentation.d.ts +15 -2
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +27 -6
- package/dest/modules/l1_synchronizer.d.ts +3 -2
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +143 -131
- 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 +38 -4
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +187 -63
- 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 +1 -65
- package/dest/store/kv_archiver_store.d.ts +28 -13
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +33 -14
- 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 +47 -10
- 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 +20 -8
- package/dest/test/fake_l1_state.d.ts +2 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +36 -6
- 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 +7 -2
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +28 -3
- package/dest/test/noop_l1_archiver.d.ts +1 -1
- package/dest/test/noop_l1_archiver.d.ts.map +1 -1
- package/dest/test/noop_l1_archiver.js +0 -1
- package/package.json +13 -13
- package/src/archiver.ts +19 -10
- package/src/config.ts +9 -2
- package/src/errors.ts +60 -2
- package/src/factory.ts +1 -3
- package/src/l1/calldata_retriever.ts +2 -1
- package/src/l1/data_retrieval.ts +25 -21
- package/src/modules/data_source_base.ts +23 -4
- package/src/modules/data_store_updater.ts +17 -83
- package/src/modules/instrumentation.ts +39 -7
- package/src/modules/l1_synchronizer.ts +166 -168
- package/src/modules/validation.ts +2 -2
- package/src/store/block_store.ts +243 -73
- package/src/store/contract_class_store.ts +1 -103
- package/src/store/kv_archiver_store.ts +52 -24
- package/src/store/l2_tips_cache.ts +58 -13
- package/src/store/log_store.ts +62 -20
- package/src/store/message_store.ts +26 -9
- package/src/structs/inbox_message.ts +1 -1
- package/src/test/fake_l1_state.ts +53 -9
- package/src/test/mock_l1_to_l2_message_source.ts +1 -0
- package/src/test/mock_l2_block_source.ts +37 -2
- package/src/test/noop_l1_archiver.ts +0 -1
|
@@ -16,7 +16,13 @@ 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
27
|
import {
|
|
22
28
|
EmptyL1RollupConstants,
|
|
@@ -39,6 +45,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
39
45
|
private provenBlockNumber: number = 0;
|
|
40
46
|
private finalizedBlockNumber: number = 0;
|
|
41
47
|
private checkpointedBlockNumber: number = 0;
|
|
48
|
+
private proposedCheckpointBlockNumber: number = 0;
|
|
42
49
|
|
|
43
50
|
private log = createLogger('archiver:mock_l2_block_source');
|
|
44
51
|
|
|
@@ -89,6 +96,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
89
96
|
});
|
|
90
97
|
// Keep tip numbers consistent with remaining blocks.
|
|
91
98
|
this.checkpointedBlockNumber = Math.min(this.checkpointedBlockNumber, maxBlockNum);
|
|
99
|
+
this.proposedCheckpointBlockNumber = Math.min(this.proposedCheckpointBlockNumber, maxBlockNum);
|
|
92
100
|
this.provenBlockNumber = Math.min(this.provenBlockNumber, maxBlockNum);
|
|
93
101
|
this.finalizedBlockNumber = Math.min(this.finalizedBlockNumber, maxBlockNum);
|
|
94
102
|
this.log.verbose(`Removed ${numBlocks} blocks from the mock L2 block source`);
|
|
@@ -105,9 +113,17 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
105
113
|
this.finalizedBlockNumber = finalizedBlockNumber;
|
|
106
114
|
}
|
|
107
115
|
|
|
116
|
+
public setProposedCheckpointBlockNumber(blockNumber: number) {
|
|
117
|
+
this.proposedCheckpointBlockNumber = blockNumber;
|
|
118
|
+
}
|
|
119
|
+
|
|
108
120
|
public setCheckpointedBlockNumber(checkpointedBlockNumber: number) {
|
|
109
121
|
const prevCheckpointed = this.checkpointedBlockNumber;
|
|
110
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
|
+
}
|
|
111
127
|
// Auto-create single-block checkpoints for newly checkpointed blocks that don't have one yet.
|
|
112
128
|
// This handles blocks added via addProposedBlocks that are now being marked as checkpointed.
|
|
113
129
|
const newCheckpoints: Checkpoint[] = [];
|
|
@@ -171,6 +187,10 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
171
187
|
return Promise.resolve(BlockNumber(this.finalizedBlockNumber));
|
|
172
188
|
}
|
|
173
189
|
|
|
190
|
+
public getProposedCheckpointL2BlockNumber() {
|
|
191
|
+
return Promise.resolve(BlockNumber(this.proposedCheckpointBlockNumber));
|
|
192
|
+
}
|
|
193
|
+
|
|
174
194
|
public getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined> {
|
|
175
195
|
if (number > this.checkpointedBlockNumber) {
|
|
176
196
|
return Promise.resolve(undefined);
|
|
@@ -408,17 +428,19 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
408
428
|
}
|
|
409
429
|
|
|
410
430
|
async getL2Tips(): Promise<L2Tips> {
|
|
411
|
-
const [latest, proven, finalized, checkpointed] = [
|
|
431
|
+
const [latest, proven, finalized, checkpointed, proposedCheckpoint] = [
|
|
412
432
|
await this.getBlockNumber(),
|
|
413
433
|
await this.getProvenBlockNumber(),
|
|
414
434
|
this.finalizedBlockNumber,
|
|
415
435
|
this.checkpointedBlockNumber,
|
|
436
|
+
await this.getProposedCheckpointL2BlockNumber(),
|
|
416
437
|
] as const;
|
|
417
438
|
|
|
418
439
|
const latestBlock = this.l2Blocks[latest - 1];
|
|
419
440
|
const provenBlock = this.l2Blocks[proven - 1];
|
|
420
441
|
const finalizedBlock = this.l2Blocks[finalized - 1];
|
|
421
442
|
const checkpointedBlock = this.l2Blocks[checkpointed - 1];
|
|
443
|
+
const proposedCheckpointBlock = this.l2Blocks[proposedCheckpoint - 1];
|
|
422
444
|
|
|
423
445
|
const latestBlockId = {
|
|
424
446
|
number: BlockNumber(latest),
|
|
@@ -436,6 +458,10 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
436
458
|
number: BlockNumber(checkpointed),
|
|
437
459
|
hash: (await checkpointedBlock?.hash())?.toString(),
|
|
438
460
|
};
|
|
461
|
+
const proposedCheckpointBlockId = {
|
|
462
|
+
number: BlockNumber(proposedCheckpoint),
|
|
463
|
+
hash: (await proposedCheckpointBlock?.hash())?.toString(),
|
|
464
|
+
};
|
|
439
465
|
|
|
440
466
|
const makeTipId = (blockId: typeof latestBlockId) => ({
|
|
441
467
|
block: blockId,
|
|
@@ -450,6 +476,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
450
476
|
checkpointed: makeTipId(checkpointedBlockId),
|
|
451
477
|
proven: makeTipId(provenBlockId),
|
|
452
478
|
finalized: makeTipId(finalizedBlockId),
|
|
479
|
+
proposedCheckpoint: makeTipId(proposedCheckpointBlockId),
|
|
453
480
|
};
|
|
454
481
|
}
|
|
455
482
|
|
|
@@ -531,6 +558,14 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
531
558
|
return Promise.resolve({ valid: true });
|
|
532
559
|
}
|
|
533
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
|
+
|
|
534
569
|
/** Returns checkpoints whose slot falls within the given epoch. */
|
|
535
570
|
private getCheckpointsInEpoch(epochNumber: EpochNumber): Checkpoint[] {
|
|
536
571
|
const epochDuration = DefaultL1ContractsConfig.aztecEpochDuration;
|