From 5685c622e167ac80ac10db835238682c1cefed8f Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Mon, 9 Jun 2025 17:58:01 +0530 Subject: [PATCH] Refactor TMKMS setup instructions --- docs/run-first-validator.md | 228 +++++++++--------- docs/run-validator.md | 5 +- scripts/generate-lps-lock.sh | 17 +- .../create-and-collect-gentx.sh | 1 - 4 files changed, 125 insertions(+), 126 deletions(-) diff --git a/docs/run-first-validator.md b/docs/run-first-validator.md index ba5ba4e..df223c9 100644 --- a/docs/run-first-validator.md +++ b/docs/run-first-validator.md @@ -34,8 +34,7 @@ export DATA_DIRECTORY= # Set mainnet deployment directory - # for eg: mainnet-laconicd-deployment - export MAINNET_DEPLOYMENT_DIR= + export MAINNET_DEPLOYMENT_DIR=mainnet-laconicd-deployment ``` - Run ansible playbook to setup the node: @@ -54,6 +53,117 @@ NOTE: This public key is required in next step to generate the genesis file +## Export testnet state + +- Run the following steps in machine where the testnet node is running + +- Get your private key from testnet deployment: + + ```bash + laconic-so deployment --dir exec laconicd "laconicd keys export --unarmored-hex --unsafe" + ``` + + NOTE: Store this key securely as it is needed in later steps + +- Stop the node for SAPO testnet: + + ```bash + laconic-so deployment --dir stop + ``` + +- Fetch the stack in machine where the testnet chain node is running: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull + ``` + +- Run script to export state from testnet chain: + + ```bash + ~/cerc/laconicd-stack/scripts/export-testnet-state.sh + ``` + + - The compressed zst file will be generated at `/export/testnet-state.zst` + +## Generate mainnet genesis file + +- Run the following steps in secure machine separate from the one where the node is setup + +- Fetch the stack: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull + ``` + +- Copy over compressed `testnet-state.zst` file to target machine + +- Set envs: + + ```bash + # Path where exported testnet state JSON file will be created + export EXPORTED_STATE_PATH= + + # Path where LPS distribution JSON file will be created + export LPS_DISTRIBUTION_PATH= + + export EARLY_SUPPORTS_ACC_ADDR= + + # Parent directory where the deployment directory will live + export DATA_DIRECTORY= + + # Set mainnet deployment directory + export MAINNET_DEPLOYMENT_DIR=mainnet-laconicd-deployment + ``` + +- Extract the testnet-state JSON file: + + ```bash + zstd -dc /testnet-state.zst > $EXPORTED_STATE_PATH + + # Remove zst folder + rm -rf /testnet-state.zst + ``` + +- Generate LPS lockup distribution JSON file + + ```bash + ~/cerc/laconicd-stack/scripts/generate-lps-lock.sh -i "" -o $LPS_DISTRIBUTION_PATH + ``` + + - This will generate the `distribution.json` file at `$LPS_DISTRIBUTION_PATH` + +- Copy the example variables file: + + ```bash + cp ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.example.yml ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml + ``` + +- Edit `~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml` with required values: + + ```bash + # Use the public key exported in previous step (make sure to wrap it with single quotes ['']) + validator_pub_key: '' + ``` + +- Run playbook to use exported state for generating mainnet genesis file with gentx: + + ```bash + ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/generate-genesis.yml -e "exported_state_path=$EXPORTED_STATE_PATH" -e "lps_distribution_path=$LPS_DISTRIBUTION_PATH" -e "early_supports_acc_address=$EARLY_SUPPORTS_ACC_ADDR" + ``` + + - Input private key of the existing account that was exported in previous steps when prompted + +- Genesis file will be generated in output directory along with a file specifying the staking amount + + ```bash + # List files in output directory - genesis.json and staking-amount.json + ls -l output + ``` + +## Run node + +- Run the following steps in the machine where the mainnet node is setup + ### Setup TMKMS (Optional but Recommended) @@ -140,121 +250,15 @@ echo "TMKMS_ENABLED=true" >> $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/config.env ``` -## Export testnet state - -- Run the following steps in machine where the testnet node is running - -- Get your private key from testnet deployment: - - ```bash - laconic-so deployment --dir exec laconicd "laconicd keys export --unarmored-hex --unsafe" - ``` - - NOTE: Store this key securely as it is needed in later steps - -- Stop the node for SAPO testnet: - - ```bash - laconic-so deployment --dir stop - ``` - -- Fetch the stack in machine where the testnet chain node is running: - - ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull - ``` - -- Run script to export state from testnet chain: - - ```bash - ~/cerc/laconicd-stack/scripts/export-testnet-state.sh - ``` - - - The compressed zst file will be generated at `/export/testnet-state.zst` - -## Generate mainnet genesis file - -- Run the following steps in secure machine separate from the one where the node is setup - -- Fetch the stack: - - ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull - ``` - -- Copy over compressed `testnet-state.zst` file to target machine - -- Extract the testnet-state JSON file: - - ```bash - zstd -dc /testnet-state.zst > testnet-state.json - - # Remove zst folder - rm -rf /testnet-state.zst - ``` - -- Generate LPS lockup distribution JSON file - - ```bash - ~/cerc/laconicd-stack/scripts/generate-lps-lock.sh -i "" -d "" - ``` - - - This will generate the `distribution.json` file - -- Set envs: - - ```bash - export EXPORTED_STATE_PATH= - export LPS_DISTRIBUTION_PATH= - export EARLY_SUPPORTS_ACC_ADDR= - - # Parent directory where the deployment directory will live - export DATA_DIRECTORY= - - # Set mainnet deployment directory - # for eg: mainnet-laconicd-deployment - export MAINNET_DEPLOYMENT_DIR= - ``` - -- Copy the example variables file: - - ```bash - cp ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.example.yml ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml - ``` - -- Edit `~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml` with required values: - - ```bash - # Use the public key exported in previous step (make sure to wrap it with single quotes ['']) - validator_pub_key: '' - ``` - -- Run playbook to use exported state for generating mainnet genesis file with gentx: - - ```bash - ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/generate-genesis.yml -e "exported_state_path=$EXPORTED_STATE_PATH" -e "lps_distribution_path=$LPS_DISTRIBUTION_PATH" -e "early_supports_acc_address=$EARLY_SUPPORTS_ACC_ADDR" - ``` - - - Input private key of the existing account that was exported in previous steps when prompted - -- Genesis file will be generated in output directory along with a file specifying the staking amount - - ```bash - # List files in output directory - genesis.json and staking-amount.json - ls -l output - ``` - - Remove the validator key from node deployment as it is no longer required: - - Run the following command in the machine where the validator node is setup - - ```bash - rm $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json - ``` + ```bash + rm $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json + ``` NOTE: Store it safely offline in case of an emergency -## Run node +### Start node - Copy the genesis file to the mainnet deployment tmp directory: diff --git a/docs/run-validator.md b/docs/run-validator.md index 4db662c..30bce96 100644 --- a/docs/run-validator.md +++ b/docs/run-validator.md @@ -55,8 +55,7 @@ export DATA_DIRECTORY= # Set mainnet deployment directory - # for eg: mainnet-laconicd-deployment - export MAINNET_DEPLOYMENT_DIR= + export MAINNET_DEPLOYMENT_DIR=mainnet-validator-deployment ``` - Run ansible playbook to set up your validator node deployment: @@ -195,7 +194,7 @@ ```bash export DATA_DIRECTORY= - export MAINNET_DEPLOYMENT_DIR= + export MAINNET_DEPLOYMENT_DIR=mainnet-validator-deployment ``` - Run ansible playbook to create validator on running chain: diff --git a/scripts/generate-lps-lock.sh b/scripts/generate-lps-lock.sh index b43f123..0765c4d 100755 --- a/scripts/generate-lps-lock.sh +++ b/scripts/generate-lps-lock.sh @@ -4,7 +4,7 @@ set -e # Default values INPUT="" -OUTPUT_DIR="." +OUTPUT_FILE="./distribution.json" # Parse command line arguments while [[ $# -gt 0 ]]; do @@ -13,13 +13,13 @@ while [[ $# -gt 0 ]]; do INPUT="$2" shift 2 ;; - -d|--dir) - OUTPUT_DIR="$2" + -o|--output) + OUTPUT_FILE="$2" shift 2 ;; *) echo "Unknown option: $1" - echo "Usage: $0 -i|--input [-d|--dir ]" + echo "Usage: $0 -i|--input [-o|--output ]" exit 1 ;; esac @@ -28,13 +28,10 @@ done # Check if input is provided if [ -z "$INPUT" ]; then echo "Error: Input URL or path is required" - echo "Usage: $0 -i|--input [-d|--dir ]" - exit 1 + echo "Usage: $0 -i|--input [-o|--output ]" + exit 1 fi -# Create output directory if it doesn't exist -mkdir -p "$OUTPUT_DIR" - venv_dir="$PWD/venv-lps-lock" script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -50,7 +47,7 @@ fi echo "Running LPS lock generation script..." "$venv_dir/bin/python" "$script_dir/generate-lps-distribution-json.py" \ --input "$INPUT" \ - --output "$OUTPUT_DIR/distribution.json" + --output "$OUTPUT_FILE" # Clean up venv echo "Cleaning up..." diff --git a/stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh b/stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh index 6de2ee3..5693d6d 100755 --- a/stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh +++ b/stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh @@ -4,7 +4,6 @@ set -e NODE_HOME=/root/.laconicd genesis_file_path=$NODE_HOME/config/genesis.json -# TODO: Set to OS keyring backend KEYRING="test" if [ -f "$genesis_file_path" ]; then