From f3a7fb6311e9d59ba2fb55799b9eab614d488095 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 6 Jun 2024 10:40:25 +0700 Subject: [PATCH] feat(miner): move `TAIKO_MIN_TIP` check to `commitL2Transactions` (#272) --- core/txpool/validation.go | 18 ++---------------- miner/taiko_worker.go | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/core/txpool/validation.go b/core/txpool/validation.go index b1aaa7f1ea62..8afc57e0a3d9 100644 --- a/core/txpool/validation.go +++ b/core/txpool/validation.go @@ -22,7 +22,6 @@ import ( "fmt" "math/big" "os" - "strconv" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -100,21 +99,8 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types return core.ErrTipAboveFeeCap } // 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 wei", minTip) - } - } - } else { - if tx.GasFeeCap().Cmp(common.Big0) == 0 { - return errors.New("max fee per gas is 0") - } - } + if os.Getenv("TAIKO_TEST") == "" && 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 { diff --git a/miner/taiko_worker.go b/miner/taiko_worker.go index d71219623bd6..3e17abd0970b 100644 --- a/miner/taiko_worker.go +++ b/miner/taiko_worker.go @@ -6,6 +6,8 @@ import ( "errors" "fmt" "math/big" + "os" + "strconv" "time" "github.com/ethereum/go-ethereum/beacon/engine" @@ -261,6 +263,20 @@ func (w *worker) commitL2Transactions( txs.Pop() continue } + + 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 { + log.Trace("Ignoring transaction with low tip", "hash", tx.Hash(), "tip", tx.GasTipCap(), "minTip", minTip) + txs.Pop() + continue + } + } + } + // Error may be ignored here. The error has already been checked // during transaction acceptance is the transaction pool. from, _ := types.Sender(env.signer, tx)