diff --git a/docker-compose.yml b/docker-compose.yml index b8e1d5d..334fc59 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,8 +16,6 @@ services: com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' ports: - 0.0.0.0:8545:8545 - environment: - - ANVIL_ACC=${ACCOUNTS} command: - anvil --port=8545 @@ -28,8 +26,10 @@ services: --block-time=12 --silent --config-out=/shared/anvil-config.txt + - /getPrivateKeys.sh volumes: - accounts-volume:/shared + - ./getPrivateKeys.sh:/getPrivateKeys.sh networks: - simulation @@ -85,7 +85,6 @@ services: - '/opt/run_nwaku.sh' volumes: - ./run_nwaku.sh:/opt/run_nwaku.sh:Z - - ./parseAccountsDetails.sh:/opt/parseAccountsDetails.sh:Z - accounts-volume:/shared depends_on: contract-repo-deployer: diff --git a/getPrivateKeys.sh b/getPrivateKeys.sh new file mode 100644 index 0000000..2c7de1d --- /dev/null +++ b/getPrivateKeys.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Install json parser +apk update +apk add jq + +# Read the JSON file +json_content=$(cat /shared/anvil-config.txt) + +# Extract private_keys array values using jq +private_keys=$(echo "$json_content" | jq -r '.private_keys[]') + +# Write private keys to a new file for easier access +echo "Writing private keys to file" +echo "$private_keys" > /shared/private-keys.txt diff --git a/parseAccountsDetails.sh b/parseAccountsDetails.sh deleted file mode 100644 index bfb3e3e..0000000 --- a/parseAccountsDetails.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# Read the JSON file -json_content=$(cat /shared/anvil-config.txt) - -# Extract available_accounts and private_keys arrays using jq -available_accounts=$(echo "$json_content" | jq -r '.available_accounts[]') -private_keys=$(echo "$json_content" | jq -r '.private_keys[]') - -# Convert the extracted strings to Bash arrays -available_accounts_array=() -while IFS= read -r account; do - available_accounts_array+=("$account") -done <<< "$available_accounts" - -private_keys_array=() -while IFS= read -r key; do - private_keys_array+=("$key") -done <<< "$private_keys" - -# echo "ACCOUNT: ${available_accounts_array[$1-1]}" -# echo "PRIVATE KEY: ${private_keys_array[$1-1]}" -echo ${private_keys_array[$1-1]} diff --git a/run_nwaku.sh b/run_nwaku.sh index 70e4783..5d7cd17 100755 --- a/run_nwaku.sh +++ b/run_nwaku.sh @@ -2,8 +2,8 @@ # Install bind-tools package used for domainname resolution apk add bind-tools -apk add jq -apk add bash +# apk add jq +# apk add bash if test -f .env; then echo "Using .env file" @@ -21,6 +21,7 @@ get_ip_address_and_replace() { # 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" @@ -52,18 +53,16 @@ INDEX=`dig -x $IP +short | sed 's/.*_\([0-9]*\)\..*/\1/'` # Hello echo "Hello I'm container $INDEX of $COUNT" - -########################################################################### if test -f .$RLN_CREDENTIAL_PATH; then echo "$RLN_CREDENTIAL_PATH already exists. Use it instead of creating a new one." else - val=$(/bin/bash ./opt/parseAccountsDetails.sh $INDEX) - echo $val + PRIVATE_KEY=$(sed -n "${INDEX}p" /shared/private-keys.txt) + echo $PRIVATE_KEY echo "Generating RLN keystore" /usr/bin/wakunode generateRlnKeystore \ --rln-relay-eth-client-address="$RPC_URL" \ - --rln-relay-eth-private-key=$val \ + --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 \