aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-03-13 17:55:48 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:22 +0800
commita0684dc255fb2d3db22ea4c03957d9b7b27a0a36 (patch)
treecd8bf69d313535ca40a28dfb24e92a39df2dd591
parentef095c201fd46d47724f1d85104d11e8a5c2978e (diff)
downloadgo-tangerine-a0684dc255fb2d3db22ea4c03957d9b7b27a0a36.tar
go-tangerine-a0684dc255fb2d3db22ea4c03957d9b7b27a0a36.tar.gz
go-tangerine-a0684dc255fb2d3db22ea4c03957d9b7b27a0a36.tar.bz2
go-tangerine-a0684dc255fb2d3db22ea4c03957d9b7b27a0a36.tar.lz
go-tangerine-a0684dc255fb2d3db22ea4c03957d9b7b27a0a36.tar.xz
go-tangerine-a0684dc255fb2d3db22ea4c03957d9b7b27a0a36.tar.zst
go-tangerine-a0684dc255fb2d3db22ea4c03957d9b7b27a0a36.zip
core/vm: use core util to get threshold of tsig (#250)
-rw-r--r--core/vm/oracle_contracts.go7
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
}