aboutsummaryrefslogtreecommitdiffstats
path: root/simulation
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-09-23 20:51:05 +0800
committerGitHub <noreply@github.com>2018-09-23 20:51:05 +0800
commit0ab5a2d4f63ece79a4df32c6fb3ac710a954fd89 (patch)
tree626db6969aee92702001e5c9f3de56e2a439ccac /simulation
parent2c71e8448a9c03e924a7869351eebf2def1af057 (diff)
downloadtangerine-consensus-0ab5a2d4f63ece79a4df32c6fb3ac710a954fd89.tar.gz
tangerine-consensus-0ab5a2d4f63ece79a4df32c6fb3ac710a954fd89.tar.zst
tangerine-consensus-0ab5a2d4f63ece79a4df32c6fb3ac710a954fd89.zip
core: run first DKG at startup. (#129)
Diffstat (limited to 'simulation')
-rw-r--r--simulation/config/config.go6
-rw-r--r--simulation/governance.go9
-rw-r--r--simulation/kubernetes/config.toml.in3
-rw-r--r--simulation/marshaller.go5
-rw-r--r--simulation/network.go8
5 files changed, 24 insertions, 7 deletions
diff --git a/simulation/config/config.go b/simulation/config/config.go
index 6c7b584..8bc4ab7 100644
--- a/simulation/config/config.go
+++ b/simulation/config/config.go
@@ -40,7 +40,8 @@ type Consensus struct {
K int
ChainNum uint32
GenesisCRS string `toml:"genesis_crs"`
- Lambda int
+ LambdaBA int `toml:"lambda_ba"`
+ LambdaDKG int `toml:"lambda_dkg"`
}
// Legacy config.
@@ -96,7 +97,8 @@ func GenerateDefault(path string) error {
K: 1,
ChainNum: 7,
GenesisCRS: "In DEXON we trust.",
- Lambda: 250,
+ LambdaBA: 250,
+ LambdaDKG: 1000,
},
Legacy: Legacy{
ProposeIntervalMean: 500,
diff --git a/simulation/governance.go b/simulation/governance.go
index 0f2bbbf..613205d 100644
--- a/simulation/governance.go
+++ b/simulation/governance.go
@@ -39,7 +39,8 @@ type simGovernance struct {
crs string
dkgComplaint map[uint64][]*types.DKGComplaint
dkgMasterPublicKey map[uint64][]*types.DKGMasterPublicKey
- lambda time.Duration
+ lambdaBA time.Duration
+ lambdaDKG time.Duration
network *network
}
@@ -57,7 +58,8 @@ func newSimGovernance(
crs: consensusConfig.GenesisCRS,
dkgComplaint: make(map[uint64][]*types.DKGComplaint),
dkgMasterPublicKey: make(map[uint64][]*types.DKGMasterPublicKey),
- lambda: time.Duration(consensusConfig.Lambda) * time.Millisecond,
+ lambdaBA: time.Duration(consensusConfig.LambdaBA) * time.Millisecond,
+ lambdaDKG: time.Duration(consensusConfig.LambdaDKG) * time.Millisecond,
}
}
@@ -84,7 +86,8 @@ func (g *simGovernance) GetConfiguration(blockHeight uint64) *types.Config {
NumShards: 1,
NumChains: g.chainNum,
GenesisCRS: g.crs,
- Lambda: g.lambda,
+ LambdaBA: g.lambdaBA,
+ LambdaDKG: g.lambdaDKG,
K: g.k,
PhiRatio: g.phiRatio,
}
diff --git a/simulation/kubernetes/config.toml.in b/simulation/kubernetes/config.toml.in
index 546fa8e..dee1fe2 100644
--- a/simulation/kubernetes/config.toml.in
+++ b/simulation/kubernetes/config.toml.in
@@ -2,7 +2,8 @@ title = "DEXON Consensus Simulation Config"
[node]
num = {{numNode}}
-lambda = 250
+lambda_ba = 250
+lambda_dkg = 1000
max_block = 1000
[node.consensus]
diff --git a/simulation/marshaller.go b/simulation/marshaller.go
index 45a186d..d1b2793 100644
--- a/simulation/marshaller.go
+++ b/simulation/marshaller.go
@@ -22,6 +22,7 @@ import (
"fmt"
"github.com/dexon-foundation/dexon-consensus-core/core/types"
+ "github.com/dexon-foundation/dexon-consensus-core/crypto/dkg"
)
// jsonMarshaller implements test.Marshaller to marshal simulation related
@@ -76,7 +77,9 @@ func (m *jsonMarshaller) Unmarshal(
}
msg = privateShare
case "dkg-master-public-key":
- masterPublicKey := &types.DKGMasterPublicKey{}
+ masterPublicKey := &types.DKGMasterPublicKey{
+ PublicKeyShares: *dkg.NewEmptyPublicKeyShares(),
+ }
if err = json.Unmarshal(payload, masterPublicKey); err != nil {
break
}
diff --git a/simulation/network.go b/simulation/network.go
index d14f07e..938d785 100644
--- a/simulation/network.go
+++ b/simulation/network.go
@@ -153,6 +153,14 @@ func (n *network) SendDKGPrivateShare(
}
}
+// BroadcastDKGPrivateShare implements core.Network interface.
+func (n *network) BroadcastDKGPrivateShare(
+ prvShare *types.DKGPrivateShare) {
+ if err := n.trans.Broadcast(prvShare); err != nil {
+ panic(err)
+ }
+}
+
// ReceiveChan implements core.Network interface.
func (n *network) ReceiveChan() <-chan interface{} {
return n.toConsensus