Rln membership registration implementation (#23)

* add anvil config and volume to remember state and output account info; nwaku config to register rln membership

* modify run_nwaku.sh for onchain rln

* add script for rln membership registration

* run_nwaku update, removed rln membership index and added other rln parameters

* merged run_register_rln with the run_nwaku script

* added environment variables for rln-contract registration

* removed rpc related flags and added rest flags for sake of completeness, also updated BOOTSTRAP_ENR query

* removed rpc flags, added cred-path and -password

* added keystore volume and 8645 port

* removed keystore volume and keystore parent directory

* remove unused service from docker-compose
This commit is contained in:
Tanya S 2024-03-14 13:35:25 +02:00 committed by GitHub
parent c56a0831c9
commit d6fb3e56e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 72 additions and 13 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "submodules/waku-rln-contract"]
path = submodules/waku-rln-contract
url = https://github.com/waku-org/waku-rln-contract.git

View File

@ -15,15 +15,16 @@ services:
labels: labels:
com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}'
ports: ports:
- 127.0.0.1:8541:8541 - 127.0.0.1:8545:8545
command: > command: >
"anvil "anvil
--port=8541 --port=8545
--host=0.0.0.0 --host=0.0.0.0
--chain-id=1337 --chain-id=1337
--block-time=12 --block-time=12
--accounts=1 --accounts=1
--allow-origin=*" --allow-origin=*
--silent"
networks: networks:
- simulation - simulation
@ -54,6 +55,12 @@ services:
deploy: deploy:
replicas: ${NUM_NWAKU_NODES:-5} replicas: ${NUM_NWAKU_NODES:-5}
entrypoint: sh entrypoint: sh
environment:
- RPC_URL=http://foundry:8545
- PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
- RLN_CONTRACT_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
- RLN_CREDENTIAL_PATH=/keystore.json
- RLN_CREDENTIAL_PASSWORD=passw123
command: command:
- '/opt/run_nwaku.sh' - '/opt/run_nwaku.sh'
volumes: volumes:
@ -158,7 +165,7 @@ services:
ports: ports:
- 127.0.0.1:8090:8090 - 127.0.0.1:8090:8090
environment: environment:
- NODE_ENDPOINT=http://foundry:8541 - NODE_ENDPOINT=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
@ -197,7 +204,7 @@ services:
ingestion: ingestion:
image: web3labs/epirus-free-ingestion:latest image: web3labs/epirus-free-ingestion:latest
environment: environment:
- NODE_ENDPOINT=http://foundry:8541 - NODE_ENDPOINT=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

View File

@ -6,10 +6,6 @@ echo "I am a bootstrap node"
exec /usr/bin/wakunode\ exec /usr/bin/wakunode\
--relay=true\ --relay=true\
--rest=true\
--rest-admin=true\
--rest-private=true\
--rest-address=0.0.0.0\
--keep-alive=true\ --keep-alive=true\
--max-connections=300\ --max-connections=300\
--dns-discovery=true\ --dns-discovery=true\
@ -19,4 +15,8 @@ exec /usr/bin/wakunode\
--metrics-server=True\ --metrics-server=True\
--metrics-server-address=0.0.0.0\ --metrics-server-address=0.0.0.0\
--nodekey=30348dd51465150e04a5d9d932c72864c8967f806cce60b5d26afeca1e77eb68\ --nodekey=30348dd51465150e04a5d9d932c72864c8967f806cce60b5d26afeca1e77eb68\
--nat=extip:${IP} --nat=extip:${IP}\
--rest=true\
--rest-admin=true\
--rest-private=true\
--rest-address=0.0.0.0

View File

@ -1,5 +1,50 @@
#!/bin/sh #!/bin/sh
# Install bind-tools package used for domainname resolution
apk add bind-tools
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="${url/$domain_name/$ip_address}"
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 [[ $RPC_URL =~ $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
/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 \
--execute
fi
IP=$(ip a | grep "inet " | grep -Fv 127.0.0.1 | sed 's/.*inet \([^/]*\).*/\1/') IP=$(ip a | grep "inet " | grep -Fv 127.0.0.1 | sed 's/.*inet \([^/]*\).*/\1/')
echo "I am a nwaku node" echo "I am a nwaku node"
@ -34,8 +79,11 @@ exec /usr/bin/wakunode\
--rest-private=true\ --rest-private=true\
--rest-address=0.0.0.0\ --rest-address=0.0.0.0\
--rln-relay=true\ --rln-relay=true\
--rln-relay-dynamic=false\ --rln-relay-dynamic=true\
--rln-relay-membership-index=${NODE_INDEX}\ --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\
--dns-discovery=true\ --dns-discovery=true\
--discv5-discovery=true\ --discv5-discovery=true\
--discv5-enr-auto-update=True\ --discv5-enr-auto-update=True\

@ -0,0 +1 @@
Subproject commit a01daa8b9475a5dd23db47625e86f585963dd473