aboutsummaryrefslogtreecommitdiffstats
path: root/miner/worker.go
diff options
context:
space:
mode:
authorbas-vk <bas-vk@users.noreply.github.com>2016-12-11 06:54:58 +0800
committerFelix Lange <fjl@users.noreply.github.com>2016-12-11 06:54:58 +0800
commit4e36b1e3dadda62a53e309a1b6cf7aed97ea7a3a (patch)
treecf54f3d14e4ac9f177b6951f92f898d8c7c9a744 /miner/worker.go
parent0fe35b907addf1c066cb4d7c717bb23f9f2e7be4 (diff)
downloadgo-tangerine-4e36b1e3dadda62a53e309a1b6cf7aed97ea7a3a.tar.gz
go-tangerine-4e36b1e3dadda62a53e309a1b6cf7aed97ea7a3a.tar.zst
go-tangerine-4e36b1e3dadda62a53e309a1b6cf7aed97ea7a3a.zip
core: bugfix state change race condition in txpool (#3412)
The transaction pool keeps track of the current nonce in its local pendingState. When a new block comes in the pendingState is reset. During the reset it fetches multiple times the current state through the use of the currentState callback. When a second block comes in during the reset its possible that the state changes during the reset. If that block holds transactions that are currently in the pool the local pendingState that is used to determine nonces can get out of sync.
Diffstat (limited to 'miner/worker.go')
-rw-r--r--miner/worker.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/miner/worker.go b/miner/worker.go
index edbd502c1..5fa7c4115 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -519,7 +519,14 @@ func (self *worker) commitNewWork() {
if self.config.DAOForkSupport && self.config.DAOForkBlock != nil && self.config.DAOForkBlock.Cmp(header.Number) == 0 {
core.ApplyDAOHardFork(work.state)
}
- txs := types.NewTransactionsByPriceAndNonce(self.eth.TxPool().Pending())
+
+ pending, err := self.eth.TxPool().Pending()
+ if err != nil {
+ glog.Errorf("Could not fetch pending transactions: %v", err)
+ return
+ }
+
+ txs := types.NewTransactionsByPriceAndNonce(pending)
work.commitTransactions(self.mux, txs, self.gasPrice, self.chain)
self.eth.TxPool().RemoveBatch(work.lowGasTxs)