aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-03-30 22:53:11 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:59 +0800
commit1f4f34cfbf3f74cc827531c51fca2ab27f20d516 (patch)
tree888b68506d617fdfd6d865e2248f9be2cd832c5c
parentb4bb2e15d4b779f3d06eb7f58d848f174926c129 (diff)
downloaddexon-1f4f34cfbf3f74cc827531c51fca2ab27f20d516.tar.gz
dexon-1f4f34cfbf3f74cc827531c51fca2ab27f20d516.tar.zst
dexon-1f4f34cfbf3f74cc827531c51fca2ab27f20d516.zip
core/vm: resetDKG if ttoo less qualified (#318)
-rw-r--r--core/vm/oracle_contracts.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/core/vm/oracle_contracts.go b/core/vm/oracle_contracts.go
index 4459b95b9..5ea4d4790 100644
--- a/core/vm/oracle_contracts.go
+++ b/core/vm/oracle_contracts.go
@@ -1968,7 +1968,15 @@ func (g *GovernanceContract) resetDKG(newSignedCRS []byte) ([]byte, error) {
// If 2f + 1 of DKG set is finalized, check if DKG succeeded.
if g.state.DKGFinalizedsCount().Uint64() >= threshold {
- _, err := g.coreDKGUtils.NewGroupPublicKey(&g.state, nextRound, tsigThreshold)
+ gpk, err := g.coreDKGUtils.NewGroupPublicKey(&g.state, nextRound, tsigThreshold)
+ if gpk, ok := gpk.(*dkgTypes.GroupPublicKey); ok {
+ nextRound := new(big.Int).Add(g.evm.Round, big.NewInt(1))
+ if len(gpk.QualifyNodeIDs) < coreUtils.GetDKGValidThreshold(&coreTypes.Config{
+ NotarySetSize: uint32(g.configNotarySetSize(nextRound).Uint64())}) {
+ err = dkgTypes.ErrNotReachThreshold
+ }
+ }
+
// DKG success.
if err == nil {
return nil, errExecutionReverted