diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-03-13 17:55:48 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:58 +0800 |
commit | e87b2f32c79a811bccc2a00c89ac2e533a7da5e0 (patch) | |
tree | c5a73c6ea7c902b233db0d73d9ffb08f8c2ffb6f | |
parent | 52ed7dfd65755661c02fcb0710bbd6089d3429c3 (diff) | |
download | dexon-e87b2f32c79a811bccc2a00c89ac2e533a7da5e0.tar dexon-e87b2f32c79a811bccc2a00c89ac2e533a7da5e0.tar.gz dexon-e87b2f32c79a811bccc2a00c89ac2e533a7da5e0.tar.bz2 dexon-e87b2f32c79a811bccc2a00c89ac2e533a7da5e0.tar.lz dexon-e87b2f32c79a811bccc2a00c89ac2e533a7da5e0.tar.xz dexon-e87b2f32c79a811bccc2a00c89ac2e533a7da5e0.tar.zst dexon-e87b2f32c79a811bccc2a00c89ac2e533a7da5e0.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 } |