@aztec/archiver 0.0.1-commit.f295ac2 → 0.0.1-commit.f8ca9b2f3
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 +6 -5
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +34 -22
- package/dest/errors.d.ts +6 -1
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +8 -0
- package/dest/factory.d.ts +5 -2
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +11 -8
- package/dest/l1/bin/retrieve-calldata.js +17 -18
- 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 +3 -3
- package/dest/l1/validate_trace.d.ts +6 -3
- package/dest/l1/validate_trace.d.ts.map +1 -1
- package/dest/l1/validate_trace.js +13 -9
- package/dest/modules/data_source_base.d.ts +19 -20
- 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 +23 -19
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +47 -49
- package/dest/modules/instrumentation.d.ts +3 -3
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +17 -10
- package/dest/modules/l1_synchronizer.d.ts +1 -1
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +9 -10
- package/dest/store/block_store.d.ts +35 -21
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +81 -40
- package/dest/store/contract_class_store.d.ts +1 -1
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +11 -7
- package/dest/store/kv_archiver_store.d.ts +37 -28
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +31 -23
- 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 +77 -43
- package/dest/test/fake_l1_state.d.ts +4 -4
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/index.js +3 -1
- package/dest/test/mock_archiver.js +1 -1
- package/dest/test/mock_l2_block_source.d.ts +20 -20
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +40 -41
- package/dest/test/mock_structs.d.ts +3 -2
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +11 -9
- package/dest/test/noop_l1_archiver.d.ts +23 -0
- package/dest/test/noop_l1_archiver.d.ts.map +1 -0
- package/dest/test/noop_l1_archiver.js +68 -0
- package/package.json +14 -13
- package/src/archiver.ts +46 -28
- package/src/errors.ts +12 -0
- package/src/factory.ts +23 -13
- package/src/l1/bin/retrieve-calldata.ts +16 -17
- package/src/l1/data_retrieval.ts +4 -4
- package/src/l1/validate_trace.ts +24 -6
- package/src/modules/data_source_base.ts +34 -81
- package/src/modules/data_store_updater.ts +59 -55
- package/src/modules/instrumentation.ts +17 -12
- package/src/modules/l1_synchronizer.ts +11 -12
- package/src/store/block_store.ts +107 -60
- package/src/store/contract_class_store.ts +11 -7
- package/src/store/kv_archiver_store.ts +52 -35
- package/src/store/log_store.ts +134 -49
- package/src/test/fake_l1_state.ts +2 -2
- package/src/test/index.ts +3 -0
- package/src/test/mock_archiver.ts +1 -1
- package/src/test/mock_l2_block_source.ts +54 -64
- package/src/test/mock_structs.ts +26 -10
- package/src/test/noop_l1_archiver.ts +109 -0
package/src/store/log_store.ts
CHANGED
|
@@ -6,7 +6,8 @@ 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 { BlockHash, L2Block } from '@aztec/stdlib/block';
|
|
10
|
+
import { MAX_LOGS_PER_TAG } from '@aztec/stdlib/interfaces/api-limit';
|
|
10
11
|
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
11
12
|
import {
|
|
12
13
|
ContractClassLog,
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
Tag,
|
|
20
21
|
TxScopedL2Log,
|
|
21
22
|
} from '@aztec/stdlib/logs';
|
|
23
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
22
24
|
|
|
23
25
|
import type { BlockStore } from './block_store.js';
|
|
24
26
|
|
|
@@ -58,7 +60,7 @@ export class LogStore {
|
|
|
58
60
|
* @param block - The L2 block to extract logs from.
|
|
59
61
|
* @returns An object containing the private and public tagged logs for the block.
|
|
60
62
|
*/
|
|
61
|
-
#extractTaggedLogsFromBlock(block:
|
|
63
|
+
#extractTaggedLogsFromBlock(block: L2Block) {
|
|
62
64
|
// SiloedTag (as string) -> array of log buffers.
|
|
63
65
|
const privateTaggedLogs = new Map<string, Buffer[]>();
|
|
64
66
|
// "{contractAddress}_{tag}" (as string) -> array of log buffers.
|
|
@@ -119,7 +121,7 @@ export class LogStore {
|
|
|
119
121
|
* @returns A map from tag (as string) to an array of serialized private logs belonging to that tag, and a map from
|
|
120
122
|
* "{contractAddress}_{tag}" (as string) to an array of serialized public logs belonging to that key.
|
|
121
123
|
*/
|
|
122
|
-
#extractTaggedLogs(blocks:
|
|
124
|
+
#extractTaggedLogs(blocks: L2Block[]): {
|
|
123
125
|
privateTaggedLogs: Map<string, Buffer[]>;
|
|
124
126
|
publicTaggedLogs: Map<string, Buffer[]>;
|
|
125
127
|
} {
|
|
@@ -145,7 +147,7 @@ export class LogStore {
|
|
|
145
147
|
return { privateTaggedLogs, publicTaggedLogs };
|
|
146
148
|
}
|
|
147
149
|
|
|
148
|
-
async #addPrivateLogs(blocks:
|
|
150
|
+
async #addPrivateLogs(blocks: L2Block[]): Promise<void> {
|
|
149
151
|
const newBlocks = await filterAsync(
|
|
150
152
|
blocks,
|
|
151
153
|
async block => !(await this.#privateLogKeysByBlock.hasAsync(block.number)),
|
|
@@ -180,7 +182,7 @@ export class LogStore {
|
|
|
180
182
|
}
|
|
181
183
|
}
|
|
182
184
|
|
|
183
|
-
async #addPublicLogs(blocks:
|
|
185
|
+
async #addPublicLogs(blocks: L2Block[]): Promise<void> {
|
|
184
186
|
const newBlocks = await filterAsync(
|
|
185
187
|
blocks,
|
|
186
188
|
async block => !(await this.#publicLogKeysByBlock.hasAsync(block.number)),
|
|
@@ -218,6 +220,7 @@ export class LogStore {
|
|
|
218
220
|
.map((txEffect, txIndex) =>
|
|
219
221
|
[
|
|
220
222
|
numToUInt32BE(txIndex),
|
|
223
|
+
txEffect.txHash.toBuffer(),
|
|
221
224
|
numToUInt32BE(txEffect.publicLogs.length),
|
|
222
225
|
txEffect.publicLogs.map(log => log.toBuffer()),
|
|
223
226
|
].flat(),
|
|
@@ -228,7 +231,7 @@ export class LogStore {
|
|
|
228
231
|
}
|
|
229
232
|
}
|
|
230
233
|
|
|
231
|
-
async #addContractClassLogs(blocks:
|
|
234
|
+
async #addContractClassLogs(blocks: L2Block[]): Promise<void> {
|
|
232
235
|
const newBlocks = await filterAsync(
|
|
233
236
|
blocks,
|
|
234
237
|
async block => !(await this.#contractClassLogsByBlock.hasAsync(block.number)),
|
|
@@ -241,6 +244,7 @@ export class LogStore {
|
|
|
241
244
|
.map((txEffect, txIndex) =>
|
|
242
245
|
[
|
|
243
246
|
numToUInt32BE(txIndex),
|
|
247
|
+
txEffect.txHash.toBuffer(),
|
|
244
248
|
numToUInt32BE(txEffect.contractClassLogs.length),
|
|
245
249
|
txEffect.contractClassLogs.map(log => log.toBuffer()),
|
|
246
250
|
].flat(),
|
|
@@ -259,7 +263,7 @@ export class LogStore {
|
|
|
259
263
|
* @param blocks - The blocks for which to add the logs.
|
|
260
264
|
* @returns True if the operation is successful.
|
|
261
265
|
*/
|
|
262
|
-
addLogs(blocks:
|
|
266
|
+
addLogs(blocks: L2Block[]): Promise<boolean> {
|
|
263
267
|
return this.db.transactionAsync(async () => {
|
|
264
268
|
await Promise.all([
|
|
265
269
|
this.#addPrivateLogs(blocks),
|
|
@@ -270,21 +274,21 @@ export class LogStore {
|
|
|
270
274
|
});
|
|
271
275
|
}
|
|
272
276
|
|
|
273
|
-
#packWithBlockHash(blockHash:
|
|
277
|
+
#packWithBlockHash(blockHash: BlockHash, data: Buffer<ArrayBufferLike>[]): Buffer<ArrayBufferLike> {
|
|
274
278
|
return Buffer.concat([blockHash.toBuffer(), ...data]);
|
|
275
279
|
}
|
|
276
280
|
|
|
277
|
-
#unpackBlockHash(reader: BufferReader):
|
|
281
|
+
#unpackBlockHash(reader: BufferReader): BlockHash {
|
|
278
282
|
const blockHash = reader.remainingBytes() > 0 ? reader.readObject(Fr) : undefined;
|
|
279
283
|
|
|
280
284
|
if (!blockHash) {
|
|
281
285
|
throw new Error('Failed to read block hash from log entry buffer');
|
|
282
286
|
}
|
|
283
287
|
|
|
284
|
-
return
|
|
288
|
+
return new BlockHash(blockHash);
|
|
285
289
|
}
|
|
286
290
|
|
|
287
|
-
deleteLogs(blocks:
|
|
291
|
+
deleteLogs(blocks: L2Block[]): Promise<boolean> {
|
|
288
292
|
return this.db.transactionAsync(async () => {
|
|
289
293
|
await Promise.all(
|
|
290
294
|
blocks.map(async block => {
|
|
@@ -314,27 +318,49 @@ export class LogStore {
|
|
|
314
318
|
}
|
|
315
319
|
|
|
316
320
|
/**
|
|
317
|
-
* Gets
|
|
321
|
+
* Gets private logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty
|
|
318
322
|
* array implies no logs match that tag.
|
|
323
|
+
* @param tags - The tags to search for.
|
|
324
|
+
* @param page - The page number (0-indexed) for pagination.
|
|
325
|
+
* @returns An array of log arrays, one per tag. Returns at most MAX_LOGS_PER_TAG logs per tag per page. If
|
|
326
|
+
* MAX_LOGS_PER_TAG logs are returned for a tag, the caller should fetch the next page to check for more logs.
|
|
319
327
|
*/
|
|
320
|
-
async getPrivateLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]> {
|
|
328
|
+
async getPrivateLogsByTags(tags: SiloedTag[], page: number = 0): Promise<TxScopedL2Log[][]> {
|
|
321
329
|
const logs = await Promise.all(tags.map(tag => this.#privateLogsByTag.getAsync(tag.toString())));
|
|
330
|
+
const start = page * MAX_LOGS_PER_TAG;
|
|
331
|
+
const end = start + MAX_LOGS_PER_TAG;
|
|
322
332
|
|
|
323
|
-
return logs.map(
|
|
333
|
+
return logs.map(
|
|
334
|
+
logBuffers => logBuffers?.slice(start, end).map(logBuffer => TxScopedL2Log.fromBuffer(logBuffer)) ?? [],
|
|
335
|
+
);
|
|
324
336
|
}
|
|
325
337
|
|
|
326
338
|
/**
|
|
327
|
-
* Gets
|
|
339
|
+
* Gets public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
|
|
328
340
|
* logs is returned. An empty array implies no logs match that tag.
|
|
341
|
+
* @param contractAddress - The contract address to search logs for.
|
|
342
|
+
* @param tags - The tags to search for.
|
|
343
|
+
* @param page - The page number (0-indexed) for pagination.
|
|
344
|
+
* @returns An array of log arrays, one per tag. Returns at most MAX_LOGS_PER_TAG logs per tag per page. If
|
|
345
|
+
* MAX_LOGS_PER_TAG logs are returned for a tag, the caller should fetch the next page to check for more logs.
|
|
329
346
|
*/
|
|
330
|
-
async getPublicLogsByTagsFromContract(
|
|
347
|
+
async getPublicLogsByTagsFromContract(
|
|
348
|
+
contractAddress: AztecAddress,
|
|
349
|
+
tags: Tag[],
|
|
350
|
+
page: number = 0,
|
|
351
|
+
): Promise<TxScopedL2Log[][]> {
|
|
331
352
|
const logs = await Promise.all(
|
|
332
353
|
tags.map(tag => {
|
|
333
354
|
const key = `${contractAddress.toString()}_${tag.value.toString()}`;
|
|
334
355
|
return this.#publicLogsByContractAndTag.getAsync(key);
|
|
335
356
|
}),
|
|
336
357
|
);
|
|
337
|
-
|
|
358
|
+
const start = page * MAX_LOGS_PER_TAG;
|
|
359
|
+
const end = start + MAX_LOGS_PER_TAG;
|
|
360
|
+
|
|
361
|
+
return logs.map(
|
|
362
|
+
logBuffers => logBuffers?.slice(start, end).map(logBuffer => TxScopedL2Log.fromBuffer(logBuffer)) ?? [],
|
|
363
|
+
);
|
|
338
364
|
}
|
|
339
365
|
|
|
340
366
|
/**
|
|
@@ -363,24 +389,33 @@ export class LogStore {
|
|
|
363
389
|
}
|
|
364
390
|
|
|
365
391
|
const buffer = (await this.#publicLogsByBlock.getAsync(blockNumber)) ?? Buffer.alloc(0);
|
|
366
|
-
const publicLogsInBlock:
|
|
392
|
+
const publicLogsInBlock: { txHash: TxHash; logs: PublicLog[] }[] = [];
|
|
367
393
|
const reader = new BufferReader(buffer);
|
|
368
394
|
|
|
369
395
|
const blockHash = this.#unpackBlockHash(reader);
|
|
370
396
|
|
|
371
397
|
while (reader.remainingBytes() > 0) {
|
|
372
398
|
const indexOfTx = reader.readNumber();
|
|
399
|
+
const txHash = reader.readObject(TxHash);
|
|
373
400
|
const numLogsInTx = reader.readNumber();
|
|
374
|
-
publicLogsInBlock[indexOfTx] = [];
|
|
401
|
+
publicLogsInBlock[indexOfTx] = { txHash, logs: [] };
|
|
375
402
|
for (let i = 0; i < numLogsInTx; i++) {
|
|
376
|
-
publicLogsInBlock[indexOfTx].push(reader.readObject(PublicLog));
|
|
403
|
+
publicLogsInBlock[indexOfTx].logs.push(reader.readObject(PublicLog));
|
|
377
404
|
}
|
|
378
405
|
}
|
|
379
406
|
|
|
380
|
-
const
|
|
407
|
+
const txData = publicLogsInBlock[txIndex];
|
|
381
408
|
|
|
382
409
|
const logs: ExtendedPublicLog[] = [];
|
|
383
|
-
const maxLogsHit = this.#
|
|
410
|
+
const maxLogsHit = this.#accumulatePublicLogs(
|
|
411
|
+
logs,
|
|
412
|
+
blockNumber,
|
|
413
|
+
blockHash,
|
|
414
|
+
txIndex,
|
|
415
|
+
txData.txHash,
|
|
416
|
+
txData.logs,
|
|
417
|
+
filter,
|
|
418
|
+
);
|
|
384
419
|
|
|
385
420
|
return { logs, maxLogsHit };
|
|
386
421
|
}
|
|
@@ -401,22 +436,31 @@ export class LogStore {
|
|
|
401
436
|
|
|
402
437
|
let maxLogsHit = false;
|
|
403
438
|
loopOverBlocks: for await (const [blockNumber, logBuffer] of this.#publicLogsByBlock.entriesAsync({ start, end })) {
|
|
404
|
-
const publicLogsInBlock:
|
|
439
|
+
const publicLogsInBlock: { txHash: TxHash; logs: PublicLog[] }[] = [];
|
|
405
440
|
const reader = new BufferReader(logBuffer);
|
|
406
441
|
|
|
407
442
|
const blockHash = this.#unpackBlockHash(reader);
|
|
408
443
|
|
|
409
444
|
while (reader.remainingBytes() > 0) {
|
|
410
445
|
const indexOfTx = reader.readNumber();
|
|
446
|
+
const txHash = reader.readObject(TxHash);
|
|
411
447
|
const numLogsInTx = reader.readNumber();
|
|
412
|
-
publicLogsInBlock[indexOfTx] = [];
|
|
448
|
+
publicLogsInBlock[indexOfTx] = { txHash, logs: [] };
|
|
413
449
|
for (let i = 0; i < numLogsInTx; i++) {
|
|
414
|
-
publicLogsInBlock[indexOfTx].push(reader.readObject(PublicLog));
|
|
450
|
+
publicLogsInBlock[indexOfTx].logs.push(reader.readObject(PublicLog));
|
|
415
451
|
}
|
|
416
452
|
}
|
|
417
453
|
for (let txIndex = filter.afterLog?.txIndex ?? 0; txIndex < publicLogsInBlock.length; txIndex++) {
|
|
418
|
-
const
|
|
419
|
-
maxLogsHit = this.#
|
|
454
|
+
const txData = publicLogsInBlock[txIndex];
|
|
455
|
+
maxLogsHit = this.#accumulatePublicLogs(
|
|
456
|
+
logs,
|
|
457
|
+
blockNumber,
|
|
458
|
+
blockHash,
|
|
459
|
+
txIndex,
|
|
460
|
+
txData.txHash,
|
|
461
|
+
txData.logs,
|
|
462
|
+
filter,
|
|
463
|
+
);
|
|
420
464
|
if (maxLogsHit) {
|
|
421
465
|
this.#log.debug(`Max logs hit at block ${blockNumber}`);
|
|
422
466
|
break loopOverBlocks;
|
|
@@ -452,24 +496,33 @@ export class LogStore {
|
|
|
452
496
|
return { logs: [], maxLogsHit: false };
|
|
453
497
|
}
|
|
454
498
|
const contractClassLogsBuffer = (await this.#contractClassLogsByBlock.getAsync(blockNumber)) ?? Buffer.alloc(0);
|
|
455
|
-
const contractClassLogsInBlock:
|
|
499
|
+
const contractClassLogsInBlock: { txHash: TxHash; logs: ContractClassLog[] }[] = [];
|
|
456
500
|
|
|
457
501
|
const reader = new BufferReader(contractClassLogsBuffer);
|
|
458
502
|
const blockHash = this.#unpackBlockHash(reader);
|
|
459
503
|
|
|
460
504
|
while (reader.remainingBytes() > 0) {
|
|
461
505
|
const indexOfTx = reader.readNumber();
|
|
506
|
+
const txHash = reader.readObject(TxHash);
|
|
462
507
|
const numLogsInTx = reader.readNumber();
|
|
463
|
-
contractClassLogsInBlock[indexOfTx] = [];
|
|
508
|
+
contractClassLogsInBlock[indexOfTx] = { txHash, logs: [] };
|
|
464
509
|
for (let i = 0; i < numLogsInTx; i++) {
|
|
465
|
-
contractClassLogsInBlock[indexOfTx].push(reader.readObject(ContractClassLog));
|
|
510
|
+
contractClassLogsInBlock[indexOfTx].logs.push(reader.readObject(ContractClassLog));
|
|
466
511
|
}
|
|
467
512
|
}
|
|
468
513
|
|
|
469
|
-
const
|
|
514
|
+
const txData = contractClassLogsInBlock[txIndex];
|
|
470
515
|
|
|
471
516
|
const logs: ExtendedContractClassLog[] = [];
|
|
472
|
-
const maxLogsHit = this.#
|
|
517
|
+
const maxLogsHit = this.#accumulateContractClassLogs(
|
|
518
|
+
logs,
|
|
519
|
+
blockNumber,
|
|
520
|
+
blockHash,
|
|
521
|
+
txIndex,
|
|
522
|
+
txData.txHash,
|
|
523
|
+
txData.logs,
|
|
524
|
+
filter,
|
|
525
|
+
);
|
|
473
526
|
|
|
474
527
|
return { logs, maxLogsHit };
|
|
475
528
|
}
|
|
@@ -493,20 +546,29 @@ export class LogStore {
|
|
|
493
546
|
start,
|
|
494
547
|
end,
|
|
495
548
|
})) {
|
|
496
|
-
const contractClassLogsInBlock:
|
|
549
|
+
const contractClassLogsInBlock: { txHash: TxHash; logs: ContractClassLog[] }[] = [];
|
|
497
550
|
const reader = new BufferReader(logBuffer);
|
|
498
551
|
const blockHash = this.#unpackBlockHash(reader);
|
|
499
552
|
while (reader.remainingBytes() > 0) {
|
|
500
553
|
const indexOfTx = reader.readNumber();
|
|
554
|
+
const txHash = reader.readObject(TxHash);
|
|
501
555
|
const numLogsInTx = reader.readNumber();
|
|
502
|
-
contractClassLogsInBlock[indexOfTx] = [];
|
|
556
|
+
contractClassLogsInBlock[indexOfTx] = { txHash, logs: [] };
|
|
503
557
|
for (let i = 0; i < numLogsInTx; i++) {
|
|
504
|
-
contractClassLogsInBlock[indexOfTx].push(reader.readObject(ContractClassLog));
|
|
558
|
+
contractClassLogsInBlock[indexOfTx].logs.push(reader.readObject(ContractClassLog));
|
|
505
559
|
}
|
|
506
560
|
}
|
|
507
561
|
for (let txIndex = filter.afterLog?.txIndex ?? 0; txIndex < contractClassLogsInBlock.length; txIndex++) {
|
|
508
|
-
const
|
|
509
|
-
maxLogsHit = this.#
|
|
562
|
+
const txData = contractClassLogsInBlock[txIndex];
|
|
563
|
+
maxLogsHit = this.#accumulateContractClassLogs(
|
|
564
|
+
logs,
|
|
565
|
+
blockNumber,
|
|
566
|
+
blockHash,
|
|
567
|
+
txIndex,
|
|
568
|
+
txData.txHash,
|
|
569
|
+
txData.logs,
|
|
570
|
+
filter,
|
|
571
|
+
);
|
|
510
572
|
if (maxLogsHit) {
|
|
511
573
|
this.#log.debug(`Max logs hit at block ${blockNumber}`);
|
|
512
574
|
break loopOverBlocks;
|
|
@@ -517,12 +579,13 @@ export class LogStore {
|
|
|
517
579
|
return { logs, maxLogsHit };
|
|
518
580
|
}
|
|
519
581
|
|
|
520
|
-
#
|
|
521
|
-
results:
|
|
582
|
+
#accumulatePublicLogs(
|
|
583
|
+
results: ExtendedPublicLog[],
|
|
522
584
|
blockNumber: number,
|
|
523
|
-
blockHash:
|
|
585
|
+
blockHash: BlockHash,
|
|
524
586
|
txIndex: number,
|
|
525
|
-
|
|
587
|
+
txHash: TxHash,
|
|
588
|
+
txLogs: PublicLog[],
|
|
526
589
|
filter: LogFilter = {},
|
|
527
590
|
): boolean {
|
|
528
591
|
let maxLogsHit = false;
|
|
@@ -530,15 +593,37 @@ export class LogStore {
|
|
|
530
593
|
for (; logIndex < txLogs.length; logIndex++) {
|
|
531
594
|
const log = txLogs[logIndex];
|
|
532
595
|
if (!filter.contractAddress || log.contractAddress.equals(filter.contractAddress)) {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
throw new Error('Unknown log type');
|
|
596
|
+
results.push(
|
|
597
|
+
new ExtendedPublicLog(new LogId(BlockNumber(blockNumber), blockHash, txHash, txIndex, logIndex), log),
|
|
598
|
+
);
|
|
599
|
+
|
|
600
|
+
if (results.length >= this.#logsMaxPageSize) {
|
|
601
|
+
maxLogsHit = true;
|
|
602
|
+
break;
|
|
541
603
|
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
return maxLogsHit;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
#accumulateContractClassLogs(
|
|
611
|
+
results: ExtendedContractClassLog[],
|
|
612
|
+
blockNumber: number,
|
|
613
|
+
blockHash: BlockHash,
|
|
614
|
+
txIndex: number,
|
|
615
|
+
txHash: TxHash,
|
|
616
|
+
txLogs: ContractClassLog[],
|
|
617
|
+
filter: LogFilter = {},
|
|
618
|
+
): boolean {
|
|
619
|
+
let maxLogsHit = false;
|
|
620
|
+
let logIndex = typeof filter.afterLog?.logIndex === 'number' ? filter.afterLog.logIndex + 1 : 0;
|
|
621
|
+
for (; logIndex < txLogs.length; logIndex++) {
|
|
622
|
+
const log = txLogs[logIndex];
|
|
623
|
+
if (!filter.contractAddress || log.contractAddress.equals(filter.contractAddress)) {
|
|
624
|
+
results.push(
|
|
625
|
+
new ExtendedContractClassLog(new LogId(BlockNumber(blockNumber), blockHash, txHash, txIndex, logIndex), log),
|
|
626
|
+
);
|
|
542
627
|
|
|
543
628
|
if (results.length >= this.#logsMaxPageSize) {
|
|
544
629
|
maxLogsHit = true;
|
|
@@ -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, L2Block } 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?: L2Block[];
|
|
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 */
|
package/src/test/index.ts
CHANGED
|
@@ -2,3 +2,6 @@ export * from './mock_structs.js';
|
|
|
2
2
|
export * from './mock_l2_block_source.js';
|
|
3
3
|
export * from './mock_l1_to_l2_message_source.js';
|
|
4
4
|
export * from './mock_archiver.js';
|
|
5
|
+
// NOTE: noop_l1_archiver.js is intentionally NOT exported here because it imports
|
|
6
|
+
// jest-mock-extended, which depends on @jest/globals and can only run inside Jest.
|
|
7
|
+
// Import it directly: import { NoopL1Archiver } from '@aztec/archiver/test/noop-l1';
|
|
@@ -57,7 +57,7 @@ export class MockPrefilledArchiver extends MockArchiver {
|
|
|
57
57
|
|
|
58
58
|
const fromBlock = this.l2Blocks.length;
|
|
59
59
|
// TODO: Add L2 blocks and checkpoints separately once archiver has the apis for that.
|
|
60
|
-
this.
|
|
60
|
+
this.addProposedBlocks(this.prefilled.slice(fromBlock, fromBlock + numBlocks).flatMap(c => c.blocks));
|
|
61
61
|
return Promise.resolve();
|
|
62
62
|
}
|
|
63
63
|
}
|