@aztec/archiver 0.0.1-commit.d1f2d6c → 0.0.1-commit.d431d1c
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 +0 -9
- 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 +2 -3
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +3 -5
- 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 +17 -16
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +52 -21
- 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 +11 -21
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +5 -34
- package/dest/store/kv_archiver_store.d.ts +13 -16
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +2 -5
- package/dest/store/log_store.d.ts +4 -4
- package/dest/store/log_store.d.ts.map +1 -1
- 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 +38 -37
- package/dest/test/mock_structs.js +4 -4
- package/package.json +13 -13
- package/src/archiver.ts +18 -15
- package/src/factory.ts +2 -4
- package/src/l1/bin/retrieve-calldata.ts +2 -7
- package/src/l1/data_retrieval.ts +3 -3
- package/src/modules/data_source_base.ts +76 -25
- package/src/modules/data_store_updater.ts +7 -7
- package/src/modules/instrumentation.ts +2 -2
- package/src/store/block_store.ts +21 -59
- package/src/store/kv_archiver_store.ts +12 -19
- package/src/store/log_store.ts +8 -8
- package/src/test/fake_l1_state.ts +2 -2
- package/src/test/mock_l2_block_source.ts +59 -49
- package/src/test/mock_structs.ts +4 -4
package/src/store/log_store.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
6
6
|
import { BufferReader, numToUInt32BE } from '@aztec/foundation/serialize';
|
|
7
7
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
8
8
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
-
import {
|
|
9
|
+
import { L2BlockHash, L2BlockNew } from '@aztec/stdlib/block';
|
|
10
10
|
import { MAX_LOGS_PER_TAG } from '@aztec/stdlib/interfaces/api-limit';
|
|
11
11
|
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
12
12
|
import {
|
|
@@ -59,7 +59,7 @@ export class LogStore {
|
|
|
59
59
|
* @param block - The L2 block to extract logs from.
|
|
60
60
|
* @returns An object containing the private and public tagged logs for the block.
|
|
61
61
|
*/
|
|
62
|
-
#extractTaggedLogsFromBlock(block:
|
|
62
|
+
#extractTaggedLogsFromBlock(block: L2BlockNew) {
|
|
63
63
|
// SiloedTag (as string) -> array of log buffers.
|
|
64
64
|
const privateTaggedLogs = new Map<string, Buffer[]>();
|
|
65
65
|
// "{contractAddress}_{tag}" (as string) -> array of log buffers.
|
|
@@ -120,7 +120,7 @@ export class LogStore {
|
|
|
120
120
|
* @returns A map from tag (as string) to an array of serialized private logs belonging to that tag, and a map from
|
|
121
121
|
* "{contractAddress}_{tag}" (as string) to an array of serialized public logs belonging to that key.
|
|
122
122
|
*/
|
|
123
|
-
#extractTaggedLogs(blocks:
|
|
123
|
+
#extractTaggedLogs(blocks: L2BlockNew[]): {
|
|
124
124
|
privateTaggedLogs: Map<string, Buffer[]>;
|
|
125
125
|
publicTaggedLogs: Map<string, Buffer[]>;
|
|
126
126
|
} {
|
|
@@ -146,7 +146,7 @@ export class LogStore {
|
|
|
146
146
|
return { privateTaggedLogs, publicTaggedLogs };
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
async #addPrivateLogs(blocks:
|
|
149
|
+
async #addPrivateLogs(blocks: L2BlockNew[]): Promise<void> {
|
|
150
150
|
const newBlocks = await filterAsync(
|
|
151
151
|
blocks,
|
|
152
152
|
async block => !(await this.#privateLogKeysByBlock.hasAsync(block.number)),
|
|
@@ -181,7 +181,7 @@ export class LogStore {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
async #addPublicLogs(blocks:
|
|
184
|
+
async #addPublicLogs(blocks: L2BlockNew[]): Promise<void> {
|
|
185
185
|
const newBlocks = await filterAsync(
|
|
186
186
|
blocks,
|
|
187
187
|
async block => !(await this.#publicLogKeysByBlock.hasAsync(block.number)),
|
|
@@ -229,7 +229,7 @@ export class LogStore {
|
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
async #addContractClassLogs(blocks:
|
|
232
|
+
async #addContractClassLogs(blocks: L2BlockNew[]): Promise<void> {
|
|
233
233
|
const newBlocks = await filterAsync(
|
|
234
234
|
blocks,
|
|
235
235
|
async block => !(await this.#contractClassLogsByBlock.hasAsync(block.number)),
|
|
@@ -260,7 +260,7 @@ export class LogStore {
|
|
|
260
260
|
* @param blocks - The blocks for which to add the logs.
|
|
261
261
|
* @returns True if the operation is successful.
|
|
262
262
|
*/
|
|
263
|
-
addLogs(blocks:
|
|
263
|
+
addLogs(blocks: L2BlockNew[]): Promise<boolean> {
|
|
264
264
|
return this.db.transactionAsync(async () => {
|
|
265
265
|
await Promise.all([
|
|
266
266
|
this.#addPrivateLogs(blocks),
|
|
@@ -285,7 +285,7 @@ export class LogStore {
|
|
|
285
285
|
return L2BlockHash.fromField(blockHash);
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
-
deleteLogs(blocks:
|
|
288
|
+
deleteLogs(blocks: L2BlockNew[]): Promise<boolean> {
|
|
289
289
|
return this.db.transactionAsync(async () => {
|
|
290
290
|
await Promise.all(
|
|
291
291
|
blocks.map(async block => {
|
|
@@ -10,7 +10,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
10
10
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
11
11
|
import { createLogger } from '@aztec/foundation/log';
|
|
12
12
|
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
13
|
-
import { CommitteeAttestation, CommitteeAttestationsAndSigners,
|
|
13
|
+
import { CommitteeAttestation, CommitteeAttestationsAndSigners, L2BlockNew } from '@aztec/stdlib/block';
|
|
14
14
|
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
15
15
|
import { getSlotAtTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
16
16
|
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
@@ -51,7 +51,7 @@ type AddCheckpointOptions = {
|
|
|
51
51
|
/** Number of L2 blocks in the checkpoint. Default: 1 */
|
|
52
52
|
numBlocks?: number;
|
|
53
53
|
/** Or the actual blocks for the checkpoint */
|
|
54
|
-
blocks?:
|
|
54
|
+
blocks?: L2BlockNew[];
|
|
55
55
|
/** Number of transactions per block. Default: 4 */
|
|
56
56
|
txsPerBlock?: number;
|
|
57
57
|
/** Max number of effects per tx (for generating large blobs). Default: undefined */
|
|
@@ -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,
|
|
13
12
|
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,
|
|
21
|
+
import { type BlockHeader, 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: L2BlockNew[] = [];
|
|
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 L2BlockNew.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: L2BlockNew[]) {
|
|
47
47
|
this.l2Blocks.push(...blocks);
|
|
48
48
|
this.log.verbose(`Added ${blocks.length} blocks to the mock L2 block source`);
|
|
49
49
|
}
|
|
@@ -96,14 +96,6 @@ 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
|
-
|
|
107
99
|
public getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined> {
|
|
108
100
|
if (number > this.checkpointedBlockNumber) {
|
|
109
101
|
return Promise.resolve(undefined);
|
|
@@ -113,7 +105,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
113
105
|
return Promise.resolve(undefined);
|
|
114
106
|
}
|
|
115
107
|
const checkpointedBlock = new CheckpointedL2Block(
|
|
116
|
-
CheckpointNumber
|
|
108
|
+
CheckpointNumber(number),
|
|
117
109
|
block,
|
|
118
110
|
new L1PublishedData(BigInt(number), BigInt(number), `0x${number.toString(16).padStart(64, '0')}`),
|
|
119
111
|
[],
|
|
@@ -121,7 +113,11 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
121
113
|
return Promise.resolve(checkpointedBlock);
|
|
122
114
|
}
|
|
123
115
|
|
|
124
|
-
public async getCheckpointedBlocks(
|
|
116
|
+
public async getCheckpointedBlocks(
|
|
117
|
+
from: BlockNumber,
|
|
118
|
+
limit: number,
|
|
119
|
+
_proven?: boolean,
|
|
120
|
+
): Promise<CheckpointedL2Block[]> {
|
|
125
121
|
const result: CheckpointedL2Block[] = [];
|
|
126
122
|
for (let i = 0; i < limit; i++) {
|
|
127
123
|
const blockNum = from + i;
|
|
@@ -141,7 +137,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
141
137
|
* @param number - The block number to return (inclusive).
|
|
142
138
|
* @returns The requested L2 block.
|
|
143
139
|
*/
|
|
144
|
-
public getBlock(number: number): Promise<
|
|
140
|
+
public getBlock(number: number): Promise<L2BlockNew | undefined> {
|
|
145
141
|
const block = this.l2Blocks[number - 1];
|
|
146
142
|
return Promise.resolve(block);
|
|
147
143
|
}
|
|
@@ -151,7 +147,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
151
147
|
* @param number - The block number to return.
|
|
152
148
|
* @returns The requested L2 block.
|
|
153
149
|
*/
|
|
154
|
-
public
|
|
150
|
+
public getL2BlockNew(number: BlockNumber): Promise<L2BlockNew | undefined> {
|
|
155
151
|
const block = this.l2Blocks[number - 1];
|
|
156
152
|
return Promise.resolve(block);
|
|
157
153
|
}
|
|
@@ -162,16 +158,20 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
162
158
|
* @param limit - The maximum number of blocks to return.
|
|
163
159
|
* @returns The requested mocked L2 blocks.
|
|
164
160
|
*/
|
|
165
|
-
public getBlocks(from: number, limit: number): Promise<
|
|
166
|
-
return Promise.resolve(
|
|
161
|
+
public getBlocks(from: number, limit: number, proven?: boolean): Promise<L2BlockNew[]> {
|
|
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
|
+
);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
public
|
|
169
|
+
public getPublishedCheckpoints(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 L2BlockNew 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,18 +189,39 @@ 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 L2BlockNew 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
|
|
198
|
+
public getPublishedBlocks(from: number, limit: number, proven?: boolean): Promise<CheckpointedL2Block[]> {
|
|
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> {
|
|
199
220
|
for (const block of this.l2Blocks) {
|
|
200
221
|
const hash = await block.hash();
|
|
201
222
|
if (hash.equals(blockHash)) {
|
|
202
223
|
return CheckpointedL2Block.fromFields({
|
|
203
|
-
checkpointNumber: CheckpointNumber
|
|
224
|
+
checkpointNumber: CheckpointNumber(block.number),
|
|
204
225
|
block,
|
|
205
226
|
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
206
227
|
attestations: [],
|
|
@@ -210,14 +231,14 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
210
231
|
return undefined;
|
|
211
232
|
}
|
|
212
233
|
|
|
213
|
-
public
|
|
234
|
+
public getPublishedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined> {
|
|
214
235
|
const block = this.l2Blocks.find(b => b.archive.root.equals(archive));
|
|
215
236
|
if (!block) {
|
|
216
237
|
return Promise.resolve(undefined);
|
|
217
238
|
}
|
|
218
239
|
return Promise.resolve(
|
|
219
240
|
CheckpointedL2Block.fromFields({
|
|
220
|
-
checkpointNumber: CheckpointNumber
|
|
241
|
+
checkpointNumber: CheckpointNumber(block.number),
|
|
221
242
|
block,
|
|
222
243
|
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
223
244
|
attestations: [],
|
|
@@ -225,7 +246,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
225
246
|
);
|
|
226
247
|
}
|
|
227
248
|
|
|
228
|
-
public async
|
|
249
|
+
public async getL2BlockNewByHash(blockHash: Fr): Promise<L2BlockNew | undefined> {
|
|
229
250
|
for (const block of this.l2Blocks) {
|
|
230
251
|
const hash = await block.hash();
|
|
231
252
|
if (hash.equals(blockHash)) {
|
|
@@ -235,7 +256,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
235
256
|
return undefined;
|
|
236
257
|
}
|
|
237
258
|
|
|
238
|
-
public
|
|
259
|
+
public getL2BlockNewByArchive(archive: Fr): Promise<L2BlockNew | undefined> {
|
|
239
260
|
const block = this.l2Blocks.find(b => b.archive.root.equals(archive));
|
|
240
261
|
return Promise.resolve(block);
|
|
241
262
|
}
|
|
@@ -267,7 +288,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
267
288
|
const slot = b.header.globalVariables.slotNumber;
|
|
268
289
|
return slot >= start && slot <= end;
|
|
269
290
|
});
|
|
270
|
-
// Create checkpoints from blocks - manually construct since
|
|
291
|
+
// Create checkpoints from blocks - manually construct since L2BlockNew doesn't have toCheckpoint()
|
|
271
292
|
return Promise.all(
|
|
272
293
|
blocks.map(async block => {
|
|
273
294
|
const checkpoint = await Checkpoint.random(block.checkpointNumber, { numBlocks: 1 });
|
|
@@ -277,33 +298,24 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
277
298
|
);
|
|
278
299
|
}
|
|
279
300
|
|
|
280
|
-
|
|
301
|
+
getBlocksForEpoch(epochNumber: EpochNumber): Promise<L2BlockNew[]> {
|
|
281
302
|
const epochDuration = DefaultL1ContractsConfig.aztecEpochDuration;
|
|
282
303
|
const [start, end] = getSlotRangeForEpoch(epochNumber, { epochDuration });
|
|
283
304
|
const blocks = this.l2Blocks.filter(b => {
|
|
284
305
|
const slot = b.header.globalVariables.slotNumber;
|
|
285
306
|
return slot >= start && slot <= end;
|
|
286
307
|
});
|
|
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
|
-
);
|
|
308
|
+
return Promise.resolve(blocks);
|
|
297
309
|
}
|
|
298
310
|
|
|
299
|
-
getBlocksForSlot(slotNumber: SlotNumber): Promise<
|
|
311
|
+
getBlocksForSlot(slotNumber: SlotNumber): Promise<L2BlockNew[]> {
|
|
300
312
|
const blocks = this.l2Blocks.filter(b => b.header.globalVariables.slotNumber === slotNumber);
|
|
301
313
|
return Promise.resolve(blocks);
|
|
302
314
|
}
|
|
303
315
|
|
|
304
|
-
async
|
|
305
|
-
const
|
|
306
|
-
return
|
|
316
|
+
async getBlockHeadersForEpoch(epochNumber: EpochNumber): Promise<BlockHeader[]> {
|
|
317
|
+
const blocks = await this.getBlocksForEpoch(epochNumber);
|
|
318
|
+
return blocks.map(b => b.header);
|
|
307
319
|
}
|
|
308
320
|
|
|
309
321
|
/**
|
|
@@ -336,12 +348,10 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
336
348
|
for (const block of this.l2Blocks) {
|
|
337
349
|
for (const txEffect of block.body.txEffects) {
|
|
338
350
|
if (txEffect.txHash.equals(txHash)) {
|
|
339
|
-
// In mock, assume all txs are checkpointed with successful execution
|
|
340
351
|
return new TxReceipt(
|
|
341
352
|
txHash,
|
|
342
|
-
TxStatus.
|
|
343
|
-
|
|
344
|
-
undefined,
|
|
353
|
+
TxStatus.SUCCESS,
|
|
354
|
+
'',
|
|
345
355
|
txEffect.transactionFee.toBigInt(),
|
|
346
356
|
L2BlockHash.fromField(await block.hash()),
|
|
347
357
|
block.number,
|
|
@@ -384,7 +394,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
384
394
|
|
|
385
395
|
const makeTipId = (blockId: typeof latestBlockId) => ({
|
|
386
396
|
block: blockId,
|
|
387
|
-
checkpoint: { number: CheckpointNumber
|
|
397
|
+
checkpoint: { number: CheckpointNumber(blockId.number), hash: blockId.hash },
|
|
388
398
|
});
|
|
389
399
|
|
|
390
400
|
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, L2BlockNew } 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
|
|
271
|
+
const block = await L2BlockNew.random(BlockNumber(blockNumber), {
|
|
272
|
+
checkpointNumber: CheckpointNumber(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
|
|
292
|
+
CheckpointNumber(blockNumber),
|
|
293
293
|
);
|
|
294
294
|
return makePublishedCheckpoint(checkpoint, blockNumber);
|
|
295
295
|
}
|