From adb012f51f79d369392999db92c6a67f32b4fbc3 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Tue, 30 Jul 2024 07:19:56 -0600 Subject: [PATCH] Pass in peer validator addresses --- .../stacks/mainnet-laconic/deploy/commands.py | 19 +++++++------------ stack_orchestrator/deploy/deploy_types.py | 1 + .../deploy/deployment_create.py | 5 +++-- tests/laconic-network/run-test.sh | 4 +++- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/stack_orchestrator/data/stacks/mainnet-laconic/deploy/commands.py b/stack_orchestrator/data/stacks/mainnet-laconic/deploy/commands.py index 3c350e54..e4838798 100644 --- a/stack_orchestrator/data/stacks/mainnet-laconic/deploy/commands.py +++ b/stack_orchestrator/data/stacks/mainnet-laconic/deploy/commands.py @@ -78,16 +78,11 @@ def _comma_delimited_to_list(list_str: str): return list_str.split(",") if list_str else [] -def _get_node_keys_from_gentx_files(gentx_file_list: str): +def _get_node_keys_from_gentx_files(gentx_address_list: str): node_keys = [] - gentx_files = _comma_delimited_to_list(gentx_file_list) - print(f"gentx_files: {gentx_files}") - for gentx_file in gentx_files: - node_key = _get_node_key_from_gentx(gentx_file) - print(f"node_key: {node_key}") - if node_key: - node_keys.append(node_key) - return node_keys + gentx_addresses = _comma_delimited_to_list(gentx_address_list) + print(f"gentx_files: {gentx_addresses}") + return gentx_addresses def _copy_gentx_files(network_dir: Path, gentx_file_list: str): @@ -262,11 +257,11 @@ def setup(command_context: DeployCommandContext, parameters: LaconicStackSetupCo copyfile(genesis_file_path, os.path.join(network_dir, "config", os.path.basename(genesis_file_path))) else: # We're generating the genesis file - if not parameters.gentx_file_list: - print("Error: --gentx-files must be supplied") + if not (parameters.gentx_file_list and parameters.gentx_address_list) : + print("Error: --gentx-files and --gentx-addresses must be supplied") sys.exit(1) # First look in the supplied gentx files for the other nodes' keys - other_node_keys = _get_node_keys_from_gentx_files(parameters.gentx_file_list) + other_node_keys = _get_node_keys_from_gentx_files(parameters.gentx_address_list) # Add those keys to our genesis, with balances we determine here (why?) print(f"other_node_keys: {other_node_keys}") for other_node_key in other_node_keys: diff --git a/stack_orchestrator/deploy/deploy_types.py b/stack_orchestrator/deploy/deploy_types.py index f97b2649..2ecf07aa 100644 --- a/stack_orchestrator/deploy/deploy_types.py +++ b/stack_orchestrator/deploy/deploy_types.py @@ -52,6 +52,7 @@ class LaconicStackSetupCommand: join_network: bool create_network: bool gentx_file_list: str + gentx_address_list: str genesis_file: str network_dir: str diff --git a/stack_orchestrator/deploy/deployment_create.py b/stack_orchestrator/deploy/deployment_create.py index 5f565854..a587e75a 100644 --- a/stack_orchestrator/deploy/deployment_create.py +++ b/stack_orchestrator/deploy/deployment_create.py @@ -535,6 +535,7 @@ def create_operation(deployment_command_context, spec_file, deployment_dir, netw @click.option("--chain-id", help="The new chain id") @click.option("--key-name", help="Name for new node key") @click.option("--gentx-files", help="List of comma-delimited gentx filenames from other nodes") +@click.option("--gentx-addresses", help="List of comma-delimited validator addresses for other nodes") @click.option("--genesis-file", help="Genesis file for the network") @click.option("--initialize-network", is_flag=True, default=False, help="Initialize phase") @click.option("--join-network", is_flag=True, default=False, help="Join phase") @@ -542,8 +543,8 @@ def create_operation(deployment_command_context, spec_file, deployment_dir, netw @click.option("--network-dir", help="Directory for network files") @click.argument('extra_args', nargs=-1) @click.pass_context -def setup(ctx, node_moniker, chain_id, key_name, gentx_files, genesis_file, initialize_network, join_network, create_network, +def setup(ctx, node_moniker, chain_id, key_name, gentx_files, gentx_addresses, genesis_file, initialize_network, join_network, create_network, network_dir, extra_args): parmeters = LaconicStackSetupCommand(chain_id, node_moniker, key_name, initialize_network, join_network, create_network, - gentx_files, genesis_file, network_dir) + gentx_files, gentx_addresses, genesis_file, network_dir) call_stack_deploy_setup(ctx.obj, parmeters, extra_args) diff --git a/tests/laconic-network/run-test.sh b/tests/laconic-network/run-test.sh index fd58ca72..47a8de03 100755 --- a/tests/laconic-network/run-test.sh +++ b/tests/laconic-network/run-test.sh @@ -63,13 +63,15 @@ for (( i=2 ; i<=$node_count ; i++ )); do node_network_dir=${node_dir_prefix}${i} node_gentx_file=$(ls ${node_network_dir}/config/gentx/*.json) + node_gentx_address=$(grep address ${node_network_dir}/config/genesis.json | head -1 | cut -d '"' -f 4) gentx_files+=${delimeter}${node_gentx_file} + gentx_addresses+=${delimeter}${node_gentx_address} delimeter="," done echo "gentx files:" echo ${gentx_files} # Generate the genesis file on node 1 -laconic-so --stack mainnet-laconic deploy setup --network-dir ${node_dir_prefix}1 --create-network --gentx-files ${gentx_files} +laconic-so --stack mainnet-laconic deploy setup --network-dir ${node_dir_prefix}1 --create-network --gentx-files ${gentx_files} --gentx-addresses ${gentx_addresses} genesis_file=${node_dir_prefix}1/config/genesis.json # Now import the genesis file to the other nodes for (( i=2 ; i<=$node_count ; i++ ));