Skip to content

Commit

Permalink
core: improve the network stability when double sign happens (#2596)
Browse files Browse the repository at this point in the history
  • Loading branch information
buddh0 authored Jul 22, 2024
1 parent 3cade73 commit b844958
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/forkchoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,12 @@ func (f *ForkChoice) ReorgNeeded(current *types.Header, extern *types.Header) (b
if f.preserve != nil {
currentPreserve, externPreserve = f.preserve(current), f.preserve(extern)
}
doubleSign := (extern.Coinbase == current.Coinbase)
reorg = !currentPreserve && (externPreserve ||
extern.Time < current.Time ||
extern.Time == current.Time && f.rand.Float64() < 0.5)
extern.Time == current.Time &&
((doubleSign && extern.Hash().Cmp(current.Hash()) < 0) ||
(!doubleSign && f.rand.Float64() < 0.5)))
}
return reorg, nil
}
Expand Down

0 comments on commit b844958

Please sign in to comment.