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.
This commit is contained in:
Mayveskii 2026-03-26 20:21:27 +03:00
parent 8a3a309fa9
commit dd9ed2f43d

View file

@ -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