core/txpool: report actual 110% threshold in intrinsic gas error

When a chain has gasCostPerStateByte != 0 (EIP-8037), the txpool
admission requires tx.Gas() >= ceil(intrGas.RegularGas * 10/9), but
the error message reported intrGas.RegularGas as the "minimum needed",
which is the unscaled value below the real threshold.

This is confusing: the user sees e.g. "gas 21000, minimum needed 21000"
for a simple transfer and assumes the comparison is broken, when in
fact the pool wants 23334.

Compute the threshold once and report it in the error.
This commit is contained in:
Barnabas Busa 2026-04-21 16:01:39 +02:00 committed by MariusVanDerWijden
parent 18025f9001
commit 075cc6417a

View file

@ -134,8 +134,8 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
// We require transactions to pay for 110% of intrinsic gas in order to
// prevent situations where a change in gas limit invalidates a lot
// of transactions in the txpool
if tx.Gas() < (intrGas.RegularGas*10)/9 {
return fmt.Errorf("%w: gas %v, minimum needed %v", core.ErrIntrinsicGas, tx.Gas(), intrGas.RegularGas)
if minGas := (intrGas.RegularGas * 10) / 9; tx.Gas() < minGas {
return fmt.Errorf("%w: gas %v, minimum needed %v", core.ErrIntrinsicGas, tx.Gas(), minGas)
}
}
if tx.Gas() < intrGas.RegularGas {