From 20f91f42428e3e91ab903aee561f2c1e10ace770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Pavl=C3=ADn?= Date: Mon, 13 Nov 2023 12:55:46 +0100 Subject: [PATCH 1/3] feat: add support for .env --- .env.example | 3 +++ .gitignore | 3 ++- README.md | 2 +- docker-compose.yml | 6 +++--- register_rln.sh | 11 +++++++++-- run_node.sh | 10 ++++------ 6 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..ef67b0a --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +ETH_CLIENT_ADDRESS=wss://sepolia.infura.io/ws/v3/ +ETH_TESTNET_KEY=012345privatekey +RLN_RELAY_CRED_PASSWORD="my_secure_keystore_password" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 87d7420..0536e1c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ **/.DS_Store keystore postgresql -rln_tree \ No newline at end of file +rln_tree +.env diff --git a/README.md b/README.md index b0d9f8d..210bd3f 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ You need: ``` export ETH_CLIENT_ADDRESS=wss://sepolia.infura.io/ws/v3/YOUR_INFURA_KEY export ETH_TESTNET_KEY=REPLACE_BY_YOUR_KEY -export KEYSTORE_PASSWORD=PICK_A_PASSWORD +export RLN_RELAY_CRED_PASSWORD=PICK_A_PASSWORD ``` **🔑 1. Register RLN membership** diff --git a/docker-compose.yml b/docker-compose.yml index 31b4ee6..1a5c8c5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -47,7 +47,7 @@ services: environment: DOMAIN: ${DOMAIN} NODEKEY: ${NODEKEY} - KEYSTORE_PASSWORD: ${KEYSTORE_PASSWORD} + KEYSTORE_PASSWORD: "${KEYSTORE_PASSWORD}" ETH_CLIENT_ADDRESS: *eth_client_address EXTRA_ARGS: ${EXTRA_ARGS} <<: @@ -119,8 +119,8 @@ services: - ./postgres_cfg/db.sql:/docker-entrypoint-initdb.d/db.sql:Z - ${PG_DATA_DIR:-./postgresql}:/var/lib/postgresql/data:Z command: postgres -c config_file=/etc/postgresql/postgresql.conf - ports: - - 127.0.0.1:5432:5432 + ports: [] + # - 127.0.0.1:5432:5432 healthcheck: test: ["CMD-SHELL", "pg_isready -d db_prod"] interval: 30s diff --git a/register_rln.sh b/register_rln.sh index a827bae..400d401 100755 --- a/register_rln.sh +++ b/register_rln.sh @@ -1,17 +1,24 @@ #!/bin/sh -if test -f ./keystore/keystore.json; then +if test -f $(pwd)/keystore/keystore.json; then echo "keystore/keystore.json alredy exists. Use it instead of creating a new one." echo "Exiting" exit 1 fi +if test -f .env; then + echo "Using .env file" + . $(pwd)/.env +fi + # TODO: Set nwaku release when ready instead of quay + + docker run -v $(pwd)/keystore:/keystore/:Z wakuorg/nwaku:v0.21.3 generateRlnKeystore \ --rln-relay-eth-client-address=${ETH_CLIENT_ADDRESS} \ --rln-relay-eth-private-key=${ETH_TESTNET_KEY} \ --rln-relay-eth-contract-address=0xF471d71E9b1455bBF4b85d475afb9BB0954A29c4 \ --rln-relay-cred-path=/keystore/keystore.json \ ---rln-relay-cred-password=${KEYSTORE_PASSWORD} \ +--rln-relay-cred-password="'"${RLN_RELAY_CRED_PASSWORD}"'" \ --execute diff --git a/run_node.sh b/run_node.sh index 25fa8c6..50b0340 100644 --- a/run_node.sh +++ b/run_node.sh @@ -46,12 +46,12 @@ 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 + +RLN_RELAY_CRED_PATH=--rln-relay-cred-path=${RLN_RELAY_CRED_PATH:-/keystore/keystore.json} + if [ -n "${RLN_RELAY_CRED_PASSWORD}" ]; then - RLN_RELAY_CRED_PASSWORD=--rln-relay-cred-password=${RLN_RELAY_CRED_PASSWORD} + RLN_RELAY_CRED_PASSWORD=--rln-relay-cred-password="'"${RLN_RELAY_CRED_PASSWORD}"'" fi exec /usr/bin/wakunode\ @@ -95,8 +95,6 @@ exec /usr/bin/wakunode\ --rln-relay-eth-contract-address="${RLN_RELAY_CONTRACT_ADDRESS}"\ --rln-relay-eth-client-address="${ETH_CLIENT_ADDRESS}"\ --rln-relay-tree-path="/etc/rln_tree"\ - --rln-relay-cred-password="${KEYSTORE_PASSWORD}"\ - --rln-relay-cred-path="/keystore/keystore.json"\ ${RLN_RELAY_CRED_PATH}\ ${RLN_RELAY_CRED_PASSWORD}\ ${DNS_WSS_CMD}\ From 7b8cebc0ced0483e2e47b80328ea93d8ee6b784d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Pavl=C3=ADn?= Date: Mon, 13 Nov 2023 12:58:23 +0100 Subject: [PATCH 2/3] add a comment to readme --- .env.example | 3 ++- README.md | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index ef67b0a..71e228a 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ ETH_CLIENT_ADDRESS=wss://sepolia.infura.io/ws/v3/ ETH_TESTNET_KEY=012345privatekey -RLN_RELAY_CRED_PASSWORD="my_secure_keystore_password" \ No newline at end of file +RLN_RELAY_CRED_PASSWORD="my_secure_keystore_password" +NODEKEY= diff --git a/README.md b/README.md index 210bd3f..145e465 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,20 @@ You need: * Ethereum Sepolia account with some balance <0.01 Eth. Get some [here](https://www.infura.io/faucet/sepolia). * A password to protect your rln membership. +You can either export the environment variable (keep in mind that this will expose your secrets in your shell history) + ``` export ETH_CLIENT_ADDRESS=wss://sepolia.infura.io/ws/v3/YOUR_INFURA_KEY export ETH_TESTNET_KEY=REPLACE_BY_YOUR_KEY export RLN_RELAY_CRED_PASSWORD=PICK_A_PASSWORD ``` +Or you can use `.env` file - copy the example and edit the variables inside + +``` +cp .env.example .env +``` + **🔑 1. Register RLN membership** The RLN membership is your access key to The Waku Network. Its registration is done onchain, and allows your nwaku node to publish messages in a decentralized and private way, respecting some [rate limits](https://rfc.vac.dev/spec/64/#rate-limit-exceeded). From c75e9d20a7079f0b294eaabc249fc97fb2287e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Pavl=C3=ADn?= Date: Mon, 13 Nov 2023 16:06:39 +0100 Subject: [PATCH 3/3] only mention .env in readme --- .env.example | 6 ++++++ README.md | 13 ++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index 71e228a..858646b 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,10 @@ ETH_CLIENT_ADDRESS=wss://sepolia.infura.io/ws/v3/ ETH_TESTNET_KEY=012345privatekey RLN_RELAY_CRED_PASSWORD="my_secure_keystore_password" + +# Advanced +NWAKU_IMAGE= NODEKEY= +DOMAIN= +EXTRA_ARGS= +RLN_RELAY_CONTRACT_ADDRESS= \ No newline at end of file diff --git a/README.md b/README.md index 145e465..627ef9d 100644 --- a/README.md +++ b/README.md @@ -14,20 +14,15 @@ You need: * Ethereum Sepolia account with some balance <0.01 Eth. Get some [here](https://www.infura.io/faucet/sepolia). * A password to protect your rln membership. -You can either export the environment variable (keep in mind that this will expose your secrets in your shell history) - -``` -export ETH_CLIENT_ADDRESS=wss://sepolia.infura.io/ws/v3/YOUR_INFURA_KEY -export ETH_TESTNET_KEY=REPLACE_BY_YOUR_KEY -export RLN_RELAY_CRED_PASSWORD=PICK_A_PASSWORD -``` - -Or you can use `.env` file - copy the example and edit the variables inside +There is `.env.example` available for you as a template to use for providing the above values. The process when working with `.env` files is to copy the `.env.example`, store it as `.env` and edit the values there. ``` cp .env.example .env +${EDITOR} .env ``` +Make sure to **NOT** place any secrets into `.env.example`, as they might be unintentionally published in the Git repository. + **🔑 1. Register RLN membership** The RLN membership is your access key to The Waku Network. Its registration is done onchain, and allows your nwaku node to publish messages in a decentralized and private way, respecting some [rate limits](https://rfc.vac.dev/spec/64/#rate-limit-exceeded).