From c7133fe759e87e42dd979f3d4e03c34ce3ee5aa8 Mon Sep 17 00:00:00 2001 From: ywzqwwt <752252086@qq.com> Date: Wed, 20 Mar 2019 10:20:13 +0800 Subject: [PATCH 1/5] core/tx_pool.go update validateTx,if it is local,but price is 0,discard it. --- core/tx_pool.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/tx_pool.go b/core/tx_pool.go index 552d3692b381..144046524fd7 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -105,7 +105,7 @@ var ( type TxStatus uint const ( - TxStatusUnknown TxStatus = iota + TxStatusUnknown TxStatus = iota TxStatusQueued TxStatusPending TxStatusIncluded @@ -316,11 +316,11 @@ func (pool *TxPool) loop() { pool.mu.Unlock() } - // Be unsubscribed due to system stopped + // Be unsubscribed due to system stopped case <-pool.chainHeadSub.Err(): return - // Handle stats reporting ticks + // Handle stats reporting ticks case <-report.C: pool.mu.RLock() pending, queued := pool.stats() @@ -332,7 +332,7 @@ func (pool *TxPool) loop() { prevPending, prevQueued, prevStales = pending, queued, stales } - // Handle inactive account transaction eviction + // Handle inactive account transaction eviction case <-evict.C: pool.mu.Lock() for addr := range pool.queue { @@ -349,7 +349,7 @@ func (pool *TxPool) loop() { } pool.mu.Unlock() - // Handle local transaction journal rotation + // Handle local transaction journal rotation case <-journal.C: if pool.journal != nil { pool.mu.Lock() @@ -606,7 +606,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { } // Drop non-local transactions under our own minimal accepted gas price local = local || pool.locals.contains(from) // account may be local even if the transaction arrived from the network - if !local && pool.gasPrice.Cmp(tx.GasPrice()) > 0 { + if !local && pool.gasPrice.Cmp(tx.GasPrice()) > 0 || tx.GasPrice().Cmp(big.NewInt(0)) < 1 { return ErrUnderpriced } // Ensure the transaction adheres to nonce ordering From 46753d6ec9d178b922a596e34bdb5fb51b2126b1 Mon Sep 17 00:00:00 2001 From: ywzqwwt <752252086@qq.com> Date: Sat, 23 Mar 2019 10:57:46 +0800 Subject: [PATCH 2/5] core/blockchain.go: del checkpoint --- core/blockchain.go | 1 - 1 file changed, 1 deletion(-) diff --git a/core/blockchain.go b/core/blockchain.go index c4481588f993..a8563e9d76ff 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -118,7 +118,6 @@ type BlockChain struct { chainmu sync.RWMutex // blockchain insertion lock procmu sync.RWMutex // block processor lock - checkpoint int // checkpoint counts towards the new checkpoint currentBlock atomic.Value // Current head of the block chain currentFastBlock atomic.Value // Current head of the fast-sync chain (may be above the block chain!) From 7ce05405190b37dfed94889b183388816dd47f97 Mon Sep 17 00:00:00 2001 From: ywzqwwt <752252086@qq.com> Date: Fri, 28 Jun 2019 10:38:48 +0800 Subject: [PATCH 3/5] core/blockchain.go: remove block in futureBlocks --- core/blockchain.go | 1 + 1 file changed, 1 insertion(+) diff --git a/core/blockchain.go b/core/blockchain.go index a8563e9d76ff..bc4e5e106a8a 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1199,6 +1199,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, [] // Some other error occurred, abort case err != nil: + bc.futureBlocks.Remove(block.Hash()) stats.ignored += len(it.chain) bc.reportBlock(block, nil, err) return it.index, events, coalescedLogs, err From 8ee274962bda33db37e5abe53525687735392fc1 Mon Sep 17 00:00:00 2001 From: ywzqwwt <39263032+ywzqwwt@users.noreply.github.com> Date: Wed, 3 Jul 2019 11:20:14 +0800 Subject: [PATCH 4/5] Update tx_pool.go --- core/tx_pool.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/tx_pool.go b/core/tx_pool.go index 0a1d56c9174a..5d37fcffc085 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -110,7 +110,7 @@ var ( type TxStatus uint const ( - TxStatusUnknown TxStatus = iota + TxStatusUnknown TxStatus = iota TxStatusQueued TxStatusPending TxStatusIncluded @@ -327,13 +327,13 @@ func (pool *TxPool) loop() { pool.requestReset(head.Header(), ev.Block.Header()) head = ev.Block } - - // Be unsubscribed due to system stopped + + // System shutdown. case <-pool.chainHeadSub.Err(): close(pool.reorgShutdownCh) return - // Handle stats reporting ticks + // Handle stats reporting ticks case <-report.C: pool.mu.RLock() pending, queued := pool.stats() @@ -345,7 +345,7 @@ func (pool *TxPool) loop() { prevPending, prevQueued, prevStales = pending, queued, stales } - // Handle inactive account transaction eviction + // Handle inactive account transaction eviction case <-evict.C: pool.mu.Lock() for addr := range pool.queue { @@ -362,7 +362,7 @@ func (pool *TxPool) loop() { } pool.mu.Unlock() - // Handle local transaction journal rotation + // Handle local transaction journal rotation case <-journal.C: if pool.journal != nil { pool.mu.Lock() @@ -526,7 +526,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { } // Drop non-local transactions under our own minimal accepted gas price local = local || pool.locals.contains(from) // account may be local even if the transaction arrived from the network - if !local && pool.gasPrice.Cmp(tx.GasPrice()) > 0 || tx.GasPrice().Cmp(big.NewInt(0)) < 1 { + if !local && pool.gasPrice.Cmp(tx.GasPrice()) > 0 { return ErrUnderpriced } // Ensure the transaction adheres to nonce ordering From 4ffe88ccfca00fd846c1c9a7934f3d09e3f20a6a Mon Sep 17 00:00:00 2001 From: ywzqwwt <39263032+ywzqwwt@users.noreply.github.com> Date: Wed, 3 Jul 2019 11:47:10 +0800 Subject: [PATCH 5/5] Update tx_pool.go