Commit c753ba81 authored by Conner Fromknecht's avatar Conner Fromknecht

fix: correct txcount used for deadlock detection

This commit fixes a bug in the way txCount was used for detecting and
aborting empty blocks. Previously, txCount was incremented immediately
after popping off the new transaction but before it is executed. This
was incorrect, as the transaction can still be rejected for nonce/gas
errors later on. Instead, we modify the logic only count transactions
that are successfully added, and utilize the existing w.current.tcount
member to implement the detection.
parent 0b0b86c8
...@@ -783,11 +783,6 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin ...@@ -783,11 +783,6 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin
} }
var coalescedLogs []*types.Log var coalescedLogs []*types.Log
// UsingOVM
// Keep track of the number of transactions being added to the block.
// Blocks should only have a single transaction. This value is used to
// compute a success return value
var txCount int
for { for {
// In the following three cases, we will interrupt the execution of the transaction. // In the following three cases, we will interrupt the execution of the transaction.
...@@ -808,7 +803,7 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin ...@@ -808,7 +803,7 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin
inc: true, inc: true,
} }
} }
return atomic.LoadInt32(interrupt) == commitInterruptNewHead return w.current.tcount == 0 || atomic.LoadInt32(interrupt) == commitInterruptNewHead
} }
// If we don't have enough gas for any further transactions then we're done // If we don't have enough gas for any further transactions then we're done
if w.current.gasPool.Gas() < params.TxGas { if w.current.gasPool.Gas() < params.TxGas {
...@@ -821,8 +816,6 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin ...@@ -821,8 +816,6 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin
break break
} }
txCount++
// Error may be ignored here. The error has already been checked // Error may be ignored here. The error has already been checked
// during transaction acceptance is the transaction pool. // during transaction acceptance is the transaction pool.
// //
...@@ -890,7 +883,7 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin ...@@ -890,7 +883,7 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin
if interrupt != nil { if interrupt != nil {
w.resubmitAdjustCh <- &intervalAdjust{inc: false} w.resubmitAdjustCh <- &intervalAdjust{inc: false}
} }
return txCount == 0 return w.current.tcount == 0
} }
// commitNewTx is an OVM addition that mines a block with a single tx in it. // commitNewTx is an OVM addition that mines a block with a single tx in it.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment