[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).
This commit is contained in:
Jerry 2024-02-27 22:32:03 -08:00 committed by Manav Darji
parent cb23b9baa3
commit 199eca46eb

View file

@ -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"