Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(taiko_miner): add BuildTransactionsListsWithMinTip method #283

Merged
merged 6 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions eth/taiko_api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,33 @@ 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,
)

return a.eth.Miner().BuildTransactionsListsWithMinTip(
beneficiary,
baseFee,
blockMaxGasLimit,
maxBytesPerTxList,
locals,
maxTransactionsLists,
minTip,
)
}
23 changes: 23 additions & 0 deletions miner/taiko_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -43,5 +65,6 @@ func (miner *Miner) BuildTransactionsLists(
maxBytesPerTxList,
locals,
maxTransactionsLists,
minTip,
)
}
20 changes: 7 additions & 13 deletions miner/taiko_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"errors"
"fmt"
"math/big"
"os"
"strconv"
"time"

"github.com/ethereum/go-ethereum/beacon/engine"
Expand All @@ -34,6 +32,7 @@ func (w *worker) BuildTransactionsLists(
maxBytesPerTxList uint64,
localAccounts []string,
maxTransactionsLists uint64,
minTip uint64,
) ([]*PreBuiltTxList, error) {
var (
txsLists []*PreBuiltTxList
Expand Down Expand Up @@ -96,6 +95,7 @@ func (w *worker) BuildTransactionsLists(
newTransactionsByPriceAndNonce(signer, locals, baseFee),
newTransactionsByPriceAndNonce(signer, remotes, baseFee),
maxBytesPerTxList,
minTip,
)

b, err := encodeAndComporeessTxList(env.txs)
Expand Down Expand Up @@ -243,6 +243,7 @@ func (w *worker) commitL2Transactions(
txsLocal *transactionsByPriceAndNonce,
txsRemote *transactionsByPriceAndNonce,
maxBytesPerTxList uint64,
minTip uint64,
) *types.Transaction {
var (
txs = txsLocal
Expand Down Expand Up @@ -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(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
Expand Down
Loading