aboutsummaryrefslogtreecommitdiffstats
path: root/simulation
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2019-02-20 12:53:18 +0800
committerGitHub <noreply@github.com>2019-02-20 12:53:18 +0800
commit8ef4fc213703620fbfa13890dee042d40eea8545 (patch)
treeba9a07d2423314396e5677b7294122caa505ae9a /simulation
parent2cf18fd299ea0fc270b213343314cab652cac271 (diff)
downloaddexon-consensus-8ef4fc213703620fbfa13890dee042d40eea8545.tar
dexon-consensus-8ef4fc213703620fbfa13890dee042d40eea8545.tar.gz
dexon-consensus-8ef4fc213703620fbfa13890dee042d40eea8545.tar.bz2
dexon-consensus-8ef4fc213703620fbfa13890dee042d40eea8545.tar.lz
dexon-consensus-8ef4fc213703620fbfa13890dee042d40eea8545.tar.xz
dexon-consensus-8ef4fc213703620fbfa13890dee042d40eea8545.tar.zst
dexon-consensus-8ef4fc213703620fbfa13890dee042d40eea8545.zip
core: switch round by block height (#450)
Diffstat (limited to 'simulation')
-rw-r--r--simulation/config/config.go8
-rw-r--r--simulation/config/utils.go18
-rw-r--r--simulation/node.go6
3 files changed, 4 insertions, 28 deletions
diff --git a/simulation/config/config.go b/simulation/config/config.go
index 428b128..0ee2109 100644
--- a/simulation/config/config.go
+++ b/simulation/config/config.go
@@ -29,9 +29,6 @@ import (
// Consensus settings.
type Consensus struct {
- PhiRatio float32
- K int
- NumChains uint32
GenesisCRS string `toml:"genesis_crs"`
LambdaBA int `toml:"lambda_ba"`
LambdaDKG int `toml:"lambda_dkg"`
@@ -114,13 +111,10 @@ func GenerateDefault(path string) error {
Title: "DEXON Consensus Simulation Config",
Node: Node{
Consensus: Consensus{
- PhiRatio: float32(2) / 3,
- K: 0,
- NumChains: 7,
GenesisCRS: "In DEXON we trust.",
LambdaBA: 250,
LambdaDKG: 1000,
- RoundInterval: 30 * 1000,
+ RoundInterval: 1000,
NotarySetSize: 7,
DKGSetSize: 7,
MinBlockInterval: 750,
diff --git a/simulation/config/utils.go b/simulation/config/utils.go
index 9d97fbd..f8f1eec 100644
--- a/simulation/config/utils.go
+++ b/simulation/config/utils.go
@@ -27,8 +27,6 @@ import (
// StateChangeTypeFromString convert a string to test.StateChangeType.
func StateChangeTypeFromString(s string) test.StateChangeType {
switch s {
- case "num_chains":
- return test.StateChangeNumChains
case "lambda_ba":
return test.StateChangeLambdaBA
case "lambda_dkg":
@@ -37,10 +35,6 @@ func StateChangeTypeFromString(s string) test.StateChangeType {
return test.StateChangeRoundInterval
case "min_block_interval":
return test.StateChangeMinBlockInterval
- case "k":
- return test.StateChangeK
- case "phi_ratio":
- return test.StateChangePhiRatio
case "notary_set_size":
return test.StateChangeNotarySetSize
case "dkg_set_size":
@@ -54,27 +48,19 @@ func StateChangeTypeFromString(s string) test.StateChangeType {
func StateChangeValueFromString(
t test.StateChangeType, v string) interface{} {
switch t {
- case test.StateChangeNumChains, test.StateChangeNotarySetSize,
- test.StateChangeDKGSetSize:
+ case test.StateChangeNotarySetSize, test.StateChangeDKGSetSize:
ret, err := strconv.ParseUint(v, 10, 32)
if err != nil {
panic(err)
}
return uint32(ret)
case test.StateChangeLambdaBA, test.StateChangeLambdaDKG,
- test.StateChangeRoundInterval, test.StateChangeMinBlockInterval,
- test.StateChangeK:
+ test.StateChangeRoundInterval, test.StateChangeMinBlockInterval:
ret, err := strconv.ParseInt(v, 10, 32)
if err != nil {
panic(err)
}
return int(ret)
- case test.StateChangePhiRatio:
- ret, err := strconv.ParseFloat(v, 32)
- if err != nil {
- panic(err)
- }
- return float32(ret)
}
panic(fmt.Errorf("unsupported state change type %s", t))
}
diff --git a/simulation/node.go b/simulation/node.go
index 7c02991..7688c25 100644
--- a/simulation/node.go
+++ b/simulation/node.go
@@ -204,9 +204,6 @@ MainLoop:
func (n *node) prepareConfigs() {
// Prepare configurations.
cConfig := n.cfg.Node.Consensus
- n.gov.State().RequestChange(test.StateChangeK, cConfig.K) // #nosec G104
- n.gov.State().RequestChange(test.StateChangePhiRatio, cConfig.PhiRatio) // #nosec G104
- n.gov.State().RequestChange(test.StateChangeNumChains, cConfig.NumChains) // #nosec G104
n.gov.State().RequestChange(
test.StateChangeNotarySetSize, cConfig.NotarySetSize) // #nosec G104
n.gov.State().RequestChange(test.StateChangeDKGSetSize, cConfig.DKGSetSize) // #nosec G104
@@ -214,8 +211,7 @@ func (n *node) prepareConfigs() {
cConfig.LambdaBA)*time.Millisecond) // #nosec G104
n.gov.State().RequestChange(test.StateChangeLambdaDKG, time.Duration(
cConfig.LambdaDKG)*time.Millisecond) // #nosec G104
- n.gov.State().RequestChange(test.StateChangeRoundInterval, time.Duration(
- cConfig.RoundInterval)*time.Millisecond) // #nosec G104
+ n.gov.State().RequestChange(test.StateChangeRoundInterval, cConfig.RoundInterval) // #nosec G104
n.gov.State().RequestChange(test.StateChangeMinBlockInterval, time.Duration(
cConfig.MinBlockInterval)*time.Millisecond) // #nosec G104
n.gov.State().ProposeCRS(0, crypto.Keccak256Hash([]byte(cConfig.GenesisCRS))) // #nosec G104