From a0684dc255fb2d3db22ea4c03957d9b7b27a0a36 Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Wed, 13 Mar 2019 17:55:48 +0800 Subject: core/vm: use core util to get threshold of tsig (#250) --- core/vm/oracle_contracts.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'core') 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 } -- cgit