Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kyscott18 committed Jan 6, 2025
2 parents c84cc0c + 20f5567 commit ea796c0
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 11 deletions.
6 changes: 6 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 11 additions & 3 deletions packages/core/src/sync-historical/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
hexToBigInt,
hexToNumber,
toHex,
zeroHash,
} from "viem";

export type HistoricalSync = {
Expand Down Expand Up @@ -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}`,
);
}
}
}

Expand Down
19 changes: 17 additions & 2 deletions packages/core/src/sync-realtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}`,
);
}
}
}
}

Expand Down
8 changes: 5 additions & 3 deletions packages/core/src/sync/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)!,
Expand Down
2 changes: 2 additions & 0 deletions packages/create-ponder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# create-ponder

## 0.8.17

## 0.8.16

## 0.8.15
Expand Down
2 changes: 1 addition & 1 deletion packages/create-ponder/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config-ponder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# eslint-config-ponder

## 0.8.17

## 0.8.16

## 0.8.15
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-ponder/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit ea796c0

Please sign in to comment.