From 1d2ebeb9a0337101827915e902cda46d68b2f02b Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Thu, 7 Oct 2021 09:13:01 +0200 Subject: [PATCH] Fix memory leak in txpool --- core/tx_pool.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/tx_pool.go b/core/tx_pool.go index ee56dae888..55ca7ce059 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -1173,9 +1173,15 @@ func (pool *TxPool) runReorg(done chan struct{}, reset *txpoolResetRequest, dirt // because of another transaction (e.g. higher gas price). if reset != nil { pool.demoteUnexecutables() - if reset.newHead != nil && pool.chainconfig.IsLondon(new(big.Int).Add(reset.newHead.Number, big.NewInt(1))) { - pendingBaseFee := misc.CalcBaseFee(pool.chainconfig, reset.newHead) - pool.priced.SetBaseFee(pendingBaseFee) + if reset.newHead != nil { + if pool.chainconfig.IsLondon(new(big.Int).Add(reset.newHead.Number, big.NewInt(1))) { + // london fork enabled, reset given the base fee + pendingBaseFee := misc.CalcBaseFee(pool.chainconfig, reset.newHead) + pool.priced.SetBaseFee(pendingBaseFee) + } else { + // london fork not enabled, reheap to "reset" the priced list + pool.priced.Reheap() + } } } // Ensure pool.queue and pool.pending sizes stay within the configured limits.