From 60704d3974387cb625c8fe2e45026fc2235622b9 Mon Sep 17 00:00:00 2001 From: kyscott18 <43524469+kyscott18@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:21:31 -0500 Subject: [PATCH 1/2] fix: zkSync system logs (#1411) * fix: zkSync system logs * chore: changeset and logs --------- Co-authored-by: typedarray <90073088+0xOlias@users.noreply.github.com> --- .changeset/chilly-pigs-shake.md | 5 +++++ packages/core/src/sync-historical/index.ts | 14 +++++++++++--- packages/core/src/sync-realtime/index.ts | 19 +++++++++++++++++-- packages/core/src/sync/events.ts | 8 +++++--- 4 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 .changeset/chilly-pigs-shake.md diff --git a/.changeset/chilly-pigs-shake.md b/.changeset/chilly-pigs-shake.md new file mode 100644 index 000000000..8dc2b7c8f --- /dev/null +++ b/.changeset/chilly-pigs-shake.md @@ -0,0 +1,5 @@ +--- +"ponder": patch +--- + +Fixed an issue where ZKsync system logs failed with the error `Detected inconsistent RPC responses. 'log.transactionHash' 0x0000000000000000000000000000000000000000000000000000000000000000 not found in 'block.transactions' (...)`. \ No newline at end of file diff --git a/packages/core/src/sync-historical/index.ts b/packages/core/src/sync-historical/index.ts index 38111b52c..2e0e96c6f 100644 --- a/packages/core/src/sync-historical/index.ts +++ b/packages/core/src/sync-historical/index.ts @@ -47,6 +47,7 @@ import { hexToBigInt, hexToNumber, toHex, + zeroHash, } from "viem"; export type HistoricalSync = { @@ -493,9 +494,16 @@ export const createHistoricalSync = async ( block.transactions.find((t) => t.hash === log.transactionHash) === undefined ) { - throw new Error( - `Detected inconsistent RPC responses. 'log.transactionHash' ${log.transactionHash} not found in 'block.transactions' ${block.hash}`, - ); + if (log.transactionHash === zeroHash) { + args.common.logger.warn({ + service: "sync", + msg: `Detected log with empty transaction hash in block ${block.hash} at log index ${hexToNumber(log.logIndex)}. This is expected for some networks like ZKsync.`, + }); + } else { + throw new Error( + `Detected inconsistent RPC responses. 'log.transactionHash' ${log.transactionHash} not found in 'block.transactions' ${block.hash}`, + ); + } } } diff --git a/packages/core/src/sync-realtime/index.ts b/packages/core/src/sync-realtime/index.ts index c4492b55d..f92c8e302 100644 --- a/packages/core/src/sync-realtime/index.ts +++ b/packages/core/src/sync-realtime/index.ts @@ -34,7 +34,7 @@ import { } from "@/utils/rpc.js"; import { wait } from "@/utils/wait.js"; import { type Queue, createQueue } from "@ponder/common"; -import { type Address, type Hash, hexToNumber } from "viem"; +import { type Address, type Hash, hexToNumber, zeroHash } from "viem"; import { isFilterInBloom, zeroLogsBloom } from "./bloom.js"; import { isBlockFilterMatched, @@ -658,13 +658,28 @@ export const createRealtimeSync = ( ); } - // Check that logs refer to the correct block for (const log of logs) { if (log.blockHash !== block.hash) { throw new Error( `Detected invalid eth_getLogs response. 'log.blockHash' ${log.blockHash} does not match requested block hash ${block.hash}`, ); } + + if ( + block.transactions.find((t) => t.hash === log.transactionHash) === + undefined + ) { + if (log.transactionHash === zeroHash) { + args.common.logger.warn({ + service: "sync", + msg: `Detected log with empty transaction hash in block ${block.hash} at log index ${hexToNumber(log.logIndex)}. This is expected for some networks like ZKsync.`, + }); + } else { + throw new Error( + `Detected inconsistent RPC responses. 'log.transactionHash' ${log.transactionHash} not found in 'block.transactions' ${block.hash}`, + ); + } + } } } diff --git a/packages/core/src/sync/events.ts b/packages/core/src/sync/events.ts index 6543aa4bc..6335a4864 100644 --- a/packages/core/src/sync/events.ts +++ b/packages/core/src/sync/events.ts @@ -231,9 +231,11 @@ export const buildEvents = ({ }), log: convertLog(log), block: convertBlock(block), - transaction: convertTransaction( - transactionCache.get(log.transactionHash)!, - ), + transaction: transactionCache.has(log.transactionHash) + ? convertTransaction( + transactionCache.get(log.transactionHash)!, + ) + : undefined, transactionReceipt: shouldGetTransactionReceipt(filter) ? convertTransactionReceipt( transactionReceiptCache.get(log.transactionHash)!, From 20f5567e2954f2be9a5fff5755313c03810467d4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:26:56 -0500 Subject: [PATCH 2/2] chore: version packages (#1412) Co-authored-by: github-actions[bot] --- .changeset/chilly-pigs-shake.md | 5 ----- packages/core/CHANGELOG.md | 6 ++++++ packages/core/package.json | 2 +- packages/create-ponder/CHANGELOG.md | 2 ++ packages/create-ponder/package.json | 2 +- packages/eslint-config-ponder/CHANGELOG.md | 2 ++ packages/eslint-config-ponder/package.json | 2 +- 7 files changed, 13 insertions(+), 8 deletions(-) delete mode 100644 .changeset/chilly-pigs-shake.md diff --git a/.changeset/chilly-pigs-shake.md b/.changeset/chilly-pigs-shake.md deleted file mode 100644 index 8dc2b7c8f..000000000 --- a/.changeset/chilly-pigs-shake.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"ponder": patch ---- - -Fixed an issue where ZKsync system logs failed with the error `Detected inconsistent RPC responses. 'log.transactionHash' 0x0000000000000000000000000000000000000000000000000000000000000000 not found in 'block.transactions' (...)`. \ No newline at end of file diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 5340c71bd..799224291 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,11 @@ # ponder +## 0.8.17 + +### Patch Changes + +- [#1411](https://github.com/ponder-sh/ponder/pull/1411) [`60704d3974387cb625c8fe2e45026fc2235622b9`](https://github.com/ponder-sh/ponder/commit/60704d3974387cb625c8fe2e45026fc2235622b9) Thanks [@kyscott18](https://github.com/kyscott18)! - Fixed an issue where ZKsync system logs failed with the error `Detected inconsistent RPC responses. 'log.transactionHash' 0x0000000000000000000000000000000000000000000000000000000000000000 not found in 'block.transactions' (...)`. + ## 0.8.16 ### Patch Changes diff --git a/packages/core/package.json b/packages/core/package.json index 778da05f9..1f8596f41 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "ponder", - "version": "0.8.16", + "version": "0.8.17", "description": "An open-source framework for crypto application backends", "license": "MIT", "type": "module", diff --git a/packages/create-ponder/CHANGELOG.md b/packages/create-ponder/CHANGELOG.md index 6c29b3df2..960f747ac 100644 --- a/packages/create-ponder/CHANGELOG.md +++ b/packages/create-ponder/CHANGELOG.md @@ -1,5 +1,7 @@ # create-ponder +## 0.8.17 + ## 0.8.16 ## 0.8.15 diff --git a/packages/create-ponder/package.json b/packages/create-ponder/package.json index 545dd352d..299b61419 100644 --- a/packages/create-ponder/package.json +++ b/packages/create-ponder/package.json @@ -1,6 +1,6 @@ { "name": "create-ponder", - "version": "0.8.16", + "version": "0.8.17", "type": "module", "description": "A CLI tool to create Ponder apps", "license": "MIT", diff --git a/packages/eslint-config-ponder/CHANGELOG.md b/packages/eslint-config-ponder/CHANGELOG.md index 609cfd600..6045c5d84 100644 --- a/packages/eslint-config-ponder/CHANGELOG.md +++ b/packages/eslint-config-ponder/CHANGELOG.md @@ -1,5 +1,7 @@ # eslint-config-ponder +## 0.8.17 + ## 0.8.16 ## 0.8.15 diff --git a/packages/eslint-config-ponder/package.json b/packages/eslint-config-ponder/package.json index 5f6a2054b..35826efe5 100644 --- a/packages/eslint-config-ponder/package.json +++ b/packages/eslint-config-ponder/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-ponder", - "version": "0.8.16", + "version": "0.8.17", "description": "ESLint config for Ponder apps", "license": "MIT", "main": "./index.js",