diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-04-19 13:53:20 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-15 22:09:56 +0800 |
commit | 8e1194d60b89df925b7d5b53395d0949df4bd4f8 (patch) | |
tree | 760146083586068d791ce84a1fe6951c62595345 | |
parent | 3f433c2137aaf4cd972009cf61bf325f6a1ad2d3 (diff) | |
download | go-tangerine-8e1194d60b89df925b7d5b53395d0949df4bd4f8.tar go-tangerine-8e1194d60b89df925b7d5b53395d0949df4bd4f8.tar.gz go-tangerine-8e1194d60b89df925b7d5b53395d0949df4bd4f8.tar.bz2 go-tangerine-8e1194d60b89df925b7d5b53395d0949df4bd4f8.tar.lz go-tangerine-8e1194d60b89df925b7d5b53395d0949df4bd4f8.tar.xz go-tangerine-8e1194d60b89df925b7d5b53395d0949df4bd4f8.tar.zst go-tangerine-8e1194d60b89df925b7d5b53395d0949df4bd4f8.zip |
vendor: sync to latest core
4 files changed, 73 insertions, 75 deletions
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 e7449c222..3443c9676 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go @@ -820,40 +820,9 @@ func (con *Consensus) prepare(initBlock *types.Block) (err error) { if _, exist := curNotarySet[con.ID]; !exist { return } - isDKGValid := func() bool { - nextConfig := utils.GetConfigWithPanic(con.gov, nextRound, - con.logger) - if !con.gov.IsDKGFinal(nextRound) { - con.logger.Error("Next DKG is not final, reset it", - "round", e.Round, - "reset", e.Reset) - return false - } - if !con.gov.IsDKGSuccess(nextRound) { - con.logger.Error("Next DKG is not success, reset it", - "round", e.Round, - "reset", e.Reset) - return false - } - gpk, err := typesDKG.NewGroupPublicKey( - nextRound, - con.gov.DKGMasterPublicKeys(nextRound), - con.gov.DKGComplaints(nextRound), - utils.GetDKGThreshold(nextConfig)) - if err != nil { - con.logger.Error("Next DKG failed to prepare, reset it", - "round", e.Round, - "reset", e.Reset, - "error", err) - return false - } - if len(gpk.QualifyNodeIDs) < utils.GetDKGValidThreshold(nextConfig) { - return false - } - return true - } con.event.RegisterHeight(e.NextDKGResetHeight(), func(uint64) { - if isDKGValid() { + if ok, _ := utils.IsDKGValid( + con.gov, con.logger, nextRound, e.Reset); ok { return } // Aborting all previous running DKG protocol instance if any. 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 b1d4d230e..bda4383fa 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 @@ -127,6 +127,9 @@ type governanceAccessor interface { // IsDKGFinal checks if DKG is final. IsDKGFinal(round uint64) bool + // IsDKGSuccess checks if DKG is success. + IsDKGSuccess(round uint64) bool + // DKGResetCount returns the reset count for DKG of given round. DKGResetCount(round uint64) uint64 @@ -162,7 +165,7 @@ type RoundEvent struct { lastTriggeredRound uint64 lastTriggeredResetCount uint64 roundShift uint64 - dkgFailed bool + gpkInvalid bool ctx context.Context ctxCancel context.CancelFunc } @@ -309,40 +312,28 @@ func (e *RoundEvent) check(blockHeight, startRound uint64) ( if resetCount > e.lastTriggeredResetCount { e.lastTriggeredResetCount++ e.config.ExtendLength() - e.dkgFailed = false + e.gpkInvalid = false triggered = true return } - if e.dkgFailed { + if e.gpkInvalid { // We know that DKG already failed, now wait for the DKG set from // previous round to reset DKG and don't have to reconstruct the // group public key again. return } if nextRound >= dkgDelayRound { - if !e.gov.IsDKGFinal(nextRound) { - e.logger.Debug("DKG is not final, waiting for DKG reset", - "round", nextRound, - "reset", e.lastTriggeredResetCount) - return - } - if _, err := typesDKG.NewGroupPublicKey( - nextRound, - e.gov.DKGMasterPublicKeys(nextRound), - e.gov.DKGComplaints(nextRound), - GetDKGThreshold(nextCfg)); err != nil { - e.logger.Debug( - "Group public key setup failed, waiting for DKG reset", - "round", nextRound, - "reset", e.lastTriggeredResetCount) - e.dkgFailed = true + var ok bool + ok, e.gpkInvalid = IsDKGValid( + e.gov, e.logger, nextRound, e.lastTriggeredResetCount) + if !ok { return } } // The DKG set for next round is well prepared. e.lastTriggeredRound = nextRound e.lastTriggeredResetCount = 0 - e.dkgFailed = false + e.gpkInvalid = false rCfg := RoundBasedConfig{} rCfg.SetupRoundBasedFields(nextRound, nextCfg) rCfg.AppendTo(e.config) diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/utils.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/utils.go index dc29bdfa5..f259f34bb 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/utils.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/utils.go @@ -167,3 +167,41 @@ func GetRoundHeight(accessor interface{}, round uint64) uint64 { } return height } + +// IsDKGValid check if DKG is correctly prepared. +func IsDKGValid( + gov governanceAccessor, logger common.Logger, round, reset uint64) ( + valid bool, gpkInvalid bool) { + if !gov.IsDKGFinal(round) { + logger.Debug("DKG is not final", "round", round, "reset", reset) + return + } + if !gov.IsDKGSuccess(round) { + logger.Debug("DKG is not successful", "round", round, "reset", reset) + return + } + cfg := GetConfigWithPanic(gov, round, logger) + gpk, err := typesDKG.NewGroupPublicKey( + round, + gov.DKGMasterPublicKeys(round), + gov.DKGComplaints(round), + GetDKGThreshold(cfg)) + if err != nil { + logger.Debug("Group public key setup failed", + "round", round, + "reset", reset, + "error", err) + gpkInvalid = true + return + } + if len(gpk.QualifyNodeIDs) < GetDKGValidThreshold(cfg) { + logger.Debug("Group public key threshold not reach", + "round", round, + "reset", reset, + "qualified", len(gpk.QualifyNodeIDs)) + gpkInvalid = true + return + } + valid = true + return +} diff --git a/vendor/vendor.json b/vendor/vendor.json index 5d97bb491..68bf4c6d8 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -141,16 +141,16 @@ { "checksumSHA1": "In6vBHYUsX7DUIGiFN2hQggBgvI=", "path": "github.com/dexon-foundation/dexon-consensus/common", - "revision": "ccba7be9105c01eba0617e5ec0a791436200a132", - "revisionTime": "2019-04-15T10:50:35Z", + "revision": "6ab10aadc24193b1366bb1f048b92c1a6aec4861", + "revisionTime": "2019-04-19T04:03:31Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "Uc+4k6fJSR3wZ4R4gZBnoBrZHq8=", + "checksumSHA1": "m2MgY+DBrYg0nQykXcGbfhbZi0s=", "path": "github.com/dexon-foundation/dexon-consensus/core", - "revision": "ccba7be9105c01eba0617e5ec0a791436200a132", - "revisionTime": "2019-04-15T10:50:35Z", + "revision": "6ab10aadc24193b1366bb1f048b92c1a6aec4861", + "revisionTime": "2019-04-19T04:03:31Z", "version": "master", "versionExact": "master" }, @@ -165,64 +165,64 @@ { "checksumSHA1": "tQSbYCu5P00lUhKsx3IbBZCuSLY=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto", - "revision": "ccba7be9105c01eba0617e5ec0a791436200a132", - "revisionTime": "2019-04-15T10:50:35Z", + "revision": "6ab10aadc24193b1366bb1f048b92c1a6aec4861", + "revisionTime": "2019-04-19T04:03:31Z", "version": "master", "versionExact": "master" }, { "checksumSHA1": "4besQaa0rm8jRUAJjpEaLZ/ZOYs=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto/dkg", - "revision": "ccba7be9105c01eba0617e5ec0a791436200a132", - "revisionTime": "2019-04-15T10:50:35Z", + "revision": "6ab10aadc24193b1366bb1f048b92c1a6aec4861", + "revisionTime": "2019-04-19T04:03:31Z", "version": "master", "versionExact": "master" }, { "checksumSHA1": "BhLKK8RveoLaeXc9UyUKMwQqchU=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto/ecdsa", - "revision": "ccba7be9105c01eba0617e5ec0a791436200a132", - "revisionTime": "2019-04-15T10:50:35Z", + "revision": "6ab10aadc24193b1366bb1f048b92c1a6aec4861", + "revisionTime": "2019-04-19T04:03:31Z", "version": "master", "versionExact": "master" }, { "checksumSHA1": "3Ludp/1V4dMBZH/c1oIVjHj0CqY=", "path": "github.com/dexon-foundation/dexon-consensus/core/db", - "revision": "ccba7be9105c01eba0617e5ec0a791436200a132", - "revisionTime": "2019-04-15T10:50:35Z", + "revision": "6ab10aadc24193b1366bb1f048b92c1a6aec4861", + "revisionTime": "2019-04-19T04:03:31Z", "version": "master", "versionExact": "master" }, { "checksumSHA1": "sO5twEFTdLvkMuQo+I3vyzm9T3o=", "path": "github.com/dexon-foundation/dexon-consensus/core/syncer", - "revision": "ccba7be9105c01eba0617e5ec0a791436200a132", - "revisionTime": "2019-04-15T10:50:35Z", + "revision": "6ab10aadc24193b1366bb1f048b92c1a6aec4861", + "revisionTime": "2019-04-19T04:03:31Z", "version": "master", "versionExact": "master" }, { "checksumSHA1": "0BY+E0E2cM7IHIMqunXwoolDS5Y=", "path": "github.com/dexon-foundation/dexon-consensus/core/types", - "revision": "ccba7be9105c01eba0617e5ec0a791436200a132", - "revisionTime": "2019-04-15T10:50:35Z", + "revision": "6ab10aadc24193b1366bb1f048b92c1a6aec4861", + "revisionTime": "2019-04-19T04:03:31Z", "version": "master", "versionExact": "master" }, { "checksumSHA1": "yEPSfn48GaJmDbd2OFY+QRhjJ0w=", "path": "github.com/dexon-foundation/dexon-consensus/core/types/dkg", - "revision": "ccba7be9105c01eba0617e5ec0a791436200a132", - "revisionTime": "2019-04-15T10:50:35Z", + "revision": "6ab10aadc24193b1366bb1f048b92c1a6aec4861", + "revisionTime": "2019-04-19T04:03:31Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "7Ib134BAyLF1M/kREou4Zm7UUS4=", + "checksumSHA1": "51hQ5Wl/n9A5cu8t2yNIqfUuIR8=", "path": "github.com/dexon-foundation/dexon-consensus/core/utils", - "revision": "ccba7be9105c01eba0617e5ec0a791436200a132", - "revisionTime": "2019-04-15T10:50:35Z", + "revision": "6ab10aadc24193b1366bb1f048b92c1a6aec4861", + "revisionTime": "2019-04-19T04:03:31Z", "version": "master", "versionExact": "master" }, |