From 7f0adc0bcb88d75922e04039a8750464153f8082 Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Mon, 31 Mar 2025 16:18:02 +0200 Subject: [PATCH] prevent divide by zero --- eth/downloader/resultstore.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth/downloader/resultstore.go b/eth/downloader/resultstore.go index d50551892f..24d1653b29 100644 --- a/eth/downloader/resultstore.go +++ b/eth/downloader/resultstore.go @@ -100,7 +100,7 @@ func (r *resultStore) getFetchResult(headerNumber uint64) (item *fetchResult, in // estimate an average block size based on the worst case: // a block filled with calldata containing all zeroes // costing ~10 gas per byte of calldata. - avgEstimatedBlockSize := (r.itemsGasUsed / (uint64(index) + 1)) / 10 + avgEstimatedBlockSize := min((r.itemsGasUsed/(uint64(index)+1))/10, 524) throttleThreshold := min(uint64(len(r.items)), uint64(blockCacheMemory)/avgEstimatedBlockSize) throttle = index >= int(throttleThreshold)