From ab0d224c731d90b4985f5cd85e3ed1e97447fe4d Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 31 Oct 2023 10:17:11 +0100 Subject: [PATCH] miner: only fill the pending block pre-merge --- miner/worker.go | 56 ++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index f680702814..2b4714f0ca 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1068,35 +1068,39 @@ func (w *worker) commitWork(interrupt *atomic.Int32, timestamp int64) { if err != nil { return } - // Fill pending transactions from the txpool into the block. - err = w.fillTransactions(interrupt, work) - switch { - case err == nil: - // The entire block is filled, decrease resubmit interval in case - // of current interval is larger than the user-specified one. - w.resubmitAdjustCh <- &intervalAdjust{inc: false} + // Don't fill the pending block post-merge + if !w.chainConfig.TerminalTotalDifficultyPassed { + // Fill pending transactions from the txpool into the block. + err = w.fillTransactions(interrupt, work) + switch { + case err == nil: + // The entire block is filled, decrease resubmit interval in case + // of current interval is larger than the user-specified one. + w.resubmitAdjustCh <- &intervalAdjust{inc: false} - case errors.Is(err, errBlockInterruptedByRecommit): - // Notify resubmit loop to increase resubmitting interval if the - // interruption is due to frequent commits. - gaslimit := work.header.GasLimit - ratio := float64(gaslimit-work.gasPool.Gas()) / float64(gaslimit) - if ratio < 0.1 { - ratio = 0.1 - } - w.resubmitAdjustCh <- &intervalAdjust{ - ratio: ratio, - inc: true, - } + case errors.Is(err, errBlockInterruptedByRecommit): + // Notify resubmit loop to increase resubmitting interval if the + // interruption is due to frequent commits. + gaslimit := work.header.GasLimit + ratio := float64(gaslimit-work.gasPool.Gas()) / float64(gaslimit) + if ratio < 0.1 { + ratio = 0.1 + } + w.resubmitAdjustCh <- &intervalAdjust{ + ratio: ratio, + inc: true, + } - case errors.Is(err, errBlockInterruptedByNewHead): - // If the block building is interrupted by newhead event, discard it - // totally. Committing the interrupted block introduces unnecessary - // delay, and possibly causes miner to mine on the previous head, - // which could result in higher uncle rate. - work.discard() - return + case errors.Is(err, errBlockInterruptedByNewHead): + // If the block building is interrupted by newhead event, discard it + // totally. Committing the interrupted block introduces unnecessary + // delay, and possibly causes miner to mine on the previous head, + // which could result in higher uncle rate. + work.discard() + return + } } + // Submit the generated block for consensus sealing. w.commit(work.copy(), w.fullTaskHook, true, start)