Skip to content

Commit

Permalink
feat(eth): update taiko-api-backend (ethereum#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Jun 30, 2023
1 parent 3650f57 commit 64dbc2a
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion eth/taiko_api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"math/big"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
Expand Down Expand Up @@ -96,7 +97,7 @@ func (s *TaikoAPIBackend) TxPoolContent(
txsCount = 0
txLists []types.Transactions
)
for _, splittedTxs := range contentSplitter.Split(pending) {
for _, splittedTxs := range contentSplitter.Split(filterTxs(pending)) {
if txsCount+splittedTxs.Len() < int(maxTransactionsPerBlock) {
txLists = append(txLists, splittedTxs)
txsCount += splittedTxs.Len()
Expand All @@ -109,3 +110,30 @@ func (s *TaikoAPIBackend) TxPoolContent(

return txLists, nil
}

func filterTxs(pendings map[common.Address]types.Transactions) map[common.Address]types.Transactions {
executableTxs := make(map[common.Address]types.Transactions)

for addr, txs := range pendings {
pendingTxs := make(types.Transactions, 0)
for _, tx := range txs {
// Check baseFee, should not be zero
if tx.GasFeeCap().Uint64() == 0 {
break
}

// If this tx is a transfer and with high gas limit, ignore it.
if len(tx.Data()) == 0 && tx.Gas() > 500_000 {
break
}

pendingTxs = append(pendingTxs, tx)
}

if len(pendingTxs) > 0 {
executableTxs[addr] = pendingTxs
}
}

return executableTxs
}

0 comments on commit 64dbc2a

Please sign in to comment.