Support laconicd2 in mainnet stack
This commit is contained in:
parent
913c3a8557
commit
046a6308ef
@ -67,7 +67,8 @@ def _get_node_key_from_gentx(gentx_file_name: str):
|
||||
if gentx_file_path.exists():
|
||||
with open(Path(gentx_file_name), "rb") as f:
|
||||
parsed_json = json.load(f)
|
||||
return parsed_json['body']['messages'][0]['delegator_address']
|
||||
print(f"parsed_json: {parsed_json}")
|
||||
return parsed_json['body']['messages'][0]['validator_address']
|
||||
else:
|
||||
print(f"Error: gentx file: {gentx_file_name} does not exist")
|
||||
sys.exit(1)
|
||||
@ -80,8 +81,10 @@ def _comma_delimited_to_list(list_str: str):
|
||||
def _get_node_keys_from_gentx_files(gentx_file_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
|
||||
@ -178,7 +181,7 @@ def setup(command_context: DeployCommandContext, parameters: LaconicStackSetupCo
|
||||
|
||||
options = opts.o
|
||||
|
||||
currency = "stake" # Does this need to be a parameter?
|
||||
currency = "photon" # Does this need to be a parameter?
|
||||
|
||||
if options.debug:
|
||||
print(f"parameters: {parameters}")
|
||||
@ -222,7 +225,7 @@ def setup(command_context: DeployCommandContext, parameters: LaconicStackSetupCo
|
||||
output2, status2 = run_container_command(
|
||||
command_context,
|
||||
"laconicd",
|
||||
f"laconicd add-genesis-account {parameters.key_name} 12900000000000000000000{currency}\
|
||||
f"laconicd genesis add-genesis-account {parameters.key_name} 12900000000000000000000{currency}\
|
||||
--home {laconicd_home_path_in_container} --keyring-backend test",
|
||||
mounts)
|
||||
if options.debug:
|
||||
@ -230,7 +233,7 @@ def setup(command_context: DeployCommandContext, parameters: LaconicStackSetupCo
|
||||
output3, status3 = run_container_command(
|
||||
command_context,
|
||||
"laconicd",
|
||||
f"laconicd gentx {parameters.key_name} 90000000000{currency} --home {laconicd_home_path_in_container}\
|
||||
f"laconicd genesis gentx {parameters.key_name} 90000000000{currency} --home {laconicd_home_path_in_container}\
|
||||
--chain-id {chain_id} --keyring-backend test",
|
||||
mounts)
|
||||
if options.debug:
|
||||
@ -265,9 +268,10 @@ def setup(command_context: DeployCommandContext, parameters: LaconicStackSetupCo
|
||||
# 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)
|
||||
# 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:
|
||||
outputk, statusk = run_container_command(
|
||||
command_context, "laconicd", f"laconicd add-genesis-account {other_node_key} 12900000000000000000000{currency}\
|
||||
command_context, "laconicd", f"laconicd genesis add-genesis-account {other_node_key} 12900000000000000000000{currency}\
|
||||
--home {laconicd_home_path_in_container} --keyring-backend test", mounts)
|
||||
if options.debug:
|
||||
print(f"Command output: {outputk}")
|
||||
@ -275,7 +279,7 @@ def setup(command_context: DeployCommandContext, parameters: LaconicStackSetupCo
|
||||
_copy_gentx_files(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)
|
||||
command_context, "laconicd", f"laconicd genesis collect-gentxs --home {laconicd_home_path_in_container}", mounts)
|
||||
if options.debug:
|
||||
print(f"Command output: {output1}")
|
||||
print(f"Generated genesis file, please copy to other nodes as required: \
|
||||
@ -284,7 +288,7 @@ def setup(command_context: DeployCommandContext, parameters: LaconicStackSetupCo
|
||||
_remove_persistent_peers(network_dir)
|
||||
# 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)
|
||||
command_context, "laconicd", f"laconicd genesis validate-genesis --home {laconicd_home_path_in_container}", mounts)
|
||||
print(f"validate-genesis result: {output2}")
|
||||
|
||||
else:
|
||||
|
@ -8,8 +8,11 @@ echo "Environment variables:"
|
||||
env
|
||||
# Test laconic stack
|
||||
echo "Running laconic stack test"
|
||||
# Bit of a hack, test the most recent package
|
||||
TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 )
|
||||
if [ "$1" == "from-path" ]; then
|
||||
TEST_TARGET_SO="laconic-so"
|
||||
else
|
||||
TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 )
|
||||
fi
|
||||
# Set a non-default repo dir
|
||||
export CERC_REPO_BASE_DIR=~/stack-orchestrator-test/repo-base-dir
|
||||
echo "Testing this package: $TEST_TARGET_SO"
|
||||
|
@ -83,7 +83,7 @@ def run_container_command(ctx: DeployCommandContext, service: str, command: str,
|
||||
docker_output = deployer.run(
|
||||
container_image,
|
||||
["-c", command], entrypoint="sh",
|
||||
user=f"{os.getuid()}:{os.getgid()}",
|
||||
# user=f"{os.getuid()}:{os.getgid()}",
|
||||
volumes=docker_volumes
|
||||
)
|
||||
# There doesn't seem to be a way to get an exit code from docker.run()
|
||||
|
@ -4,6 +4,10 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
set_ownership () {
|
||||
sudo chown $USER: -R $1
|
||||
}
|
||||
|
||||
node_count=4
|
||||
node_dir_prefix="laconic-network-dir"
|
||||
chain_id="laconic_81337-6"
|
||||
@ -15,7 +19,7 @@ do
|
||||
node_network_dir=${node_dir_prefix}${i}
|
||||
if [[ -d $node_network_dir ]]; then
|
||||
echo "Deleting ${node_network_dir}"
|
||||
rm -rf ${node_network_dir}
|
||||
sudo rm -rf ${node_network_dir}
|
||||
fi
|
||||
done
|
||||
echo "Deleting any existing deployments..."
|
||||
@ -39,6 +43,7 @@ do
|
||||
node_network_dir=${node_dir_prefix}${i}
|
||||
node_moniker=${node_moniker_prefix}${i}
|
||||
laconic-so --stack mainnet-laconic deploy setup --network-dir ${node_network_dir} --initialize-network --chain-id ${chain_id} --node-moniker ${node_moniker}
|
||||
set_ownership ${node_network_dir}
|
||||
done
|
||||
|
||||
echo "Joining ${node_count} nodes to the network..."
|
||||
@ -47,6 +52,7 @@ do
|
||||
node_network_dir=${node_dir_prefix}${i}
|
||||
node_moniker=${node_moniker_prefix}${i}
|
||||
laconic-so --stack mainnet-laconic deploy setup --network-dir ${node_network_dir} --join-network --key-name ${node_moniker}
|
||||
set_ownership ${node_network_dir}
|
||||
done
|
||||
|
||||
echo "Merging ${node_count} nodes genesis txns..."
|
||||
@ -60,6 +66,8 @@ do
|
||||
gentx_files+=${delimeter}${node_gentx_file}
|
||||
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}
|
||||
genesis_file=${node_dir_prefix}1/config/genesis.json
|
||||
@ -69,6 +77,7 @@ 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}
|
||||
set_ownership ${node_network_dir}
|
||||
done
|
||||
|
||||
# Create deployments
|
||||
|
Loading…
Reference in New Issue
Block a user