Compare commits

...

1 Commits

Author SHA1 Message Date
fa861bcf34 Use calculated staking amount for running first val node 2025-05-15 15:59:17 +05:30
5 changed files with 27 additions and 9 deletions

View File

@ -1,3 +1,3 @@
# laconicd-stack # 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

View File

@ -64,14 +64,18 @@
# Private key of the existing account in hex format (required for gentx) # Private key of the existing account in hex format (required for gentx)
pvt_key: "" pvt_key: ""
# Path to the generated mainnet genesis file generated in the previous step # Path to the generated mainnet genesis file
genesis_file: "<path-to-generated-genesis-file>" # Use the absolute path of generated output directory in the previous steps
genesis_file: "<absolute-path-to-generated-output-dir>/genesis.json"
# Path to staking-amount.json generated in previous steps
staking_amount_file: "<absolute-path-to-generated-output-dir>/staking-amount.json"
# Set custom moniker for the node # Set custom moniker for the node
cerc_moniker: "LaconicMainnetNode" cerc_moniker: "LaconicMainnetNode"
# Set desired key name # Set desired key name
key_name: "validator" key_name: "laconic-validator"
``` ```
- Export the data directory and mainnet deployment directory as environment variables: - Export the data directory and mainnet deployment directory as environment variables:

View File

@ -5,3 +5,4 @@ cerc_loglevel: "info"
key_name: "validator" key_name: "validator"
pvt_key: "" pvt_key: ""
genesis_file: genesis_file:
staking_amount_file:

View File

@ -20,8 +20,9 @@
fail: fail:
msg: >- msg: >-
Required key files are not defined. Required key files are not defined.
Please set genesis_file in first-validator-vars.yml. Please set genesis_file and staking_amount_file in first-validator-vars.yml.
when: not genesis_file when: not genesis_file or not staking_amount_file
- name: Fetch laconicd stack - name: Fetch laconicd stack
shell: laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull shell: laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
@ -63,6 +64,12 @@
state: directory state: directory
mode: '0755' 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 - name: Copy genesis file to laconicd-data tmp directory
copy: copy:
src: "{{ genesis_file }}" src: "{{ genesis_file }}"

View File

@ -4,6 +4,7 @@ set -e
NODE_HOME=/root/.laconicd NODE_HOME=/root/.laconicd
genesis_file_path=$NODE_HOME/config/genesis.json genesis_file_path=$NODE_HOME/config/genesis.json
# TODO: Set to OS keyring backend
KEYRING="test" KEYRING="test"
if [ -f "$genesis_file_path" ]; then if [ -f "$genesis_file_path" ]; then
@ -27,6 +28,12 @@ if [ ! -f ${input_genesis_file} ]; then
exit 1 exit 1
fi 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 DENOM=alnt
# Strip leading and trailing quotes ("") if they exist # Strip leading and trailing quotes ("") if they exist
@ -53,9 +60,8 @@ if [ -z "$account_address" ]; then
exit 1 exit 1
fi fi
# TODO: Use staking amount from output/staking-amount.json # Set staking amount
# Get balance of account stake_amount=$(jq -r '.amount' "$staking_amount_file")
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)
# Create gentx with staked amount equal to allocated balance # Create gentx with staked amount equal to allocated balance
laconicd genesis gentx $KEY_NAME $stake_amount$DENOM --chain-id $CHAIN_ID --keyring-backend $KEYRING laconicd genesis gentx $KEY_NAME $stake_amount$DENOM --chain-id $CHAIN_ID --keyring-backend $KEYRING