consensus: check current chain height before processing timer
The chain may already be more current than our dBFT state (like when the node has commited something at view 0, but all the other nodes changed view and accepted something at view 1), so in this case we should reinit dBFT on new height.
This commit is contained in:
parent
e65b5c9914
commit
9ceefe17e2
1 changed files with 8 additions and 1 deletions
|
@ -168,7 +168,14 @@ func (s *service) eventLoop() {
|
|||
s.log.Debug("timer fired",
|
||||
zap.Uint32("height", hv.Height),
|
||||
zap.Uint("view", uint(hv.View)))
|
||||
s.dbft.OnTimeout(hv)
|
||||
if s.Chain.BlockHeight() >= s.dbft.BlockIndex {
|
||||
s.log.Debug("chain already advanced",
|
||||
zap.Uint32("dbft index", s.dbft.BlockIndex),
|
||||
zap.Uint32("chain index", s.Chain.BlockHeight()))
|
||||
s.dbft.InitializeConsensus(0)
|
||||
} else {
|
||||
s.dbft.OnTimeout(hv)
|
||||
}
|
||||
case msg := <-s.messages:
|
||||
fields := []zap.Field{
|
||||
zap.Uint16("from", msg.validatorIndex),
|
||||
|
|
Loading…
Reference in a new issue