diff --git a/core/txpool/celo_validation.go b/core/txpool/celo_validation.go index 018f5c460e..e4ac4590c3 100644 --- a/core/txpool/celo_validation.go +++ b/core/txpool/celo_validation.go @@ -10,9 +10,13 @@ import ( "github.com/ethereum/go-ethereum/params" ) -// ErrGasPriceDoesNotExceedBaseFeeFloor is returned if the gas price specified is -// lower than the configured base-fee-floor -var ErrGasPriceDoesNotExceedBaseFeeFloor = errors.New("gas-price is less than the base-fee-floor") +var ( + + // ErrGasPriceDoesNotExceedBaseFeeFloor is returned if the gas price specified is + // lower than the configured base-fee-floor + ErrGasPriceDoesNotExceedBaseFeeFloor = errors.New("gas-price is less than the base-fee-floor") + ErrMinimumEffectiveGasTipBelowMinTip = errors.New("effective gas tip at base-fee-floor is below threshold") +) // AcceptSet is a set of accepted transaction types for a transaction subpool. type AcceptSet = map[uint8]struct{} @@ -61,16 +65,34 @@ func CeloValidateTransaction(tx *types.Transaction, head *types.Header, return exchange.ErrUnregisteredFeeCurrency } - celoGasPrice, err := exchange.ConvertCurrencyToCelo( - currencyCtx.ExchangeRates, - tx.FeeCurrency(), - tx.GasFeeCap(), - ) - if err != nil { - return err - } - if opts.Config.Celo != nil { + // Make sure that the effective gas tip at the base fee floor is at least the + // requested min-tip. + // The min-tip for local transactions is set to 0, we can skip checking here. + if opts.MinTip != nil && opts.MinTip.Cmp(new(big.Int)) != 0 { + // If not, this would never be included, so we can reject early. + minTip, err := exchange.ConvertCeloToCurrency(currencyCtx.ExchangeRates, tx.FeeCurrency(), opts.MinTip) + if err != nil { + return err + } + minBaseFee, err := exchange.ConvertCeloToCurrency(currencyCtx.ExchangeRates, tx.FeeCurrency(), new(big.Int).SetUint64(opts.Config.Celo.EIP1559BaseFeeFloor)) + if err != nil { + return err + } + if tx.EffectiveGasTipIntCmp(minTip, minBaseFee) < 0 { + return ErrUnderpriced + } + } + + celoGasPrice, err := exchange.ConvertCurrencyToCelo( + currencyCtx.ExchangeRates, + tx.FeeCurrency(), + tx.GasFeeCap(), + ) + if err != nil { + return err + } + if new(big.Int).SetUint64(opts.Config.Celo.EIP1559BaseFeeFloor).Cmp(celoGasPrice) == 1 { return ErrGasPriceDoesNotExceedBaseFeeFloor }