feat(miner): move TAIKO_MIN_TIP check to commitL2Transactions (#272)

This commit is contained in:
David 2024-06-06 10:40:25 +07:00 committed by GitHub
parent aa70708a69
commit f3a7fb6311
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 16 deletions

View file

@ -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 {

View file

@ -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)