Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Fix flashbots miners not correctly handling reorgs
Browse files Browse the repository at this point in the history
  • Loading branch information
jparyani authored and frostRed committed Aug 16, 2021
1 parent 292221c commit ef1f9f2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,8 @@ func (w *worker) taskLoop() {
stopCh chan struct{}
prev common.Hash

prevNumber *big.Int
prevProfit *big.Int
prevParentHash common.Hash
prevProfit *big.Int
)

// interrupt aborts the in-flight sealing task.
Expand All @@ -608,17 +608,19 @@ func (w *worker) taskLoop() {
continue
}

taskParentHash := task.block.Header().ParentHash
// reject new tasks which don't profit
if prevNumber != nil && prevProfit != nil &&
task.block.Number().Cmp(prevNumber) == 0 && task.profit.Cmp(prevProfit) < 0 {
if taskParentHash == prevParentHash &&
prevProfit != nil && task.profit.Cmp(prevProfit) < 0 {
continue
}
prevNumber, prevProfit = task.block.Number(), task.profit
prevParentHash = taskParentHash
prevProfit = task.profit

// Interrupt previous sealing operation
interrupt()
stopCh, prev = make(chan struct{}), sealHash
log.Info("Proposed miner block", "blockNumber", prevNumber, "profit", prevProfit, "isFlashbots", task.isFlashbots, "sealhash", sealHash)
log.Info("Proposed miner block", "blockNumber", task.block.Number(), "profit", prevProfit, "isFlashbots", task.isFlashbots, "sealhash", sealHash, "parentHash", prevParentHash)
if w.skipSealHook != nil && w.skipSealHook(task) {
continue
}
Expand Down

0 comments on commit ef1f9f2

Please sign in to comment.