Refactoring and adding optional rln env variables

This commit is contained in:
Gabriel Mermelstein 2023-09-22 11:45:45 +03:00 committed by alrevuelta
parent 91e860220d
commit 1ef2aa5503
No known key found for this signature in database
GPG Key ID: F345C9F3CCDB886E
3 changed files with 22 additions and 13 deletions

View File

@ -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=<your_eth_client_address_here>
```
Start everything: `nwaku`, `postgres`, `prometheus`, and `grafana`.
```console
docker-compose up -d

View File

@ -6,6 +6,13 @@ x-logging: &logging
max-size: 1000m
# Environment variable definitions
x-eth-client-address: &eth_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

View File

@ -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}