From 8166dee68c55ec766eacdc04afa86bb1cd93ab89 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Mon, 19 May 2025 15:27:24 +0530 Subject: [PATCH] Update readme for running validators on separate machine --- docs/run-first-validator.md | 49 ++++++++++++------- docs/run-validator.md | 10 ++++ .../generate-genesis-vars.example.yml} | 0 .../generate-genesis.yml | 11 ++++- .../templates/specs/spec-template.yml.j2 | 0 playbooks/validator/run-validator.yml | 10 +--- .../validator/validator-vars.example.yml | 4 +- .../create-and-collect-gentx.sh | 4 +- 8 files changed, 56 insertions(+), 32 deletions(-) rename playbooks/{first-validator/first-validator-vars.example.yml => generate-genesis/generate-genesis-vars.example.yml} (100%) rename playbooks/{first-validator => generate-genesis}/generate-genesis.yml (92%) rename playbooks/{first-validator => generate-genesis}/templates/specs/spec-template.yml.j2 (100%) diff --git a/docs/run-first-validator.md b/docs/run-first-validator.md index 686638f..bf68a95 100644 --- a/docs/run-first-validator.md +++ b/docs/run-first-validator.md @@ -21,7 +21,7 @@ laconic-so deployment --dir stop ``` -- Fetch the stack in machine where the testnet chain node is running: +- Fetch the stack in machine where the testnet chain node was running: ```bash laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull @@ -56,15 +56,17 @@ - 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 + cp ~/cerc/laconicd-stack/playbooks/generate-genesis/generate-genesis-vars.example.yml ~/cerc/laconicd-stack/playbooks/generate-genesis/generate-genesis-vars.yml ``` - Run playbook to use exported state for generating mainnet genesis: ```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" + ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/generate-genesis/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 @@ -72,31 +74,42 @@ ls -l output ``` +- Copy over the generated genesis file and staking amount file to the machine where the node is to be run + + - The genesis file will be used to start the node + + - Once the node is running we will publish the genesis file, staking amount file and node address so that it is available to other validators + ## Run node -- Copy the example variables file if not already done: +- Run these steps in a separate machine where the mainnet node is to be run + +- Fetch the stack: ```bash - cp ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.example.yml ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml + laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull ``` -- Update `~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml` with required values: + This command clones the entire repository into the `~/cerc` folder + +- Copy the example variables file: ```bash - # Path to the generated mainnet genesis file - # Use the absolute path of generated output directory in the previous steps - genesis_file: "/genesis.json" + cp ~/cerc/laconicd-stack/playbooks/validator/validator-vars.example.yml ~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml + ``` - # Path to staking-amount.json generated in previous steps - staking_amount_file: "/staking-amount.json" +- Update `~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml` with required values: + ```bash # Set custom moniker for the node - cerc_moniker: "LaconicMainnetNode" + cerc_moniker: "" - # Set desired key name - key_name: "laconic-validator" + # Set path to genesis file + genesis_file: "" ``` + - Keep rest of the values empty + - Export the data directory and mainnet deployment directory as environment variables: ```bash @@ -108,14 +121,12 @@ export MAINNET_DEPLOYMENT_DIR= ``` -- Run ansible playbook to submit the gentx and run the node: +- Run ansible playbook to set up and start your validator node: ```bash - ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/run-first-validator.yml + ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/run-validator.yml ``` - - Input private key of the existing account that was exported in previous steps when prompted - - Check logs to ensure that node is running: ```bash @@ -154,7 +165,7 @@ - Copy the genesis file to [config](./config) folder: ```bash - cp $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/genesis.json ~/cerc/laconicd-stack/config/mainnet-genesis.json + cp /genesis.json ~/cerc/laconicd-stack/config/mainnet-genesis.json ``` - Copy the staking amount file to [config](./config) folder: diff --git a/docs/run-validator.md b/docs/run-validator.md index 8a47aca..ead81b5 100644 --- a/docs/run-validator.md +++ b/docs/run-validator.md @@ -41,6 +41,9 @@ # Set custom moniker for the node cerc_moniker: "" + genesis_file: "~/cerc/laconicd-stack/config/mainnet-genesis.json" + staking_amount_file: "~/cerc/laconicd-stack/config/staking-amount.json" + # Set persistent peers (comma-separated list of node IDs and addresses) # You can find the list of available peers in https://git.vdb.to/cerc-io/laconicd-stack/src/branch/main/node-addresses.yml cerc_peers: "@:26656,@:26656" @@ -71,6 +74,8 @@ ## Create Validator +- Run these steps in a machine different from the one where the node is running + - Export required env vars: ```bash @@ -79,6 +84,9 @@ export DATA_DIRECTORY= export MAINNET_DEPLOYMENT_DIR= + + # Set the public IP address of the machine where your node is running + export NODE_URL="tcp://PUBLIC_IP_ADDRESS:26657" ``` - Run ansible playbook to create validator on running chain: @@ -98,6 +106,8 @@ ## Register Your Node +- Run these steps in a machine where the node is running + - Get your node's address: ```bash diff --git a/playbooks/first-validator/first-validator-vars.example.yml b/playbooks/generate-genesis/generate-genesis-vars.example.yml similarity index 100% rename from playbooks/first-validator/first-validator-vars.example.yml rename to playbooks/generate-genesis/generate-genesis-vars.example.yml diff --git a/playbooks/first-validator/generate-genesis.yml b/playbooks/generate-genesis/generate-genesis.yml similarity index 92% rename from playbooks/first-validator/generate-genesis.yml rename to playbooks/generate-genesis/generate-genesis.yml index ce96107..ea09faf 100644 --- a/playbooks/first-validator/generate-genesis.yml +++ b/playbooks/generate-genesis/generate-genesis.yml @@ -2,7 +2,7 @@ - name: Generate Mainnet Genesis File hosts: localhost vars_files: - - first-validator-vars.yml + - generate-genesis-vars.yml vars: data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}" mainnet_deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}" @@ -104,3 +104,12 @@ -e "CERC_MONIKER={{ cerc_moniker }}" \ -e "CERC_CHAIN_ID={{ cerc_chain_id }}" \ cerc/laconicd:local bash -c "/scripts/create-and-collect-gentx.sh" + + - name: Update genesis file in output + shell: | + cp {{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/config/genesis.json output/genesis.json + + - name: Clear tmp directory + file: + path: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp" + state: absent diff --git a/playbooks/first-validator/templates/specs/spec-template.yml.j2 b/playbooks/generate-genesis/templates/specs/spec-template.yml.j2 similarity index 100% rename from playbooks/first-validator/templates/specs/spec-template.yml.j2 rename to playbooks/generate-genesis/templates/specs/spec-template.yml.j2 diff --git a/playbooks/validator/run-validator.yml b/playbooks/validator/run-validator.yml index 8fcc0a9..eb404a4 100644 --- a/playbooks/validator/run-validator.yml +++ b/playbooks/validator/run-validator.yml @@ -20,8 +20,8 @@ fail: msg: >- Required key files are not defined. - Please set genesis_file and staking_amount_file in validator-vars.yml. - when: not genesis_file or not staking_amount_file + Please set genesis_file in validator-vars.yml. + when: not genesis_file - name: Fetch laconicd stack shell: laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull @@ -64,12 +64,6 @@ state: directory mode: '0755' - - name: Copy staking amount file to laconicd-data tmp directory - copy: - src: "{{ staking_amount_file }}" - dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/staking-amount.json" - mode: '0644' - - name: Copy genesis file to laconicd-data tmp directory copy: src: "{{ genesis_file }}" diff --git a/playbooks/validator/validator-vars.example.yml b/playbooks/validator/validator-vars.example.yml index df003fe..d75731b 100644 --- a/playbooks/validator/validator-vars.example.yml +++ b/playbooks/validator/validator-vars.example.yml @@ -1,7 +1,7 @@ cerc_chain_id: "laconic-mainnet" min_gas_price: 0.001 cerc_loglevel: "info" -genesis_file: "~/cerc/laconicd-stack/config/mainnet-genesis.json" -staking_amount_file: "~/cerc/laconicd-stack/config/staking-amount.json" cerc_moniker: "" +genesis_file: "" +staking_amount_file: "" cerc_peers: "" 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 d845554..b41f37c 100755 --- a/stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh +++ b/stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh @@ -72,5 +72,5 @@ laconicd genesis validate chmod 777 $genesis_file_path -# Update the input genesis file -cp $genesis_file_path $input_genesis_file +# Clear tmp directory +rm -rf $NODE_HOME/tmp