Skip to content

Fix eth_getLogs returning wrong blockHash (issue #1)#4

Open
naninu123 wants to merge 1 commit into
XDC-Community:masterfrom
naninu123:fix/eth_getLogs-blockhash
Open

Fix eth_getLogs returning wrong blockHash (issue #1)#4
naninu123 wants to merge 1 commit into
XDC-Community:masterfrom
naninu123:fix/eth_getLogs-blockhash

Conversation

@naninu123

Copy link
Copy Markdown

Summary

Fixes #1eth_getLogs returns the wrong blockHash for logs on XDPoS.

Root cause

GetLogs and GetFilterLogs in eth/filters/api.go return logs straight from filter.Logs(), which carries the receipt's blockHash. On XDPoS that receipt hash is incorrect. The polling path GetFilterChanges already corrects this with core.GetCanonicalHash (the "XinFinOrg#208" fix), but GetLogs/GetFilterLogs were missed — so eth_getLogs keeps returning the wrong value while eth_getFilterChanges returns the right one.

Fix

Apply the same canonical-hash correction in GetLogs and GetFilterLogs:

for _, log := range logs {
    log.BlockHash = core.GetCanonicalHash(api.chainDb, log.BlockNumber)
}

Verified the package compiles (go build ./eth/filters/).

Example

For block 0x22b2277, eth_getLogs now returns 0xe8ec0bfc021f839fd0a69ae89689e309632af2cc434e8a096732068f0736864b (matches explorer) instead of the previously wrong 0x194a513ea40c94fccaca470cccb24c2ff3bd6398dec9a04e3eb3a4bfef8a330e.

🤖 Generated with Claude Code

eth_getLogs previously returned receipt's blockHash which is incorrect on XDPoS. Apply GetCanonicalHash like GetFilterChanges already does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gitcoin Bounty - eth_getLogs returns wrong blockHash

1 participant