diff --git a/run_nwaku.sh b/run_nwaku.sh index b79c771..f957c2f 100755 --- a/run_nwaku.sh +++ b/run_nwaku.sh @@ -1,5 +1,7 @@ #!/bin/sh +ANVIL_CONFIG_PATH=${ANVIL_CONFIG_PATH:-/shared/anvil-config.txt} + # Check Linux Distro Version - it can differ depending on the nwaku image used OS=$(cat /etc/os-release) if echo $OS | grep -q "Debian"; then @@ -49,7 +51,7 @@ fi get_private_key(){ # Read the JSON file - json_content=$(cat /shared/anvil-config.txt) + json_content=$(cat "$ANVIL_CONFIG_PATH") # Check if json_content has a value if [ -z "$json_content" ]; then diff --git a/tools/token-mint-service/get_account_key.sh b/tools/token-mint-service/get_account_key.sh index 6a8ec36..c093a5a 100644 --- a/tools/token-mint-service/get_account_key.sh +++ b/tools/token-mint-service/get_account_key.sh @@ -1,18 +1,12 @@ #!/bin/sh -# Helper script to get the index of the container and use it to retrieve a unique account private key per nwaku node to be used to generate the keystore +# Helper script to get the index of the container and use it to retrieve a unique account private key. +# Each node uses a unique Ethereum account to register with the RLN contract. +# The account and private key pairs are stored in anvil-config.txt on a shared volume at anvil startup in the foundry service set -e -# Tools already installed in Dockerfile - ANVIL_CONFIG_PATH=${ANVIL_CONFIG_PATH:-/shared/anvil-config.txt} -# Wait for anvil config to be available -echo "Waiting for anvil config at $ANVIL_CONFIG_PATH..." -while [ ! -f "$ANVIL_CONFIG_PATH" ]; do - sleep 2 -done - # Get container IP and determine index (same method as run_nwaku.sh) IP=$(ip a | grep "inet " | grep -Fv 127.0.0.1 | sed 's/.*inet \([^/]*\).*/\1/') echo "Container IP: $IP" diff --git a/tools/token-mint-service/init_node_tokens.py b/tools/token-mint-service/init_node_tokens.py index 30c643d..62cb119 100644 --- a/tools/token-mint-service/init_node_tokens.py +++ b/tools/token-mint-service/init_node_tokens.py @@ -30,10 +30,12 @@ class NodeTokenInitializer: self.rpc_url = os.getenv('RPC_URL', 'http://foundry:8545') self.token_address = os.getenv('TOKEN_ADDRESS', '0x5FbDB2315678afecb367f032d93F642f64180aa3') self.contract_address = os.getenv('CONTRACT_ADDRESS', '0x5FC8d32690cc91D4c39d9d3abcBD16989F875707') - self.private_key = os.getenv('NODE_PRIVATE_KEY') # Ethereum account private key (not nwaku node-key) - self.node_address = os.getenv('NODE_ADDRESS') # Ethereum account address + # The values for NODE_PRIVATE_KEY, NODE_ADDRESS, and NODE_INDEX are set by the get_account_key.sh script + self.private_key = os.getenv('NODE_PRIVATE_KEY') + self.node_address = os.getenv('NODE_ADDRESS') self.node_index = os.getenv('NODE_INDEX', '0') - self.mint_amount = int(os.getenv('MINT_AMOUNT', '5000000000000000000')) # 5 tokens + + self.mint_amount = int(os.getenv('MINT_AMOUNT', '5000000000000000000')) # at least 5 tokens required for membership with RLN_RELAY_MSG_LIMIT=100 if not self.private_key: raise ValueError("NODE_PRIVATE_KEY (Ethereum account private key) environment variable is required")