connect external store node

This commit is contained in:
stubbsta 2024-09-13 12:17:50 +02:00
parent 829a8929ad
commit 5a1e3974ae
No known key found for this signature in database
5 changed files with 293 additions and 185 deletions

View File

@ -12,72 +12,72 @@ services:
# Accounts are hardcoded to 520 with the idea that nwaku nodes use up to 500 for membership registration and the last 20 are used for ad-hoc testing. # Accounts are hardcoded to 520 with the idea that nwaku nodes use up to 500 for membership registration and the last 20 are used for ad-hoc testing.
# The account number and private key pairs of the last 20 accounts can be found in the Register memberships section of the Waku-simulator book. # The account number and private key pairs of the last 20 accounts can be found in the Register memberships section of the Waku-simulator book.
# foundry: foundry:
# image: ghcr.io/foundry-rs/foundry:nightly-9b73e06e1fe376738b92ae081107620291d50188 image: ghcr.io/foundry-rs/foundry:nightly-9b73e06e1fe376738b92ae081107620291d50188
# labels: labels:
# com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}'
# ports: ports:
# - 0.0.0.0:8545:8545 - 0.0.0.0:8545:8545
# command: command:
# - anvil - anvil
# --port=8545 --port=8545
# --host=0.0.0.0 --host=0.0.0.0
# --accounts=520 --accounts=520
# --allow-origin=* --allow-origin=*
# --block-time=3 --block-time=3
# --chain-id=1234 --chain-id=1234
# --silent --silent
# --config-out=/shared/anvil-config.txt --config-out=/shared/anvil-config.txt
# volumes: volumes:
# - privatekeys-volume:/shared - privatekeys-volume:/shared
# networks: networks:
# - simulation - simulation
# contract-repo-deployer: contract-repo-deployer:
# image: node:hydrogen-bullseye image: node:hydrogen-bullseye
# labels: labels:
# com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}'
# environment: environment:
# - PRIVATE_KEY=${PRIVATE_KEY} - PRIVATE_KEY=${PRIVATE_KEY}
# - RPC_URL=${RPC_URL:-http://foundry:8545} - RPC_URL=${RPC_URL:-http://foundry:8545}
# - ETH_FROM=${ETH_FROM} - ETH_FROM=${ETH_FROM}
# - MAX_MESSAGE_LIMIT=${MAX_MESSAGE_LIMIT:-20} - MAX_MESSAGE_LIMIT=${MAX_MESSAGE_LIMIT:-20}
# entrypoint: sh entrypoint: sh
# command: command:
# - '/opt/deploy_rln_contract.sh' - '/opt/deploy_rln_contract.sh'
# volumes: volumes:
# - ./deploy_rln_contract.sh:/opt/deploy_rln_contract.sh - ./deploy_rln_contract.sh:/opt/deploy_rln_contract.sh
# depends_on: depends_on:
# - foundry - foundry
# networks: networks:
# - simulation - simulation
# bootstrap: bootstrap:
# image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest} image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest}
# restart: on-failure restart: on-failure
# labels: labels:
# com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}'
# # TODO: expose some ports to inject traffic # TODO: expose some ports to inject traffic
# ports: ports:
# - 127.0.0.1:60000:60000 - 127.0.0.1:60000:60000
# - 127.0.0.1:8008:8008 - 127.0.0.1:8008:8008
# - 127.0.0.1:9000:9000 - 127.0.0.1:9000:9000
# - 127.0.0.1:8645:8645 - 127.0.0.1:8645:8645
# entrypoint: sh entrypoint: sh
# command: command:
# - '/opt/run_bootstrap.sh' - '/opt/run_bootstrap.sh'
# volumes: volumes:
# - ./run_bootstrap.sh:/opt/run_bootstrap.sh:Z - ./run_bootstrap.sh:/opt/run_bootstrap.sh:Z
# networks: networks:
# - simulation - simulation
nwaku: nwaku:
image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest} image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest}
restart: on-failure restart: on-failure
labels: labels:
com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}'
# deploy: deploy:
# replicas: ${NUM_NWAKU_NODES:-5} replicas: ${NUM_NWAKU_NODES:-5}
entrypoint: sh entrypoint: sh
environment: environment:
- RPC_URL=${RPC_URL:-http://foundry:8545} - RPC_URL=${RPC_URL:-http://foundry:8545}
@ -87,13 +87,15 @@ services:
- RLN_RELAY_MSG_LIMIT=${RLN_RELAY_MSG_LIMIT:-10} - RLN_RELAY_MSG_LIMIT=${RLN_RELAY_MSG_LIMIT:-10}
- RLN_RELAY_EPOCH_SEC=${RLN_RELAY_EPOCH_SEC:-60} - RLN_RELAY_EPOCH_SEC=${RLN_RELAY_EPOCH_SEC:-60}
command: command:
- '/opt/run_nwaku_noRLN.sh' - '/opt/run_nwaku.sh'
volumes: volumes:
- ./run_nwaku_noRLN.sh:/opt/run_nwaku_noRLN.sh:Z - ./run_nwaku.sh:/opt/run_nwaku.sh:Z
- privatekeys-volume:/shared - privatekeys-volume:/shared
depends_on:
contract-repo-deployer:
condition: service_completed_successfully
networks: networks:
simulation: - simulation
ipv4_address: 10.2.0.50
# nwaku_store: # nwaku_store:
# image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest} # image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest}
@ -116,61 +118,61 @@ services:
# simulation: # simulation:
# ipv4_address: 10.2.0.99 # ipv4_address: 10.2.0.99
# rest-traffic: rest-traffic:
# image: alrevuelta/rest-traffic:6992bb5 image: alrevuelta/rest-traffic:6992bb5
# command: command:
# --multiple-nodes=http://waku-simulator_nwaku_[1..${NUM_NWAKU_NODES:-5}]:8645 --multiple-nodes=http://waku-simulator_nwaku_[1..${NUM_NWAKU_NODES:-5}]:8645
# --msg-size-kbytes=${MSG_SIZE_KBYTES:-10} --msg-size-kbytes=${MSG_SIZE_KBYTES:-10}
# --delay-seconds=${TRAFFIC_DELAY_SECONDS:-15} --delay-seconds=${TRAFFIC_DELAY_SECONDS:-15}
# networks: networks:
# - simulation - simulation
# depends_on: depends_on:
# - nwaku - nwaku
# postgres: postgres:
# # This service is used when the Waku node has the 'store' protocol enabled # This service is used when the Waku node has the 'store' protocol enabled
# # and the store-message-db-url is set to use Postgres # and the store-message-db-url is set to use Postgres
# image: postgres:15.4-alpine3.18 image: postgres:15.4-alpine3.18
# restart: on-failure:5 restart: on-failure:5
# environment: environment:
# - POSTGRES_USER=${POSTGRES_USER:-postgres} - POSTGRES_USER=${POSTGRES_USER:-postgres}
# - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123}
# volumes: volumes:
# - ./postgres_cfg/postgresql.conf:/etc/postgresql/postgresql.conf:Z - ./postgres_cfg/postgresql.conf:/etc/postgresql/postgresql.conf:Z
# - ./postgres_cfg/db.sql:/docker-entrypoint-initdb.d/db.sql:Z - ./postgres_cfg/db.sql:/docker-entrypoint-initdb.d/db.sql:Z
# - ${PG_DATA_DIR:-./postgresql}:/var/lib/postgresql/data:Z - ${PG_DATA_DIR:-./postgresql}:/var/lib/postgresql/data:Z
# command: postgres -c config_file=/etc/postgresql/postgresql.conf command: postgres -c config_file=/etc/postgresql/postgresql.conf
# ports: ports:
# - 127.0.0.1:5432:5432 - 127.0.0.1:5432:5432
# networks: networks:
# - simulation - simulation
# healthcheck: healthcheck:
# test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"] test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"]
# interval: 30s interval: 30s
# timeout: 60s timeout: 60s
# retries: 5 retries: 5
# start_period: 80s start_period: 80s
# postgres-exporter: postgres-exporter:
# # Service aimed to scrape information from Postgres and post it to Prometeus # Service aimed to scrape information from Postgres and post it to Prometeus
# image: quay.io/prometheuscommunity/postgres-exporter:v0.12.0 image: quay.io/prometheuscommunity/postgres-exporter:v0.12.0
# restart: on-failure:5 restart: on-failure:5
# environment: environment:
# - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123}
# - DATA_SOURCE_URI=postgres?sslmode=disable - DATA_SOURCE_URI=postgres?sslmode=disable
# - DATA_SOURCE_USER=${POSTGRES_USER:-postgres} - DATA_SOURCE_USER=${POSTGRES_USER:-postgres}
# - DATA_SOURCE_PASS=${POSTGRES_PASSWORD:-test123} - DATA_SOURCE_PASS=${POSTGRES_PASSWORD:-test123}
# - PG_EXPORTER_EXTEND_QUERY_PATH=/etc/pgexporter/queries.yml - PG_EXPORTER_EXTEND_QUERY_PATH=/etc/pgexporter/queries.yml
# volumes: volumes:
# - ./monitoring/configuration/postgres-exporter.yml:/etc/pgexporter/postgres-exporter.yml:Z - ./monitoring/configuration/postgres-exporter.yml:/etc/pgexporter/postgres-exporter.yml:Z
# - ./monitoring/configuration/pg-exporter-queries.yml:/etc/pgexporter/queries.yml:Z - ./monitoring/configuration/pg-exporter-queries.yml:/etc/pgexporter/queries.yml:Z
# command: command:
# # Both the config file and 'DATA_SOURCE_NAME' should contain valid connection info # Both the config file and 'DATA_SOURCE_NAME' should contain valid connection info
# - --config.file=/etc/pgexporter/postgres-exporter.yml - --config.file=/etc/pgexporter/postgres-exporter.yml
# depends_on: depends_on:
# - postgres - postgres
# networks: networks:
# - simulation - simulation
prometheus: prometheus:
image: prom/prometheus:latest image: prom/prometheus:latest
@ -231,71 +233,71 @@ services:
networks: networks:
- simulation - simulation
# api: api:
# image: web3labs/epirus-free-api:latest image: web3labs/epirus-free-api:latest
# ports: ports:
# - 127.0.0.1:8090:8090 - 127.0.0.1:8090:8090
# environment: environment:
# - NODE_ENDPOINT=${RPC_URL:-http://foundry:8545} - NODE_ENDPOINT=${RPC_URL:-http://foundry:8545}
# - MONGO_CLIENT_URI=mongodb://mongodb:27017 - MONGO_CLIENT_URI=mongodb://mongodb:27017
# - REINDEX_ENDPOINT=http://ingestion/reindex/ - REINDEX_ENDPOINT=http://ingestion/reindex/
# - MONGO_DB_NAME=epirus - MONGO_DB_NAME=epirus
# - MONGO_CREATE_INDICES=true - MONGO_CREATE_INDICES=true
# - REDIS_HOST=redis - REDIS_HOST=redis
# - REDIS_PORT=6379 - REDIS_PORT=6379
# depends_on: depends_on:
# - redis - redis
# - mongodb - mongodb
# - foundry - foundry
# networks: networks:
# - simulation - simulation
# mongodb: mongodb:
# image: mongo:5.0.8 image: mongo:5.0.8
# environment: environment:
# - COMPOSE_HTTP_TIMEOUT=900 - COMPOSE_HTTP_TIMEOUT=900
# - DOCKER_CLIENT_TIMEOUT=900 - DOCKER_CLIENT_TIMEOUT=900
# entrypoint: mongod --bind_ip "0.0.0.0" entrypoint: mongod --bind_ip "0.0.0.0"
# networks: networks:
# - simulation - simulation
# web: web:
# image: web3labs/epirus-free-web:latest image: web3labs/epirus-free-web:latest
# environment: environment:
# - API_URL=${EPIRUS_WEB_API_URL:-/api} - API_URL=${EPIRUS_WEB_API_URL:-/api}
# - WS_API_URL=${EPIRUS_WEB_WS_API_URL:-ws://localhost:8090} - WS_API_URL=${EPIRUS_WEB_WS_API_URL:-ws://localhost:8090}
# - DISPLAY_NETWORK_TAB=disabled - DISPLAY_NETWORK_TAB=disabled
# depends_on: depends_on:
# - api - api
# networks: networks:
# - simulation - simulation
# ingestion: ingestion:
# image: web3labs/epirus-free-ingestion:latest image: web3labs/epirus-free-ingestion:latest
# environment: environment:
# - NODE_ENDPOINT=${RPC_URL:-http://foundry:8545} - NODE_ENDPOINT=${RPC_URL:-http://foundry:8545}
# - MONGO_CLIENT_URI=mongodb://mongodb:27017 - MONGO_CLIENT_URI=mongodb://mongodb:27017
# - MONGO_DB_NAME=epirus - MONGO_DB_NAME=epirus
# - LIST_OF_METRICS_TO_CALCULATE_PER_MINUTE=hourly,daily,monthly,yearly - LIST_OF_METRICS_TO_CALCULATE_PER_MINUTE=hourly,daily,monthly,yearly
# depends_on: depends_on:
# - mongodb - mongodb
# - redis - redis
# - foundry - foundry
# networks: networks:
# - simulation - simulation
# nginx: nginx:
# image: nginx:latest image: nginx:latest
# volumes: volumes:
# - ./nginx.conf:/etc/nginx/nginx.conf - ./nginx.conf:/etc/nginx/nginx.conf
# - ./5xx.html:/www/error_pages/5xx.html - ./5xx.html:/www/error_pages/5xx.html
# ports: ports:
# - 0.0.0.0:3000:80 - 0.0.0.0:3000:80
# depends_on: depends_on:
# - api - api
# - web - web
# networks: networks:
# - simulation - simulation
volumes: volumes:
privatekeys-volume: privatekeys-volume:

View File

@ -7,8 +7,6 @@ echo "I am a bootstrap node"
exec /usr/bin/wakunode\ exec /usr/bin/wakunode\
--relay=false\ --relay=false\
--rest=true\ --rest=true\
--rest-admin=true\
--rest-private=true\
--rest-address=0.0.0.0\ --rest-address=0.0.0.0\
--max-connections=300\ --max-connections=300\
--dns-discovery=true\ --dns-discovery=true\

View File

@ -136,8 +136,6 @@ exec /usr/bin/wakunode\
--lightpush=true\ --lightpush=true\
--max-connections=250\ --max-connections=250\
--rest=true\ --rest=true\
--rest-admin=true\
--rest-private=true\
--rest-address=0.0.0.0\ --rest-address=0.0.0.0\
--rest-port=8645\ --rest-port=8645\
--rln-relay=true\ --rln-relay=true\
@ -152,11 +150,10 @@ exec /usr/bin/wakunode\
--dns-discovery=true\ --dns-discovery=true\
--discv5-discovery=true\ --discv5-discovery=true\
--discv5-enr-auto-update=True\ --discv5-enr-auto-update=True\
--log-level=TRACE\ --log-level=DEBUG\
--metrics-server=True\ --metrics-server=True\
--metrics-server-address=0.0.0.0\ --metrics-server-address=0.0.0.0\
--discv5-bootstrap-node=${BOOTSTRAP_ENR}\ --discv5-bootstrap-node=${BOOTSTRAP_ENR}\
--nat=extip:${IP}\ --nat=extip:${IP}\
--pubsub-topic=/waku/2/rs/66/0\ --pubsub-topic=/waku/2/rs/66/0\
--cluster-id=66\ --cluster-id=66
--storenode=/ip4/10.2.0.99/tcp/60001/p2p/16Uiu2HAmTVafvweaXrXKmFFkUo4qWYP7wTa2H6PXee8iMyQw4eHm

View File

@ -29,8 +29,6 @@ exec /usr/bin/wakunode\
--lightpush=true\ --lightpush=true\
--max-connections=250\ --max-connections=250\
--rest=true\ --rest=true\
--rest-admin=true\
--rest-private=true\
--rest-address=0.0.0.0\ --rest-address=0.0.0.0\
--rest-port=8645\ --rest-port=8645\
--dns-discovery=true\ --dns-discovery=true\

113
run_nwaku_static1.sh Normal file
View File

@ -0,0 +1,113 @@
#!/bin/sh
# Check Linux Distro Version - it can differ depending on the nwaku image used
# Install bind-tools/dnsutils package used for domain name resolution
OS=$(cat /etc/os-release)
if echo $OS | grep -q "Debian"; then
echo "The operating system is Debian."
apt update
apt install -y dnsutils
elif echo $OS | grep -q "Alpine"; then
echo "The operating system is Alpine."
apk add bind-tools
fi
if test -f .env; then
echo "Using .env file"
. $(pwd)/.env
fi
# 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
if test -f .$RLN_CREDENTIAL_PATH; then
echo "$RLN_CREDENTIAL_PATH already exists. Use it instead of creating a new one."
else
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 \
--log-level=DEBUG \
--execute
fi
IP=$(ip a | grep "inet " | grep -Fv 127.0.0.1 | sed 's/.*inet \([^/]*\).*/\1/')
echo "I am a nwaku node"
# Get an unique node index based on the container's IP
FOURTH_OCTET=${IP##*.}
THIRD_OCTET="${IP%.*}"; THIRD_OCTET="${THIRD_OCTET##*.}"
NODE_INDEX=$((FOURTH_OCTET + 256 * THIRD_OCTET))
echo "NODE_INDEX $NODE_INDEX"
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}"
exec /usr/bin/wakunode\
--relay=true\
--max-connections=250\
--rest=true\
--rest-admin=true\
--rest-private=true\
--rest-address=0.0.0.0\
--cluster-id=0\
--pubsub-topic=/waku/2/default-waku/proto\
--rest-port=8645\
--rln-relay=true\
--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=true\
--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}\
--nodekey=5978783f8b1a16795032371fff7a526af352d9dca38179af7d71c0122942df25