aboutsummaryrefslogtreecommitdiffstats
path: root/simulation
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-01-09 15:32:08 +0800
committerWei-Ning Huang <w@dexon.org>2019-01-09 15:32:08 +0800
commit25018527ec18ec2830801983d19e63a0ebf7b263 (patch)
tree6c6f1bc251b24da1fd9d6df7375f931fbae35a00 /simulation
parentc62ce07468cea07035ddcad3c89b0a5c0b25746a (diff)
downloadtangerine-consensus-25018527ec18ec2830801983d19e63a0ebf7b263.tar
tangerine-consensus-25018527ec18ec2830801983d19e63a0ebf7b263.tar.gz
tangerine-consensus-25018527ec18ec2830801983d19e63a0ebf7b263.tar.bz2
tangerine-consensus-25018527ec18ec2830801983d19e63a0ebf7b263.tar.lz
tangerine-consensus-25018527ec18ec2830801983d19e63a0ebf7b263.tar.xz
tangerine-consensus-25018527ec18ec2830801983d19e63a0ebf7b263.tar.zst
tangerine-consensus-25018527ec18ec2830801983d19e63a0ebf7b263.zip
simulation: fix k8s dmoment issue (#416)
* Handshake with server dmoment * Start simulation from dMoment * Update k8s config
Diffstat (limited to 'simulation')
-rw-r--r--simulation/kubernetes/config.toml.in4
-rw-r--r--simulation/node.go4
-rw-r--r--simulation/peer-server.go3
-rw-r--r--simulation/simulation.go5
4 files changed, 9 insertions, 7 deletions
diff --git a/simulation/kubernetes/config.toml.in b/simulation/kubernetes/config.toml.in
index af76097..4828903 100644
--- a/simulation/kubernetes/config.toml.in
+++ b/simulation/kubernetes/config.toml.in
@@ -30,8 +30,8 @@ mean = 3e+02
sigma = 5e+01
[networking.gossip]
-mean = 3e+02
-sigma = 2.5e+01
+mean = 6e+02
+sigma = 1e+02
[scheduler]
worker_num = 2
diff --git a/simulation/node.go b/simulation/node.go
index 026db66..517253d 100644
--- a/simulation/node.go
+++ b/simulation/node.go
@@ -115,13 +115,15 @@ func (n *node) GetID() types.NodeID {
// run starts the node.
func (n *node) run(
- serverEndpoint interface{}, dMoment time.Time) {
+ serverEndpoint interface{}) {
// Run network.
if err := n.netModule.Setup(serverEndpoint); err != nil {
panic(err)
}
msgChannel := n.netModule.ReceiveChanForNode()
peers := n.netModule.Peers()
+ dMoment := n.netModule.DMoment()
+ n.logger.Info("Simulation DMoment", "dMoment", dMoment)
go n.netModule.Run()
// Run consensus.
hashes := make(common.Hashes, 0, len(peers))
diff --git a/simulation/peer-server.go b/simulation/peer-server.go
index 69ed029..11785f4 100644
--- a/simulation/peer-server.go
+++ b/simulation/peer-server.go
@@ -175,15 +175,18 @@ func (p *PeerServer) mainLoop() {
// Setup prepares simualtion.
func (p *PeerServer) Setup(
cfg *config.Config) (serverEndpoint interface{}, err error) {
+ dMoment := time.Now().UTC()
// Setup transport layer.
switch cfg.Networking.Type {
case "tcp", "tcp-local":
p.trans = test.NewTCPTransportServer(&jsonMarshaller{}, peerPort)
+ dMoment = dMoment.Add(5 * time.Second)
case "fake":
p.trans = test.NewFakeTransportServer()
default:
panic(fmt.Errorf("unknown network type: %v", cfg.Networking.Type))
}
+ p.trans.SetDMoment(dMoment)
p.msgChannel, err = p.trans.Host()
if err != nil {
return
diff --git a/simulation/simulation.go b/simulation/simulation.go
index 938b302..c74bb91 100644
--- a/simulation/simulation.go
+++ b/simulation/simulation.go
@@ -22,7 +22,6 @@ import (
"io"
"os"
"sync"
- "time"
"github.com/dexon-foundation/dexon/log"
@@ -49,8 +48,6 @@ func Run(cfg *config.Config, logPrefix string) {
panic(fmt.Errorf("DKGSetSze should not be larger the node num"))
}
- dMoment := time.Now().UTC()
-
newLogger := func(logPrefix string) common.Logger {
mw := io.Writer(os.Stderr)
if logPrefix != "" {
@@ -75,7 +72,7 @@ func Run(cfg *config.Config, logPrefix string) {
wg.Add(1)
go func() {
defer wg.Done()
- v.run(serverEndpoint, dMoment)
+ v.run(serverEndpoint)
}()
}