diff --git a/stack_orchestrator/data/stacks/mainnet-laconic/deploy/commands.py b/stack_orchestrator/data/stacks/mainnet-laconic/deploy/commands.py index 8c4fa0d1..40e271a9 100644 --- a/stack_orchestrator/data/stacks/mainnet-laconic/deploy/commands.py +++ b/stack_orchestrator/data/stacks/mainnet-laconic/deploy/commands.py @@ -33,8 +33,9 @@ class SetupPhase(Enum): INITIALIZE = 1 JOIN = 2 - CREATE = 3 - ILLEGAL = 3 + CONNECT = 3 + CREATE = 4 + ILLEGAL = 5 def _client_toml_path(network_dir: Path): @@ -182,6 +183,11 @@ def _phase_from_params(parameters): print("Can't supply --initialize-network or --join-network with --create-network") sys.exit(1) phase = SetupPhase.CREATE + elif parameters.connect_network: + if parameters.initialize_network or parameters.join_network: + print("Can't supply --initialize-network or --join-network with --connect-network") + sys.exit(1) + phase = SetupPhase.CONNECT return phase @@ -219,6 +225,7 @@ def setup(command_context: DeployCommandContext, parameters: LaconicStackSetupCo print(f"Command output: {output}") elif phase == SetupPhase.JOIN: + # In the join phase (alternative to connect) we are participating in a genesis ceremony for the chain if not os.path.exists(network_dir): print(f"Error: network directory {network_dir} doesn't exist") sys.exit(1) @@ -251,7 +258,28 @@ def setup(command_context: DeployCommandContext, parameters: LaconicStackSetupCo "laconicd", f"laconicd keys show {parameters.key_name} -a --home {laconicd_home_path_in_container} --keyring-backend test", mounts) - print(f"Node validator address: {output4}") + print(f"Node account address: {output4}") + + elif phase == SetupPhase.CONNECT: + # In the connect phase (named to not conflict with join) we are making a node that syncs a chain with existing genesis.json + # but not with validator role. We need this kind of node in order to bootstrap it into a validator after it syncs + output1, status1 = run_container_command( + command_context, "laconicd", f"laconicd keys add {parameters.key_name} --home {laconicd_home_path_in_container}\ + --keyring-backend test", mounts) + if options.debug: + print(f"Command output: {output1}") + output2, status2 = run_container_command( + command_context, + "laconicd", + f"laconicd keys show {parameters.key_name} -a --home {laconicd_home_path_in_container} --keyring-backend test", + mounts) + print(f"Node account address: {output2}") + output3, status3 = run_container_command( + command_context, + "laconicd", + f"laconicd cometbft show-validator --home {laconicd_home_path_in_container}", + mounts) + print(f"Node validator address: {output3}") elif phase == SetupPhase.CREATE: if not os.path.exists(network_dir): diff --git a/stack_orchestrator/deploy/deploy_types.py b/stack_orchestrator/deploy/deploy_types.py index 2ecf07aa..f59d9f67 100644 --- a/stack_orchestrator/deploy/deploy_types.py +++ b/stack_orchestrator/deploy/deploy_types.py @@ -50,6 +50,7 @@ class LaconicStackSetupCommand: key_name: str initialize_network: bool join_network: bool + connect_network: bool create_network: bool gentx_file_list: str gentx_address_list: str diff --git a/stack_orchestrator/deploy/deployment_create.py b/stack_orchestrator/deploy/deployment_create.py index fa00feea..f9cb8317 100644 --- a/stack_orchestrator/deploy/deployment_create.py +++ b/stack_orchestrator/deploy/deployment_create.py @@ -539,12 +539,13 @@ def create_operation(deployment_command_context, spec_file, deployment_dir, netw @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") +@click.option("--connect-network", is_flag=True, default=False, help="Connect phase") @click.option("--create-network", is_flag=True, default=False, help="Create phase") @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, 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, gentx_addresses, genesis_file, network_dir) + connect_network, create_network, network_dir, extra_args): + parmeters = LaconicStackSetupCommand(chain_id, node_moniker, key_name, initialize_network, join_network, connect_network, + create_network, gentx_files, gentx_addresses, genesis_file, network_dir) call_stack_deploy_setup(ctx.obj, parmeters, extra_args)