aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-04-10 10:41:21 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-15 22:09:55 +0800
commit1bbface79d499243aa836140b7ee295ba9f572a5 (patch)
tree1b713685cec8eb7c4bb5b6fa714159c0863695e6 /vendor/github.com
parent33e70e61e04cfab68bcb6ce26665f7947be77a5f (diff)
downloadgo-tangerine-1bbface79d499243aa836140b7ee295ba9f572a5.tar
go-tangerine-1bbface79d499243aa836140b7ee295ba9f572a5.tar.gz
go-tangerine-1bbface79d499243aa836140b7ee295ba9f572a5.tar.bz2
go-tangerine-1bbface79d499243aa836140b7ee295ba9f572a5.tar.lz
go-tangerine-1bbface79d499243aa836140b7ee295ba9f572a5.tar.xz
go-tangerine-1bbface79d499243aa836140b7ee295ba9f572a5.tar.zst
go-tangerine-1bbface79d499243aa836140b7ee295ba9f572a5.zip
vendor: sync to latest core
Diffstat (limited to 'vendor/github.com')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/configuration-chain.go62
1 files changed, 42 insertions, 20 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/configuration-chain.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/configuration-chain.go
index 4a99d3dcc..76917a310 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/configuration-chain.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/configuration-chain.go
@@ -580,31 +580,31 @@ func (cc *configurationChain) recoverDKGInfo(
return ErrDKGNotReady
}
+ threshold := utils.GetDKGThreshold(
+ utils.GetConfigWithPanic(cc.gov, round, cc.logger))
+ cc.logger.Debug("Calling Governance.DKGMasterPublicKeys for recoverDKGInfo",
+ "round", round)
+ mpk := cc.gov.DKGMasterPublicKeys(round)
+ cc.logger.Debug("Calling Governance.DKGComplaints for recoverDKGInfo",
+ "round", round)
+ comps := cc.gov.DKGComplaints(round)
+ qualifies, _, err := typesDKG.CalcQualifyNodes(mpk, comps, threshold)
+ if err != nil {
+ return err
+ }
+ if len(qualifies) <
+ utils.GetDKGValidThreshold(utils.GetConfigWithPanic(
+ cc.gov, round, cc.logger)) {
+ return typesDKG.ErrNotReachThreshold
+ }
+
if !npksExists {
- threshold := utils.GetDKGThreshold(
- utils.GetConfigWithPanic(cc.gov, round, cc.logger))
- // Restore group public key.
- cc.logger.Debug("Calling Governance.DKGMasterPublicKeys for recoverDKGInfo",
- "round", round)
- mpk := cc.gov.DKGMasterPublicKeys(round)
- cc.logger.Debug("Calling Governance.DKGComplaints for recoverDKGInfo",
- "round", round)
- comps := cc.gov.DKGComplaints(round)
- qualifies, _, err := typesDKG.CalcQualifyNodes(mpk, comps, threshold)
- if err != nil {
- return err
- }
- if len(qualifies) <
- utils.GetDKGValidThreshold(utils.GetConfigWithPanic(
- cc.gov, round, cc.logger)) {
- return typesDKG.ErrNotReachThreshold
- }
npks, err := typesDKG.NewNodePublicKeys(round,
cc.gov.DKGMasterPublicKeys(round),
cc.gov.DKGComplaints(round),
threshold)
if err != nil {
- cc.logger.Warn("Failed to create DKGGroupPublicKey",
+ cc.logger.Warn("Failed to create DKGNodePublicKeys",
"round", round, "error", err)
return err
}
@@ -620,7 +620,29 @@ func (cc *configurationChain) recoverDKGInfo(
if err != nil {
cc.logger.Warn("Failed to create DKGPrivateKey",
"round", round, "error", err)
- return err
+ dkgProtocolInfo, err := cc.db.GetDKGProtocol()
+ if err != nil {
+ cc.logger.Warn("Unable to recover DKGProtocolInfo",
+ "round", round, "error", err)
+ return err
+ }
+ if dkgProtocolInfo.Round != round {
+ cc.logger.Warn("DKGProtocolInfo round mismatch",
+ "round", round, "infoRound", dkgProtocolInfo.Round)
+ return err
+ }
+ prvKeyRecover, err :=
+ dkgProtocolInfo.PrvShares.RecoverPrivateKey(qualifies)
+ if err != nil {
+ cc.logger.Warn("Failed to recover DKGPrivateKey",
+ "round", round, "error", err)
+ return err
+ }
+ if err = cc.db.PutDKGPrivateKey(round, *prvKeyRecover); err != nil {
+ cc.logger.Warn("Failed to save DKGPrivateKey",
+ "round", round, "error", err)
+ }
+ prvKey = *prvKeyRecover
}
func() {
cc.dkgResult.Lock()