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
|
||||
defaults ="--log-level:DEBUG --log-metrics --metrics-server --rpc"
|
||||
wakuNodeBin = "build" / "wakunode"
|
||||
wakuNodeBin = "build" / "wakunode1"
|
||||
metricsDir = "metrics"
|
||||
portOffset = 2
|
||||
|
||||
|
@ -29,6 +29,11 @@ type
|
|||
defaultValue: 4
|
||||
name: "amount" .}: int
|
||||
|
||||
testNodes* {.
|
||||
desc: "Initialize light test nodes as part of network."
|
||||
defaultValue: true
|
||||
name: "test-nodes" .}: bool
|
||||
|
||||
testNodePeers* {.
|
||||
desc: "Amount of peers a test node should connect to."
|
||||
defaultValue: 1
|
||||
|
@ -166,15 +171,16 @@ when isMainModule:
|
|||
of DiscoveryBased:
|
||||
nodes = discoveryNetwork(conf.amount)
|
||||
|
||||
var staticnodes: seq[string]
|
||||
for i in 0..<conf.testNodePeers:
|
||||
# TODO: could also select nodes randomly
|
||||
staticnodes.add(nodes[i].enode)
|
||||
# light node with topic interest
|
||||
nodes.add(initNodeCmd(LightNode, 0, staticnodes, topicInterest = true,
|
||||
label = "light node topic interest"))
|
||||
# Regular light node
|
||||
nodes.add(initNodeCmd(LightNode, 1, staticnodes, label = "light node"))
|
||||
if conf.testNodes:
|
||||
var staticnodes: seq[string]
|
||||
for i in 0..<conf.testNodePeers:
|
||||
# TODO: could also select nodes randomly
|
||||
staticnodes.add(nodes[i].enode)
|
||||
# light node with topic interest
|
||||
nodes.add(initNodeCmd(LightNode, 0, staticnodes, topicInterest = true,
|
||||
label = "light node topic interest"))
|
||||
# Regular light node
|
||||
nodes.add(initNodeCmd(LightNode, 1, staticnodes, label = "light node"))
|
||||
|
||||
var commandStr = "multitail -s 2 -M 0 -x \"Waku Simulation\""
|
||||
var count = 0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import
|
||||
strformat, os, osproc, net, strformat, chronicles, json,
|
||||
strformat, os, osproc, net, strformat, chronicles, confutils, json,
|
||||
libp2p/multiaddress,
|
||||
libp2p/crypto/crypto,
|
||||
libp2p/crypto/secp,
|
||||
|
@ -9,7 +9,7 @@ import
|
|||
import strutils except fromHex
|
||||
|
||||
const
|
||||
defaults ="--log-level:TRACE --log-metrics --metrics-server --rpc"
|
||||
defaults ="--log-level:TRACE --metrics-logging --metrics-server --rpc"
|
||||
wakuNodeBin = "build" / "wakunode2"
|
||||
metricsDir = "metrics"
|
||||
portOffset = 2
|
||||
|
@ -26,6 +26,17 @@ type
|
|||
Star,
|
||||
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
|
||||
proc initNodeCmd(shift: int, staticNodes: seq[string] = @[], master = false, label: string): NodeInfo =
|
||||
let
|
||||
|
@ -134,12 +145,14 @@ proc proccessGrafanaDashboard(nodes: int, inputFile: string,
|
|||
writeFile(outputFile, pretty(outputData))
|
||||
|
||||
when isMainModule:
|
||||
let conf = WakuNetworkConf.load()
|
||||
|
||||
# TODO: WakuNetworkConf
|
||||
var nodes: seq[NodeInfo]
|
||||
let topology = FullMesh
|
||||
let topology = conf.topology
|
||||
|
||||
# Scenario xx2 14
|
||||
let amount = 16
|
||||
let amount = conf.amount
|
||||
|
||||
case topology:
|
||||
of Star:
|
||||
|
@ -147,10 +160,10 @@ when isMainModule:
|
|||
of FullMesh:
|
||||
nodes = fullMeshNetwork(amount)
|
||||
|
||||
var staticnodes: seq[string]
|
||||
for i in 0..<amount:
|
||||
# TODO: could also select nodes randomly
|
||||
staticnodes.add(nodes[i].address)
|
||||
# var staticnodes: seq[string]
|
||||
# for i in 0..<amount:
|
||||
# # TODO: could also select nodes randomly
|
||||
# staticnodes.add(nodes[i].address)
|
||||
|
||||
# Scenario xx1 - 16 full nodes, one app topic, full mesh, gossip
|
||||
|
||||
|
|
Loading…
Reference in New Issue