From dd9ed2f43d39c0ea9dd18600641069e3de9e6ff0 Mon Sep 17 00:00:00 2001 From: Mayveskii Date: Thu, 26 Mar 2026 20:21:27 +0300 Subject: [PATCH] core/filtermaps: return early on error in tailPartialBlocks When getLastBlockOfMap fails in tailPartialBlocks, the error is logged but the uninitialized/zero end value is still used in the subtraction (end - start), potentially returning a garbage block count to the caller. Return 0 immediately on error to avoid propagating incorrect block counts through the indexing pipeline. --- core/filtermaps/indexer.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/filtermaps/indexer.go b/core/filtermaps/indexer.go index ca50fb466c..8c710bba4d 100644 --- a/core/filtermaps/indexer.go +++ b/core/filtermaps/indexer.go @@ -440,12 +440,14 @@ func (f *FilterMaps) tailPartialBlocks() uint64 { end, _, err := f.getLastBlockOfMap(f.indexedRange.maps.First() - f.mapsPerEpoch + f.indexedRange.tailPartialEpoch - 1) if err != nil { log.Error("Error fetching last block of map", "mapIndex", f.indexedRange.maps.First()-f.mapsPerEpoch+f.indexedRange.tailPartialEpoch-1, "error", err) + return 0 } var start uint64 if f.indexedRange.maps.First()-f.mapsPerEpoch > 0 { start, _, err = f.getLastBlockOfMap(f.indexedRange.maps.First() - f.mapsPerEpoch - 1) if err != nil { log.Error("Error fetching last block of map", "mapIndex", f.indexedRange.maps.First()-f.mapsPerEpoch-1, "error", err) + return 0 } } return end - start