Skip to content

Commit

Permalink
feat: Ignore transactions that do not meet the baseFee.
Browse files Browse the repository at this point in the history
  • Loading branch information
luanxu-mxc committed Jul 7, 2023
1 parent 6eed5c7 commit 6f93f45
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
File renamed without changes.
File renamed without changes.
14 changes: 10 additions & 4 deletions eth/mxc_api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (s *MxcAPIBackend) TxPoolContent(
minTxGasLimit uint64,
locals []string,
) ([]types.Transactions, error) {
pending := s.eth.TxPool().Pending(true)
pending := s.eth.TxPool().Pending(false)

log.Debug(
"Fetching L2 pending transactions finished",
Expand Down Expand Up @@ -97,7 +97,7 @@ func (s *MxcAPIBackend) TxPoolContent(
txsCount = 0
txLists []types.Transactions
)
for _, splittedTxs := range contentSplitter.Split(filterTxs(pending)) {
for _, splittedTxs := range contentSplitter.Split(filterTxs(pending, s.eth.blockchain.CurrentHeader().BaseFee)) {
if txsCount+splittedTxs.Len() < int(maxTransactionsPerBlock) {
txLists = append(txLists, splittedTxs)
txsCount += splittedTxs.Len()
Expand All @@ -111,14 +111,20 @@ func (s *MxcAPIBackend) TxPoolContent(
return txLists, nil
}

func filterTxs(pendings map[common.Address]types.Transactions) map[common.Address]types.Transactions {
func filterTxs(pendings map[common.Address]types.Transactions, baseFee *big.Int) map[common.Address]types.Transactions {
executableTxs := make(map[common.Address]types.Transactions)
gasPriceLowerLimit := big.NewInt(0).Div(big.NewInt(0).Mul(baseFee, big.NewInt(95)), big.NewInt(100))

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 {
if tx.GasFeeCap().Uint64() == 0 || tx.GasPrice().Cmp(gasPriceLowerLimit) < 0 {
log.Debug("Ignore max fee per gas less than block base fee",
"gas price", baseFee.Uint64(),
"tx gas price", tx.GasPrice().Uint64(),
"lower limit", gasPriceLowerLimit.Uint64(),
)
break
}

Expand Down

0 comments on commit 6f93f45

Please sign in to comment.