From 619cd4bb74f5399db546a9bed34b9c0c44406c72 Mon Sep 17 00:00:00 2001 From: Nabarun Date: Thu, 15 May 2025 15:59:17 +0530 Subject: [PATCH] Use calculated staking amount for running first val node --- demo.md | 33 +++++++++++++++---- .../run-first-validator.md | 10 ++++-- .../first-validator-vars.example.yml | 1 + .../first-validator/run-first-validator.yml | 11 +++++-- .../create-and-collect-gentx.sh | 11 +++++-- 5 files changed, 53 insertions(+), 13 deletions(-) rename run-first-validator.md => docs/run-first-validator.md (91%) diff --git a/demo.md b/demo.md index b17db00..ef69f6d 100644 --- a/demo.md +++ b/demo.md @@ -64,12 +64,6 @@ - '3317:1317' ``` -- Update permission for `genesis/mainnet-genesis.json`: - - ```bash - sudo chmod 777 ~/cerc/laconicd-stack/genesis/mainnet-genesis.json - ``` - - Run ansible playbook to set up and start your validator node: ```bash @@ -81,3 +75,30 @@ ```bash laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR logs laconicd -f ``` + +## Create Validator + +- Export required env vars: + + ```bash + # private key of the existing account + export PVT_KEY= + + # desired key name + export KEY_NAME= + + export DATA_DIRECTORY= + export MAINNET_DEPLOYMENT_DIR= + ``` + +- Run ansible playbook to create validator on running chain: + + ```bash + ansible-playbook -i localhost, -c local playbooks/validator/create-validator.yml + ``` + +- Check the validator list: + + ```bash + laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query staking validators' + ``` diff --git a/run-first-validator.md b/docs/run-first-validator.md similarity index 91% rename from run-first-validator.md rename to docs/run-first-validator.md index a8507c8..8b17b12 100644 --- a/run-first-validator.md +++ b/docs/run-first-validator.md @@ -79,14 +79,18 @@ # Private key of the existing account in hex format (required for gentx) pvt_key: "" - # Path to the generated mainnet genesis file generated in the previous step - genesis_file: "" + # Path to the generated mainnet genesis file + # Use the absolute path of generated output directory in the previous steps + genesis_file: "/genesis.json" + + # Path to staking-amount.json generated in previous steps + staking_amount_file: "/staking-amount.json" # Set custom moniker for the node cerc_moniker: "LaconicMainnetNode" # Set desired key name - key_name: "validator" + key_name: "laconic-validator" ``` - Export the data directory and mainnet deployment directory as environment variables: diff --git a/playbooks/first-validator/first-validator-vars.example.yml b/playbooks/first-validator/first-validator-vars.example.yml index 6d8b34f..719ff11 100644 --- a/playbooks/first-validator/first-validator-vars.example.yml +++ b/playbooks/first-validator/first-validator-vars.example.yml @@ -5,3 +5,4 @@ cerc_loglevel: "info" key_name: "validator" pvt_key: "" genesis_file: +staking_amount_file: diff --git a/playbooks/first-validator/run-first-validator.yml b/playbooks/first-validator/run-first-validator.yml index 732a7c9..5ca8530 100644 --- a/playbooks/first-validator/run-first-validator.yml +++ b/playbooks/first-validator/run-first-validator.yml @@ -20,8 +20,9 @@ fail: msg: >- Required key files are not defined. - Please set genesis_file in first-validator-vars.yml. - when: not genesis_file + Please set genesis_file and staking_amount_file in first-validator-vars.yml. + when: not genesis_file or not staking_amount_file + - name: Fetch laconicd stack shell: laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull @@ -62,6 +63,12 @@ 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/stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh b/stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh index 1e1e111..12e00f1 100755 --- a/stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh +++ b/stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh @@ -4,6 +4,7 @@ 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 @@ -27,6 +28,12 @@ if [ ! -f ${input_genesis_file} ]; then exit 1 fi +staking_amount_file="$NODE_HOME/tmp/staking-amount.json" +if [ ! -f "$staking_amount_file" ]; then + echo "staking-amount.json file not provided, exiting..." + exit 1 +fi + DENOM=alnt # Strip leading and trailing quotes ("") if they exist @@ -53,8 +60,8 @@ if [ -z "$account_address" ]; then exit 1 fi -# TODO: Use staking amount from output/staking-amount.json -stake_amount=900000000 +# Set staking amount +stake_amount=$(jq -r '.amount' "$staking_amount_file") # Create gentx with staked amount equal to allocated balance laconicd genesis gentx $KEY_NAME $stake_amount$DENOM --chain-id $CHAIN_ID --keyring-backend $KEYRING