From fa861bcf34d14119d4ec1f53184c56656fe1b4b2 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 --- README.md | 2 +- .../run-first-validator.md | 10 +++++++--- .../first-validator/first-validator-vars.example.yml | 1 + playbooks/first-validator/run-first-validator.yml | 11 +++++++++-- .../mainnet-laconicd/create-and-collect-gentx.sh | 12 +++++++++--- 5 files changed, 27 insertions(+), 9 deletions(-) rename run-first-validator.md => docs/run-first-validator.md (90%) diff --git a/README.md b/README.md index c870d42..8f25c8b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # laconicd-stack -- Follow [run-first-validator.md](run-first-validator.md) to run the first validator node +- Follow [run-first-validator.md](./docs/run-first-validator.md) to run the first validator node diff --git a/run-first-validator.md b/docs/run-first-validator.md similarity index 90% rename from run-first-validator.md rename to docs/run-first-validator.md index ffb5d0a..3988d94 100644 --- a/run-first-validator.md +++ b/docs/run-first-validator.md @@ -64,14 +64,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 8022454..f2631e9 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 @@ -63,6 +64,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 f213846..72529ee 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,9 +60,8 @@ if [ -z "$account_address" ]; then exit 1 fi -# TODO: Use staking amount from output/staking-amount.json -# Get balance of account -stake_amount=$(jq -r --arg address "$account_address" --arg denom "$DENOM" '.app_state.bank.balances[] | select(.address == $address) | .coins[] | select(.denom == $denom) | .amount' $genesis_file_path) +# 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