From f390875cf9c05389225ffcf9fc468000bd8470eb Mon Sep 17 00:00:00 2001 From: andyzhang2023 Date: Wed, 30 Oct 2024 17:36:58 +0800 Subject: [PATCH] fix:staled transactions will lead to oom if the pool is always not-empty --- core/txpool/legacypool/legacypool.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index 234c0e511..677e1e563 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -1902,6 +1902,7 @@ func (pool *LegacyPool) demoteUnexecutables(demoteAddrs []common.Address) { } demoteTxMeter.Mark(int64(len(demoteAddrs))) + var removed = 0 // Iterate over all accounts and demote any non-executable transactions gasLimit := txpool.EffectiveGasLimit(pool.chainconfig, pool.currentHead.Load().GasLimit, pool.config.EffectiveGasCeil) for _, addr := range demoteAddrs { @@ -1965,7 +1966,9 @@ func (pool *LegacyPool) demoteUnexecutables(demoteAddrs []common.Address) { } } pool.pendingCache.del(dropPendingCache, pool.signer) + removed += len(dropPendingCache) } + pool.priced.Removed(removed) } // addressByHeartbeat is an account address tagged with its last activity timestamp.