From 439e6d38c3711d9ae933c573e78414d754e4fcd2 Mon Sep 17 00:00:00 2001 From: YUSEP MAULANA Date: Sun, 12 Jul 2026 16:38:46 +0000 Subject: [PATCH] eth/filters: fix eth_getLogs wrong blockHash by using GetCanonicalHash eth_getLogs previously returned receipt's blockHash which is incorrect on XDPoS. Apply GetCanonicalHash like GetFilterChanges already does. --- eth/filters/api.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/eth/filters/api.go b/eth/filters/api.go index aef9adba103f..6d35c2fba287 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -341,6 +341,11 @@ func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([ if err != nil { return nil, err } + // update BlockHash to fix #208 (eth_getLogs previously returned the + // receipt's blockHash, which is wrong on XDPoS; use the canonical hash) + for _, log := range logs { + log.BlockHash = core.GetCanonicalHash(api.chainDb, log.BlockNumber) + } return returnLogs(logs), err } @@ -389,6 +394,10 @@ func (api *PublicFilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*ty if err != nil { return nil, err } + // update BlockHash to fix #208 + for _, log := range logs { + log.BlockHash = core.GetCanonicalHash(api.chainDb, log.BlockNumber) + } return returnLogs(logs), nil }