Pass in peer validator addresses

This commit is contained in:
David Boreham 2024-07-30 07:19:56 -06:00
parent 046a6308ef
commit adb012f51f
4 changed files with 14 additions and 15 deletions

View File

@ -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:

View File

@ -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

View File

@ -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)

View File

@ -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++ ));