aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-09-28 13:06:16 +0800
committerGitHub <noreply@github.com>2018-09-28 13:06:16 +0800
commit9ad4ae71b5a49ddc77687cc368c31416a0ee0688 (patch)
treeca29f72aa63b6610f0a8ec1aef2e842677e9ac6f
parent5fc0efa940c7663a33d0fc501807a2627d2cb573 (diff)
downloaddexon-consensus-9ad4ae71b5a49ddc77687cc368c31416a0ee0688.tar
dexon-consensus-9ad4ae71b5a49ddc77687cc368c31416a0ee0688.tar.gz
dexon-consensus-9ad4ae71b5a49ddc77687cc368c31416a0ee0688.tar.bz2
dexon-consensus-9ad4ae71b5a49ddc77687cc368c31416a0ee0688.tar.lz
dexon-consensus-9ad4ae71b5a49ddc77687cc368c31416a0ee0688.tar.xz
dexon-consensus-9ad4ae71b5a49ddc77687cc368c31416a0ee0688.tar.zst
dexon-consensus-9ad4ae71b5a49ddc77687cc368c31416a0ee0688.zip
core: Add sizes of various nodeSets (#148)
-rw-r--r--core/test/governance.go24
-rw-r--r--core/types/config.go33
-rw-r--r--simulation/config/config.go26
-rw-r--r--simulation/governance.go19
-rw-r--r--simulation/kubernetes/config.toml.in3
5 files changed, 81 insertions, 24 deletions
diff --git a/core/test/governance.go b/core/test/governance.go
index c666ffc..69d8bdd 100644
--- a/core/test/governance.go
+++ b/core/test/governance.go
@@ -41,6 +41,9 @@ type Governance struct {
tsig map[uint64]crypto.Signature
DKGComplaint map[uint64][]*types.DKGComplaint
DKGMasterPublicKey map[uint64][]*types.DKGMasterPublicKey
+ RoundInterval time.Duration
+ MinBlockInterval time.Duration
+ MaxBlockInterval time.Duration
lock sync.RWMutex
}
@@ -54,6 +57,9 @@ func NewGovernance(nodeCount int, lambda time.Duration) (
tsig: make(map[uint64]crypto.Signature),
DKGComplaint: make(map[uint64][]*types.DKGComplaint),
DKGMasterPublicKey: make(map[uint64][]*types.DKGMasterPublicKey),
+ RoundInterval: 365 * 86400 * time.Second,
+ MinBlockInterval: lambda * 3,
+ MaxBlockInterval: lambda * 8,
}
for i := 0; i < nodeCount; i++ {
prv, err := ecdsa.NewPrivateKey()
@@ -79,12 +85,18 @@ func (g *Governance) GetNodeSet(_ uint64) (
// GetConfiguration returns the configuration at a given block height.
func (g *Governance) GetConfiguration(_ uint64) *types.Config {
return &types.Config{
- NumShards: 1,
- NumChains: uint32(len(g.privateKeys)),
- LambdaBA: g.lambdaBA,
- LambdaDKG: g.lambdaDKG,
- K: 0,
- PhiRatio: 0.667,
+ NumShards: 1,
+ NumChains: uint32(len(g.privateKeys)),
+ LambdaBA: g.lambdaBA,
+ LambdaDKG: g.lambdaDKG,
+ K: 0,
+ PhiRatio: 0.667,
+ NumNotarySet: len(g.privateKeys),
+ NumWitnessSet: len(g.privateKeys),
+ NumDKGSet: len(g.privateKeys),
+ RoundInterval: g.RoundInterval,
+ MinBlockInterval: g.MinBlockInterval,
+ MaxBlockInterval: g.MaxBlockInterval,
}
}
diff --git a/core/types/config.go b/core/types/config.go
index 9434d62..0b85363 100644
--- a/core/types/config.go
+++ b/core/types/config.go
@@ -36,6 +36,16 @@ type Config struct {
// Total ordering related.
K int
PhiRatio float32
+
+ // NodeSet related.
+ NumNotarySet int
+ NumWitnessSet int
+ NumDKGSet int
+
+ // Time related.
+ RoundInterval time.Duration
+ MinBlockInterval time.Duration
+ MaxBlockInterval time.Duration
}
// Bytes returns []byte representation of Config.
@@ -57,6 +67,23 @@ func (c *Config) Bytes() []byte {
binaryPhiRatio := make([]byte, 4)
binary.LittleEndian.PutUint32(binaryPhiRatio, math.Float32bits(c.PhiRatio))
+ binaryNumNotarySet := make([]byte, 4)
+ binary.LittleEndian.PutUint32(binaryNumNotarySet, uint32(c.NumNotarySet))
+ binaryNumWitnessSet := make([]byte, 4)
+ binary.LittleEndian.PutUint32(binaryNumWitnessSet, uint32(c.NumWitnessSet))
+ binaryNumDKGSet := make([]byte, 4)
+ binary.LittleEndian.PutUint32(binaryNumDKGSet, uint32(c.NumDKGSet))
+
+ binaryRoundInterval := make([]byte, 8)
+ binary.LittleEndian.PutUint64(binaryRoundInterval,
+ uint64(c.RoundInterval.Nanoseconds()))
+ binaryMinBlockInterval := make([]byte, 8)
+ binary.LittleEndian.PutUint64(binaryMinBlockInterval,
+ uint64(c.MinBlockInterval.Nanoseconds()))
+ binaryMaxBlockInterval := make([]byte, 8)
+ binary.LittleEndian.PutUint64(binaryMaxBlockInterval,
+ uint64(c.MaxBlockInterval.Nanoseconds()))
+
enc := make([]byte, 0, 40)
enc = append(enc, binaryNumShards...)
enc = append(enc, binaryNumChains...)
@@ -64,5 +91,11 @@ func (c *Config) Bytes() []byte {
enc = append(enc, binaryLambdaDKG...)
enc = append(enc, binaryK...)
enc = append(enc, binaryPhiRatio...)
+ enc = append(enc, binaryNumNotarySet...)
+ enc = append(enc, binaryNumWitnessSet...)
+ enc = append(enc, binaryNumDKGSet...)
+ enc = append(enc, binaryRoundInterval...)
+ enc = append(enc, binaryMinBlockInterval...)
+ enc = append(enc, binaryMaxBlockInterval...)
return enc
}
diff --git a/simulation/config/config.go b/simulation/config/config.go
index 8bc4ab7..ac4303d 100644
--- a/simulation/config/config.go
+++ b/simulation/config/config.go
@@ -36,12 +36,13 @@ const (
// Consensus settings.
type Consensus struct {
- PhiRatio float32
- K int
- ChainNum uint32
- GenesisCRS string `toml:"genesis_crs"`
- LambdaBA int `toml:"lambda_ba"`
- LambdaDKG int `toml:"lambda_dkg"`
+ PhiRatio float32
+ K int
+ ChainNum uint32
+ GenesisCRS string `toml:"genesis_crs"`
+ LambdaBA int `toml:"lambda_ba"`
+ LambdaDKG int `toml:"lambda_dkg"`
+ RoundInterval int
}
// Legacy config.
@@ -93,12 +94,13 @@ func GenerateDefault(path string) error {
Title: "DEXON Consensus Simulation Config",
Node: Node{
Consensus: Consensus{
- PhiRatio: float32(2) / 3,
- K: 1,
- ChainNum: 7,
- GenesisCRS: "In DEXON we trust.",
- LambdaBA: 250,
- LambdaDKG: 1000,
+ PhiRatio: float32(2) / 3,
+ K: 1,
+ ChainNum: 7,
+ GenesisCRS: "In DEXON we trust.",
+ LambdaBA: 250,
+ LambdaDKG: 1000,
+ RoundInterval: 365 * 86400 * 1000,
},
Legacy: Legacy{
ProposeIntervalMean: 500,
diff --git a/simulation/governance.go b/simulation/governance.go
index 3290075..3351202 100644
--- a/simulation/governance.go
+++ b/simulation/governance.go
@@ -43,6 +43,7 @@ type simGovernance struct {
dkgMasterPublicKey map[uint64][]*types.DKGMasterPublicKey
lambdaBA time.Duration
lambdaDKG time.Duration
+ roundInterval time.Duration
network *network
}
@@ -63,6 +64,7 @@ func newSimGovernance(
dkgMasterPublicKey: make(map[uint64][]*types.DKGMasterPublicKey),
lambdaBA: time.Duration(consensusConfig.LambdaBA) * time.Millisecond,
lambdaDKG: time.Duration(consensusConfig.LambdaDKG) * time.Millisecond,
+ roundInterval: time.Duration(consensusConfig.RoundInterval) * time.Millisecond,
}
}
@@ -84,12 +86,17 @@ func (g *simGovernance) GetNodeSet(round uint64) (ret []crypto.PublicKey) {
// GetConfiguration returns the configuration at a given round.
func (g *simGovernance) GetConfiguration(round uint64) *types.Config {
return &types.Config{
- NumShards: 1,
- NumChains: g.chainNum,
- LambdaBA: g.lambdaBA,
- LambdaDKG: g.lambdaDKG,
- K: g.k,
- PhiRatio: g.phiRatio,
+ NumShards: 1,
+ NumChains: g.chainNum,
+ LambdaBA: g.lambdaBA,
+ LambdaDKG: g.lambdaDKG,
+ K: g.k,
+ PhiRatio: g.phiRatio,
+ NumNotarySet: len(g.nodeSet),
+ NumWitnessSet: len(g.nodeSet),
+ NumDKGSet: len(g.nodeSet),
+ MinBlockInterval: g.lambdaBA * 3,
+ MaxBlockInterval: g.lambdaBA * 8,
}
}
diff --git a/simulation/kubernetes/config.toml.in b/simulation/kubernetes/config.toml.in
index dee1fe2..f34ee76 100644
--- a/simulation/kubernetes/config.toml.in
+++ b/simulation/kubernetes/config.toml.in
@@ -11,6 +11,9 @@ phi_ratio = 6.66670024394989e-01
k = 1
chain_num = 7
genesis_crs = "In DEXON we trust."
+lambda_ba = 250
+lambda_dkg = 1000
+round_interval = 31536000000
[node.legacy]
propose_interval_mean = 5e+02