From b1a73d27f19122574e055b066270912b7c340669 Mon Sep 17 00:00:00 2001 From: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com> Date: Tue, 10 Jun 2025 16:12:41 +0200 Subject: [PATCH] Adapt to latest nwaku master changes on configuration --- docker-compose.yml | 28 +- .../liter-protocol-test-monitoring.json | 4 +- .../configuration/dashboards/nimgc.json | 741 ++++++++++++++++++ run_bootstrap.sh | 4 +- run_edgenode.sh | 2 - run_nwaku.sh | 6 +- run_relaynode.sh | 161 ++++ run_servicenode.sh | 9 +- 8 files changed, 937 insertions(+), 18 deletions(-) create mode 100644 monitoring/configuration/dashboards/nimgc.json create mode 100755 run_relaynode.sh diff --git a/docker-compose.yml b/docker-compose.yml index d241a52..ee111d1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -75,7 +75,7 @@ services: - simulation contract-repo-deployer: - image: node:hydrogen-bullseye + image: node:hydrogen-bookworm labels: com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-true}' environment: @@ -116,10 +116,11 @@ services: ipv4_address: 10.2.0.100 servicenode: - image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest} + image: ${SERVICENODE_IMAGE:-wakuorg/nwaku:latest} # container_name: servicenode cpuset: ${SERVICENODE_CPU_CORES:-4} mem_limit: ${SERVICENODE_MEM_LIMIT:-512m} + memswap_limit: ${SERVICENODE_MEM_LIMIT:-512m} restart: on-failure labels: com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-true}' @@ -150,6 +151,29 @@ services: simulation: ipv4_address: 10.2.0.101 + relaynode: + image: ${SERVICENODE_IMAGE:-wakuorg/nwaku:latest} + restart: on-failure + labels: + com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-true}' + ports: + - 127.0.0.1:8643:8645 # Service node REST-API + entrypoint: sh + environment: + <<: + - *rln_env + - *bootstrap_env + command: + - '/opt/run_relaynode.sh' + volumes: + - ./run_relaynode.sh:/opt/run_relaynode.sh:Z + - privatekeys-volume:/shared + depends_on: + contract-repo-deployer: + condition: service_completed_successfully + networks: + - simulation + nwaku: image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest} restart: on-failure diff --git a/monitoring/configuration/dashboards/liter-protocol-test-monitoring.json b/monitoring/configuration/dashboards/liter-protocol-test-monitoring.json index e094b5b..ce65153 100644 --- a/monitoring/configuration/dashboards/liter-protocol-test-monitoring.json +++ b/monitoring/configuration/dashboards/liter-protocol-test-monitoring.json @@ -2051,13 +2051,13 @@ "text": "lpt-receivernode-1:8003", "value": "lpt-receivernode-1:8003" }, - "definition": "label_values({instance=~\".*receivernode.*\"},instance)", + "definition": "label_values({instance=~\".*receiver.*\"},instance)", "includeAll": false, "name": "receiver", "options": [], "query": { "qryType": 1, - "query": "label_values({instance=~\".*receivernode.*\"},instance)", + "query": "label_values({instance=~\".*receiver.*\"},instance)", "refId": "PrometheusVariableQueryEditor-VariableQuery" }, "refresh": 1, diff --git a/monitoring/configuration/dashboards/nimgc.json b/monitoring/configuration/dashboards/nimgc.json new file mode 100644 index 0000000..e70aea8 --- /dev/null +++ b/monitoring/configuration/dashboards/nimgc.json @@ -0,0 +1,741 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Measuring performance of request/response nwaku protocols.\nLightpush, Filter and Store request processing times are measured.", + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": 2, + "links": [], + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 9, + "panels": [], + "title": "Lightpush performance in scope of Nim Memory Management", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 13, + "x": 0, + "y": 1 + }, + "id": 11, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "editorMode": "builder", + "expr": "rate(waku_service_requests_total{service = \"/vac/waku/lightpush/2.0.0-beta1\", instance=\"servicenode:8008\"}[$__rate_interval])", + "legendFormat": "{{service}}", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "rate(waku_service_requests_total{service=\"/vac/waku/filter-subscribe/2.0.0-beta1\", instance=\"servicenode:8008\"}[$__rate_interval])", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "legendFormat": "{{service}}", + "range": true, + "refId": "B", + "useBackend": false + } + ], + "title": "Lightpush and filter request rate", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 30, + "w": 11, + "x": 13, + "y": 1 + }, + "id": 15, + "options": { + "legend": { + "calcs": [ + "lastNotNull", + "max", + "min" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "builder", + "expr": "nim_gc_heap_instance_occupied_bytes{instance=\"servicenode:8008\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "legendFormat": "{{type_name}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Heap allocation per objects", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "scaleDistribution": { + "type": "linear" + } + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 13, + "x": 0, + "y": 9 + }, + "id": 1, + "options": { + "calculate": false, + "cellGap": 1, + "color": { + "exponent": 0.5, + "fill": "dark-orange", + "mode": "scheme", + "reverse": true, + "scale": "exponential", + "scheme": "Reds", + "steps": 64 + }, + "exemplars": { + "color": "rgba(255,0,255,0.7)" + }, + "filterValues": { + "le": 1e-9 + }, + "legend": { + "show": true + }, + "rowsFrame": { + "layout": "auto" + }, + "tooltip": { + "mode": "single", + "showColorScale": false, + "yHistogram": false + }, + "yAxis": { + "axisPlacement": "left", + "reverse": false, + "unit": "s" + } + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "exemplar": false, + "expr": "sum by(le) (increase(waku_service_request_handling_duration_seconds_bucket{instance=\"servicenode:8008\", service=\"/vac/waku/lightpush/2.0.0-beta1\"}[$__rate_interval]))", + "format": "heatmap", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "interval": "", + "legendFormat": "{{le}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Lightpush request performance", + "type": "heatmap" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 25, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 16, + "w": 13, + "x": 0, + "y": 15 + }, + "id": 5, + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "builder", + "expr": "nim_gc_mem_bytes{instance=\"servicenode:8008\"}", + "format": "time_series", + "fullMetaSearch": false, + "includeNullMetadata": true, + "legendFormat": "Nim gc mem bytes of {{instance}}", + "range": true, + "refId": "A", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "nim_gc_mem_occupied_bytes{instance=\"servicenode:8008\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "Nim gc occupied bytes of {{instance}}", + "range": true, + "refId": "B", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "nim_gc_heap_instance_occupied_summed_bytes{instance=\"servicenode:8008\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "Nim gc heap bytes of {{instance}}", + "range": true, + "refId": "C", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "process_virtual_memory_bytes{instance=\"servicenode:8008\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "Process virtual memory of {{instance}}", + "range": true, + "refId": "D", + "useBackend": false + } + ], + "title": "NIM GC Memory", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 13, + "x": 0, + "y": 31 + }, + "id": 14, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "editorMode": "code", + "expr": "rate(container_cpu_usage_seconds_total{container_label_com_docker_compose_service=\"servicenode\"}[$__rate_interval])", + "legendFormat": "{{container_label_com_docker_compose_service}}", + "range": true, + "refId": "A" + } + ], + "title": "CPU usage", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 27, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 11, + "x": 13, + "y": 31 + }, + "id": 7, + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "container_memory_usage_bytes{container_label_com_docker_compose_service=\"servicenode\"}", + "format": "time_series", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{container_label_com_docker_compose_service}}", + "range": true, + "refId": "B", + "useBackend": false + } + ], + "title": "Container memory usage", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 39 + }, + "id": 8, + "panels": [], + "title": "General load", + "type": "row" + } + ], + "preload": false, + "refresh": "auto", + "schemaVersion": 41, + "tags": [], + "templating": { + "list": [ + { + "allowCustomValue": false, + "current": { + "text": "servicenode:8008", + "value": "servicenode:8008" + }, + "definition": "label_values(libp2p_peers{instance=~\".*servicenode.*\"},instance)", + "label": "nwaku-instance", + "name": "nwaku_instance", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(libp2p_peers{instance=~\".*servicenode.*\"},instance)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "", + "type": "query" + } + ] + }, + "time": { + "from": "now-15m", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Nim GC performance testing", + "uid": "cegfnbzrn2yv4cnimgc", + "version": 1 +} \ No newline at end of file diff --git a/run_bootstrap.sh b/run_bootstrap.sh index d27dfe7..476264e 100755 --- a/run_bootstrap.sh +++ b/run_bootstrap.sh @@ -13,7 +13,7 @@ exec /usr/bin/wakunode\ --rest-allow-origin="waku-org.github.io"\ --rest-allow-origin="localhost:*"\ --max-connections=300\ - --dns-discovery=true\ + --dns-discovery=false\ --discv5-discovery=true\ --discv5-enr-auto-update=True\ --log-level=DEBUG\ @@ -23,5 +23,3 @@ exec /usr/bin/wakunode\ --nat=extip:${IP}\ --shard=0\ --cluster-id=66 - - # --pubsub-topic=/waku/2/rs/66/0\ \ No newline at end of file diff --git a/run_edgenode.sh b/run_edgenode.sh index e2f5c94..2ef6ec8 100755 --- a/run_edgenode.sh +++ b/run_edgenode.sh @@ -46,5 +46,3 @@ exec /usr/bin/wakunode\ --shard=0\ --cluster-id=66\ --nodekey=5358f02c157accb30a6c1d5920e778604de12e23d6009512be44f72f1a64d828 - - # --pubsub-topic=/waku/2/rs/66/0\ \ No newline at end of file diff --git a/run_nwaku.sh b/run_nwaku.sh index e419848..7c07cdc 100755 --- a/run_nwaku.sh +++ b/run_nwaku.sh @@ -141,15 +141,13 @@ exec /usr/bin/wakunode\ --rln-relay-tree-path="rlnv2_tree1"\ --rln-relay-epoch-sec=$RLN_RELAY_EPOCH_SEC\ --rln-relay-user-message-limit=$RLN_RELAY_MSG_LIMIT\ - --dns-discovery=true\ + --dns-discovery=false\ --discv5-discovery=true\ --discv5-enr-auto-update=True\ - --log-level=DEBUG\ + --log-level=INFO\ --metrics-server=True\ --metrics-server-address=0.0.0.0\ --discv5-bootstrap-node=${BOOTSTRAP_ENR}\ --nat=extip:${IP}\ --shard=0\ --cluster-id=66 - - #--pubsub-topic=/waku/2/rs/66/0\ \ No newline at end of file diff --git a/run_relaynode.sh b/run_relaynode.sh new file mode 100755 index 0000000..5c6404a --- /dev/null +++ b/run_relaynode.sh @@ -0,0 +1,161 @@ +#!/bin/sh + +# Check Linux Distro Version - it can differ depending on the nwaku image used +OS=$(cat /etc/os-release) +if echo $OS | grep -q "Debian"; then + echo "The operating system is Debian." + apt update + apt install -y dnsutils + apt install -y jq +elif echo $OS | grep -q "Alpine"; then + echo "The operating system is Alpine." + apk add bind-tools + apk add jq +fi + +if test -f .env; then + echo "Using .env file" + . $(pwd)/.env +fi + +IP=$(ip a | grep "inet " | grep -Fv 127.0.0.1 | sed 's/.*inet \([^/]*\).*/\1/') + +# Function to extract IP address from URL, resolve the IP and replace it in the original URL +get_ip_address_and_replace() { + local url=$1 + local domain_name=$(echo $RPC_URL | awk -F[/:] '{print $4}') + local ip_address=$(dig +short $domain_name) + valid_rpc_url="$(echo "$url" | sed "s/$domain_name/$ip_address/g")" + echo $valid_rpc_url +} + +# the format of the RPC URL is checked in the generateRlnKeystore command and hostnames are not valid +pattern="^(https?):\/\/((localhost)|([\w_-]+(?:(?:\.[\w_-]+)+)))(:[0-9]{1,5})?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])*" +# Perform regex matching +if echo "$RPC_URL" | grep -q "$pattern"; then + echo "RPC URL is valid" +else + echo "RPC URL is invalid: $RPC_URL. Attempting to resolve hostname." + resolved_rpc_url="$(get_ip_address_and_replace $RPC_URL)" + if [ -z "$resolved_rpc_url" ]; then + echo -e "Failed to retrieve IP address for $RPC_URL\n" + else + echo -e "Resolved RPC URL for $RPC_URL: $resolved_rpc_url" + RPC_URL="$resolved_rpc_url" + fi +fi + +#Function to get the index of the container and use it to retrieve a private key to be used to generate the keystore, allowing for either dash or underscore container name format (for docker-compose backward compatibility) +get_private_key(){ + + # Read the JSON file + json_content=$(cat /shared/anvil-config.txt) + + # Check if json_content has a value + if [ -z "$json_content" ]; then + echo "Error: Failed to read the JSON file or the file is empty." >&2 + return 1 + fi + + # Extract private_keys json array using jq + private_keys=$(echo "$json_content" | jq -r '.private_keys[]') + + CNTR=`dig -x $IP +short | cut -d'.' -f1` + INDEX=`echo $CNTR | sed 's/.*[-_]\([0-9]*\)/\1/'` + + if [ $? -ne 0 ] || [ -z "$INDEX" ]; then + echo "Error: Failed to determine the replica index from IP." >&2 + return 1 + fi + + + # iterate through list of private keys and get the one corresponding to the container index + # we need to iterate because array objects cannot be used in /bin/ash (Alpine) and a separate script would need to be called to use bash + current_index=1 + for key in $private_keys + do + if [ $current_index -eq $INDEX ]; then + pk=$key + echo $key + break + fi + current_index=$((current_index+1)) + done + + if [ -z "$pk" ]; then + echo "Error: Failed to get private key for the container with index=$INDEX." >&2 + return 1 + fi +} + +if test -f .$RLN_CREDENTIAL_PATH; then + echo "$RLN_CREDENTIAL_PATH already exists. Use it instead of creating a new one." +else + private_key="$(get_private_key)" + echo "Private key: $private_key" + + echo "Generating RLN keystore" + /usr/bin/wakunode generateRlnKeystore \ + --rln-relay-eth-client-address="$RPC_URL" \ + --rln-relay-eth-private-key=$private_key \ + --rln-relay-eth-contract-address=$RLN_CONTRACT_ADDRESS \ + --rln-relay-cred-path=$RLN_CREDENTIAL_PATH \ + --rln-relay-cred-password=$RLN_CREDENTIAL_PASSWORD \ + --rln-relay-user-message-limit=$RLN_RELAY_MSG_LIMIT \ + --rln-relay-epoch-sec=$RLN_RELAY_EPOCH_SEC \ + --log-level=DEBUG \ + --execute +fi + +echo "I am a nwaku node" + +RETRIES=${RETRIES:=10} + +while [ -z "${BOOTSTRAP_ENR}" ] && [ ${RETRIES} -ge 0 ]; do + BOOTSTRAP_ENR=$(wget -qO- http://bootstrap:8645/debug/v1/info --header='Content-Type:application/json' 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}" +echo "My IP is: ${IP}" +echo "Run with RLN ${RLN_ENABLED}" + +exec /usr/bin/wakunode\ + --relay=true\ + --lightpush=true\ + --max-connections=250\ + --rest=true\ + --rest-admin=true\ + --rest-address=0.0.0.0\ + --rest-port=8645\ + --rest-allow-origin="waku-org.github.io"\ + --rest-allow-origin="localhost:*"\ + --rln-relay=${RLN_ENABLED}\ + --rln-relay-dynamic=true\ + --rln-relay-eth-client-address="$RPC_URL"\ + --rln-relay-eth-contract-address=$RLN_CONTRACT_ADDRESS\ + --rln-relay-cred-path=$RLN_CREDENTIAL_PATH\ + --rln-relay-cred-password=$RLN_CREDENTIAL_PASSWORD\ + --rln-relay-tree-path="rlnv2_tree1"\ + --rln-relay-epoch-sec=$RLN_RELAY_EPOCH_SEC\ + --rln-relay-user-message-limit=$RLN_RELAY_MSG_LIMIT\ + --dns-discovery=false\ + --discv5-discovery=true\ + --discv5-enr-auto-update=True\ + --log-level=DEBUG\ + --metrics-server=True\ + --metrics-server-address=0.0.0.0\ + --discv5-bootstrap-node=${BOOTSTRAP_ENR}\ + --nat=extip:${IP}\ + --shard=0\ + --num-shards-in-network=1\ + --cluster-id=66 + + #--pubsub-topic=/waku/2/rs/66/0\ \ No newline at end of file diff --git a/run_servicenode.sh b/run_servicenode.sh index 14ad629..dc4d5a7 100755 --- a/run_servicenode.sh +++ b/run_servicenode.sh @@ -155,19 +155,18 @@ exec /usr/bin/wakunode\ --rln-relay-tree-path="rlnv2_tree1"\ --rln-relay-epoch-sec=$RLN_RELAY_EPOCH_SEC\ --rln-relay-user-message-limit=$RLN_RELAY_MSG_LIMIT\ - --dns-discovery=true\ + --dns-discovery=false\ --discv5-discovery=true\ --discv5-enr-auto-update=True\ --discv5-bootstrap-node=${BOOTSTRAP_ENR}\ - --log-level=INFO\ + --log-level=DEBUG\ --metrics-server=True\ --metrics-server-address=0.0.0.0\ --nat=extip:${IP}\ --tcp-port:60001\ --nodekey=e3416f0b00005aa3ebc9cd42797b3847bfbf4fe810edaa6a1fc65e755638b7fb\ --shard=0\ + --num-shards-in-network=1\ --cluster-id=66\ --store-message-db-url="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/postgres"\ - ${STORE_RETENTION_POLICY}\ - - #--pubsub-topic=/waku/2/rs/66/0\ \ No newline at end of file + ${STORE_RETENTION_POLICY}