diff --git a/eth/taiko_api_backend.go b/eth/taiko_api_backend.go index b6612ca11f15..aa506d40b9cc 100644 --- a/eth/taiko_api_backend.go +++ b/eth/taiko_api_backend.go @@ -102,3 +102,34 @@ func (a *TaikoAuthAPIBackend) TxPoolContent( maxTransactionsLists, ) } + +// TxPoolContentWithMinTip retrieves the transaction pool content with the given upper limits and minimum tip. +func (a *TaikoAuthAPIBackend) TxPoolContentWithMinTip( + beneficiary common.Address, + baseFee *big.Int, + blockMaxGasLimit uint64, + maxBytesPerTxList uint64, + locals []string, + maxTransactionsLists uint64, + minTip uint64, +) ([]*miner.PreBuiltTxList, error) { + log.Debug( + "Fetching L2 pending transactions finished", + "baseFee", baseFee, + "blockMaxGasLimit", blockMaxGasLimit, + "maxBytesPerTxList", maxBytesPerTxList, + "maxTransactions", maxTransactionsLists, + "locals", locals, + "minTip", minTip, + ) + + return a.eth.Miner().BuildTransactionsListsWithMinTip( + beneficiary, + baseFee, + blockMaxGasLimit, + maxBytesPerTxList, + locals, + maxTransactionsLists, + minTip, + ) +} diff --git a/miner/taiko_miner.go b/miner/taiko_miner.go index 81dc8d1e7737..9b9a246c94fd 100644 --- a/miner/taiko_miner.go +++ b/miner/taiko_miner.go @@ -35,6 +35,28 @@ func (miner *Miner) BuildTransactionsLists( maxBytesPerTxList uint64, locals []string, maxTransactionsLists uint64, +) ([]*PreBuiltTxList, error) { + return miner.BuildTransactionsListsWithMinTip( + beneficiary, + baseFee, + blockMaxGasLimit, + maxBytesPerTxList, + locals, + maxTransactionsLists, + 0, + ) +} + +// BuildTransactionsListsWithMinTip builds multiple transactions lists which satisfy all +// the given limits and minimum tip. +func (miner *Miner) BuildTransactionsListsWithMinTip( + beneficiary common.Address, + baseFee *big.Int, + blockMaxGasLimit uint64, + maxBytesPerTxList uint64, + locals []string, + maxTransactionsLists uint64, + minTip uint64, ) ([]*PreBuiltTxList, error) { return miner.worker.BuildTransactionsLists( beneficiary, @@ -43,5 +65,6 @@ func (miner *Miner) BuildTransactionsLists( maxBytesPerTxList, locals, maxTransactionsLists, + minTip, ) } diff --git a/miner/taiko_worker.go b/miner/taiko_worker.go index 353a02513c3f..3f02d21d174a 100644 --- a/miner/taiko_worker.go +++ b/miner/taiko_worker.go @@ -6,8 +6,6 @@ import ( "errors" "fmt" "math/big" - "os" - "strconv" "time" "github.com/ethereum/go-ethereum/beacon/engine" @@ -34,6 +32,7 @@ func (w *worker) BuildTransactionsLists( maxBytesPerTxList uint64, localAccounts []string, maxTransactionsLists uint64, + minTip uint64, ) ([]*PreBuiltTxList, error) { var ( txsLists []*PreBuiltTxList @@ -96,6 +95,7 @@ func (w *worker) BuildTransactionsLists( newTransactionsByPriceAndNonce(signer, locals, baseFee), newTransactionsByPriceAndNonce(signer, remotes, baseFee), maxBytesPerTxList, + minTip, ) b, err := encodeAndComporeessTxList(env.txs) @@ -243,6 +243,7 @@ func (w *worker) commitL2Transactions( txsLocal *transactionsByPriceAndNonce, txsRemote *transactionsByPriceAndNonce, maxBytesPerTxList uint64, + minTip uint64, ) *types.Transaction { var ( txs = txsLocal @@ -280,17 +281,10 @@ loop: 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 - } - } + if tx.GasTipCapIntCmp(new(big.Int).SetUint64(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