fix: readme, setup wizard (#160)

This commit is contained in:
Darshan K 2025-07-18 15:48:35 +05:30 committed by GitHub
parent 0a5442b5e1
commit cedb8b6637
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 224 additions and 92 deletions

View File

@ -1,32 +1,40 @@
# nwaku-compose
Ready to use docker-compose to run your own [nwaku](https://github.com/waku-org/nwaku) full node:
* nwaku node running relay and store protocols with RLN enabled.
* Simple frontend to interact with your node and the network, to publish and receive messages.
* Grafana dashboard for advanced users or node operators.
* Requires `docker-compose` and `git`.
Readytouse **dockercompose** stack for running your own [nwaku](https://github.com/waku-org/nwaku) full node:
## Setup and Run
* RLNenabled nwaku node (relay + store protocols)
* Simple web UI to publish and receive messages
* Grafana dashboard for metrics
* Requires **Docker Compose** and **Git**
### 📝 0. Prerequisites
## 📝 Prerequisites
You need:
* Linea Sepolia HTTP endpoint. Get one free from [Infura](https://www.infura.io/).
* Linea Sepolia account with some balance <0.01 Eth.
* You can get some Linea Sepolia [here](https://www.infura.io/faucet/sepolia)
* If you have ETH on Sepolia, it can be bridged to Linea Sepolia [here](https://bridge.linea.build/native-bridge).
* A password to protect your rln membership.
* **Linea Sepolia RPC endpoint** — grab one for free on [Infura](https://www.infura.io)
* **Linea Sepolia wallet** with at least **0.01 ETH**
* Need test ETH? Use the [Linea Sepolia faucet](https://www.infura.io/faucet/sepolia)
* Already have ETH on Sepolia? Bridge it to Linea via the [official bridge](https://bridge.linea.build/native-bridge)
`docker-compose` [will read the `./.env` file](https://docs.docker.com/compose/environment-variables/set-environment-variables/#additional-information-3) from the filesystem. 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.
### 🚀 Starting your node — pick one of three paths
```
cp .env.example .env
${EDITOR} .env
```
| # | Path | Quick-start command | What happens |
|---|------|--------------------|--------------|
| **1** | **rln.waku.org** | Guided web setup | Register RLN in the browser, download `keystore.json`, then return here to proceed |
| **2** | **setup_wizard** | Fastest one-command bootstrap | Generates `.env`, registers RLN, and spins up the whole stack automatically |
| **3** | **Manual script** | Power users / CI | Mint & approve tokens yourself, then run the script for maximum control |
Make sure to **NOT** place any secrets into `.env.example`, as they might be unintentionally published in the Git repository.
<details>
<summary>🌐 option 1 :- RLN.WAKU.ORG [ recommended ]</summary>
### EXPERIMENTAL - Use wizard script
To register for RLN membership and generate your keystore:
1. Visit [https://rln.waku.org](https://rln.waku.org).
2. Follow the instructions to register your membership and generate a `keystore.json` file.
3. Download the generated `keystore.json` and place it in the `keystore/` directory of your `nwaku-compose` setup (i.e., at `keystore/keystore.json`).
</details>
<details>
<summary>⚙️ option 2 :- SETUP-WIZARD [ experimental ]</summary>
Run the wizard script.
Once the script is done, the node will be started for you, so there is nothing else to do.
@ -37,29 +45,12 @@ The script is experimental, feedback and pull requests are welcome.
./setup_wizard.sh
```
### 🔑 1. Register RLN membership
</details>
> **Note:** If upgrading from less than v0.36.0, run the following commands before proceeding with the registration:
>
> ```sh
> sudo rm -r rln_tree
> sudo rm keystore/keystore.json
> ```
The RLN membership is your access key to The Waku Network. Its registration is done on-chain, allowing your `nwaku` node to send messages in a decentralized and private way, respecting some [rate limits](https://rfc.vac.dev/spec/64/#rate-limit-exceeded). Other peers won't relay messages that exceed the rate limit.
#### Recommended: Register via rln.waku.org
To register for RLN membership and generate your keystore:
1. Visit [https://rln.waku.org](https://rln.waku.org).
2. Follow the instructions to register your membership and generate a `keystore.json` file.
3. Download the generated `keystore.json` and place it in the `keystore/` directory of your `nwaku-compose` setup (i.e., at `keystore/keystore.json`).
#### Alternative: Register locally
<details>
<summary>🧪 option 3 :- MANUAL SCRIPT [ advanced ] </summary>
You can also register your membership using the provided script, which will store it in `keystore/keystore.json`.
Note that if you just want to relay traffic (not publish), you don't need to perform the registration.
Before registering you need to mint and approve the tokens to pay for the registration.
The simplest way is using Foundry's [cast](https://getfoundry.sh/) tool, which you can install with:
@ -154,6 +145,27 @@ curl -X GET "http://127.0.0.1:8645/store/v1/messages?contentTopics=%2Fmy-app%2F2
For advanced documentation, refer to [ADVANCED.md](https://github.com/waku-org/nwaku-compose/blob/master/ADVANCED.md).
</details>
### 📌 Note
RLN membership is your access key to The Waku Network. It is registered on-chain, enabling your nwaku node to send messages in a decentralized and privacy-preserving way while adhering to rate limits. Messages exceeding the rate limit will not be relayed by other peers.
If youre upgrading from a version earlier than v0.36.0, we recommend starting from a fresh clone.
docker-compose automatically reads the .env file from the filesystem. A .env.example is provided as a template — copy it and update the values as needed:
```
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.
if you just want to relay traffic (not publish), you don't need to perform the registration.
-----
## How to update to latest version

View File

@ -1,13 +1,78 @@
#!/bin/sh
if [ -f ./.env ] ; then
echo "'./.env\` already exists, exiting wizard"
exit 1
echocol()
{
COL='\033[0;32m'
NC='\033[0m'
printf "$COL${1}${NC}\n"
}
RLN_CONTRACT_ADDRESS=0xB9cd878C90E49F797B4431fBF4fb333108CB90e6
TOKEN_CONTRACT_ADDRESS=0x185A0015aC462a0aECb81beCc0497b649a64B9ea
REQUIRED_AMOUNT=5
TTT_AMOUNT_WEI=5000000000000000000
mint_tokens() {
echocol ""
echocol "Minting TTT tokens ..."
cast send $TOKEN_CONTRACT_ADDRESS "mint(address,uint256)" \
$ETH_TESTNET_ACCOUNT $TTT_AMOUNT_WEI \
--private-key $ETH_TESTNET_KEY \
--rpc-url $RLN_RELAY_ETH_CLIENT_ADDRESS || {
echocol "❌ Mint transaction failed."
exit 1
}
echocol "✅ Mint complete!"
echocol ""
}
approve_tokens() {
echocol ""
echocol "Approving RLN contract to spend your TTT tokens ..."
cast send $TOKEN_CONTRACT_ADDRESS "approve(address,uint256)" \
$RLN_CONTRACT_ADDRESS $TTT_AMOUNT_WEI \
--private-key $ETH_TESTNET_KEY \
--rpc-url $RLN_RELAY_ETH_CLIENT_ADDRESS || {
echocol "❌ Approve transaction failed."
exit 1
}
echocol "✅ Approval complete!"
echocol ""
}
check_eth_balance() {
# 0.01 ETH in wei
local MIN=10000000000000000
local BAL
BAL=$(cast balance "$ETH_TESTNET_ACCOUNT" --rpc-url "$RLN_RELAY_ETH_CLIENT_ADDRESS" 2>/dev/null | tr -d '[:space:]')
[ -z "$BAL" ] && { echocol "Couldnt fetch ETH balance."; exit 1; }
[ "$BAL" -lt "$MIN" ] && { echocol "Need ≥ 0.01 Sepolia ETH. Top up at https://www.infura.io/faucet/sepolia"; exit 1; }
echocol "✅ You have enough Linea Sepolia ETH to register."
}
if [ -f ./.env ]; then
echocol ".env file already exists."
read -p "Do you want to delete and regenerate it? (y/N): " RECREATE_ENV
if [ "$RECREATE_ENV" = "y" ] || [ "$RECREATE_ENV" = "Y" ]; then
rm -f ./.env
echocol "Old .env removed. Generating a new one..."
else
echocol "Keeping existing .env. Exiting wizard."
exit 1
fi
fi
if [ -f keystore/keystore.json ] ; then
echo "'keystore/keystore.json\` already exists, exiting wizard"
exit 1
if [ -f keystore/keystore.json ]; then
echocol "'keystore/keystore.json' already exists."
read -p "Do you want to delete and regenerate it? (y/N): " RECREATE_KEYSTORE
if [ "$RECREATE_KEYSTORE" = "y" ] || [ "$RECREATE_KEYSTORE" = "Y" ]; then
rm -f keystore/keystore.json
echocol "Old keystore/keystore.json removed. Generating a new one..."
else
echocol "Keeping existing keystore/keystore.json. Exiting wizard."
fi
fi
if [ -z "$(which docker 2>/dev/null)" ]; then
@ -20,20 +85,17 @@ if [ -z "$(which docker-compose 2>/dev/null)" ]; then
exit 1
fi
echocol()
{
COL='\033[0;32m'
NC='\033[0m'
printf "$COL${1}${NC}\n"
}
echocol "##############################"
echocol "#### nwaku-compose wizard ####"
echocol "##############################"
echocol "First, you need a RPC HTTP endpoint for Ethereum Sepolia"
echocol "If you don't have one, try out https://www.infura.io/"
echocol "Expected format is https://sepolia.infura.io/v3/<api key>:"
read -r RLN_RELAY_ETH_CLIENT_ADDRESS
echocol ""
echocol "╔══════════════════════════════════════════════════════════════════════════════╗"
echocol "║ ║"
echocol "║ Welcome to nwaku-compose wizard ║"
echocol "║ ║"
echocol "╚══════════════════════════════════════════════════════════════════════════════╝"
echocol ""
echocol "First, you need a RPC HTTP endpoint for Linea Sepolia"
echocol "If you don't have one, try out https://www.infura.io/ (Expected format is https://linea-sepolia.infura.io/v3/<api key>)"
read -p "RLN_RELAY_ETH_CLIENT_ADDRESS: " RLN_RELAY_ETH_CLIENT_ADDRESS
if [ -z "$RLN_RELAY_ETH_CLIENT_ADDRESS" ] \
|| [ $(echo "$RLN_RELAY_ETH_CLIENT_ADDRESS" | grep -c "^https:") -eq 0 ]; then
@ -41,24 +103,36 @@ if [ -z "$RLN_RELAY_ETH_CLIENT_ADDRESS" ] \
exit 1
fi
echocol "...."
echocol "Double check you have some Eth Sepolia, at least 0.01Eth."
echocol "If not, you can use this faucet: https://www.infura.io/faucet/sepolia"
echocol "Now enter your SEPOLIA TESTNET private key in hex format 0a...1f without 0x prefix"
read ETH_TESTNET_KEY
echocol ""
echocol "Now enter your Linea Sepolia Testnet account address (should start with 0x and be 42 characters)"
read -p "ETH_TESTNET_ACCOUNT: " ETH_TESTNET_ACCOUNT
if [ -z "$ETH_TESTNET_KEY" ] \
|| [ $(echo -n "$ETH_TESTNET_KEY" | grep -c '^[0-9a-fA-F]\{64\}$' ) -ne 1 ]; then
echo "Invalid value, received '$ETH_TESTNET_KEY'"
exit 1
if ! [[ "$ETH_TESTNET_ACCOUNT" =~ ^0x[0-9a-fA-F]{40}$ ]]; then
echo "Invalid value, received '$ETH_TESTNET_ACCOUNT'"
exit 1
fi
echocol "...."
echocol "Generating a password for the RLN membership keystore file..."
RLN_RELAY_CRED_PASSWORD=$(< /dev/urandom tr -dc ',/.;:<>?!@#$%^&*()+\-_A-Z-a-z-0-9' | head -c${1:-16};echo;)
echocol ""
echocol "Checking your Linea Sepolia Testnet balance..."
check_eth_balance
echocol ""
echocol "...."
echocol "Selecting a size for DB..."
echocol "Now enter your Linea Sepolia Testnet private key in hex format 0a...1f without 0x prefix"
read -p "ETH_TESTNET_KEY: " ETH_TESTNET_KEY
if ! [[ "$ETH_TESTNET_KEY" =~ ^[0-9a-fA-F]{64}$ ]]; then
echo "Invalid value, received '$ETH_TESTNET_KEY'"
exit 1
fi
echocol ""
echocol "Generating a password for the RLN membership keystore file..."
read -p "Press ENTER to continue..." foo
RLN_RELAY_CRED_PASSWORD=$(LC_ALL=C < /dev/urandom tr -dc ',/.;:<>?!@#$%^&*()+\-_A-Z-a-z-0-9' | head -c${1:-16}; echo)
echocol ""
echocol "Estimating storage size for DB..."
read -p "Press ENTER to continue..." foo
STORAGE_SIZE=$(./set_storage_retention.sh echo-value)
if [ -z "$STORAGE_SIZE" ]; then
@ -66,8 +140,9 @@ if [ -z "$STORAGE_SIZE" ]; then
exit 1
fi
echocol "...."
echocol "Selecting a SHM for Postgres..."
echocol ""
echocol "Estimating SHM for Postgres..."
read -p "Press ENTER to continue..." foo
POSTGRES_SHM=$(./set_postgres_shm.sh echo-value)
if [ -z "$POSTGRES_SHM" ]; then
@ -75,21 +150,57 @@ if [ -z "$POSTGRES_SHM" ]; then
exit 1
fi
echocol "...."
echocol "The following parameters will be saved to your .env file. Press ENTER to confirm or quit with CONTROL-C to abort:"
echo "RLN_RELAY_ETH_CLIENT_ADDRESS='$RLN_RELAY_ETH_CLIENT_ADDRESS'
ETH_TESTNET_KEY=$ETH_TESTNET_KEY
RLN_RELAY_CRED_PASSWORD='$RLN_RELAY_CRED_PASSWORD'
STORAGE_SIZE=$STORAGE_SIZE
POSTGRES_SHM=$POSTGRES_SHM"
read foo
echocol ""
echocol "🔐 Review your credentials and environment configuration below."
echocol "They will be saved to '.env'. Press ENTER to confirm or CONTROL-C to cancel:"
echocol ""
echocol "RLN_RELAY_ETH_CLIENT_ADDRESS: $RLN_RELAY_ETH_CLIENT_ADDRESS"
echocol "ETH_TESTNET_KEY: $ETH_TESTNET_KEY"
echocol "ETH_TESTNET_ACCOUNT: $ETH_TESTNET_ACCOUNT"
echocol "RLN_RELAY_CRED_PASSWORD: $RLN_RELAY_CRED_PASSWORD"
echocol "STORAGE_SIZE: $STORAGE_SIZE"
echocol "POSTGRES_SHM: $POSTGRES_SHM"
read -p "Press ENTER to continue..." foo
echo "RLN_RELAY_ETH_CLIENT_ADDRESS='$RLN_RELAY_ETH_CLIENT_ADDRESS'
ETH_TESTNET_KEY=$ETH_TESTNET_KEY
ETH_TESTNET_ACCOUNT=$ETH_TESTNET_ACCOUNT
RLN_RELAY_CRED_PASSWORD='$RLN_RELAY_CRED_PASSWORD'
STORAGE_SIZE=$STORAGE_SIZE
POSTGRES_SHM=$POSTGRES_SHM" > ./.env
echocol ""
echocol "Checking your TTT token balance..."
USER_BALANCE_RAW=$(cast call $TOKEN_CONTRACT_ADDRESS "balanceOf(address)(uint256)" $ETH_TESTNET_ACCOUNT --rpc-url $RLN_RELAY_ETH_CLIENT_ADDRESS 2>/dev/null)
USER_BALANCE=$(echo "$USER_BALANCE_RAW" | awk '{print $1}')
USER_BALANCE=$(echo "$USER_BALANCE / 10^18" | bc)
if [ -z "$USER_BALANCE" ]; then
echocol "Could not fetch balance. Please ensure your RPC endpoint and account are correct."
exit 1
fi
echocol "Your current TTT token balance is: $USER_BALANCE"
echocol "Required amount: $REQUIRED_AMOUNT"
echocol ""
if [ "$USER_BALANCE" -ge "$REQUIRED_AMOUNT" ]; then
echocol "You already have enough TTT tokens to register."
read -p "Do you want to mint more tokens? (y/N): " MINT_CHOICE
if [ "$MINT_CHOICE" = "y" ] || [ "$MINT_CHOICE" = "Y" ]; then
mint_tokens
approve_tokens
else
approve_tokens
fi
else
echocol "Minting and approving required TTT tokens …"
mint_tokens
approve_tokens
fi
SUDO=""
if ! docker info > /dev/null 2>&1; then
echocol "...."
@ -98,17 +209,26 @@ if ! docker info > /dev/null 2>&1; then
fi
echocol "...."
echocol "Registering an RLN membership..."
echocol ""
echocol "🔐 Registering RLN membership..."
read -p "Press ENTER to continue..." foo
if ! $SUDO ./register_rln.sh; then
echocol "###"
echocol "Failed to register RLN membership, usually due to high gas fee"
echocol "Double check you have enough Sepolia eth and run the following command:"
echocol "$SUDO ./register_rln.sh"
echocol "###"
echocol ""
echocol "❌ RLN registration failed. This may be due to high gas fees."
echocol "💡 Make sure you have enough Sepolia ETH and try again with:"
echocol " $SUDO ./register_rln.sh"
echocol ""
exit 1
fi
echocol "...."
echocol ""
echocol "✅ RLN membership registered successfully!"
echocol ""
echocol "Your node is ready! enter the following command to start it:"
echo "> $SUDO docker-compose up -d"
read -p "Press ENTER to continue..." foo
echo "> $SUDO docker-compose up -d"
echocol "✅ Node started successfully!"
echocol ""