From a29520e066809dda21af463272b6ec1ef1cdfcae Mon Sep 17 00:00:00 2001 From: David Date: Sat, 1 Jun 2024 10:49:42 +0700 Subject: [PATCH] feat(txpool): introduce `TAIKO_MIN_TIP` env (#264) --- core/txpool/validation.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/core/txpool/validation.go b/core/txpool/validation.go index 45dfe33a9b85..1f6d31a3c669 100644 --- a/core/txpool/validation.go +++ b/core/txpool/validation.go @@ -22,6 +22,7 @@ import ( "fmt" "math/big" "os" + "strconv" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -98,9 +99,22 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types if tx.GasFeeCapIntCmp(tx.GasTipCap()) < 0 { return core.ErrTipAboveFeeCap } - // CHANGE(taiko): ensure gasFeeCap fee cap larger than 0. - if os.Getenv("TAIKO_TEST") == "" && tx.GasFeeCap().Cmp(common.Big0) == 0 { - return errors.New("max fee per gas is 0") + // CHANGE(taiko): check gasFeeCap. + if os.Getenv("TAIKO_TEST") == "" { + if os.Getenv("TAIKO_MIN_TIP") != "" { + minTip, err := strconv.Atoi(os.Getenv("TAIKO_MIN_TIP")) + if err != nil { + log.Error("Failed to parse TAIKO_MIN_TIP", "err", err) + } else { + if tx.GasTipCapIntCmp(new(big.Int).SetUint64(uint64(minTip))) < 0 { + return fmt.Errorf("max fee per gas is less than %d Gwei", minTip) + } + } + } else { + if tx.GasFeeCap().Cmp(common.Big0) == 0 { + return errors.New("max fee per gas is 0") + } + } } // Make sure the transaction is signed properly if _, err := types.Sender(signer, tx); err != nil {