From f2b434bbf954aa74b1af2705a4c3c54969b88b34 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Fri, 3 Oct 2025 12:53:10 +0200 Subject: [PATCH] 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 --- core/txpool/legacypool/legacypool.go | 12 +++++++++++- core/txpool/legacypool/queue.go | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index d57ee02b3d..2ff905603b 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -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 } diff --git a/core/txpool/legacypool/queue.go b/core/txpool/legacypool/queue.go index 8edb03056e..4b792aa200 100644 --- a/core/txpool/legacypool/queue.go +++ b/core/txpool/legacypool/queue.go @@ -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