diff --git a/waku/README.md b/waku/README.md index 523f8f55ec..49f29ecf83 100644 --- a/waku/README.md +++ b/waku/README.md @@ -54,16 +54,13 @@ Example of a quick simulation using this approach: # Build wakunode + quicksim make NIMFLAGS="-d:insecure" wakusim -# Start the simulation nodes -./waku/start_network.sh -# Or when multitail is installed -USE_MULTITAIL="yes" ./waku/start_network.sh - -# In another shell +# Start the simulation nodes, this currently requires multitail to be installed +./build/start_network --topology:FullMesh --amount:6 --test-node-peers:2 +# In another shell run ./build/quicksim ``` -The `start_network.sh` script will also provide a `prometheus.yml` with targets +The `start_network` tool will also provide a `prometheus.yml` with targets set to all simulation nodes that are started. This way you can easily start prometheus with this config, e.g.: @@ -74,4 +71,4 @@ prometheus A Grafana dashboard containing the example dashboard for each simulation node is also generated and can be imported in case you have Grafana running. -This dashboard can be found at `./waku/metrics/waku-sim-all-nodes-grafana-dashboard.json` \ No newline at end of file +This dashboard can be found at `./waku/metrics/waku-sim-all-nodes-grafana-dashboard.json` diff --git a/waku/process_dashboard.nim b/waku/process_dashboard.nim deleted file mode 100644 index cf741c4341..0000000000 --- a/waku/process_dashboard.nim +++ /dev/null @@ -1,55 +0,0 @@ -# copy from https://github.com/status-im/nim-beacon-chain/blob/master/tests/simulation/process_dashboard.nim -import json, parseopt, strutils - -# usage: process_dashboard --nodes=2 --in=node0_dashboard.json --out=all_nodes_dashboard.json -var - p = initOptParser() - nodes: int - inputFileName, outputFilename: string - -while true: - p.next() - case p.kind: - of cmdEnd: - break - of cmdShortOption, cmdLongOption: - if p.key == "nodes": - nodes = p.val.parseInt() - elif p.key == "in": - inputFileName = p.val - elif p.key == "out": - outputFileName = p.val - else: - echo "unsupported argument: ", p.key - of cmdArgument: - echo "unsupported argument: ", p.key - -var - inputData = parseFile(inputFileName) - panels = inputData["panels"].copy() - numPanels = len(panels) - gridHeight = 0 - outputData = inputData - -for panel in panels: - if panel["gridPos"]["x"].getInt() == 0: - gridHeight += panel["gridPos"]["h"].getInt() - -outputData["panels"] = %* [] -for nodeNum in 0 .. (nodes - 1): - var - nodePanels = panels.copy() - panelIndex = 0 - for panel in nodePanels.mitems: - panel["title"] = %* replace(panel["title"].getStr(), "#0", "#" & $nodeNum) - panel["id"] = %* (panelIndex + (nodeNum * numPanels)) - panel["gridPos"]["y"] = %* (panel["gridPos"]["y"].getInt() + (nodeNum * gridHeight)) - var targets = panel["targets"] - for target in targets.mitems: - target["expr"] = %* replace(target["expr"].getStr(), "{node=\"0\"}", "{node=\"" & $nodeNum & "\"}") - outputData["panels"].add(panel) - panelIndex.inc() - -outputData["uid"] = %* (outputData["uid"].getStr() & "a") -outputData["title"] = %* (outputData["title"].getStr() & " (all nodes)") -writeFile(outputFilename, pretty(outputData)) diff --git a/waku/start_network.nim b/waku/start_network.nim index 9446a3bfd9..36977c85ad 100644 --- a/waku/start_network.nim +++ b/waku/start_network.nim @@ -1,10 +1,11 @@ import - strformat, osproc, net, confutils, strformat, chronicles, + strformat, os, osproc, net, confutils, strformat, chronicles, json, strutils, eth/keys, eth/p2p/enode const defaults ="--log-level:DEBUG --log-metrics --metrics-server --rpc" - wakuNodeBin = "./build/wakunode" + wakuNodeBin = "build" / "wakunode" + metricsDir = "waku" / "metrics" portOffset = 2 type @@ -38,6 +39,7 @@ type cmd: string master: bool enode: string + shift: int label: string proc initNodeCmd(nodeType: NodeType, shift: int, staticNodes: seq[string] = @[], @@ -66,6 +68,7 @@ proc initNodeCmd(nodeType: NodeType, shift: int, staticNodes: seq[string] = @[], result.master = master result.enode = $enode + result.shift = shift result.label = label debug "Node command created.", cmd=result.cmd @@ -95,37 +98,97 @@ proc discoveryNetwork(amount: int): seq[NodeInfo] = result.add(initNodeCmd(FullNode, portOffset + i, label = "full node", discovery = true, bootNodes = @[bootNode.enode])) -let conf = WakuNetworkConf.load() - -var nodes: seq[NodeInfo] -case conf.topology: - of Star: - nodes = starNetwork(conf.amount) - of FullMesh: - nodes = fullMeshNetwork(conf.amount) - of DiscoveryBased: - nodes = discoveryNetwork(conf.amount) - -var staticnodes: seq[string] -for i in 0../dev/null || USE_MULTITAIL="no" - -# TODO: This is based on the nim-beacon-chain eth2_network_simulation but quite -# the much worse version due to the custom nodes we need. Need to rework this -# to be less hardcoded, but might use a Nim application for this, hence the -# quick and dirty way for now. - -mkdir -p "${METRICS_DIR}"/prometheus/ -cat > "${METRICS_DIR}/prometheus/prometheus.yml" <