From 1ef2aa550399aa5d9cfbec478920ffab5e23a036 Mon Sep 17 00:00:00 2001 From: Gabriel Mermelstein Date: Fri, 22 Sep 2023 11:45:45 +0300 Subject: [PATCH] Refactoring and adding optional rln env variables --- README.md | 10 +--------- docker-compose.yml | 11 +++++++++-- run_node.sh | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index a04f734..d20216b 100644 --- a/README.md +++ b/README.md @@ -15,20 +15,12 @@ cd nwaku-compose Edit the environment variables present at the beginning of the `docker-compose.yml` file. -Get a node's URL: - It is required to set the `ETH_CLIENT_ADDRESS` environment variable before starting the instance. `ETH_CLIENT_ADDRESS` must be a WebSockets URL for your Ethereum Node. -For the current default contract, it must a node for the Sepolia network. +For the current default contract, it must be a node for the Sepolia network. In case you're not running your own node, you can get it from [Infura](https://www.infura.io/) -You can set the environment variable from inside the `docker-compose.yml` file or you can simply run - -```console -export ETH_CLIENT_ADDRESS= -``` - Start everything: `nwaku`, `postgres`, `prometheus`, and `grafana`. ```console docker-compose up -d diff --git a/docker-compose.yml b/docker-compose.yml index e095e79..d5fdd64 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,13 @@ x-logging: &logging max-size: 1000m # Environment variable definitions +x-eth-client-address: ð_client_address ${ETH_CLIENT_ADDRESS:-} # Add your ETH_CLIENT_ADDRESS after the "-" + +x-rln-environment: &rln_env + RLN_RELAY_CONTRACT_ADDRESS: ${RLN_RELAY_CONTRACT_ADDRESS:-0xF471d71E9b1455bBF4b85d475afb9BB0954A29c4} + RLN_RELAY_CRED_PATH: ${RLN_RELAY_CRED_PATH:-} # Optional: Add your RLN_RELAY_CRED_PATH after the "-" + RLN_RELAY_CRED_PASSWORD: ${RLN_RELAY_CRED_PASSWORD:-} # Optional: Add your RLN_RELAY_CRED_PASSWORD after the "-" + x-pg-pass: &pg_pass ${POSTGRES_PASSWORD:-test123} x-pg-user: &pg_user ${POSTGRES_USER:-postgres} @@ -57,10 +64,10 @@ services: environment: DOMAIN: ${DOMAIN} NODEKEY: ${NODEKEY} - RLN_RELAY_CONTRACT_ADDRESS: ${RLN_RELAY_CONTRACT_ADDRESS:-0xF471d71E9b1455bBF4b85d475afb9BB0954A29c4} - ETH_CLIENT_ADDRESS: ${ETH_CLIENT_ADDRESS} + ETH_CLIENT_ADDRESS: *eth_client_address EXTRA_ARGS: ${EXTRA_ARGS} <<: *pg_env + <<: *rln_env volumes: - ./run_node.sh:/opt/run_node.sh:Z - ./certs:/etc/letsencrypt/:Z diff --git a/run_node.sh b/run_node.sh index 8da0cf5..fe432cf 100644 --- a/run_node.sh +++ b/run_node.sh @@ -3,7 +3,7 @@ echo "I am a nwaku node" if [ -z "${ETH_CLIENT_ADDRESS}" ]; then - echo -e "Missing Eth client address, please refer to README.md for detailed instructions" + echo "Missing Eth client address, please refer to README.md for detailed instructions" exit 1 fi @@ -42,10 +42,18 @@ if [ -n "${DOMAIN}" ]; then DNS_WSS_CMD="${WS_SUPPORT} ${WSS_SUPPORT} ${WSS_CERT} ${WSS_KEY} ${DNS4_DOMAIN}" fi -if [ "${NODEKEY}" != "" ]; then +if [ -n "${NODEKEY}" ]; then NODEKEY=--nodekey=${NODEKEY} fi +if [ -n "${RLN_RELAY_CRED_PATH}" ]; then + RLN_RELAY_CRED_PATH=--rln-relay-cred-path=${RLN_RELAY_CRED_PATH} +fi + +if [ -n "${RLN_RELAY_CRED_PASSWORD}" ]; then + RLN_RELAY_CRED_PASSWORD=--rln-relay-cred-password=${RLN_RELAY_CRED_PASSWORD} +fi + exec /usr/bin/wakunode\ --relay=true\ --topic=/waku/2/default-waku/proto\ @@ -81,5 +89,7 @@ exec /usr/bin/wakunode\ --rln-relay-tree-path="/etc/rln_tree"\ ${DNS_WSS_CMD}\ ${NODEKEY}\ + ${RLN_RELAY_CRED_PATH}\ + ${RLN_RELAY_CRED_PASSWORD}\ ${EXTRA_ARGS}