Mainnet laconic setup #510
@ -180,21 +180,33 @@ def setup(command_context: DeployCommandContext, parameters: LaconicStackSetupCo
|
||||
print(f"Error: network directory {network_dir} doesn't exist")
|
||||
sys.exit(1)
|
||||
|
||||
# First look in the supplied gentx files for the other nodes' keys
|
||||
other_node_keys = _get_node_keys_from_gentx_files(options, parameters.gentx_file_list)
|
||||
# Add those keys to our genesis, with balances we determine here (why?)
|
||||
for other_node_key in other_node_keys:
|
||||
outputk, statusk = run_container_command(
|
||||
command_context, "laconicd", f"laconicd add-genesis-account {other_node_key} 12900000000000000000000achk\
|
||||
--home {laconicd_home_path_in_container} --keyring-backend test", mounts)
|
||||
print(f"Command output: {outputk}")
|
||||
# Copy the gentx json files into our network dir
|
||||
_copy_gentx_files(options, network_dir, parameters.gentx_file_list)
|
||||
# Now we can run collect-gentxs
|
||||
|
||||
output1, status1 = run_container_command(
|
||||
command_context, "laconicd", f"laconicd collect-gentxs --home {laconicd_home_path_in_container}", mounts)
|
||||
print(f"Command output: {output1}")
|
||||
# In the CREATE phase, we are either a "coordinator" node, generating the genesis.json file ourselves
|
||||
# OR we are a "not-coordinator" node, consuming a genesis file we got from the coordinator node.
|
||||
if parameters.genesis_file:
|
||||
# We got the genesis file from elsewhere
|
||||
# Copy it into our network dir
|
||||
genesis_file_path = Path(parameters.genesis_file)
|
||||
if not os.path.exists(genesis_file_path):
|
||||
print(f"Error: supplied genesis file: {parameters.genesis_file} does not exist.")
|
||||
sys.exit(1)
|
||||
copyfile(genesis_file_path, os.path.join(network_dir, "config", os.path.basename(genesis_file_path)))
|
||||
else:
|
||||
# We're generating the genesis file
|
||||
# First look in the supplied gentx files for the other nodes' keys
|
||||
other_node_keys = _get_node_keys_from_gentx_files(options, parameters.gentx_file_list)
|
||||
# Add those keys to our genesis, with balances we determine here (why?)
|
||||
for other_node_key in other_node_keys:
|
||||
outputk, statusk = run_container_command(
|
||||
command_context, "laconicd", f"laconicd add-genesis-account {other_node_key} 12900000000000000000000achk\
|
||||
--home {laconicd_home_path_in_container} --keyring-backend test", mounts)
|
||||
print(f"Command output: {outputk}")
|
||||
# Copy the gentx json files into our network dir
|
||||
_copy_gentx_files(options, network_dir, parameters.gentx_file_list)
|
||||
# Now we can run collect-gentxs
|
||||
output1, status1 = run_container_command(
|
||||
command_context, "laconicd", f"laconicd collect-gentxs --home {laconicd_home_path_in_container}", mounts)
|
||||
print(f"Command output: {output1}")
|
||||
# In both cases we validate the genesis file now
|
||||
output2, status1 = run_container_command(
|
||||
command_context, "laconicd", f"laconicd validate-genesis --home {laconicd_home_path_in_container}", mounts)
|
||||
print(f"Command output: {output2}")
|
||||
|
@ -58,6 +58,7 @@ class LaconicStackSetupCommand:
|
||||
join_network: bool
|
||||
create_network: bool
|
||||
gentx_file_list: str
|
||||
genesis_file: str
|
||||
network_dir: str
|
||||
|
||||
|
||||
|
@ -258,14 +258,15 @@ def create(ctx, spec_file, deployment_dir):
|
||||
@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("--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("--create-network", is_flag=True, default=False, help="Create phase")
|
||||
@click.option("--network-dir", required=True, 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, initialize_network, join_network, create_network, network_dir,
|
||||
extra_args):
|
||||
def setup(ctx, node_moniker, chain_id, key_name, gentx_files, 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, network_dir)
|
||||
gentx_files, genesis_file, network_dir)
|
||||
call_stack_deploy_setup(ctx.obj, parmeters, extra_args)
|
||||
|
@ -46,4 +46,13 @@ do
|
||||
gentx_files+=${delimeter}${node_gentx_file}
|
||||
delimeter=","
|
||||
done
|
||||
# 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}
|
||||
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++ ));
|
||||
do
|
||||
echo "Importing genesis.json into node ${i}"
|
||||
node_network_dir=${node_dir_prefix}${i}
|
||||
laconic-so --stack mainnet-laconic deploy setup --network-dir ${node_network_dir} --create-network --genesis-file ${genesis_file}
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user