Skip to content

Commit 9584f56

Browse files
authored
miner: avoid sleeping in miner (ethereum#22108)
This PR removes a logic in the miner, which was originally intended to help temporary testnets based on ethash from "running off into the future". If the difficulty was low, and a few computers started mining several blocks per second, the ethash rules (which demand 1s delay between blocks) would push the blocktimes further and further away. The solution was to make the miner sleep while this happened. Nowadays, this problem is solved instead by PoA chains, and it's recommended to let testnets and devnets be based on clique instead. The existing logic is problematic, since it can cause stalls within the miner making it difficult for remote workers to submit work if the channel is blocked on a sleep. Credits to Saar Tochner for reporting this via the bug bounty
1 parent 6ada9f0 commit 9584f56

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

miner/worker.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -861,13 +861,6 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64)
861861
if parent.Time() >= uint64(timestamp) {
862862
timestamp = int64(parent.Time() + 1)
863863
}
864-
// this will ensure we're not going off too far in the future
865-
if now := time.Now().Unix(); timestamp > now+1 {
866-
wait := time.Duration(timestamp-now) * time.Second
867-
log.Info("Mining too far in the future", "wait", common.PrettyDuration(wait))
868-
time.Sleep(wait)
869-
}
870-
871864
num := parent.Number()
872865
header := &types.Header{
873866
ParentHash: parent.Hash(),

0 commit comments

Comments
 (0)