ponder 0.8.16 → 0.8.18

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.
@@ -4587,7 +4587,7 @@ var createDatabase = ({
4587
4587
  await qb.internal.updateTable("_ponder_meta").where("key", "=", "app").set({
4588
4588
  value: sql2`jsonb_set(value, '{heartbeat_at}', ${heartbeat})`
4589
4589
  }).execute();
4590
- common.logger.debug({
4590
+ common.logger.trace({
4591
4591
  service: "database",
4592
4592
  msg: `Updated heartbeat timestamp to ${heartbeat} (build_id=${buildId})`
4593
4593
  });
@@ -7686,9 +7686,9 @@ var buildEvents = ({
7686
7686
  }),
7687
7687
  log: convertLog(log),
7688
7688
  block: convertBlock(block),
7689
- transaction: convertTransaction(
7689
+ transaction: transactionCache.has(log.transactionHash) ? convertTransaction(
7690
7690
  transactionCache.get(log.transactionHash)
7691
- ),
7691
+ ) : void 0,
7692
7692
  transactionReceipt: shouldGetTransactionReceipt(filter) ? convertTransactionReceipt(
7693
7693
  transactionReceiptCache.get(log.transactionHash)
7694
7694
  ) : void 0,
@@ -7888,7 +7888,7 @@ var decodeEvents = (common, sources, rawEvents) => {
7888
7888
  name: `${source.name}:${safeName}`,
7889
7889
  event: {
7890
7890
  name: safeName,
7891
- args,
7891
+ args: removeNullCharacters(args),
7892
7892
  log: event.log,
7893
7893
  block: event.block,
7894
7894
  transaction: event.transaction,
@@ -7933,8 +7933,8 @@ var decodeEvents = (common, sources, rawEvents) => {
7933
7933
  // NOTE: `safename` includes ()
7934
7934
  name: `${source.name}.${safeName}`,
7935
7935
  event: {
7936
- args,
7937
- result,
7936
+ args: removeNullCharacters(args),
7937
+ result: removeNullCharacters(result),
7938
7938
  trace: event.trace,
7939
7939
  block: event.block,
7940
7940
  transaction: event.transaction,
@@ -8074,6 +8074,22 @@ function decodeTopic({ param, value }) {
8074
8074
  const decodedArg = decodeAbiParameters([param], value) || [];
8075
8075
  return decodedArg[0];
8076
8076
  }
8077
+ function removeNullCharacters(obj) {
8078
+ if (typeof obj === "string") {
8079
+ return obj.replace(/\0/g, "");
8080
+ }
8081
+ if (Array.isArray(obj)) {
8082
+ return obj.map(removeNullCharacters);
8083
+ }
8084
+ if (obj && typeof obj === "object") {
8085
+ const newObj = {};
8086
+ for (const [key, val] of Object.entries(obj)) {
8087
+ newObj[key] = removeNullCharacters(val);
8088
+ }
8089
+ return newObj;
8090
+ }
8091
+ return obj;
8092
+ }
8077
8093
  var convertBlock = (block) => ({
8078
8094
  baseFeePerGas: block.baseFeePerGas ? hexToBigInt4(block.baseFeePerGas) : null,
8079
8095
  difficulty: hexToBigInt4(block.difficulty),
@@ -8325,7 +8341,8 @@ import { getLogsRetryHelper } from "@ponder/utils";
8325
8341
  import {
8326
8342
  hexToBigInt as hexToBigInt5,
8327
8343
  hexToNumber as hexToNumber4,
8328
- toHex
8344
+ toHex,
8345
+ zeroHash
8329
8346
  } from "viem";
8330
8347
  var createHistoricalSync = async (args) => {
8331
8348
  let isKilled = false;
@@ -8575,9 +8592,16 @@ var createHistoricalSync = async (args) => {
8575
8592
  );
8576
8593
  }
8577
8594
  if (block.transactions.find((t) => t.hash === log.transactionHash) === void 0) {
8578
- throw new Error(
8579
- `Detected inconsistent RPC responses. 'log.transactionHash' ${log.transactionHash} not found in 'block.transactions' ${block.hash}`
8580
- );
8595
+ if (log.transactionHash === zeroHash) {
8596
+ args.common.logger.warn({
8597
+ service: "sync",
8598
+ msg: `Detected log with empty transaction hash in block ${block.hash} at log index ${hexToNumber4(log.logIndex)}. This is expected for some networks like ZKsync.`
8599
+ });
8600
+ } else {
8601
+ throw new Error(
8602
+ `Detected inconsistent RPC responses. 'log.transactionHash' ${log.transactionHash} not found in 'block.transactions' ${block.hash}`
8603
+ );
8604
+ }
8581
8605
  }
8582
8606
  }
8583
8607
  const transactionHashes = new Set(logs.map((l) => l.transactionHash));
@@ -8831,7 +8855,7 @@ var createHistoricalSync = async (args) => {
8831
8855
  };
8832
8856
 
8833
8857
  // src/sync-realtime/index.ts
8834
- import { hexToNumber as hexToNumber6 } from "viem";
8858
+ import { hexToNumber as hexToNumber6, zeroHash as zeroHash2 } from "viem";
8835
8859
 
8836
8860
  // src/sync-realtime/bloom.ts
8837
8861
  import { hexToBytes, hexToNumber as hexToNumber5, keccak256 } from "viem";
@@ -9291,6 +9315,18 @@ var createRealtimeSync = (args) => {
9291
9315
  `Detected invalid eth_getLogs response. 'log.blockHash' ${log.blockHash} does not match requested block hash ${block.hash}`
9292
9316
  );
9293
9317
  }
9318
+ if (block.transactions.find((t) => t.hash === log.transactionHash) === void 0) {
9319
+ if (log.transactionHash === zeroHash2) {
9320
+ args.common.logger.warn({
9321
+ service: "sync",
9322
+ msg: `Detected log with empty transaction hash in block ${block.hash} at log index ${hexToNumber6(log.logIndex)}. This is expected for some networks like ZKsync.`
9323
+ });
9324
+ } else {
9325
+ throw new Error(
9326
+ `Detected inconsistent RPC responses. 'log.transactionHash' ${log.transactionHash} not found in 'block.transactions' ${block.hash}`
9327
+ );
9328
+ }
9329
+ }
9294
9330
  }
9295
9331
  }
9296
9332
  if (shouldRequestLogs === false && args.sources.some((s) => s.filter.type === "log")) {