diff options
author | Mission Liao <mission.liao@dexon.org> | 2019-03-28 14:03:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-28 14:03:12 +0800 |
commit | e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161 (patch) | |
tree | b753090b8ee723b17ca8afb30106dc9229304397 /core/consensus.go | |
parent | a8b01422da4a66cf2844012c89d46a7d22ac1664 (diff) | |
download | dexon-consensus-e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161.tar dexon-consensus-e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161.tar.gz dexon-consensus-e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161.tar.bz2 dexon-consensus-e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161.tar.lz dexon-consensus-e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161.tar.xz dexon-consensus-e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161.tar.zst dexon-consensus-e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161.zip |
core: fix issues (#525)
* Refine the logic to append config
* Potential fix for round not increase when fast syncing
Diffstat (limited to 'core/consensus.go')
-rw-r--r-- | core/consensus.go | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/core/consensus.go b/core/consensus.go index 4e01860..6d0f683 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -390,15 +390,17 @@ CleanChannelLoop: } } newPos := block.Position - if block.Position.Height+1 == recv.changeNotaryHeight() { - recv.consensus.logger.Info("Round will change", "block", block) + changeNotaryHeight := recv.changeNotaryHeight() + if block.Position.Height+1 >= changeNotaryHeight { + recv.consensus.logger.Info("Round will change", + "block", block, + "change-height", changeNotaryHeight) newPos.Round++ recv.updateRound(newPos.Round) } currentRound := recv.round() - changeNotaryHeight := recv.changeNotaryHeight() if block.Position.Height > changeNotaryHeight && - block.Position.Round <= currentRound { + block.Position.Round < currentRound { panic(fmt.Errorf( "round not switch when confirming: %s, %d, should switch at %d, %s", block, currentRound, changeNotaryHeight, newPos)) @@ -810,20 +812,13 @@ func (con *Consensus) prepare(initBlock *types.Block) (err error) { // Register round event handler to update BA and BC modules. con.roundEvent.Register(func(evts []utils.RoundEventParam) { defer elapse("append-config", evts[len(evts)-1])() - // Always updates newer configs to the later modules first in the flow. + // Always updates newer configs to the later modules first in the data + // flow. if err := con.bcModule.notifyRoundEvents(evts); err != nil { panic(err) } - // The init config is provided to baModule when construction. - // TODO(jimmy): remove -1 after we match the height with fullnode. - roundHeight := con.gov.GetRoundHeight(initRound) - if initRound > 0 { - roundHeight-- - } - if evts[len(evts)-1].BeginHeight != roundHeight { - if err := con.baMgr.notifyRoundEvents(evts); err != nil { - panic(err) - } + if err := con.baMgr.notifyRoundEvents(evts); err != nil { + panic(err) } }) // Register round event handler to reset DKG if the DKG set for next round |