From 46ec972c9c56a4e0d97d812f2eaf9e3657c66276 Mon Sep 17 00:00:00 2001 From: jin <35813306+lochjin@users.noreply.github.com> Date: Mon, 19 Jun 2023 04:43:53 +0800 Subject: [PATCH] core/txpool/legacypool: reheap the tx list if london fork not enabled (#27481) This change ensures Reheap will be called even before the London fork activates. Since Reheap would otherwise only be called through `SetBaseFee` after London, the list would just keep growing if the fork was not enabled or not reached yet. --- core/txpool/legacypool/legacypool.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index 3525747c72de9..fc6fc43bdd101 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -1206,9 +1206,13 @@ func (pool *LegacyPool) runReorg(done chan struct{}, reset *txpoolResetRequest, // 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))) { + pendingBaseFee := misc.CalcBaseFee(pool.chainconfig, reset.newHead) + pool.priced.SetBaseFee(pendingBaseFee) + } else { + pool.priced.Reheap() + } } // Update all accounts to the latest known pending nonce nonces := make(map[common.Address]uint64, len(pool.pending))