mirror of https://github.com/waku-org/nwaku.git
Fix network simulations (#719)
* Fix/tweak network simulations * fix terminology
This commit is contained in:
parent
d74ef67087
commit
a335a40a21
|
@ -4,7 +4,7 @@ import
|
||||||
|
|
||||||
const
|
const
|
||||||
defaults ="--log-level:DEBUG --log-metrics --metrics-server --rpc"
|
defaults ="--log-level:DEBUG --log-metrics --metrics-server --rpc"
|
||||||
wakuNodeBin = "build" / "wakunode"
|
wakuNodeBin = "build" / "wakunode1"
|
||||||
metricsDir = "metrics"
|
metricsDir = "metrics"
|
||||||
portOffset = 2
|
portOffset = 2
|
||||||
|
|
||||||
|
@ -28,6 +28,11 @@ type
|
||||||
desc: "Amount of full nodes to be started."
|
desc: "Amount of full nodes to be started."
|
||||||
defaultValue: 4
|
defaultValue: 4
|
||||||
name: "amount" .}: int
|
name: "amount" .}: int
|
||||||
|
|
||||||
|
testNodes* {.
|
||||||
|
desc: "Initialize light test nodes as part of network."
|
||||||
|
defaultValue: true
|
||||||
|
name: "test-nodes" .}: bool
|
||||||
|
|
||||||
testNodePeers* {.
|
testNodePeers* {.
|
||||||
desc: "Amount of peers a test node should connect to."
|
desc: "Amount of peers a test node should connect to."
|
||||||
|
@ -166,15 +171,16 @@ when isMainModule:
|
||||||
of DiscoveryBased:
|
of DiscoveryBased:
|
||||||
nodes = discoveryNetwork(conf.amount)
|
nodes = discoveryNetwork(conf.amount)
|
||||||
|
|
||||||
var staticnodes: seq[string]
|
if conf.testNodes:
|
||||||
for i in 0..<conf.testNodePeers:
|
var staticnodes: seq[string]
|
||||||
# TODO: could also select nodes randomly
|
for i in 0..<conf.testNodePeers:
|
||||||
staticnodes.add(nodes[i].enode)
|
# TODO: could also select nodes randomly
|
||||||
# light node with topic interest
|
staticnodes.add(nodes[i].enode)
|
||||||
nodes.add(initNodeCmd(LightNode, 0, staticnodes, topicInterest = true,
|
# light node with topic interest
|
||||||
label = "light node topic interest"))
|
nodes.add(initNodeCmd(LightNode, 0, staticnodes, topicInterest = true,
|
||||||
# Regular light node
|
label = "light node topic interest"))
|
||||||
nodes.add(initNodeCmd(LightNode, 1, staticnodes, label = "light node"))
|
# Regular light node
|
||||||
|
nodes.add(initNodeCmd(LightNode, 1, staticnodes, label = "light node"))
|
||||||
|
|
||||||
var commandStr = "multitail -s 2 -M 0 -x \"Waku Simulation\""
|
var commandStr = "multitail -s 2 -M 0 -x \"Waku Simulation\""
|
||||||
var count = 0
|
var count = 0
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import
|
import
|
||||||
strformat, os, osproc, net, strformat, chronicles, json,
|
strformat, os, osproc, net, strformat, chronicles, confutils, json,
|
||||||
libp2p/multiaddress,
|
libp2p/multiaddress,
|
||||||
libp2p/crypto/crypto,
|
libp2p/crypto/crypto,
|
||||||
libp2p/crypto/secp,
|
libp2p/crypto/secp,
|
||||||
|
@ -9,7 +9,7 @@ import
|
||||||
import strutils except fromHex
|
import strutils except fromHex
|
||||||
|
|
||||||
const
|
const
|
||||||
defaults ="--log-level:TRACE --log-metrics --metrics-server --rpc"
|
defaults ="--log-level:TRACE --metrics-logging --metrics-server --rpc"
|
||||||
wakuNodeBin = "build" / "wakunode2"
|
wakuNodeBin = "build" / "wakunode2"
|
||||||
metricsDir = "metrics"
|
metricsDir = "metrics"
|
||||||
portOffset = 2
|
portOffset = 2
|
||||||
|
@ -25,6 +25,17 @@ type
|
||||||
Topology = enum
|
Topology = enum
|
||||||
Star,
|
Star,
|
||||||
FullMesh
|
FullMesh
|
||||||
|
|
||||||
|
WakuNetworkConf* = object
|
||||||
|
topology* {.
|
||||||
|
desc: "Set the network topology."
|
||||||
|
defaultValue: FullMesh
|
||||||
|
name: "topology" .}: Topology
|
||||||
|
|
||||||
|
amount* {.
|
||||||
|
desc: "Amount of relay nodes to be started."
|
||||||
|
defaultValue: 16
|
||||||
|
name: "amount" .}: int
|
||||||
|
|
||||||
# NOTE: Don't distinguish between node types here a la full node, light node etc
|
# NOTE: Don't distinguish between node types here a la full node, light node etc
|
||||||
proc initNodeCmd(shift: int, staticNodes: seq[string] = @[], master = false, label: string): NodeInfo =
|
proc initNodeCmd(shift: int, staticNodes: seq[string] = @[], master = false, label: string): NodeInfo =
|
||||||
|
@ -134,12 +145,14 @@ proc proccessGrafanaDashboard(nodes: int, inputFile: string,
|
||||||
writeFile(outputFile, pretty(outputData))
|
writeFile(outputFile, pretty(outputData))
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
|
let conf = WakuNetworkConf.load()
|
||||||
|
|
||||||
# TODO: WakuNetworkConf
|
# TODO: WakuNetworkConf
|
||||||
var nodes: seq[NodeInfo]
|
var nodes: seq[NodeInfo]
|
||||||
let topology = FullMesh
|
let topology = conf.topology
|
||||||
|
|
||||||
# Scenario xx2 14
|
# Scenario xx2 14
|
||||||
let amount = 16
|
let amount = conf.amount
|
||||||
|
|
||||||
case topology:
|
case topology:
|
||||||
of Star:
|
of Star:
|
||||||
|
@ -147,10 +160,10 @@ when isMainModule:
|
||||||
of FullMesh:
|
of FullMesh:
|
||||||
nodes = fullMeshNetwork(amount)
|
nodes = fullMeshNetwork(amount)
|
||||||
|
|
||||||
var staticnodes: seq[string]
|
# var staticnodes: seq[string]
|
||||||
for i in 0..<amount:
|
# for i in 0..<amount:
|
||||||
# TODO: could also select nodes randomly
|
# # TODO: could also select nodes randomly
|
||||||
staticnodes.add(nodes[i].address)
|
# staticnodes.add(nodes[i].address)
|
||||||
|
|
||||||
# Scenario xx1 - 16 full nodes, one app topic, full mesh, gossip
|
# Scenario xx1 - 16 full nodes, one app topic, full mesh, gossip
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue