Skip to content

Commit 045bbce

Browse files
committed
Fix flashbots miners not correctly handling reorgs
1 parent 64cbf24 commit 045bbce

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

miner/worker.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,8 @@ func (w *worker) taskLoop() {
570570
stopCh chan struct{}
571571
prev common.Hash
572572

573-
prevNumber *big.Int
574-
prevProfit *big.Int
573+
prevParentHash common.Hash
574+
prevProfit *big.Int
575575
)
576576

577577
// interrupt aborts the in-flight sealing task.
@@ -593,17 +593,19 @@ func (w *worker) taskLoop() {
593593
continue
594594
}
595595

596+
taskParentHash := task.block.Header().ParentHash
596597
// reject new tasks which don't profit
597-
if prevNumber != nil && prevProfit != nil &&
598-
task.block.Number().Cmp(prevNumber) == 0 && task.profit.Cmp(prevProfit) < 0 {
598+
if taskParentHash == prevParentHash &&
599+
prevProfit != nil && task.profit.Cmp(prevProfit) < 0 {
599600
continue
600601
}
601-
prevNumber, prevProfit = task.block.Number(), task.profit
602+
prevParentHash = taskParentHash
603+
prevProfit = task.profit
602604

603605
// Interrupt previous sealing operation
604606
interrupt()
605607
stopCh, prev = make(chan struct{}), sealHash
606-
log.Info("Proposed miner block", "blockNumber", prevNumber, "profit", prevProfit, "isFlashbots", task.isFlashbots, "sealhash", sealHash)
608+
log.Info("Proposed miner block", "blockNumber", task.block.Number(), "profit", prevProfit, "isFlashbots", task.isFlashbots, "sealhash", sealHash, "parentHash", prevParentHash)
607609
if w.skipSealHook != nil && w.skipSealHook(task) {
608610
continue
609611
}

0 commit comments

Comments
 (0)