Skip to content

Commit

Permalink
Invalidate txs with below base-fee-floor gas-price in txpool
Browse files Browse the repository at this point in the history
Fixes #291

Before, the transaction pool accepted transactions that have a
gas-price below the configured base-fee-floor, which would never be
executed.

Now, the transaction pool rejects those transactions immediately -
giving the submitting user an immediate response and better UX.
  • Loading branch information
ezdac committed Dec 5, 2024
1 parent f102315 commit c9efc24
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions core/txpool/celo_validation.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package txpool

import (
"errors"
"math/big"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -9,6 +10,10 @@ 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")

// AcceptSet is a set of accepted transaction types for a transaction subpool.
type AcceptSet = map[uint8]struct{}

Expand Down Expand Up @@ -56,5 +61,16 @@ 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 new(big.Int).SetUint64(opts.Config.Celo.EIP1559BaseFeeFloor).Cmp(celoGasPrice) == 1 {
return ErrGasPriceDoesNotExceedBaseFeeFloor
}
return nil
}

0 comments on commit c9efc24

Please sign in to comment.