From ea9272610d2e681a10f0f43fd2021aa46a9fad54 Mon Sep 17 00:00:00 2001 From: Tobi Okedeji Date: Tue, 16 Jul 2024 18:23:43 +0100 Subject: [PATCH] update topic spec and add auto address funding to workers --- allocmd/templates/dev-docker-compose.yaml.j2 | 2 +- allocmd/templates/prod-docker-compose.yaml.j2 | 2 +- allocmd/utilities/constants.py | 2 +- allocmd/utilities/utils.py | 19 +++++++++++++++---- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/allocmd/templates/dev-docker-compose.yaml.j2 b/allocmd/templates/dev-docker-compose.yaml.j2 index 11bc4b9..3da9eec 100644 --- a/allocmd/templates/dev-docker-compose.yaml.j2 +++ b/allocmd/templates/dev-docker-compose.yaml.j2 @@ -14,7 +14,7 @@ services: - --private-key=/data/{{ b7s_type }}/key/priv.bin - --log-level=debug - --port=9011 - - --topic={{ topic_id }} + - --topic={{ allora_topic_id }} - --boot-nodes=/ip4/172.19.0.100/tcp/9010/p2p/{{ head_peer_id }} volumes: - type: bind diff --git a/allocmd/templates/prod-docker-compose.yaml.j2 b/allocmd/templates/prod-docker-compose.yaml.j2 index 96c998c..237cc40 100644 --- a/allocmd/templates/prod-docker-compose.yaml.j2 +++ b/allocmd/templates/prod-docker-compose.yaml.j2 @@ -22,7 +22,7 @@ services: - --log-level=debug - --port=9010 - --boot-nodes={{ boot_nodes }} - - --topic={{ topic_id }} + - --topic={{ allora_topic_id }} - --allora-node-rpc-address={{ chain_rpc_address }} - --allora-chain-home-dir=/data/.allorad - --allora-chain-key-name={{ worker_name}} diff --git a/allocmd/utilities/constants.py b/allocmd/utilities/constants.py index 013f55c..e01b833 100644 --- a/allocmd/utilities/constants.py +++ b/allocmd/utilities/constants.py @@ -1 +1 @@ -cliVersion = "2.0.7" +cliVersion = "2.0.8" diff --git a/allocmd/utilities/utils.py b/allocmd/utilities/utils.py index a2f7727..d30bed9 100644 --- a/allocmd/utilities/utils.py +++ b/allocmd/utilities/utils.py @@ -176,6 +176,8 @@ def generateWorkerAccount(worker_name, type): with open(config_path, 'w') as file: yaml.safe_dump(config, file) + return address + def generateProdCompose(env: Environment, type): """Deploy resource production kubernetes cluster""" @@ -201,10 +203,12 @@ def generateProdCompose(env: Environment, type): return worker_name = config['name'] + faucet_url = config['faucet_url'] hex_coded_pk = config[type]['hex_coded_pk'] boot_nodes = config[type]['boot_nodes'] chain_rpc_address = config[type]['chain_rpc_address'] chain_topic_id = config[type]['chain_topic_id'] + account_address = config[type]['address'] alloraTopic = None @@ -221,7 +225,8 @@ def generateProdCompose(env: Environment, type): "worker_name": worker_name, "boot_nodes": boot_nodes, "chain_rpc_address": chain_rpc_address, - "topic_id": alloraTopic, + "allora_topic_id": alloraTopic, + "topic_id": chain_topic_id, } }, { @@ -235,13 +240,15 @@ def generateProdCompose(env: Environment, type): ] generate_all_files(env, file_configs, Command.DEPLOY, type) + + fundAddress(faucet_url, account_address) cprint(f"production docker compose file generated to be deployed", 'green') cprint(f"please run chmod -R +rx ./data/scripts to grant script access to the image", 'yellow') else: cprint("\nOperation cancelled.", 'red') -def blocklessNode(environment, env, type, name=None, topic=None): +def blocklessNode(environment, env, type, name=None, topic=None, network='edgenet'): """Initialize your Allora Worker Node with necessary boilerplates""" if not check_docker_running(): @@ -286,7 +293,7 @@ def blocklessNode(environment, env, type, name=None, topic=None): { "template_name": "dev-docker-compose.yaml.j2", "file_name": "dev-docker-compose.yaml", - "context": {"head_peer_id": head_peer_id, "topic_id": alloraTopic, "b7s_type": type} + "context": {"head_peer_id": head_peer_id, "allora_topic_id": alloraTopic, "b7s_type": type} }, { "template_name": "requirements.txt.j2", @@ -312,7 +319,11 @@ def blocklessNode(environment, env, type, name=None, topic=None): generate_all_files(env, file_configs, Command.INIT, type, name) - generateWorkerAccount(name, type) + address = generateWorkerAccount(name, type) + + faucet_url = f'https://faucet.{network}.allora.network/' + + fundAddress(faucet_url, address) else: cprint("\nOperation cancelled.", 'red') elif environment == 'prod':