diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5045b4a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "submodules/waku-rln-contract"] + path = submodules/waku-rln-contract + url = https://github.com/waku-org/waku-rln-contract.git diff --git a/docker-compose.yml b/docker-compose.yml index af3e37a..0aff6a7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,15 +15,16 @@ services: labels: com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' ports: - - 127.0.0.1:8541:8541 + - 127.0.0.1:8545:8545 command: > "anvil - --port=8541 + --port=8545 --host=0.0.0.0 --chain-id=1337 --block-time=12 --accounts=1 - --allow-origin=*" + --allow-origin=* + --silent" networks: - simulation @@ -54,6 +55,12 @@ services: deploy: replicas: ${NUM_NWAKU_NODES:-5} 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: - '/opt/run_nwaku.sh' volumes: @@ -158,7 +165,7 @@ services: ports: - 127.0.0.1:8090:8090 environment: - - NODE_ENDPOINT=http://foundry:8541 + - NODE_ENDPOINT=http://foundry:8545 - MONGO_CLIENT_URI=mongodb://mongodb:27017 - REINDEX_ENDPOINT=http://ingestion/reindex/ - MONGO_DB_NAME=epirus @@ -197,7 +204,7 @@ services: ingestion: image: web3labs/epirus-free-ingestion:latest environment: - - NODE_ENDPOINT=http://foundry:8541 + - NODE_ENDPOINT=http://foundry:8545 - MONGO_CLIENT_URI=mongodb://mongodb:27017 - MONGO_DB_NAME=epirus - LIST_OF_METRICS_TO_CALCULATE_PER_MINUTE=hourly,daily,monthly,yearly diff --git a/run_bootstrap.sh b/run_bootstrap.sh index ff7dac1..28c905b 100755 --- a/run_bootstrap.sh +++ b/run_bootstrap.sh @@ -6,10 +6,6 @@ echo "I am a bootstrap node" exec /usr/bin/wakunode\ --relay=true\ - --rest=true\ - --rest-admin=true\ - --rest-private=true\ - --rest-address=0.0.0.0\ --keep-alive=true\ --max-connections=300\ --dns-discovery=true\ @@ -19,4 +15,8 @@ exec /usr/bin/wakunode\ --metrics-server=True\ --metrics-server-address=0.0.0.0\ --nodekey=30348dd51465150e04a5d9d932c72864c8967f806cce60b5d26afeca1e77eb68\ - --nat=extip:${IP} \ No newline at end of file + --nat=extip:${IP}\ + --rest=true\ + --rest-admin=true\ + --rest-private=true\ + --rest-address=0.0.0.0 \ No newline at end of file diff --git a/run_nwaku.sh b/run_nwaku.sh index 438bed0..8dc15c8 100755 --- a/run_nwaku.sh +++ b/run_nwaku.sh @@ -1,5 +1,50 @@ #!/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/') echo "I am a nwaku node" @@ -34,8 +79,11 @@ exec /usr/bin/wakunode\ --rest-private=true\ --rest-address=0.0.0.0\ --rln-relay=true\ - --rln-relay-dynamic=false\ - --rln-relay-membership-index=${NODE_INDEX}\ + --rln-relay-dynamic=true\ + --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\ --discv5-discovery=true\ --discv5-enr-auto-update=True\ @@ -43,4 +91,4 @@ exec /usr/bin/wakunode\ --metrics-server=True\ --metrics-server-address=0.0.0.0\ --discv5-bootstrap-node=${BOOTSTRAP_ENR}\ - --nat=extip:${IP} + --nat=extip:${IP} \ No newline at end of file diff --git a/submodules/waku-rln-contract b/submodules/waku-rln-contract new file mode 160000 index 0000000..a01daa8 --- /dev/null +++ b/submodules/waku-rln-contract @@ -0,0 +1 @@ +Subproject commit a01daa8b9475a5dd23db47625e86f585963dd473