core/txpool/legacypool: fix tx removal

promoteExecutable already removes the txs from the queue.
We just need to remove them from the lookup.

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2025-10-03 12:53:10 +02:00
parent 39ce64b8b0
commit f2b434bbf9
No known key found for this signature in database
GPG key ID: 0FE274EE8C95166E
2 changed files with 17 additions and 1 deletions

View file

@ -1413,8 +1413,18 @@ func (pool *LegacyPool) promoteExecutables(accounts []common.Address) []*types.T
// remove all removable transactions
for _, hash := range removeable {
pool.removeTx(hash, true, true)
pool.all.Remove(hash)
}
// release all accounts that have no more transactions in the pool
for _, addr := range accounts {
_, hasPending := pool.pending[addr]
_, hasQueued := pool.queue.get(addr)
if !hasPending && !hasQueued {
pool.reserver.Release(addr)
}
}
return promoted
}

View file

@ -145,6 +145,12 @@ func (q *queue) add(hash common.Hash, tx *types.Transaction) (*common.Hash, erro
return &h, nil
}
// promoteExecutables iterates over all accounts with queued transactions, selecting
// for promotion any that are now executable. It also drops any transactions that are
// deemed too old (nonce too low) or too costly (insufficient funds or over gas limit).
//
// Returns two lists: all transactions that were removed from the queue and selected
// for promotion; all other transactions that were removed from the queue and dropped.
func (q *queue) promoteExecutables(accounts []common.Address, gasLimit uint64, currentState *state.StateDB, nonces *noncer) ([]*types.Transaction, []common.Hash) {
// Track the promoteable transactions to broadcast them at once
var promoteable []*types.Transaction