@aztec/archiver 0.0.1-commit.6d63667d → 0.0.1-commit.86469d5

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.
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { CheckpointNumber } from '@aztec/foundation/branded-types';
2
+ import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
3
3
  import { EthAddress } from '@aztec/foundation/eth-address';
4
4
  import { createLogger } from '@aztec/foundation/log';
5
- import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
6
- import { createPublicClient, getAbiItem, http, toEventSelector } from 'viem';
5
+ import { createPublicClient, http } from 'viem';
7
6
  import { mainnet } from 'viem/chains';
8
7
  import { CalldataRetriever } from '../calldata_retriever.js';
9
8
  const logger = createLogger('archiver:calldata-test');
@@ -87,33 +86,35 @@ async function main() {
87
86
  slashingProposerAddress,
88
87
  slashFactoryAddress
89
88
  });
90
- // Extract checkpoint number from transaction logs
91
- logger.info('Decoding transaction to extract checkpoint number...');
89
+ // Extract L2 block number from transaction logs
90
+ logger.info('Decoding transaction to extract L2 block number...');
92
91
  const receipt = await publicClient.getTransactionReceipt({
93
92
  hash: txHash
94
93
  });
95
- // Look for CheckpointProposed event (emitted when a checkpoint is proposed to the rollup)
96
- // Event signature: CheckpointProposed(uint256 indexed checkpointNumber, bytes32 indexed archive, bytes32[], bytes32, bytes32)
97
- // Hash: keccak256("CheckpointProposed(uint256,bytes32,bytes32[],bytes32,bytes32)")
98
- const checkpointProposedEvent = receipt.logs.find((log)=>{
94
+ const l2BlockProposedEvent = receipt.logs.find((log)=>{
99
95
  try {
100
- return log.address.toLowerCase() === rollupAddress.toString().toLowerCase() && log.topics[0] === toEventSelector(getAbiItem({
101
- abi: RollupAbi,
102
- name: 'CheckpointProposed'
103
- }));
96
+ // Try to match the L2BlockProposed event
97
+ return log.address.toLowerCase() === rollupAddress.toString().toLowerCase() && log.topics[0] === '0x2f1d0e696fa5186494a2f2f89a0e0bcbb15d607f6c5eac4637e07e1e5e7d3c00' // L2BlockProposed event signature
98
+ ;
104
99
  } catch {
105
100
  return false;
106
101
  }
107
102
  });
108
- if (!checkpointProposedEvent || checkpointProposedEvent.topics[1] === undefined) {
109
- throw new Error(`Checkpoint proposed event not found`);
103
+ let l2BlockNumber;
104
+ if (l2BlockProposedEvent && l2BlockProposedEvent.topics[1]) {
105
+ // L2 block number is typically the first indexed parameter
106
+ l2BlockNumber = Number(BigInt(l2BlockProposedEvent.topics[1]));
107
+ logger.info(`L2 Block Number (from event): ${l2BlockNumber}`);
108
+ } else {
109
+ // Fallback: try to extract from transaction data or use a default
110
+ logger.warn('Could not extract L2 block number from event, using block number as fallback');
111
+ l2BlockNumber = Number(tx.blockNumber);
110
112
  }
111
- const checkpointNumber = CheckpointNumber.fromBigInt(BigInt(checkpointProposedEvent.topics[1]));
112
113
  logger.info('');
113
- logger.info('Retrieving checkpoint from rollup transaction...');
114
+ logger.info('Retrieving block header from rollup transaction...');
114
115
  logger.info('');
115
116
  // For this script, we don't have blob hashes or expected hashes, so pass empty arrays/objects
116
- const result = await retriever.getCheckpointFromRollupTx(txHash, [], checkpointNumber, {});
117
+ const result = await retriever.getCheckpointFromRollupTx(txHash, [], CheckpointNumber.fromBlockNumber(BlockNumber(l2BlockNumber)), {});
117
118
  logger.info(' Successfully retrieved block header!');
118
119
  logger.info('');
119
120
  logger.info('Block Header Details:');
@@ -51,4 +51,4 @@ export declare class LogStore {
51
51
  */
52
52
  getContractClassLogs(filter: LogFilter): Promise<GetContractClassLogsResponse>;
53
53
  }
54
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nX3N0b3JlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc3RvcmUvbG9nX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQU1BLE9BQU8sS0FBSyxFQUFFLGl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7
  import { BlockHash } from '@aztec/stdlib/block';
8
8
  import { MAX_LOGS_PER_TAG } from '@aztec/stdlib/interfaces/api-limit';
9
9
  import { ContractClassLog, ExtendedContractClassLog, ExtendedPublicLog, LogId, PublicLog, TxScopedL2Log } from '@aztec/stdlib/logs';
10
- import { TxHash } from '@aztec/stdlib/tx';
11
10
  /**
12
11
  * A store for logs
13
12
  */ export class LogStore {
@@ -143,7 +142,6 @@ import { TxHash } from '@aztec/stdlib/tx';
143
142
  await this.#publicLogKeysByBlock.set(block.number, publicTagsInBlock);
144
143
  const publicLogsInBlock = block.body.txEffects.map((txEffect, txIndex)=>[
145
144
  numToUInt32BE(txIndex),
146
- txEffect.txHash.toBuffer(),
147
145
  numToUInt32BE(txEffect.publicLogs.length),
148
146
  txEffect.publicLogs.map((log)=>log.toBuffer())
149
147
  ].flat()).flat();
@@ -156,7 +154,6 @@ import { TxHash } from '@aztec/stdlib/tx';
156
154
  const blockHash = await block.hash();
157
155
  const contractClassLogsInBlock = block.body.txEffects.map((txEffect, txIndex)=>[
158
156
  numToUInt32BE(txIndex),
159
- txEffect.txHash.toBuffer(),
160
157
  numToUInt32BE(txEffect.contractClassLogs.length),
161
158
  txEffect.contractClassLogs.map((log)=>log.toBuffer())
162
159
  ].flat()).flat();
@@ -264,24 +261,22 @@ import { TxHash } from '@aztec/stdlib/tx';
264
261
  };
265
262
  }
266
263
  const buffer = await this.#publicLogsByBlock.getAsync(blockNumber) ?? Buffer.alloc(0);
267
- const publicLogsInBlock = [];
264
+ const publicLogsInBlock = [
265
+ []
266
+ ];
268
267
  const reader = new BufferReader(buffer);
269
268
  const blockHash = this.#unpackBlockHash(reader);
270
269
  while(reader.remainingBytes() > 0){
271
270
  const indexOfTx = reader.readNumber();
272
- const txHash = reader.readObject(TxHash);
273
271
  const numLogsInTx = reader.readNumber();
274
- publicLogsInBlock[indexOfTx] = {
275
- txHash,
276
- logs: []
277
- };
272
+ publicLogsInBlock[indexOfTx] = [];
278
273
  for(let i = 0; i < numLogsInTx; i++){
279
- publicLogsInBlock[indexOfTx].logs.push(reader.readObject(PublicLog));
274
+ publicLogsInBlock[indexOfTx].push(reader.readObject(PublicLog));
280
275
  }
281
276
  }
282
- const txData = publicLogsInBlock[txIndex];
277
+ const txLogs = publicLogsInBlock[txIndex];
283
278
  const logs = [];
284
- const maxLogsHit = this.#accumulatePublicLogs(logs, blockNumber, blockHash, txIndex, txData.txHash, txData.logs, filter);
279
+ const maxLogsHit = this.#accumulateLogs(logs, blockNumber, blockHash, txIndex, txLogs, filter);
285
280
  return {
286
281
  logs,
287
282
  maxLogsHit
@@ -302,24 +297,22 @@ import { TxHash } from '@aztec/stdlib/tx';
302
297
  start,
303
298
  end
304
299
  })){
305
- const publicLogsInBlock = [];
300
+ const publicLogsInBlock = [
301
+ []
302
+ ];
306
303
  const reader = new BufferReader(logBuffer);
307
304
  const blockHash = this.#unpackBlockHash(reader);
308
305
  while(reader.remainingBytes() > 0){
309
306
  const indexOfTx = reader.readNumber();
310
- const txHash = reader.readObject(TxHash);
311
307
  const numLogsInTx = reader.readNumber();
312
- publicLogsInBlock[indexOfTx] = {
313
- txHash,
314
- logs: []
315
- };
308
+ publicLogsInBlock[indexOfTx] = [];
316
309
  for(let i = 0; i < numLogsInTx; i++){
317
- publicLogsInBlock[indexOfTx].logs.push(reader.readObject(PublicLog));
310
+ publicLogsInBlock[indexOfTx].push(reader.readObject(PublicLog));
318
311
  }
319
312
  }
320
313
  for(let txIndex = filter.afterLog?.txIndex ?? 0; txIndex < publicLogsInBlock.length; txIndex++){
321
- const txData = publicLogsInBlock[txIndex];
322
- maxLogsHit = this.#accumulatePublicLogs(logs, blockNumber, blockHash, txIndex, txData.txHash, txData.logs, filter);
314
+ const txLogs = publicLogsInBlock[txIndex];
315
+ maxLogsHit = this.#accumulateLogs(logs, blockNumber, blockHash, txIndex, txLogs, filter);
323
316
  if (maxLogsHit) {
324
317
  this.#log.debug(`Max logs hit at block ${blockNumber}`);
325
318
  break loopOverBlocks;
@@ -356,24 +349,22 @@ import { TxHash } from '@aztec/stdlib/tx';
356
349
  };
357
350
  }
358
351
  const contractClassLogsBuffer = await this.#contractClassLogsByBlock.getAsync(blockNumber) ?? Buffer.alloc(0);
359
- const contractClassLogsInBlock = [];
352
+ const contractClassLogsInBlock = [
353
+ []
354
+ ];
360
355
  const reader = new BufferReader(contractClassLogsBuffer);
361
356
  const blockHash = this.#unpackBlockHash(reader);
362
357
  while(reader.remainingBytes() > 0){
363
358
  const indexOfTx = reader.readNumber();
364
- const txHash = reader.readObject(TxHash);
365
359
  const numLogsInTx = reader.readNumber();
366
- contractClassLogsInBlock[indexOfTx] = {
367
- txHash,
368
- logs: []
369
- };
360
+ contractClassLogsInBlock[indexOfTx] = [];
370
361
  for(let i = 0; i < numLogsInTx; i++){
371
- contractClassLogsInBlock[indexOfTx].logs.push(reader.readObject(ContractClassLog));
362
+ contractClassLogsInBlock[indexOfTx].push(reader.readObject(ContractClassLog));
372
363
  }
373
364
  }
374
- const txData = contractClassLogsInBlock[txIndex];
365
+ const txLogs = contractClassLogsInBlock[txIndex];
375
366
  const logs = [];
376
- const maxLogsHit = this.#accumulateContractClassLogs(logs, blockNumber, blockHash, txIndex, txData.txHash, txData.logs, filter);
367
+ const maxLogsHit = this.#accumulateLogs(logs, blockNumber, blockHash, txIndex, txLogs, filter);
377
368
  return {
378
369
  logs,
379
370
  maxLogsHit
@@ -394,24 +385,22 @@ import { TxHash } from '@aztec/stdlib/tx';
394
385
  start,
395
386
  end
396
387
  })){
397
- const contractClassLogsInBlock = [];
388
+ const contractClassLogsInBlock = [
389
+ []
390
+ ];
398
391
  const reader = new BufferReader(logBuffer);
399
392
  const blockHash = this.#unpackBlockHash(reader);
400
393
  while(reader.remainingBytes() > 0){
401
394
  const indexOfTx = reader.readNumber();
402
- const txHash = reader.readObject(TxHash);
403
395
  const numLogsInTx = reader.readNumber();
404
- contractClassLogsInBlock[indexOfTx] = {
405
- txHash,
406
- logs: []
407
- };
396
+ contractClassLogsInBlock[indexOfTx] = [];
408
397
  for(let i = 0; i < numLogsInTx; i++){
409
- contractClassLogsInBlock[indexOfTx].logs.push(reader.readObject(ContractClassLog));
398
+ contractClassLogsInBlock[indexOfTx].push(reader.readObject(ContractClassLog));
410
399
  }
411
400
  }
412
401
  for(let txIndex = filter.afterLog?.txIndex ?? 0; txIndex < contractClassLogsInBlock.length; txIndex++){
413
- const txData = contractClassLogsInBlock[txIndex];
414
- maxLogsHit = this.#accumulateContractClassLogs(logs, blockNumber, blockHash, txIndex, txData.txHash, txData.logs, filter);
402
+ const txLogs = contractClassLogsInBlock[txIndex];
403
+ maxLogsHit = this.#accumulateLogs(logs, blockNumber, blockHash, txIndex, txLogs, filter);
415
404
  if (maxLogsHit) {
416
405
  this.#log.debug(`Max logs hit at block ${blockNumber}`);
417
406
  break loopOverBlocks;
@@ -423,28 +412,19 @@ import { TxHash } from '@aztec/stdlib/tx';
423
412
  maxLogsHit
424
413
  };
425
414
  }
426
- #accumulatePublicLogs(results, blockNumber, blockHash, txIndex, txHash, txLogs, filter = {}) {
415
+ #accumulateLogs(results, blockNumber, blockHash, txIndex, txLogs, filter = {}) {
427
416
  let maxLogsHit = false;
428
417
  let logIndex = typeof filter.afterLog?.logIndex === 'number' ? filter.afterLog.logIndex + 1 : 0;
429
418
  for(; logIndex < txLogs.length; logIndex++){
430
419
  const log = txLogs[logIndex];
431
420
  if (!filter.contractAddress || log.contractAddress.equals(filter.contractAddress)) {
432
- results.push(new ExtendedPublicLog(new LogId(BlockNumber(blockNumber), blockHash, txHash, txIndex, logIndex), log));
433
- if (results.length >= this.#logsMaxPageSize) {
434
- maxLogsHit = true;
435
- break;
421
+ if (log instanceof ContractClassLog) {
422
+ results.push(new ExtendedContractClassLog(new LogId(BlockNumber(blockNumber), blockHash, txIndex, logIndex), log));
423
+ } else if (log instanceof PublicLog) {
424
+ results.push(new ExtendedPublicLog(new LogId(BlockNumber(blockNumber), blockHash, txIndex, logIndex), log));
425
+ } else {
426
+ throw new Error('Unknown log type');
436
427
  }
437
- }
438
- }
439
- return maxLogsHit;
440
- }
441
- #accumulateContractClassLogs(results, blockNumber, blockHash, txIndex, txHash, txLogs, filter = {}) {
442
- let maxLogsHit = false;
443
- let logIndex = typeof filter.afterLog?.logIndex === 'number' ? filter.afterLog.logIndex + 1 : 0;
444
- for(; logIndex < txLogs.length; logIndex++){
445
- const log = txLogs[logIndex];
446
- if (!filter.contractAddress || log.contractAddress.equals(filter.contractAddress)) {
447
- results.push(new ExtendedContractClassLog(new LogId(BlockNumber(blockNumber), blockHash, txHash, txIndex, logIndex), log));
448
428
  if (results.length >= this.#logsMaxPageSize) {
449
429
  maxLogsHit = true;
450
430
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/archiver",
3
- "version": "0.0.1-commit.6d63667d",
3
+ "version": "0.0.1-commit.86469d5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -65,18 +65,18 @@
65
65
  ]
66
66
  },
67
67
  "dependencies": {
68
- "@aztec/blob-client": "0.0.1-commit.6d63667d",
69
- "@aztec/blob-lib": "0.0.1-commit.6d63667d",
70
- "@aztec/constants": "0.0.1-commit.6d63667d",
71
- "@aztec/epoch-cache": "0.0.1-commit.6d63667d",
72
- "@aztec/ethereum": "0.0.1-commit.6d63667d",
73
- "@aztec/foundation": "0.0.1-commit.6d63667d",
74
- "@aztec/kv-store": "0.0.1-commit.6d63667d",
75
- "@aztec/l1-artifacts": "0.0.1-commit.6d63667d",
76
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.6d63667d",
77
- "@aztec/protocol-contracts": "0.0.1-commit.6d63667d",
78
- "@aztec/stdlib": "0.0.1-commit.6d63667d",
79
- "@aztec/telemetry-client": "0.0.1-commit.6d63667d",
68
+ "@aztec/blob-client": "0.0.1-commit.86469d5",
69
+ "@aztec/blob-lib": "0.0.1-commit.86469d5",
70
+ "@aztec/constants": "0.0.1-commit.86469d5",
71
+ "@aztec/epoch-cache": "0.0.1-commit.86469d5",
72
+ "@aztec/ethereum": "0.0.1-commit.86469d5",
73
+ "@aztec/foundation": "0.0.1-commit.86469d5",
74
+ "@aztec/kv-store": "0.0.1-commit.86469d5",
75
+ "@aztec/l1-artifacts": "0.0.1-commit.86469d5",
76
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.86469d5",
77
+ "@aztec/protocol-contracts": "0.0.1-commit.86469d5",
78
+ "@aztec/stdlib": "0.0.1-commit.86469d5",
79
+ "@aztec/telemetry-client": "0.0.1-commit.86469d5",
80
80
  "lodash.groupby": "^4.6.0",
81
81
  "lodash.omit": "^4.5.0",
82
82
  "tslib": "^2.5.0",
@@ -1,11 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
3
- import { CheckpointNumber } from '@aztec/foundation/branded-types';
3
+ import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
4
4
  import { EthAddress } from '@aztec/foundation/eth-address';
5
5
  import { createLogger } from '@aztec/foundation/log';
6
- import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
7
6
 
8
- import { type Hex, createPublicClient, getAbiItem, http, toEventSelector } from 'viem';
7
+ import { type Hex, createPublicClient, http } from 'viem';
9
8
  import { mainnet } from 'viem/chains';
10
9
 
11
10
  import { CalldataRetriever } from '../calldata_retriever.js';
@@ -112,36 +111,43 @@ async function main() {
112
111
  },
113
112
  );
114
113
 
115
- // Extract checkpoint number from transaction logs
116
- logger.info('Decoding transaction to extract checkpoint number...');
114
+ // Extract L2 block number from transaction logs
115
+ logger.info('Decoding transaction to extract L2 block number...');
117
116
  const receipt = await publicClient.getTransactionReceipt({ hash: txHash });
118
-
119
- // Look for CheckpointProposed event (emitted when a checkpoint is proposed to the rollup)
120
- // Event signature: CheckpointProposed(uint256 indexed checkpointNumber, bytes32 indexed archive, bytes32[], bytes32, bytes32)
121
- // Hash: keccak256("CheckpointProposed(uint256,bytes32,bytes32[],bytes32,bytes32)")
122
- const checkpointProposedEvent = receipt.logs.find(log => {
117
+ const l2BlockProposedEvent = receipt.logs.find(log => {
123
118
  try {
119
+ // Try to match the L2BlockProposed event
124
120
  return (
125
121
  log.address.toLowerCase() === rollupAddress.toString().toLowerCase() &&
126
- log.topics[0] === toEventSelector(getAbiItem({ abi: RollupAbi, name: 'CheckpointProposed' }))
122
+ log.topics[0] === '0x2f1d0e696fa5186494a2f2f89a0e0bcbb15d607f6c5eac4637e07e1e5e7d3c00' // L2BlockProposed event signature
127
123
  );
128
124
  } catch {
129
125
  return false;
130
126
  }
131
127
  });
132
128
 
133
- if (!checkpointProposedEvent || checkpointProposedEvent.topics[1] === undefined) {
134
- throw new Error(`Checkpoint proposed event not found`);
129
+ let l2BlockNumber: number;
130
+ if (l2BlockProposedEvent && l2BlockProposedEvent.topics[1]) {
131
+ // L2 block number is typically the first indexed parameter
132
+ l2BlockNumber = Number(BigInt(l2BlockProposedEvent.topics[1]));
133
+ logger.info(`L2 Block Number (from event): ${l2BlockNumber}`);
134
+ } else {
135
+ // Fallback: try to extract from transaction data or use a default
136
+ logger.warn('Could not extract L2 block number from event, using block number as fallback');
137
+ l2BlockNumber = Number(tx.blockNumber);
135
138
  }
136
139
 
137
- const checkpointNumber = CheckpointNumber.fromBigInt(BigInt(checkpointProposedEvent.topics[1]));
138
-
139
140
  logger.info('');
140
- logger.info('Retrieving checkpoint from rollup transaction...');
141
+ logger.info('Retrieving block header from rollup transaction...');
141
142
  logger.info('');
142
143
 
143
144
  // For this script, we don't have blob hashes or expected hashes, so pass empty arrays/objects
144
- const result = await retriever.getCheckpointFromRollupTx(txHash, [], checkpointNumber, {});
145
+ const result = await retriever.getCheckpointFromRollupTx(
146
+ txHash,
147
+ [],
148
+ CheckpointNumber.fromBlockNumber(BlockNumber(l2BlockNumber)),
149
+ {},
150
+ );
145
151
 
146
152
  logger.info(' Successfully retrieved block header!');
147
153
  logger.info('');
@@ -20,7 +20,6 @@ import {
20
20
  Tag,
21
21
  TxScopedL2Log,
22
22
  } from '@aztec/stdlib/logs';
23
- import { TxHash } from '@aztec/stdlib/tx';
24
23
 
25
24
  import type { BlockStore } from './block_store.js';
26
25
 
@@ -220,7 +219,6 @@ export class LogStore {
220
219
  .map((txEffect, txIndex) =>
221
220
  [
222
221
  numToUInt32BE(txIndex),
223
- txEffect.txHash.toBuffer(),
224
222
  numToUInt32BE(txEffect.publicLogs.length),
225
223
  txEffect.publicLogs.map(log => log.toBuffer()),
226
224
  ].flat(),
@@ -244,7 +242,6 @@ export class LogStore {
244
242
  .map((txEffect, txIndex) =>
245
243
  [
246
244
  numToUInt32BE(txIndex),
247
- txEffect.txHash.toBuffer(),
248
245
  numToUInt32BE(txEffect.contractClassLogs.length),
249
246
  txEffect.contractClassLogs.map(log => log.toBuffer()),
250
247
  ].flat(),
@@ -389,33 +386,24 @@ export class LogStore {
389
386
  }
390
387
 
391
388
  const buffer = (await this.#publicLogsByBlock.getAsync(blockNumber)) ?? Buffer.alloc(0);
392
- const publicLogsInBlock: { txHash: TxHash; logs: PublicLog[] }[] = [];
389
+ const publicLogsInBlock: [PublicLog[]] = [[]];
393
390
  const reader = new BufferReader(buffer);
394
391
 
395
392
  const blockHash = this.#unpackBlockHash(reader);
396
393
 
397
394
  while (reader.remainingBytes() > 0) {
398
395
  const indexOfTx = reader.readNumber();
399
- const txHash = reader.readObject(TxHash);
400
396
  const numLogsInTx = reader.readNumber();
401
- publicLogsInBlock[indexOfTx] = { txHash, logs: [] };
397
+ publicLogsInBlock[indexOfTx] = [];
402
398
  for (let i = 0; i < numLogsInTx; i++) {
403
- publicLogsInBlock[indexOfTx].logs.push(reader.readObject(PublicLog));
399
+ publicLogsInBlock[indexOfTx].push(reader.readObject(PublicLog));
404
400
  }
405
401
  }
406
402
 
407
- const txData = publicLogsInBlock[txIndex];
403
+ const txLogs = publicLogsInBlock[txIndex];
408
404
 
409
405
  const logs: ExtendedPublicLog[] = [];
410
- const maxLogsHit = this.#accumulatePublicLogs(
411
- logs,
412
- blockNumber,
413
- blockHash,
414
- txIndex,
415
- txData.txHash,
416
- txData.logs,
417
- filter,
418
- );
406
+ const maxLogsHit = this.#accumulateLogs(logs, blockNumber, blockHash, txIndex, txLogs, filter);
419
407
 
420
408
  return { logs, maxLogsHit };
421
409
  }
@@ -436,31 +424,22 @@ export class LogStore {
436
424
 
437
425
  let maxLogsHit = false;
438
426
  loopOverBlocks: for await (const [blockNumber, logBuffer] of this.#publicLogsByBlock.entriesAsync({ start, end })) {
439
- const publicLogsInBlock: { txHash: TxHash; logs: PublicLog[] }[] = [];
427
+ const publicLogsInBlock: [PublicLog[]] = [[]];
440
428
  const reader = new BufferReader(logBuffer);
441
429
 
442
430
  const blockHash = this.#unpackBlockHash(reader);
443
431
 
444
432
  while (reader.remainingBytes() > 0) {
445
433
  const indexOfTx = reader.readNumber();
446
- const txHash = reader.readObject(TxHash);
447
434
  const numLogsInTx = reader.readNumber();
448
- publicLogsInBlock[indexOfTx] = { txHash, logs: [] };
435
+ publicLogsInBlock[indexOfTx] = [];
449
436
  for (let i = 0; i < numLogsInTx; i++) {
450
- publicLogsInBlock[indexOfTx].logs.push(reader.readObject(PublicLog));
437
+ publicLogsInBlock[indexOfTx].push(reader.readObject(PublicLog));
451
438
  }
452
439
  }
453
440
  for (let txIndex = filter.afterLog?.txIndex ?? 0; txIndex < publicLogsInBlock.length; txIndex++) {
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
- );
441
+ const txLogs = publicLogsInBlock[txIndex];
442
+ maxLogsHit = this.#accumulateLogs(logs, blockNumber, blockHash, txIndex, txLogs, filter);
464
443
  if (maxLogsHit) {
465
444
  this.#log.debug(`Max logs hit at block ${blockNumber}`);
466
445
  break loopOverBlocks;
@@ -496,33 +475,24 @@ export class LogStore {
496
475
  return { logs: [], maxLogsHit: false };
497
476
  }
498
477
  const contractClassLogsBuffer = (await this.#contractClassLogsByBlock.getAsync(blockNumber)) ?? Buffer.alloc(0);
499
- const contractClassLogsInBlock: { txHash: TxHash; logs: ContractClassLog[] }[] = [];
478
+ const contractClassLogsInBlock: [ContractClassLog[]] = [[]];
500
479
 
501
480
  const reader = new BufferReader(contractClassLogsBuffer);
502
481
  const blockHash = this.#unpackBlockHash(reader);
503
482
 
504
483
  while (reader.remainingBytes() > 0) {
505
484
  const indexOfTx = reader.readNumber();
506
- const txHash = reader.readObject(TxHash);
507
485
  const numLogsInTx = reader.readNumber();
508
- contractClassLogsInBlock[indexOfTx] = { txHash, logs: [] };
486
+ contractClassLogsInBlock[indexOfTx] = [];
509
487
  for (let i = 0; i < numLogsInTx; i++) {
510
- contractClassLogsInBlock[indexOfTx].logs.push(reader.readObject(ContractClassLog));
488
+ contractClassLogsInBlock[indexOfTx].push(reader.readObject(ContractClassLog));
511
489
  }
512
490
  }
513
491
 
514
- const txData = contractClassLogsInBlock[txIndex];
492
+ const txLogs = contractClassLogsInBlock[txIndex];
515
493
 
516
494
  const logs: ExtendedContractClassLog[] = [];
517
- const maxLogsHit = this.#accumulateContractClassLogs(
518
- logs,
519
- blockNumber,
520
- blockHash,
521
- txIndex,
522
- txData.txHash,
523
- txData.logs,
524
- filter,
525
- );
495
+ const maxLogsHit = this.#accumulateLogs(logs, blockNumber, blockHash, txIndex, txLogs, filter);
526
496
 
527
497
  return { logs, maxLogsHit };
528
498
  }
@@ -546,29 +516,20 @@ export class LogStore {
546
516
  start,
547
517
  end,
548
518
  })) {
549
- const contractClassLogsInBlock: { txHash: TxHash; logs: ContractClassLog[] }[] = [];
519
+ const contractClassLogsInBlock: [ContractClassLog[]] = [[]];
550
520
  const reader = new BufferReader(logBuffer);
551
521
  const blockHash = this.#unpackBlockHash(reader);
552
522
  while (reader.remainingBytes() > 0) {
553
523
  const indexOfTx = reader.readNumber();
554
- const txHash = reader.readObject(TxHash);
555
524
  const numLogsInTx = reader.readNumber();
556
- contractClassLogsInBlock[indexOfTx] = { txHash, logs: [] };
525
+ contractClassLogsInBlock[indexOfTx] = [];
557
526
  for (let i = 0; i < numLogsInTx; i++) {
558
- contractClassLogsInBlock[indexOfTx].logs.push(reader.readObject(ContractClassLog));
527
+ contractClassLogsInBlock[indexOfTx].push(reader.readObject(ContractClassLog));
559
528
  }
560
529
  }
561
530
  for (let txIndex = filter.afterLog?.txIndex ?? 0; txIndex < contractClassLogsInBlock.length; txIndex++) {
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
- );
531
+ const txLogs = contractClassLogsInBlock[txIndex];
532
+ maxLogsHit = this.#accumulateLogs(logs, blockNumber, blockHash, txIndex, txLogs, filter);
572
533
  if (maxLogsHit) {
573
534
  this.#log.debug(`Max logs hit at block ${blockNumber}`);
574
535
  break loopOverBlocks;
@@ -579,13 +540,12 @@ export class LogStore {
579
540
  return { logs, maxLogsHit };
580
541
  }
581
542
 
582
- #accumulatePublicLogs(
583
- results: ExtendedPublicLog[],
543
+ #accumulateLogs(
544
+ results: (ExtendedContractClassLog | ExtendedPublicLog)[],
584
545
  blockNumber: number,
585
546
  blockHash: BlockHash,
586
547
  txIndex: number,
587
- txHash: TxHash,
588
- txLogs: PublicLog[],
548
+ txLogs: (ContractClassLog | PublicLog)[],
589
549
  filter: LogFilter = {},
590
550
  ): boolean {
591
551
  let maxLogsHit = false;
@@ -593,37 +553,15 @@ export class LogStore {
593
553
  for (; logIndex < txLogs.length; logIndex++) {
594
554
  const log = txLogs[logIndex];
595
555
  if (!filter.contractAddress || log.contractAddress.equals(filter.contractAddress)) {
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;
556
+ if (log instanceof ContractClassLog) {
557
+ results.push(
558
+ new ExtendedContractClassLog(new LogId(BlockNumber(blockNumber), blockHash, txIndex, logIndex), log),
559
+ );
560
+ } else if (log instanceof PublicLog) {
561
+ results.push(new ExtendedPublicLog(new LogId(BlockNumber(blockNumber), blockHash, txIndex, logIndex), log));
562
+ } else {
563
+ throw new Error('Unknown log type');
603
564
  }
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
- );
627
565
 
628
566
  if (results.length >= this.#logsMaxPageSize) {
629
567
  maxLogsHit = true;