Initial release

This commit is contained in:
alrevuelta 2023-06-26 16:19:59 +02:00
commit 978a276ed3
No known key found for this signature in database
GPG Key ID: F345C9F3CCDB886E
16 changed files with 4434 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
**/.DS_Store

38
README.md Normal file
View File

@ -0,0 +1,38 @@
# nwaku-simulator
## Requires
* docker
* docker-compose
## How to run
Without changing anything:
```
git clone
cd waku-simulator
```
```
export NWAKU_IMAGE=statusteam/nim-waku:v0.17.0
export NUM_NWAKU_NODES=5
docker-compose up -d
```
This will:
* spin up grafana/prometheus for monitoring
* spin up a bootstrap nwaku node
* spin up NUM_NWAKU_NODES nwaku nodes
* spin up a `waku-publisher` instance that will inject traffic into the network (see flags for rate and msg size)
Nodes can be monitored here:
http://localhost:3000/d/yns_4vFVk/nwaku-monitoring?orgId=1
## warning
in case arp tables are overflowing:
```
sysctl net.ipv4.neigh.default.gc_thresh3=32000
```

107
docker-compose.yml Normal file
View File

@ -0,0 +1,107 @@
version: "3.7"
services:
bootstrap:
image: ${NWAKU_IMAGE}
restart: on-failure
# TODO: expose some ports to inject traffic
ports:
- 127.0.0.1:60000:60000
- 127.0.0.1:8008:8008
- 127.0.0.1:9000:9000
- 127.0.0.1:8545:8545
entrypoint: sh
command:
- '/opt/run_bootstrap.sh'
volumes:
- ./run_bootstrap.sh:/opt/run_bootstrap.sh:Z
nwaku:
image: ${NWAKU_IMAGE}
restart: on-failure
deploy:
replicas: ${NUM_NWAKU_NODES}
entrypoint: sh
command:
- '/opt/run_nwaku.sh'
volumes:
- ./run_nwaku.sh:/opt/run_nwaku.sh:Z
depends_on:
- bootstrap
##gowaku:
## # crazy discv5 loop
## #image: ac1aa5d18e62c668c3644320247d3df0c6dcec6470fd48c70b6b6bfc659456ab
## #image: 51c2a81e23588acc8ee00c10523364d9ae4717241c8d59cce12c8d50146e7992 # relaxed disv5 loop 15 sec out if
## image: caaea91fdaf0992c4e98522a40531f37927e87f2feb39b91cbcf48f935fddeed # 5 sec delay out of if
## restart: on-failure
## deploy:
## replicas: 5
## entrypoint: sh
## command:
## - '/opt/run_gowaku.sh'
## volumes:
## - ./run_gowaku.sh:/opt/run_gowaku.sh:Z
## depends_on:
## - bootstrap
## environment:
## GO_WAKU: "true"
waku-publisher:
image: alrevuelta/waku-publisher:c985cb3
entrypoint: sh
- 'opt/run_wakupublisher.sh'
volumes:
- ./run_wakupublisher.sh:/opt/run_wakupublisher.sh:Z
prometheus:
image: prom/prometheus:latest
volumes:
- ./monitoring/prometheus-config.yml:/etc/prometheus/prometheus.yml:z
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.retention.time=7d
ports:
- 127.0.0.1:9090:9090
restart: on-failure
grafana:
image: grafana/grafana:latest
env_file:
- ./monitoring/configuration/grafana-plugins.env
volumes:
- ./monitoring/configuration/grafana.ini:/etc/grafana/grafana.ini:z
- ./monitoring/configuration/dashboards.yaml:/etc/grafana/provisioning/dashboards/dashboards.yaml:z
- ./monitoring/configuration/datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml:z
- ./monitoring/configuration/dashboards:/var/lib/grafana/dashboards/:z
- ./monitoring/configuration/customizations/custom-logo.svg:/usr/share/grafana/public/img/grafana_icon.svg:z
- ./monitoring/configuration/customizations/custom-logo.svg:/usr/share/grafana/public/img/grafana_typelogo.svg:z
- ./monitoring/configuration/customizations/custom-logo.png:/usr/share/grafana/public/img/fav32.png:z
ports:
#- 127.0.0.1:3000:3000
# open port to access the dashboard
- 3000:3000
restart: on-failure
depends_on:
- prometheus
cadvisor:
image: gcr.io/cadvisor/cadvisor:latest
container_name: cadvisor
#ports:
# - 8080:8080
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
depends_on:
- redis
redis:
image: redis:latest
container_name: redis
#ports:
# - 6379:6379

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1,9 @@
apiVersion: 1
providers:
- name: 'Prometheus'
orgId: 1
folder: ''
type: file
options:
path: /var/lib/grafana/dashboards

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
org_id: 1
url: http://prometheus:9090
is_default: true
version: 1
editable: true

View File

@ -0,0 +1,2 @@
#GF_INSTALL_PLUGINS=grafana-worldmap-panel,grafana-piechart-panel,digrich-bubblechart-panel,yesoreyeram-boomtheme-panel,briangann-gauge-panel,jdbranham-diagram-panel,agenty-flowcharting-panel,citilogics-geoloop-panel,savantly-heatmap-panel,mtanda-histogram-panel,pierosavi-imageit-panel,michaeldmoore-multistat-panel,zuburqan-parity-report-panel,natel-plotly-panel,bessler-pictureit-panel,grafana-polystat-panel,corpglory-progresslist-panel,snuids-radar-panel,fzakaria-simple-config.config.annotations-datasource,vonage-status-panel,snuids-trafficlights-panel,pr0ps-trackmap-panel,alexandra-trackmap-panel,btplc-trend-box-panel
GF_INSTALL_PLUGINS=grafana-worldmap-panel,grafana-piechart-panel,yesoreyeram-boomtheme-panel,briangann-gauge-panel,pierosavi-imageit-panel,bessler-pictureit-panel,vonage-status-panel

View File

@ -0,0 +1,51 @@
instance_name = nwaku dashboard
;[dashboards.json]
;enabled = true
;path = /home/git/grafana/grafana-dashboards/dashboards
#################################### Auth ##########################
[auth]
disable_login_form = false
#################################### Anonymous Auth ##########################
[auth.anonymous]
# enable anonymous access
enabled = true
# specify organization name that should be used for unauthenticated users
;org_name = Public
# specify role for unauthenticated users
; org_role = Admin
org_role = Viewer
;[security]
;admin_user = ocr
;admin_password = ocr
;[users]
# disable user signup / registration
;allow_sign_up = false
# Set to true to automatically assign new users to the default organization (id 1)
;auto_assign_org = true
# Default role new users will be automatically assigned (if disabled above is set to true)
;auto_assign_org_role = Viewer
#################################### SMTP / Emailing ##########################
;[smtp]
;enabled = false
;host = localhost:25
;user =
;password =
;cert_file =
;key_file =
;skip_verify = false
;from_address = admin@grafana.localhost
;[emails]
;welcome_email_on_sign_up = false

View File

@ -0,0 +1,217 @@
global:
scrape_interval: 15s
evaluation_interval: 15s
external_labels:
monitor: "Monitoring"
scrape_configs:
- job_name: cadvisor
scrape_interval: 5s
static_configs:
- targets:
- cadvisor:8080
- job_name: "nwaku"
static_configs:
- targets:
- bootstrap:8008
- waku-simulator_nwaku_1:8008
- waku-simulator_nwaku_2:8008
- waku-simulator_nwaku_3:8008
- waku-simulator_nwaku_4:8008
- waku-simulator_nwaku_5:8008
- waku-simulator_nwaku_6:8008
- waku-simulator_nwaku_7:8008
- waku-simulator_nwaku_8:8008
- waku-simulator_nwaku_9:8008
- waku-simulator_nwaku_10:8008
- waku-simulator_nwaku_11:8008
- waku-simulator_nwaku_12:8008
- waku-simulator_nwaku_13:8008
- waku-simulator_nwaku_14:8008
- waku-simulator_nwaku_15:8008
- waku-simulator_nwaku_16:8008
- waku-simulator_nwaku_17:8008
- waku-simulator_nwaku_18:8008
- waku-simulator_nwaku_19:8008
- waku-simulator_nwaku_20:8008
- waku-simulator_nwaku_21:8008
- waku-simulator_nwaku_22:8008
- waku-simulator_nwaku_23:8008
- waku-simulator_nwaku_24:8008
- waku-simulator_nwaku_25:8008
- waku-simulator_nwaku_26:8008
- waku-simulator_nwaku_27:8008
- waku-simulator_nwaku_28:8008
- waku-simulator_nwaku_29:8008
- waku-simulator_nwaku_30:8008
- waku-simulator_nwaku_31:8008
- waku-simulator_nwaku_32:8008
- waku-simulator_nwaku_33:8008
- waku-simulator_nwaku_34:8008
- waku-simulator_nwaku_35:8008
- waku-simulator_nwaku_36:8008
- waku-simulator_nwaku_37:8008
- waku-simulator_nwaku_38:8008
- waku-simulator_nwaku_39:8008
- waku-simulator_nwaku_40:8008
- waku-simulator_nwaku_41:8008
- waku-simulator_nwaku_42:8008
- waku-simulator_nwaku_43:8008
- waku-simulator_nwaku_44:8008
- waku-simulator_nwaku_45:8008
- waku-simulator_nwaku_46:8008
- waku-simulator_nwaku_47:8008
- waku-simulator_nwaku_48:8008
- waku-simulator_nwaku_49:8008
- waku-simulator_nwaku_50:8008
- waku-simulator_nwaku_51:8008
- waku-simulator_nwaku_52:8008
- waku-simulator_nwaku_53:8008
- waku-simulator_nwaku_54:8008
- waku-simulator_nwaku_55:8008
- waku-simulator_nwaku_56:8008
- waku-simulator_nwaku_57:8008
- waku-simulator_nwaku_58:8008
- waku-simulator_nwaku_59:8008
- waku-simulator_nwaku_60:8008
- waku-simulator_nwaku_61:8008
- waku-simulator_nwaku_62:8008
- waku-simulator_nwaku_63:8008
- waku-simulator_nwaku_64:8008
- waku-simulator_nwaku_65:8008
- waku-simulator_nwaku_66:8008
- waku-simulator_nwaku_67:8008
- waku-simulator_nwaku_68:8008
- waku-simulator_nwaku_69:8008
- waku-simulator_nwaku_70:8008
- waku-simulator_nwaku_71:8008
- waku-simulator_nwaku_72:8008
- waku-simulator_nwaku_73:8008
- waku-simulator_nwaku_74:8008
- waku-simulator_nwaku_75:8008
- waku-simulator_nwaku_76:8008
- waku-simulator_nwaku_77:8008
- waku-simulator_nwaku_78:8008
- waku-simulator_nwaku_79:8008
- waku-simulator_nwaku_80:8008
- waku-simulator_nwaku_81:8008
- waku-simulator_nwaku_82:8008
- waku-simulator_nwaku_83:8008
- waku-simulator_nwaku_84:8008
- waku-simulator_nwaku_85:8008
- waku-simulator_nwaku_86:8008
- waku-simulator_nwaku_87:8008
- waku-simulator_nwaku_88:8008
- waku-simulator_nwaku_89:8008
- waku-simulator_nwaku_90:8008
- waku-simulator_nwaku_91:8008
- waku-simulator_nwaku_92:8008
- waku-simulator_nwaku_93:8008
- waku-simulator_nwaku_94:8008
- waku-simulator_nwaku_95:8008
- waku-simulator_nwaku_96:8008
- waku-simulator_nwaku_97:8008
- waku-simulator_nwaku_98:8008
- waku-simulator_nwaku_99:8008
- waku-simulator_nwaku_100:8008
- waku-simulator_nwaku_101:8008
- waku-simulator_nwaku_102:8008
- waku-simulator_nwaku_103:8008
- waku-simulator_nwaku_104:8008
- waku-simulator_nwaku_105:8008
- waku-simulator_nwaku_106:8008
- waku-simulator_nwaku_107:8008
- waku-simulator_nwaku_108:8008
- waku-simulator_nwaku_109:8008
- waku-simulator_nwaku_110:8008
- waku-simulator_nwaku_111:8008
- waku-simulator_nwaku_112:8008
- waku-simulator_nwaku_113:8008
- waku-simulator_nwaku_114:8008
- waku-simulator_nwaku_115:8008
- waku-simulator_nwaku_116:8008
- waku-simulator_nwaku_117:8008
- waku-simulator_nwaku_118:8008
- waku-simulator_nwaku_119:8008
- waku-simulator_nwaku_120:8008
- waku-simulator_nwaku_121:8008
- waku-simulator_nwaku_122:8008
- waku-simulator_nwaku_123:8008
- waku-simulator_nwaku_124:8008
- waku-simulator_nwaku_125:8008
- waku-simulator_nwaku_126:8008
- waku-simulator_nwaku_127:8008
- waku-simulator_nwaku_128:8008
- waku-simulator_nwaku_129:8008
- waku-simulator_nwaku_130:8008
- waku-simulator_nwaku_131:8008
- waku-simulator_nwaku_132:8008
- waku-simulator_nwaku_133:8008
- waku-simulator_nwaku_134:8008
- waku-simulator_nwaku_135:8008
- waku-simulator_nwaku_136:8008
- waku-simulator_nwaku_137:8008
- waku-simulator_nwaku_138:8008
- waku-simulator_nwaku_139:8008
- waku-simulator_nwaku_140:8008
- waku-simulator_nwaku_141:8008
- waku-simulator_nwaku_142:8008
- waku-simulator_nwaku_143:8008
- waku-simulator_nwaku_144:8008
- waku-simulator_nwaku_145:8008
- waku-simulator_nwaku_146:8008
- waku-simulator_nwaku_147:8008
- waku-simulator_nwaku_148:8008
- waku-simulator_nwaku_149:8008
- waku-simulator_nwaku_150:8008
- waku-simulator_nwaku_151:8008
- waku-simulator_nwaku_152:8008
- waku-simulator_nwaku_153:8008
- waku-simulator_nwaku_154:8008
- waku-simulator_nwaku_155:8008
- waku-simulator_nwaku_156:8008
- waku-simulator_nwaku_157:8008
- waku-simulator_nwaku_158:8008
- waku-simulator_nwaku_159:8008
- waku-simulator_nwaku_160:8008
- waku-simulator_nwaku_161:8008
- waku-simulator_nwaku_162:8008
- waku-simulator_nwaku_163:8008
- waku-simulator_nwaku_164:8008
- waku-simulator_nwaku_165:8008
- waku-simulator_nwaku_166:8008
- waku-simulator_nwaku_167:8008
- waku-simulator_nwaku_168:8008
- waku-simulator_nwaku_169:8008
- waku-simulator_nwaku_170:8008
- waku-simulator_nwaku_171:8008
- waku-simulator_nwaku_172:8008
- waku-simulator_nwaku_173:8008
- waku-simulator_nwaku_174:8008
- waku-simulator_nwaku_175:8008
- waku-simulator_nwaku_176:8008
- waku-simulator_nwaku_177:8008
- waku-simulator_nwaku_178:8008
- waku-simulator_nwaku_179:8008
- waku-simulator_nwaku_180:8008
- waku-simulator_nwaku_181:8008
- waku-simulator_nwaku_182:8008
- waku-simulator_nwaku_183:8008
- waku-simulator_nwaku_184:8008
- waku-simulator_nwaku_185:8008
- waku-simulator_nwaku_186:8008
- waku-simulator_nwaku_187:8008
- waku-simulator_nwaku_188:8008
- waku-simulator_nwaku_189:8008
- waku-simulator_nwaku_190:8008
- waku-simulator_nwaku_191:8008
- waku-simulator_nwaku_192:8008
- waku-simulator_nwaku_193:8008
- waku-simulator_nwaku_194:8008
- waku-simulator_nwaku_195:8008
- waku-simulator_nwaku_196:8008
- waku-simulator_nwaku_197:8008
- waku-simulator_nwaku_198:8008
- waku-simulator_nwaku_199:8008
- waku-simulator_nwaku_200:8008

20
run_bootstrap.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
IP=$(ip a | grep "inet " | grep -Fv 127.0.0.1 | sed 's/.*inet \([^/]*\).*/\1/')
echo "I am a bootstrap node"
exec /usr/bin/wakunode\
--relay=true\
--rpc-admin=true\
--keep-alive=true\
--max-connections=300\
--dns-discovery=true\
--discv5-discovery=true\
--discv5-enr-auto-update=True\
--log-level=INFO\
--rpc-address=0.0.0.0\
--metrics-server=True\
--metrics-server-address=0.0.0.0\
--nodekey=30348dd51465150e04a5d9d932c72864c8967f806cce60b5d26afeca1e77eb68\
--nat=extip:${IP}

28
run_gowaku.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
IP=$(ip a | grep "inet " | grep -Fv 127.0.0.1 | sed 's/.*inet \([^/]*\).*/\1/')
echo "I am a gowaku node"
RETRIES=${RETRIES:=10}
while [ -z "${BOOTSTRAP_ENR}" ] && [ ${RETRIES} -ge 0 ]; do
BOOTSTRAP_ENR=$(wget -O - --post-data='{"jsonrpc":"2.0","method":"get_waku_v2_debug_v1_info","params":[],"id":1}' --header='Content-Type:application/json' http://bootstrap:8545/ 2> /dev/null | sed 's/.*"enrUri":"\([^"]*\)".*/\1/');
echo "Bootstrap node not ready, retrying (retries left: ${RETRIES})"
sleep 1
RETRIES=$(( $RETRIES - 1 ))
done
if [ -z "${BOOTSTRAP_ENR}" ]; then
echo "Could not get BOOTSTRAP_ENR and none provided. Failing"
exit 1
fi
echo "Using bootstrap node: ${BOOTSTRAP_ENR}"
exec /usr/bin/waku\
--discv5-discovery\
--discv5-bootstrap-node=${BOOTSTRAP_ENR}\
--metrics-server=True\
--metrics-server-address=0.0.0.0

35
run_nwaku.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/sh
IP=$(ip a | grep "inet " | grep -Fv 127.0.0.1 | sed 's/.*inet \([^/]*\).*/\1/')
echo "I am a nwaku node"
RETRIES=${RETRIES:=10}
while [ -z "${BOOTSTRAP_ENR}" ] && [ ${RETRIES} -ge 0 ]; do
BOOTSTRAP_ENR=$(wget -O - --post-data='{"jsonrpc":"2.0","method":"get_waku_v2_debug_v1_info","params":[],"id":1}' --header='Content-Type:application/json' http://bootstrap:8545/ 2> /dev/null | sed 's/.*"enrUri":"\([^"]*\)".*/\1/');
echo "Bootstrap node not ready, retrying (retries left: ${RETRIES})"
sleep 1
RETRIES=$(( $RETRIES - 1 ))
done
if [ -z "${BOOTSTRAP_ENR}" ]; then
echo "Could not get BOOTSTRAP_ENR and none provided. Failing"
exit 1
fi
echo "Using bootstrap node: ${BOOTSTRAP_ENR}"
exec /usr/bin/wakunode\
--relay=true\
--rpc-admin=true\
--keep-alive=true\
--max-connections=150\
--dns-discovery=true\
--discv5-discovery=true\
--discv5-enr-auto-update=True\
--log-level=INFO\
--rpc-address=0.0.0.0\
--metrics-server=True\
--metrics-server-address=0.0.0.0\
--discv5-bootstrap-node=${BOOTSTRAP_ENR}\
--nat=extip:${IP}

28
run_wakupublisher.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
IP=$(ip a | grep "inet " | grep -Fv 127.0.0.1 | sed 's/.*inet \([^/]*\).*/\1/')
echo "I am a traffic generator"
RETRIES=${RETRIES:=10}
while [ -z "${BOOTSTRAP_ENR}" ] && [ ${RETRIES} -ge 0 ]; do
BOOTSTRAP_ENR=$(wget -O - --post-data='{"jsonrpc":"2.0","method":"get_waku_v2_debug_v1_info","params":[],"id":1}' --header='Content-Type:application/json' http://bootstrap:8545/ 2> /dev/null | sed 's/.*"enrUri":"\([^"]*\)".*/\1/');
echo "Bootstrap node not ready, retrying (retries left: ${RETRIES})"
sleep 1
RETRIES=$(( $RETRIES - 1 ))
done
if [ -z "${BOOTSTRAP_ENR}" ]; then
echo "Could not get BOOTSTRAP_ENR and none provided. Failing"
exit 1
fi
echo "Using bootstrap node: ${BOOTSTRAP_ENR}"
exec /main\
--pubsub-topic="/waku/2/default-waku/proto"\
--content-topic="my-ctopic"\
--msg-per-second=10\
--msg-size-kb=1\
--bootstrap-node=${BOOTSTRAP_ENR}\
--max-peers=50

34
traffic.py Normal file

File diff suppressed because one or more lines are too long