From a19f1ff11b99d39611053114fb47693705b42d63 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Wed, 25 Feb 2026 09:36:22 +0100 Subject: [PATCH] core/txpool/blobpool: remove the log-log grouping for positive priorities The priority groups for positive fee difference were not used. In these cases we always used the tip as the basis for comparison. Thus, it is useless to do an extra log, just to then throw it away. Signed-off-by: Csaba Kiraly --- core/txpool/blobpool/priority.go | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/core/txpool/blobpool/priority.go b/core/txpool/blobpool/priority.go index 5c17b44d9c..27e87a775a 100644 --- a/core/txpool/blobpool/priority.go +++ b/core/txpool/blobpool/priority.go @@ -18,7 +18,6 @@ package blobpool import ( "math" - "math/bits" "github.com/holiman/uint256" ) @@ -46,7 +45,10 @@ func evictionPriority1D(basefeeJumps float64, txfeeJumps float64) int { if jumps <= 0 { return int(math.Floor(jumps)) } - return intLog2(uint(math.Ceil(jumps))) + // We only use the negative part for ordering. The positive part is only used + // for threshold comparision (with a negative threshold), so the value is almost + // irrelevant, as long as it's positive. + return int((math.Ceil(jumps))) } // dynamicFeeJumps calculates the log1.125(fee), namely the number of fee jumps @@ -64,21 +66,5 @@ func dynamicFeeJumps(fee *uint256.Int) float64 { return math.Log(fee.Float64()) / log1_125 } -// intLog2 is a helper to calculate the integral part of a log2 of an unsigned -// integer. It is a very specific calculation that's not particularly useful in -// general, but it's what we need here (it's fast). -func intLog2(n uint) int { - switch { - case n == 0: - panic("log2(0) is undefined") - - case n < 2048: - return bits.UintSize - bits.LeadingZeros(n) - 1 - - default: - // The input is log1.125(uint256) = log2(uint256) / log2(1.125). At the - // most extreme, log2(uint256) will be a bit below 257, and the constant - // log2(1.125) ~= 0.17. The larges input thus is ~257 / ~0.17 ~= ~1511. - panic("dynamic fee jump diffs cannot reach this") } }