@aztec/archiver 4.0.0-nightly.20260121 → 4.0.0-nightly.20260123
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 +9 -0
- package/dest/archiver.d.ts +3 -3
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +12 -12
- package/dest/factory.d.ts +3 -2
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +5 -3
- package/dest/l1/bin/retrieve-calldata.js +2 -2
- package/dest/l1/data_retrieval.d.ts +1 -1
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +2 -2
- package/dest/modules/data_source_base.d.ts +18 -19
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +25 -56
- package/dest/modules/data_store_updater.d.ts +5 -5
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/instrumentation.d.ts +3 -3
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/store/block_store.d.ts +21 -11
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +34 -5
- package/dest/store/kv_archiver_store.d.ts +25 -17
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +16 -8
- package/dest/store/log_store.d.ts +17 -8
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +20 -6
- package/dest/test/fake_l1_state.d.ts +4 -4
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.d.ts +18 -18
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +37 -38
- package/dest/test/mock_structs.js +4 -4
- package/package.json +13 -13
- package/src/archiver.ts +15 -18
- package/src/factory.ts +4 -2
- package/src/l1/bin/retrieve-calldata.ts +7 -2
- package/src/l1/data_retrieval.ts +3 -3
- package/src/modules/data_source_base.ts +33 -80
- package/src/modules/data_store_updater.ts +7 -7
- package/src/modules/instrumentation.ts +2 -2
- package/src/store/block_store.ts +59 -21
- package/src/store/kv_archiver_store.ts +35 -19
- package/src/store/log_store.ts +37 -14
- package/src/test/fake_l1_state.ts +2 -2
- package/src/test/mock_l2_block_source.ts +49 -59
- package/src/test/mock_structs.ts +4 -4
|
@@ -9,8 +9,8 @@ import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
|
9
9
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
10
|
import {
|
|
11
11
|
CheckpointedL2Block,
|
|
12
|
+
L2Block,
|
|
12
13
|
L2BlockHash,
|
|
13
|
-
L2BlockNew,
|
|
14
14
|
type L2BlockSource,
|
|
15
15
|
type L2Tips,
|
|
16
16
|
type ValidateCheckpointResult,
|
|
@@ -18,14 +18,14 @@ import {
|
|
|
18
18
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } 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
|
-
import { type BlockHeader, TxHash, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
21
|
+
import { type BlockHeader, TxExecutionResult, TxHash, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
22
22
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* A mocked implementation of L2BlockSource to be used in tests.
|
|
26
26
|
*/
|
|
27
27
|
export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
28
|
-
protected l2Blocks:
|
|
28
|
+
protected l2Blocks: L2Block[] = [];
|
|
29
29
|
|
|
30
30
|
private provenBlockNumber: number = 0;
|
|
31
31
|
private finalizedBlockNumber: number = 0;
|
|
@@ -36,14 +36,14 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
36
36
|
public async createBlocks(numBlocks: number) {
|
|
37
37
|
for (let i = 0; i < numBlocks; i++) {
|
|
38
38
|
const blockNum = this.l2Blocks.length + 1;
|
|
39
|
-
const block = await
|
|
39
|
+
const block = await L2Block.random(BlockNumber(blockNum), { slotNumber: SlotNumber(blockNum) });
|
|
40
40
|
this.l2Blocks.push(block);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
this.log.verbose(`Created ${numBlocks} blocks in the mock L2 block source`);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
public addBlocks(blocks:
|
|
46
|
+
public addBlocks(blocks: L2Block[]) {
|
|
47
47
|
this.l2Blocks.push(...blocks);
|
|
48
48
|
this.log.verbose(`Added ${blocks.length} blocks to the mock L2 block source`);
|
|
49
49
|
}
|
|
@@ -96,6 +96,14 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
96
96
|
return Promise.resolve(BlockNumber(this.provenBlockNumber));
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
public getCheckpointedL2BlockNumber() {
|
|
100
|
+
return Promise.resolve(BlockNumber(this.checkpointedBlockNumber));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public getFinalizedL2BlockNumber() {
|
|
104
|
+
return Promise.resolve(BlockNumber(this.finalizedBlockNumber));
|
|
105
|
+
}
|
|
106
|
+
|
|
99
107
|
public getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined> {
|
|
100
108
|
if (number > this.checkpointedBlockNumber) {
|
|
101
109
|
return Promise.resolve(undefined);
|
|
@@ -105,7 +113,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
105
113
|
return Promise.resolve(undefined);
|
|
106
114
|
}
|
|
107
115
|
const checkpointedBlock = new CheckpointedL2Block(
|
|
108
|
-
CheckpointNumber(number),
|
|
116
|
+
CheckpointNumber.fromBlockNumber(number),
|
|
109
117
|
block,
|
|
110
118
|
new L1PublishedData(BigInt(number), BigInt(number), `0x${number.toString(16).padStart(64, '0')}`),
|
|
111
119
|
[],
|
|
@@ -113,11 +121,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
113
121
|
return Promise.resolve(checkpointedBlock);
|
|
114
122
|
}
|
|
115
123
|
|
|
116
|
-
public async getCheckpointedBlocks(
|
|
117
|
-
from: BlockNumber,
|
|
118
|
-
limit: number,
|
|
119
|
-
_proven?: boolean,
|
|
120
|
-
): Promise<CheckpointedL2Block[]> {
|
|
124
|
+
public async getCheckpointedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]> {
|
|
121
125
|
const result: CheckpointedL2Block[] = [];
|
|
122
126
|
for (let i = 0; i < limit; i++) {
|
|
123
127
|
const blockNum = from + i;
|
|
@@ -137,7 +141,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
137
141
|
* @param number - The block number to return (inclusive).
|
|
138
142
|
* @returns The requested L2 block.
|
|
139
143
|
*/
|
|
140
|
-
public getBlock(number: number): Promise<
|
|
144
|
+
public getBlock(number: number): Promise<L2Block | undefined> {
|
|
141
145
|
const block = this.l2Blocks[number - 1];
|
|
142
146
|
return Promise.resolve(block);
|
|
143
147
|
}
|
|
@@ -147,7 +151,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
147
151
|
* @param number - The block number to return.
|
|
148
152
|
* @returns The requested L2 block.
|
|
149
153
|
*/
|
|
150
|
-
public
|
|
154
|
+
public getL2Block(number: BlockNumber): Promise<L2Block | undefined> {
|
|
151
155
|
const block = this.l2Blocks[number - 1];
|
|
152
156
|
return Promise.resolve(block);
|
|
153
157
|
}
|
|
@@ -158,20 +162,16 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
158
162
|
* @param limit - The maximum number of blocks to return.
|
|
159
163
|
* @returns The requested mocked L2 blocks.
|
|
160
164
|
*/
|
|
161
|
-
public getBlocks(from: number, limit: number
|
|
162
|
-
return Promise.resolve(
|
|
163
|
-
this.l2Blocks
|
|
164
|
-
.slice(from - 1, from - 1 + limit)
|
|
165
|
-
.filter(b => !proven || this.provenBlockNumber === undefined || b.number <= this.provenBlockNumber),
|
|
166
|
-
);
|
|
165
|
+
public getBlocks(from: number, limit: number): Promise<L2Block[]> {
|
|
166
|
+
return Promise.resolve(this.l2Blocks.slice(from - 1, from - 1 + limit));
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
public
|
|
169
|
+
public getCheckpoints(from: CheckpointNumber, limit: number) {
|
|
170
170
|
// TODO(mbps): Implement this properly. This only works when we have one block per checkpoint.
|
|
171
171
|
const blocks = this.l2Blocks.slice(from - 1, from - 1 + limit);
|
|
172
172
|
return Promise.all(
|
|
173
173
|
blocks.map(async block => {
|
|
174
|
-
// Create a checkpoint from the block - manually construct since
|
|
174
|
+
// Create a checkpoint from the block - manually construct since L2Block doesn't have toCheckpoint()
|
|
175
175
|
const checkpoint = await Checkpoint.random(block.checkpointNumber, { numBlocks: 1 });
|
|
176
176
|
checkpoint.blocks = [block];
|
|
177
177
|
return new PublishedCheckpoint(
|
|
@@ -189,39 +189,18 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
189
189
|
if (!block) {
|
|
190
190
|
return undefined;
|
|
191
191
|
}
|
|
192
|
-
// Create a checkpoint from the block - manually construct since
|
|
192
|
+
// Create a checkpoint from the block - manually construct since L2Block doesn't have toCheckpoint()
|
|
193
193
|
const checkpoint = await Checkpoint.random(block.checkpointNumber, { numBlocks: 1 });
|
|
194
194
|
checkpoint.blocks = [block];
|
|
195
195
|
return checkpoint;
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
public
|
|
199
|
-
const blocks = this.l2Blocks
|
|
200
|
-
.slice(from - 1, from - 1 + limit)
|
|
201
|
-
.filter(b => !proven || this.provenBlockNumber === undefined || b.number <= this.provenBlockNumber);
|
|
202
|
-
return Promise.resolve(
|
|
203
|
-
blocks.map(block =>
|
|
204
|
-
CheckpointedL2Block.fromFields({
|
|
205
|
-
checkpointNumber: CheckpointNumber(block.number),
|
|
206
|
-
block,
|
|
207
|
-
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
208
|
-
attestations: [],
|
|
209
|
-
}),
|
|
210
|
-
),
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
getL2BlocksNew(from: BlockNumber, limit: number, proven?: boolean): Promise<L2BlockNew[]> {
|
|
215
|
-
// getBlocks already returns L2BlockNew[], so just return directly
|
|
216
|
-
return this.getBlocks(from, limit, proven);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
public async getPublishedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined> {
|
|
198
|
+
public async getCheckpointedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined> {
|
|
220
199
|
for (const block of this.l2Blocks) {
|
|
221
200
|
const hash = await block.hash();
|
|
222
201
|
if (hash.equals(blockHash)) {
|
|
223
202
|
return CheckpointedL2Block.fromFields({
|
|
224
|
-
checkpointNumber: CheckpointNumber(block.number),
|
|
203
|
+
checkpointNumber: CheckpointNumber.fromBlockNumber(block.number),
|
|
225
204
|
block,
|
|
226
205
|
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
227
206
|
attestations: [],
|
|
@@ -231,14 +210,14 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
231
210
|
return undefined;
|
|
232
211
|
}
|
|
233
212
|
|
|
234
|
-
public
|
|
213
|
+
public getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined> {
|
|
235
214
|
const block = this.l2Blocks.find(b => b.archive.root.equals(archive));
|
|
236
215
|
if (!block) {
|
|
237
216
|
return Promise.resolve(undefined);
|
|
238
217
|
}
|
|
239
218
|
return Promise.resolve(
|
|
240
219
|
CheckpointedL2Block.fromFields({
|
|
241
|
-
checkpointNumber: CheckpointNumber(block.number),
|
|
220
|
+
checkpointNumber: CheckpointNumber.fromBlockNumber(block.number),
|
|
242
221
|
block,
|
|
243
222
|
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
244
223
|
attestations: [],
|
|
@@ -246,7 +225,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
246
225
|
);
|
|
247
226
|
}
|
|
248
227
|
|
|
249
|
-
public async
|
|
228
|
+
public async getL2BlockByHash(blockHash: Fr): Promise<L2Block | undefined> {
|
|
250
229
|
for (const block of this.l2Blocks) {
|
|
251
230
|
const hash = await block.hash();
|
|
252
231
|
if (hash.equals(blockHash)) {
|
|
@@ -256,7 +235,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
256
235
|
return undefined;
|
|
257
236
|
}
|
|
258
237
|
|
|
259
|
-
public
|
|
238
|
+
public getL2BlockByArchive(archive: Fr): Promise<L2Block | undefined> {
|
|
260
239
|
const block = this.l2Blocks.find(b => b.archive.root.equals(archive));
|
|
261
240
|
return Promise.resolve(block);
|
|
262
241
|
}
|
|
@@ -288,7 +267,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
288
267
|
const slot = b.header.globalVariables.slotNumber;
|
|
289
268
|
return slot >= start && slot <= end;
|
|
290
269
|
});
|
|
291
|
-
// Create checkpoints from blocks - manually construct since
|
|
270
|
+
// Create checkpoints from blocks - manually construct since L2Block doesn't have toCheckpoint()
|
|
292
271
|
return Promise.all(
|
|
293
272
|
blocks.map(async block => {
|
|
294
273
|
const checkpoint = await Checkpoint.random(block.checkpointNumber, { numBlocks: 1 });
|
|
@@ -298,24 +277,33 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
298
277
|
);
|
|
299
278
|
}
|
|
300
279
|
|
|
301
|
-
|
|
280
|
+
getCheckpointedBlocksForEpoch(epochNumber: EpochNumber): Promise<CheckpointedL2Block[]> {
|
|
302
281
|
const epochDuration = DefaultL1ContractsConfig.aztecEpochDuration;
|
|
303
282
|
const [start, end] = getSlotRangeForEpoch(epochNumber, { epochDuration });
|
|
304
283
|
const blocks = this.l2Blocks.filter(b => {
|
|
305
284
|
const slot = b.header.globalVariables.slotNumber;
|
|
306
285
|
return slot >= start && slot <= end;
|
|
307
286
|
});
|
|
308
|
-
return Promise.resolve(
|
|
287
|
+
return Promise.resolve(
|
|
288
|
+
blocks.map(block =>
|
|
289
|
+
CheckpointedL2Block.fromFields({
|
|
290
|
+
checkpointNumber: CheckpointNumber.fromBlockNumber(block.number),
|
|
291
|
+
block,
|
|
292
|
+
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
293
|
+
attestations: [],
|
|
294
|
+
}),
|
|
295
|
+
),
|
|
296
|
+
);
|
|
309
297
|
}
|
|
310
298
|
|
|
311
|
-
getBlocksForSlot(slotNumber: SlotNumber): Promise<
|
|
299
|
+
getBlocksForSlot(slotNumber: SlotNumber): Promise<L2Block[]> {
|
|
312
300
|
const blocks = this.l2Blocks.filter(b => b.header.globalVariables.slotNumber === slotNumber);
|
|
313
301
|
return Promise.resolve(blocks);
|
|
314
302
|
}
|
|
315
303
|
|
|
316
|
-
async
|
|
317
|
-
const
|
|
318
|
-
return
|
|
304
|
+
async getCheckpointedBlockHeadersForEpoch(epochNumber: EpochNumber): Promise<BlockHeader[]> {
|
|
305
|
+
const checkpointedBlocks = await this.getCheckpointedBlocksForEpoch(epochNumber);
|
|
306
|
+
return checkpointedBlocks.map(b => b.block.header);
|
|
319
307
|
}
|
|
320
308
|
|
|
321
309
|
/**
|
|
@@ -348,10 +336,12 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
348
336
|
for (const block of this.l2Blocks) {
|
|
349
337
|
for (const txEffect of block.body.txEffects) {
|
|
350
338
|
if (txEffect.txHash.equals(txHash)) {
|
|
339
|
+
// In mock, assume all txs are checkpointed with successful execution
|
|
351
340
|
return new TxReceipt(
|
|
352
341
|
txHash,
|
|
353
|
-
TxStatus.
|
|
354
|
-
|
|
342
|
+
TxStatus.CHECKPOINTED,
|
|
343
|
+
TxExecutionResult.SUCCESS,
|
|
344
|
+
undefined,
|
|
355
345
|
txEffect.transactionFee.toBigInt(),
|
|
356
346
|
L2BlockHash.fromField(await block.hash()),
|
|
357
347
|
block.number,
|
|
@@ -394,7 +384,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
394
384
|
|
|
395
385
|
const makeTipId = (blockId: typeof latestBlockId) => ({
|
|
396
386
|
block: blockId,
|
|
397
|
-
checkpoint: { number: CheckpointNumber(blockId.number), hash: blockId.hash },
|
|
387
|
+
checkpoint: { number: CheckpointNumber.fromBlockNumber(blockId.number), hash: blockId.hash },
|
|
398
388
|
});
|
|
399
389
|
|
|
400
390
|
return {
|
package/src/test/mock_structs.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer'
|
|
|
12
12
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
13
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
14
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
|
-
import { CommitteeAttestation,
|
|
15
|
+
import { CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
|
|
16
16
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
17
17
|
import { PrivateLog, PublicLog, SiloedTag, Tag } from '@aztec/stdlib/logs';
|
|
18
18
|
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
@@ -268,8 +268,8 @@ export async function makeCheckpointWithLogs(
|
|
|
268
268
|
): Promise<PublishedCheckpoint> {
|
|
269
269
|
const { previousArchive, numTxsPerBlock = 4, privateLogs, publicLogs } = options;
|
|
270
270
|
|
|
271
|
-
const block = await
|
|
272
|
-
checkpointNumber: CheckpointNumber(blockNumber),
|
|
271
|
+
const block = await L2Block.random(BlockNumber(blockNumber), {
|
|
272
|
+
checkpointNumber: CheckpointNumber.fromBlockNumber(BlockNumber(blockNumber)),
|
|
273
273
|
indexWithinCheckpoint: IndexWithinCheckpoint(0),
|
|
274
274
|
state: makeStateForBlock(blockNumber, numTxsPerBlock),
|
|
275
275
|
...(previousArchive ? { lastArchive: previousArchive } : {}),
|
|
@@ -289,7 +289,7 @@ export async function makeCheckpointWithLogs(
|
|
|
289
289
|
AppendOnlyTreeSnapshot.random(),
|
|
290
290
|
CheckpointHeader.random(),
|
|
291
291
|
[block],
|
|
292
|
-
CheckpointNumber(blockNumber),
|
|
292
|
+
CheckpointNumber.fromBlockNumber(BlockNumber(blockNumber)),
|
|
293
293
|
);
|
|
294
294
|
return makePublishedCheckpoint(checkpoint, blockNumber);
|
|
295
295
|
}
|