diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-03-28 18:24:46 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-15 22:09:55 +0800 |
commit | 41193d921118b4bdef5f0a1a5b7349a4c58abe94 (patch) | |
tree | f5a274c3d007810064e3ed65e6e52390fb93669e /vendor/github.com | |
parent | 4efc1cf485200000420bd79638139eb5383641ae (diff) | |
download | go-tangerine-41193d921118b4bdef5f0a1a5b7349a4c58abe94.tar.gz go-tangerine-41193d921118b4bdef5f0a1a5b7349a4c58abe94.tar.zst go-tangerine-41193d921118b4bdef5f0a1a5b7349a4c58abe94.zip |
vendor: sync to latest core
Diffstat (limited to 'vendor/github.com')
5 files changed, 39 insertions, 11 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go index 979045223..7006242b1 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go @@ -199,6 +199,11 @@ func (mgr *agreementMgr) notifyRoundEvents(evts []utils.RoundEventParam) error { if len(mgr.configs) > 0 { lastCfg := mgr.configs[len(mgr.configs)-1] if e.BeginHeight != lastCfg.RoundEndHeight() { + // the init config of BA part is provided when constructing. + if len(mgr.configs) == 1 && + e.BeginHeight == lastCfg.LastPeriodBeginHeight() { + return nil + } return ErrInvalidBlockHeight } if lastCfg.RoundID() == e.Round { diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement.go index d4f1bbd0c..6727ecbee 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement.go @@ -171,6 +171,8 @@ func (a *agreement) restart( return false } } + a.logger.Debug("Restarting BA", + "notarySet", notarySet, "position", aID, "leader", leader) a.data.lock.Lock() defer a.data.lock.Unlock() a.data.blocksLock.Lock() diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go index 4a95eac6f..6d0f68377 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go @@ -390,14 +390,17 @@ CleanChannelLoop: } } newPos := block.Position - if block.Position.Height+1 == recv.changeNotaryHeight() { + 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)) @@ -733,7 +736,12 @@ func newConsensusForRound( } baConfig := agreementMgrConfig{} baConfig.from(initRound, initConfig, initCRS) - baConfig.SetRoundBeginHeight(gov.GetRoundHeight(initRound)) + // TODO(jimmy): remove -1 after we match the height with fullnode. + roundHeight := gov.GetRoundHeight(initRound) + if initRound > 0 { + roundHeight-- + } + baConfig.SetRoundBeginHeight(roundHeight) con.baMgr, err = newAgreementMgr(con, baConfig) if err != nil { panic(err) @@ -804,15 +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. - if evts[len(evts)-1].BeginHeight != con.gov.GetRoundHeight(initRound) { - 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 diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/node.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/node.go index 2c90f65c8..18b6831e0 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/node.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/node.go @@ -19,6 +19,7 @@ package types import ( "bytes" + "encoding/hex" "github.com/dexon-foundation/dexon-consensus/common" "github.com/dexon-foundation/dexon-consensus/core/crypto" @@ -40,6 +41,10 @@ func (v NodeID) Equal(v2 NodeID) bool { return v.Hash == v2.Hash } +func (v NodeID) String() string { + return hex.EncodeToString(v.Hash[:])[:6] +} + // NodeIDs implements sort.Interface for NodeID. type NodeIDs []NodeID diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/round-event.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/round-event.go index 885c755f7..0e70cf250 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/round-event.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/round-event.go @@ -92,6 +92,11 @@ func (e RoundEventParam) NextDKGRegisterHeight() uint64 { return e.BeginHeight + e.Config.RoundLength/2 } +// RoundEndHeight returns the round ending height of this round event. +func (e RoundEventParam) RoundEndHeight() uint64 { + return e.BeginHeight + e.Config.RoundLength +} + func (e RoundEventParam) String() string { return fmt.Sprintf("roundEvtParam{Round:%d Reset:%d Height:%d}", e.Round, @@ -179,7 +184,12 @@ func NewRoundEvent(parentCtx context.Context, gov governanceAccessor, e.ctx, e.ctxCancel = context.WithCancel(parentCtx) e.config = RoundBasedConfig{} e.config.SetupRoundBasedFields(initRound, initConfig) - e.config.SetRoundBeginHeight(gov.GetRoundHeight(initRound)) + // TODO(jimmy): remove -1 after we match the height with fullnode. + roundHeight := gov.GetRoundHeight(initRound) + if initRound != 0 { + roundHeight-- + } + e.config.SetRoundBeginHeight(roundHeight) // Make sure the DKG reset count in current governance can cover the initial // block height. resetCount := gov.DKGResetCount(initRound + 1) |