diff options
Diffstat (limited to 'vendor')
6 files changed, 62 insertions, 34 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) diff --git a/vendor/vendor.json b/vendor/vendor.json index 7c3c37469..e662a5591 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -141,16 +141,16 @@ { "checksumSHA1": "8EuKVkP1v/w5fRuuvUaXX5k/F+I=", "path": "github.com/dexon-foundation/dexon-consensus/common", - "revision": "e41fcf0bb3f5fe6d473ef2056b6143b92c65faf3", - "revisionTime": "2019-03-27T10:11:57Z", + "revision": "e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161", + "revisionTime": "2019-03-28T06:03:12Z", "version": "single-chain", "versionExact": "single-chain" }, { - "checksumSHA1": "BXM+kUVDhV8uQt0MuE9mwdHNB2c=", + "checksumSHA1": "rjRAq7PMnUJK1vwh9MZrlHpq5Bc=", "path": "github.com/dexon-foundation/dexon-consensus/core", - "revision": "e41fcf0bb3f5fe6d473ef2056b6143b92c65faf3", - "revisionTime": "2019-03-27T10:11:57Z", + "revision": "e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161", + "revisionTime": "2019-03-28T06:03:12Z", "version": "single-chain", "versionExact": "single-chain" }, @@ -165,64 +165,64 @@ { "checksumSHA1": "tQSbYCu5P00lUhKsx3IbBZCuSLY=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto", - "revision": "e41fcf0bb3f5fe6d473ef2056b6143b92c65faf3", - "revisionTime": "2019-03-27T10:11:57Z", + "revision": "e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161", + "revisionTime": "2019-03-28T06:03:12Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "mMdctxTa/jNwAwZjjYoyEZdLoF8=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto/dkg", - "revision": "e41fcf0bb3f5fe6d473ef2056b6143b92c65faf3", - "revisionTime": "2019-03-27T10:11:57Z", + "revision": "e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161", + "revisionTime": "2019-03-28T06:03:12Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "BhLKK8RveoLaeXc9UyUKMwQqchU=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto/ecdsa", - "revision": "e41fcf0bb3f5fe6d473ef2056b6143b92c65faf3", - "revisionTime": "2019-03-27T10:11:57Z", + "revision": "e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161", + "revisionTime": "2019-03-28T06:03:12Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "b99zZvbWvBimv1NiPGGF1yQ4dKY=", "path": "github.com/dexon-foundation/dexon-consensus/core/db", - "revision": "e41fcf0bb3f5fe6d473ef2056b6143b92c65faf3", - "revisionTime": "2019-03-27T10:11:57Z", + "revision": "e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161", + "revisionTime": "2019-03-28T06:03:12Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "+k6JeUI7CGgSK6aQBV5l3d9/YaE=", "path": "github.com/dexon-foundation/dexon-consensus/core/syncer", - "revision": "e41fcf0bb3f5fe6d473ef2056b6143b92c65faf3", - "revisionTime": "2019-03-27T10:11:57Z", + "revision": "e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161", + "revisionTime": "2019-03-28T06:03:12Z", "version": "single-chain", "versionExact": "single-chain" }, { - "checksumSHA1": "/Dys3UcnQ3w8Yc9YzN0GAVXFwwQ=", + "checksumSHA1": "YhUsUJjNHitRb/ZdxEaXCClMyxc=", "path": "github.com/dexon-foundation/dexon-consensus/core/types", - "revision": "e41fcf0bb3f5fe6d473ef2056b6143b92c65faf3", - "revisionTime": "2019-03-27T10:11:57Z", + "revision": "e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161", + "revisionTime": "2019-03-28T06:03:12Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "yoVRmvJDCp/1jSfY7wMt2LBQ9e8=", "path": "github.com/dexon-foundation/dexon-consensus/core/types/dkg", - "revision": "e41fcf0bb3f5fe6d473ef2056b6143b92c65faf3", - "revisionTime": "2019-03-27T10:11:57Z", + "revision": "e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161", + "revisionTime": "2019-03-28T06:03:12Z", "version": "single-chain", "versionExact": "single-chain" }, { - "checksumSHA1": "hZq/A+YpLzTjL+cCsIly+qZiEfM=", + "checksumSHA1": "Dp0qf81zYP7qV81x3wYh+5oSzgI=", "path": "github.com/dexon-foundation/dexon-consensus/core/utils", - "revision": "e41fcf0bb3f5fe6d473ef2056b6143b92c65faf3", - "revisionTime": "2019-03-27T10:11:57Z", + "revision": "e3e7f4fbd840819b1ef44ae2c345f64e0bb2c161", + "revisionTime": "2019-03-28T06:03:12Z", "version": "single-chain", "versionExact": "single-chain" }, |