From 199eca46ebd932f196cdcb42885207eb0cc22622 Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 27 Feb 2024 22:32:03 -0800 Subject: [PATCH] [Bug fix] Re-prioritize commit interrupts (#1170) This change will check commit interrupt signal coming from other channels, e.g. newHead, reSubmit, before checking transaction level interrupt. This is to fix a corner case where an interrupt signal coming from another channel getting intercepted by transaction level interrupt, which resulted in an uncleaned state (potentially deadlock). --- miner/worker.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index 0e1dd83691..b3815ac2eb 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -955,6 +955,14 @@ func (w *worker) commitTransactions(env *environment, txs *transactionsByPriceAn mainloop: for { + // Check interruption signal and abort building if it's fired. + if interrupt != nil { + if signal := interrupt.Load(); signal != commitInterruptNone { + breakCause = "interrupt" + return signalToErr(signal) + } + } + if interruptCtx != nil { if EnableMVHashMap && w.IsRunning() { env.state.AddEmptyMVHashMap() @@ -970,13 +978,6 @@ mainloop: } } - // Check interruption signal and abort building if it's fired. - if interrupt != nil { - if signal := interrupt.Load(); signal != commitInterruptNone { - breakCause = "interrupt" - return signalToErr(signal) - } - } // If we don't have enough gas for any further transactions then we're done. if env.gasPool.Gas() < params.TxGas { breakCause = "Not enough gas for further transactions"