diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-03-13 17:55:48 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-13 17:55:48 +0800 |
commit | fb7785a4070ed61eab99e5c947916cd26776a2f3 (patch) | |
tree | 4e97f633506f30c7a0f229eb37fd00eec6a5bd42 | |
parent | d8cf16570f79473bba46f7163311d591cb32ad4f (diff) | |
download | dexon-fb7785a4070ed61eab99e5c947916cd26776a2f3.tar.gz dexon-fb7785a4070ed61eab99e5c947916cd26776a2f3.tar.zst dexon-fb7785a4070ed61eab99e5c947916cd26776a2f3.zip |
core/vm: use core util to get threshold of tsig (#250)
-rw-r--r-- | core/vm/oracle_contracts.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/core/vm/oracle_contracts.go b/core/vm/oracle_contracts.go index cd20b7afa..4168c7b37 100644 --- a/core/vm/oracle_contracts.go +++ b/core/vm/oracle_contracts.go @@ -1603,7 +1603,7 @@ func (g *GovernanceContract) proposeCRS(nextRound *big.Int, signedCRS []byte) ([ } } - threshold := int(g.state.DKGSetSize().Uint64()/3 + 1) + threshold := coreUtils.GetDKGThreshold(&coreTypes.Config{DKGSetSize: uint32(g.state.DKGSetSize().Uint64())}) dkgGPK, err := g.coreDKGUtils.NewGroupPublicKey(nextRound, threshold) if err != nil { return nil, errExecutionReverted @@ -1755,10 +1755,11 @@ func (g *GovernanceContract) resetDKG(newSignedCRS []byte) ([]byte, error) { threshold := new(big.Int).Mul( big.NewInt(2), new(big.Int).Div(g.state.DKGSetSize(), big.NewInt(3))) + tsigThreshold := coreUtils.GetDKGThreshold(&coreTypes.Config{DKGSetSize: uint32(g.state.DKGSetSize().Uint64())}) // If 2f + 1 of DKG set is finalized, check if DKG succeeded. if g.state.DKGFinalizedsCount().Cmp(threshold) > 0 { - _, err := g.coreDKGUtils.NewGroupPublicKey(nextRound, int(threshold.Int64())) + _, err := g.coreDKGUtils.NewGroupPublicKey(nextRound, tsigThreshold) // DKG success. if err == nil { return nil, errExecutionReverted @@ -1780,7 +1781,7 @@ func (g *GovernanceContract) resetDKG(newSignedCRS []byte) ([]byte, error) { prevCRS = crypto.Keccak256Hash(prevCRS[:]) } - dkgGPK, err := g.coreDKGUtils.NewGroupPublicKey(round, int(config.DKGSetSize/3+1)) + dkgGPK, err := g.coreDKGUtils.NewGroupPublicKey(round, tsigThreshold) if err != nil { return nil, errExecutionReverted } |