@aztec/archiver 0.0.1-commit.934299a21 → 0.0.1-commit.949a33fd8
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 +18 -10
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +146 -57
- package/dest/config.d.ts +5 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +16 -4
- package/dest/errors.d.ts +61 -10
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +88 -14
- package/dest/factory.d.ts +4 -5
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +26 -22
- package/dest/index.d.ts +3 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -1
- package/dest/l1/calldata_retriever.d.ts +2 -1
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +11 -5
- package/dest/l1/data_retrieval.d.ts +24 -12
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +36 -37
- package/dest/l1/validate_historical_logs.d.ts +23 -0
- package/dest/l1/validate_historical_logs.d.ts.map +1 -0
- package/dest/l1/validate_historical_logs.js +108 -0
- package/dest/modules/data_source_base.d.ts +12 -6
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +24 -6
- package/dest/modules/data_store_updater.d.ts +28 -15
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +102 -80
- package/dest/modules/instrumentation.d.ts +7 -2
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +22 -6
- package/dest/modules/l1_synchronizer.d.ts +8 -2
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +292 -144
- package/dest/modules/validation.d.ts +4 -3
- package/dest/modules/validation.d.ts.map +1 -1
- package/dest/modules/validation.js +6 -6
- package/dest/store/block_store.d.ts +83 -17
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +399 -124
- 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 +70 -23
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +88 -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 +20 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +114 -18
- 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 +19 -4
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +57 -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 +9 -3
- package/package.json +13 -13
- package/src/archiver.ts +179 -56
- package/src/config.ts +23 -2
- package/src/errors.ts +133 -22
- package/src/factory.ts +24 -15
- package/src/index.ts +2 -1
- package/src/l1/calldata_retriever.ts +17 -5
- package/src/l1/data_retrieval.ts +52 -53
- package/src/l1/validate_historical_logs.ts +140 -0
- package/src/modules/data_source_base.ts +43 -7
- package/src/modules/data_store_updater.ts +126 -109
- package/src/modules/instrumentation.ts +27 -7
- package/src/modules/l1_synchronizer.ts +371 -178
- package/src/modules/validation.ts +10 -9
- package/src/store/block_store.ts +489 -143
- 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 +133 -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 +142 -29
- package/src/test/mock_l1_to_l2_message_source.ts +1 -0
- package/src/test/mock_l2_block_source.ts +73 -5
- package/src/test/mock_structs.ts +20 -6
- package/src/test/noop_l1_archiver.ts +10 -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);
|
|
@@ -290,6 +321,26 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
290
321
|
};
|
|
291
322
|
}
|
|
292
323
|
|
|
324
|
+
public getCheckpointData(_n: CheckpointNumber): Promise<CheckpointData | undefined> {
|
|
325
|
+
return Promise.resolve(undefined);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
public getCheckpointDataRange(_from: CheckpointNumber, _limit: number): Promise<CheckpointData[]> {
|
|
329
|
+
return Promise.resolve([]);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
public getCheckpointNumberBySlot(_slot: SlotNumber): Promise<CheckpointNumber | undefined> {
|
|
333
|
+
return Promise.resolve(undefined);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
public async getBlockDataWithCheckpointContext(number: BlockNumber) {
|
|
337
|
+
const data = await this.getBlockData(number);
|
|
338
|
+
if (!data) {
|
|
339
|
+
return undefined;
|
|
340
|
+
}
|
|
341
|
+
return { data, checkpoint: undefined, l1: undefined, attestations: [] };
|
|
342
|
+
}
|
|
343
|
+
|
|
293
344
|
public async getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
|
|
294
345
|
const block = this.l2Blocks.find(b => b.archive.root.equals(archive));
|
|
295
346
|
if (!block) {
|
|
@@ -325,6 +376,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
325
376
|
),
|
|
326
377
|
startBlock: checkpoint.blocks[0].number,
|
|
327
378
|
blockCount: checkpoint.blocks.length,
|
|
379
|
+
feeAssetPriceModifier: checkpoint.feeAssetPriceModifier,
|
|
328
380
|
attestations: [],
|
|
329
381
|
l1: this.mockL1DataForCheckpoint(checkpoint),
|
|
330
382
|
}),
|
|
@@ -388,6 +440,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
388
440
|
txEffect.transactionFee.toBigInt(),
|
|
389
441
|
await block.hash(),
|
|
390
442
|
block.number,
|
|
443
|
+
getEpochAtSlot(block.slot, EmptyL1RollupConstants),
|
|
391
444
|
);
|
|
392
445
|
}
|
|
393
446
|
}
|
|
@@ -396,17 +449,19 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
396
449
|
}
|
|
397
450
|
|
|
398
451
|
async getL2Tips(): Promise<L2Tips> {
|
|
399
|
-
const [latest, proven, finalized, checkpointed] = [
|
|
452
|
+
const [latest, proven, finalized, checkpointed, proposedCheckpoint] = [
|
|
400
453
|
await this.getBlockNumber(),
|
|
401
454
|
await this.getProvenBlockNumber(),
|
|
402
455
|
this.finalizedBlockNumber,
|
|
403
456
|
this.checkpointedBlockNumber,
|
|
457
|
+
await this.getProposedCheckpointL2BlockNumber(),
|
|
404
458
|
] as const;
|
|
405
459
|
|
|
406
460
|
const latestBlock = this.l2Blocks[latest - 1];
|
|
407
461
|
const provenBlock = this.l2Blocks[proven - 1];
|
|
408
462
|
const finalizedBlock = this.l2Blocks[finalized - 1];
|
|
409
463
|
const checkpointedBlock = this.l2Blocks[checkpointed - 1];
|
|
464
|
+
const proposedCheckpointBlock = this.l2Blocks[proposedCheckpoint - 1];
|
|
410
465
|
|
|
411
466
|
const latestBlockId = {
|
|
412
467
|
number: BlockNumber(latest),
|
|
@@ -424,6 +479,10 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
424
479
|
number: BlockNumber(checkpointed),
|
|
425
480
|
hash: (await checkpointedBlock?.hash())?.toString(),
|
|
426
481
|
};
|
|
482
|
+
const proposedCheckpointBlockId = {
|
|
483
|
+
number: BlockNumber(proposedCheckpoint),
|
|
484
|
+
hash: (await proposedCheckpointBlock?.hash())?.toString(),
|
|
485
|
+
};
|
|
427
486
|
|
|
428
487
|
const makeTipId = (blockId: typeof latestBlockId) => ({
|
|
429
488
|
block: blockId,
|
|
@@ -438,14 +497,15 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
438
497
|
checkpointed: makeTipId(checkpointedBlockId),
|
|
439
498
|
proven: makeTipId(provenBlockId),
|
|
440
499
|
finalized: makeTipId(finalizedBlockId),
|
|
500
|
+
proposedCheckpoint: makeTipId(proposedCheckpointBlockId),
|
|
441
501
|
};
|
|
442
502
|
}
|
|
443
503
|
|
|
444
|
-
|
|
504
|
+
getSyncedL2EpochNumber(): Promise<EpochNumber> {
|
|
445
505
|
throw new Error('Method not implemented.');
|
|
446
506
|
}
|
|
447
507
|
|
|
448
|
-
|
|
508
|
+
getSyncedL2SlotNumber(): Promise<SlotNumber> {
|
|
449
509
|
throw new Error('Method not implemented.');
|
|
450
510
|
}
|
|
451
511
|
|
|
@@ -519,6 +579,14 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
519
579
|
return Promise.resolve({ valid: true });
|
|
520
580
|
}
|
|
521
581
|
|
|
582
|
+
getLastCheckpoint(): Promise<ProposedCheckpointData | undefined> {
|
|
583
|
+
return Promise.resolve(undefined);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
getLastProposedCheckpoint(): Promise<ProposedCheckpointData | undefined> {
|
|
587
|
+
return Promise.resolve(undefined);
|
|
588
|
+
}
|
|
589
|
+
|
|
522
590
|
/** Returns checkpoints whose slot falls within the given epoch. */
|
|
523
591
|
private getCheckpointsInEpoch(epochNumber: EpochNumber): Checkpoint[] {
|
|
524
592
|
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();
|
|
@@ -69,9 +70,10 @@ export class NoopL1Archiver extends Archiver {
|
|
|
69
70
|
debugClient,
|
|
70
71
|
rollup,
|
|
71
72
|
{
|
|
73
|
+
rollupAddress: EthAddress.ZERO,
|
|
72
74
|
registryAddress: EthAddress.ZERO,
|
|
75
|
+
inboxAddress: EthAddress.ZERO,
|
|
73
76
|
governanceProposerAddress: EthAddress.ZERO,
|
|
74
|
-
slashFactoryAddress: EthAddress.ZERO,
|
|
75
77
|
slashingProposerAddress: EthAddress.ZERO,
|
|
76
78
|
},
|
|
77
79
|
dataStore,
|
|
@@ -81,6 +83,7 @@ export class NoopL1Archiver extends Archiver {
|
|
|
81
83
|
skipValidateCheckpointAttestations: true,
|
|
82
84
|
maxAllowedEthClientDriftSeconds: 300,
|
|
83
85
|
ethereumAllowNoDebugHosts: true, // Skip trace validation
|
|
86
|
+
skipHistoricalLogsCheck: true, // Skip historical logs validation
|
|
84
87
|
},
|
|
85
88
|
blobClient,
|
|
86
89
|
instrumentation,
|
|
@@ -96,6 +99,11 @@ export class NoopL1Archiver extends Archiver {
|
|
|
96
99
|
this.runningPromise.start();
|
|
97
100
|
return Promise.resolve();
|
|
98
101
|
}
|
|
102
|
+
|
|
103
|
+
/** Always reports as fully synced since there is no real L1 to sync from. */
|
|
104
|
+
public override getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
105
|
+
return Promise.resolve(SlotNumber(Number.MAX_SAFE_INTEGER));
|
|
106
|
+
}
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
/** Creates an archiver with mocked L1 connectivity for testing. */
|