aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/configuration-chain.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-12-21 12:03:28 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:19 +0800
commit1dae18a03ae58e4b98a81a1596fedb9cb2b893e6 (patch)
tree5a938edadfb36844a1b64fafc85c6b9124d69304 /vendor/github.com/dexon-foundation/dexon-consensus/core/configuration-chain.go
parent1c3de255e5507b32116bb37ba206fe66d6edde35 (diff)
downloadgo-tangerine-1dae18a03ae58e4b98a81a1596fedb9cb2b893e6.tar
go-tangerine-1dae18a03ae58e4b98a81a1596fedb9cb2b893e6.tar.gz
go-tangerine-1dae18a03ae58e4b98a81a1596fedb9cb2b893e6.tar.bz2
go-tangerine-1dae18a03ae58e4b98a81a1596fedb9cb2b893e6.tar.lz
go-tangerine-1dae18a03ae58e4b98a81a1596fedb9cb2b893e6.tar.xz
go-tangerine-1dae18a03ae58e4b98a81a1596fedb9cb2b893e6.tar.zst
go-tangerine-1dae18a03ae58e4b98a81a1596fedb9cb2b893e6.zip
core: vm: Add `MPKReady` to governance (#97)
* core/vm: Add DKGMPKReady * param: update GenesisHash * vendor: sync to latest core
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/configuration-chain.go')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/configuration-chain.go37
1 files changed, 33 insertions, 4 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 2b3a859ed..d341cb524 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
@@ -105,6 +105,13 @@ func (cc *configurationChain) registerDKG(round uint64, threshold int) {
cc.recv,
round,
threshold)
+ go func() {
+ ticker := newTicker(cc.gov, round, TickerDKG)
+ <-ticker.Tick()
+ cc.dkgLock.Lock()
+ defer cc.dkgLock.Unlock()
+ cc.dkg.proposeMPKReady()
+ }()
}
func (cc *configurationChain) runDKG(round uint64) error {
@@ -126,13 +133,34 @@ func (cc *configurationChain) runDKG(round uint64) error {
cc.logger.Warn("DKG already final", "round", round)
return nil
}
+ cc.logger.Debug("Calling Governance.IsDKGMPKReady", "round", round)
+ for !cc.gov.IsDKGMPKReady(round) {
+ cc.logger.Info("DKG MPKs are not ready yet. Try again later...",
+ "nodeID", cc.ID)
+ cc.dkgLock.Unlock()
+ time.Sleep(500 * time.Millisecond)
+ cc.dkgLock.Lock()
+ }
ticker := newTicker(cc.gov, round, TickerDKG)
cc.dkgLock.Unlock()
<-ticker.Tick()
cc.dkgLock.Lock()
- // Phase 2(T = 0): Exchange DKG secret key share.
+ // Check if this node successfully join the protocol.
cc.logger.Debug("Calling Governance.DKGMasterPublicKeys", "round", round)
- cc.dkg.processMasterPublicKeys(cc.gov.DKGMasterPublicKeys(round))
+ mpks := cc.gov.DKGMasterPublicKeys(round)
+ inProtocol := false
+ for _, mpk := range mpks {
+ if mpk.ProposerID == cc.ID {
+ inProtocol = true
+ break
+ }
+ }
+ if !inProtocol {
+ cc.logger.Warn("Failed to join DKG protocol", "round", round)
+ return nil
+ }
+ // Phase 2(T = 0): Exchange DKG secret key share.
+ cc.dkg.processMasterPublicKeys(mpks)
cc.mpkReady = true
for _, prvShare := range cc.pendingPrvShare {
if err := cc.dkg.processPrivateShare(prvShare); err != nil {
@@ -219,7 +247,7 @@ func (cc *configurationChain) runDKG(round uint64) error {
return nil
}
-func (cc *configurationChain) isDKGReady(round uint64) bool {
+func (cc *configurationChain) isDKGFinal(round uint64) bool {
if !cc.gov.IsDKGFinal(round) {
return false
}
@@ -261,7 +289,8 @@ func (cc *configurationChain) recoverDKGInfo(round uint64) error {
return ErrDKGNotReady
}
- threshold := getDKGThreshold(cc.gov.Configuration(round))
+ threshold := getDKGThreshold(
+ utils.GetConfigWithPanic(cc.gov, round, cc.logger))
// Restore group public key.
gpk, err := NewDKGGroupPublicKey(round,
cc.gov.DKGMasterPublicKeys(round),