Skip to content

Commit

Permalink
feat(miner): move TAIKO_MIN_TIP check to commitL2Transactions (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jun 6, 2024
1 parent aa70708 commit f3a7fb6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
18 changes: 2 additions & 16 deletions core/txpool/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"fmt"
"math/big"
"os"
"strconv"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions miner/taiko_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"errors"
"fmt"
"math/big"
"os"
"strconv"
"time"

"github.com/ethereum/go-ethereum/beacon/engine"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f3a7fb6

Please sign in to comment.