Skip to content

Commit

Permalink
Merge pull request 'Add stage 1 support' (#910) from dboreham/stage1-…
Browse files Browse the repository at this point in the history
  • Loading branch information
David Boreham committed Aug 7, 2024
2 parents 573f99d + 7590d6e commit 6f8f034
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
34 changes: 31 additions & 3 deletions stack_orchestrator/data/stacks/mainnet-laconic/deploy/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions stack_orchestrator/deploy/deploy_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions stack_orchestrator/deploy/deployment_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 6f8f034

Please sign in to comment.