Skip to content

Commit

Permalink
feat(txpool): introduce TAIKO_MIN_TIP env (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jun 1, 2024
1 parent 037640e commit a29520e
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions core/txpool/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"math/big"
"os"
"strconv"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a29520e

Please sign in to comment.