Skip to content

Commit

Permalink
miner: keep update pending state even the Merge is happened
Browse files Browse the repository at this point in the history
  • Loading branch information
rjl493456442 committed Jan 5, 2022
1 parent 4b9ad92 commit 7574518
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions miner/worker.go
Expand Up @@ -1130,26 +1130,24 @@ func (w *worker) commit(env *environment, interval func(), update bool, start ti
if interval != nil {
interval()
}
// Deep copy receipts here to avoid interaction between different tasks.
block, err := w.engine.FinalizeAndAssemble(w.chain, env.header, env.state, env.txs, env.unclelist(), env.receipts)
if err != nil {
return err
}
// If we're post merge, just ignore
// Send the sealing task only if the merge is not happened yet.
td, ttd := w.chain.GetTd(block.ParentHash(), block.NumberU64()-1), w.chain.Config().TerminalTotalDifficulty
if td != nil && ttd != nil && td.Cmp(ttd) >= 0 {
return nil
}
select {
case w.taskCh <- &task{receipts: env.receipts, state: env.state, block: block, createdAt: time.Now()}:
w.unconfirmed.Shift(block.NumberU64() - 1)
log.Info("Commit new sealing work", "number", block.Number(), "sealhash", w.engine.SealHash(block.Header()),
"uncles", len(env.uncles), "txs", env.tcount,
"gas", block.GasUsed(), "fees", totalFees(block, env.receipts),
"elapsed", common.PrettyDuration(time.Since(start)))

case <-w.exitCh:
log.Info("Worker has exited")
if !(td != nil && ttd != nil && td.Cmp(ttd) >= 0) {
select {
case w.taskCh <- &task{receipts: env.receipts, state: env.state, block: block, createdAt: time.Now()}:
w.unconfirmed.Shift(block.NumberU64() - 1)
log.Info("Commit new sealing work", "number", block.Number(), "sealhash", w.engine.SealHash(block.Header()),
"uncles", len(env.uncles), "txs", env.tcount,
"gas", block.GasUsed(), "fees", totalFees(block, env.receipts),
"elapsed", common.PrettyDuration(time.Since(start)))

case <-w.exitCh:
log.Info("Worker has exited")
}
}
}
if update {
Expand Down

0 comments on commit 7574518

Please sign in to comment.