From 71d58c7c2c6e059b786db4750d38d0261e81e169 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Wed, 14 May 2025 16:21:46 +0530 Subject: [PATCH] Add README instructions to run first validator node --- README.md | 2 + genesis/.gitkeep | 0 node-addresses.yml | 4 ++ playbooks/README.md | 42 +++++++++++ .../run-first-validator-vars.yml | 10 +-- .../first-validator/run-first-validator.yml | 3 - run-first-validator.md | 72 +++++++++++++++++++ .../docker-compose-mainnet-laconicd.yml | 4 +- .../create-and-collect-gentx.sh | 12 ++-- 9 files changed, 129 insertions(+), 20 deletions(-) create mode 100644 genesis/.gitkeep create mode 100644 node-addresses.yml create mode 100644 playbooks/README.md create mode 100644 run-first-validator.md diff --git a/README.md b/README.md index 2d49303..c870d42 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ # laconicd-stack + +- Follow [run-first-validator.md](run-first-validator.md) to run the first validator node diff --git a/genesis/.gitkeep b/genesis/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/node-addresses.yml b/node-addresses.yml new file mode 100644 index 0000000..5ff7b09 --- /dev/null +++ b/node-addresses.yml @@ -0,0 +1,4 @@ +# Add your node addresses here +# Example: +# - node-1-id@node-1-host:26656 +# - node-2-id@node-2-host:26656 diff --git a/playbooks/README.md b/playbooks/README.md new file mode 100644 index 0000000..679dd14 --- /dev/null +++ b/playbooks/README.md @@ -0,0 +1,42 @@ +# Ansible Installation + +- Install [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-and-upgrading-ansible-with-pip) + +- Add location of the directory containing the ansible binary to your `PATH` + +- Set Locale Encoding to `UTF-8` + + Ansible requires the locale encoding to be `UTF-8`. You can either use the `LANG` prefix when running Ansible commands or set the system-wide locale + + - Option 1: Use `LANG` Prefix in Commands + + If you prefer not to change the system-wide locale, you can use the `LANG` prefix when running Ansible commands: + + ```bash + LANG=en_US.UTF-8 ansible-playbook your_playbook.yml + ``` + + - Option 2: Set System-Wide Locale + + - Edit the `/etc/default/locale` file: + + ```bash + sudo nano /etc/default/locale + ``` + + - Set the `LANG` variable to en_US.UTF-8: + + ```bash + LANG="en_US.UTF-8" + ``` + + - Reboot your system or log out and log back in to apply the changes + + - Reference: + +- Verify ansible installation by running the following command: + + ```bash + ansible --version + # ansible [core 2.17.2] + ``` diff --git a/playbooks/first-validator/run-first-validator-vars.yml b/playbooks/first-validator/run-first-validator-vars.yml index c0b1697..78d11ec 100644 --- a/playbooks/first-validator/run-first-validator-vars.yml +++ b/playbooks/first-validator/run-first-validator-vars.yml @@ -1,13 +1,7 @@ -cerc_moniker: "TestnetNode" -cerc_chain_id: "laconic_9000-1" -cerc_peers: +cerc_moniker: "MainnetNode" +cerc_chain_id: "laconic-mainnet" min_gas_price: 0.001 cerc_loglevel: "info" -# Token denomination (alnt or alps) -denom: "alnt" -# Validator key name key_name: "validator" -# Private key in hex format (required for gentx) pvt_key: "" -# Required files genesis_file: diff --git a/playbooks/first-validator/run-first-validator.yml b/playbooks/first-validator/run-first-validator.yml index a81b998..8b90468 100644 --- a/playbooks/first-validator/run-first-validator.yml +++ b/playbooks/first-validator/run-first-validator.yml @@ -52,10 +52,8 @@ content: | CERC_MONIKER: "{{ cerc_moniker }}" CERC_CHAIN_ID: "{{ cerc_chain_id }}" - CERC_PEERS: "{{ cerc_peers}}" MIN_GAS_PRICE: "{{ min_gas_price }}" CERC_LOGLEVEL: "{{ cerc_loglevel }}" - DENOM: "{{ denom }}" KEY_NAME: "{{ key_name }}" mode: '0777' @@ -85,7 +83,6 @@ -v {{data_directory}}/{{ mainnet_deployment_dir }}/config/mainnet-laconicd:/scripts \ -e "PVT_KEY={{ pvt_key }}" \ -e "KEY_NAME={{ key_name }}" \ - -e "DENOM={{ denom }}" \ -e "CERC_MONIKER={{ cerc_moniker }}" \ -e "CERC_CHAIN_ID={{ cerc_chain_id }}" \ cerc/laconicd:local bash -c "/scripts/create-and-collect-gentx.sh" diff --git a/run-first-validator.md b/run-first-validator.md new file mode 100644 index 0000000..9c8d543 --- /dev/null +++ b/run-first-validator.md @@ -0,0 +1,72 @@ +# Run First Validator Node + +## Prerequisites + +- [ansible](playbooks/README.md#ansible-installation) +- [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install) + +## Generate mainnet genesis file + + + +## Run node + +- Update [run-first-validator-vars.yml](playbooks/first-validator/run-first-validator-vars.yml) with required values: + + - Use the mainnet genesis file generated in the previous step + + ```bash + # Private key of the existing account in hex format (required for gentx) + pvt_key: "" + + # Path to the generated mainnet genesis file + genesis_file: "" + + # Optional + cerc_chain_id: "laconic-mainnet" + cerc_moniker: "MainnetNode" + min_gas_price: 0.001 + cerc_loglevel: "info" + key_name: "validator" + ``` + +- Export the data directory and mainnet deployment directory as environment variables: + + ```bash + # Parent directory where the deployment directory will live + export DATA_DIRECTORY= + + # Set mainnet deployment directory + # for eg: mainnet-laconicd-deployment + export MAINNET_DEPLOYMENT_DIR= + ``` + +- Run ansible playbook to submit the gentx and run the node: + + ```bash + ansible-playbook -i localhost, -c local playbooks/first-validator/run-first-validator.yml + ``` + +- Check logs to ensure that node is running: + + ```bash + laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR logs laconicd -f + ``` + +## Publish Genesis File and Node Address + +- Copy the genesis file to [genesis](./genesis) folder: + + ```bash + sudo cp $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/genesis.json ./genesis/mainnet-genesis.json + ``` + +- Get your node's address: + + ```bash + laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'echo $(laconicd cometbft show-node-id)@YOUR_PUBLIC_IP_ADDRESS:26656' + ``` + +- Add your node's address to [node-addresses.yml](./node-addresses.yml) + +- Submit a PR with this genesis file and node address so that it is available to other validators diff --git a/stack-orchestrator/compose/docker-compose-mainnet-laconicd.yml b/stack-orchestrator/compose/docker-compose-mainnet-laconicd.yml index 33d3b26..e649dea 100644 --- a/stack-orchestrator/compose/docker-compose-mainnet-laconicd.yml +++ b/stack-orchestrator/compose/docker-compose-mainnet-laconicd.yml @@ -4,8 +4,8 @@ services: image: cerc/laconicd:local command: ["bash", "-c", "/opt/run-laconicd.sh"] environment: - CERC_MONIKER: ${CERC_MONIKER:-TestnetNode} - CERC_CHAIN_ID: ${CERC_CHAIN_ID:-laconic_9000-1} + CERC_MONIKER: ${CERC_MONIKER:-MainnetNode} + CERC_CHAIN_ID: ${CERC_CHAIN_ID:-laconic-mainnet} CERC_PEERS: ${CERC_PEERS} MIN_GAS_PRICE: ${MIN_GAS_PRICE:-0.001} CERC_LOGLEVEL: ${CERC_LOGLEVEL:-info} 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 9f8902f..b6a446d 100755 --- a/stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh +++ b/stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh @@ -21,21 +21,17 @@ if [ -z "$KEY_NAME" ]; then exit 1 fi -if [ -z "$DENOM" ]; then - echo "DENOM environment variable not set, exiting..." - exit 1 -fi - input_genesis_file=$NODE_HOME/tmp/genesis.json if [ ! -f ${input_genesis_file} ]; then echo "Genesis file not provided, exiting..." exit 1 fi +DENOM=alnt + # Strip leading and trailing quotes ("") if they exist export MONIKER=$(echo "$CERC_MONIKER" | sed -e 's/^["'\'']//g' -e 's/["'\'']$//g') export CHAIN_ID=$(echo "$CERC_CHAIN_ID" | sed -e 's/^["'\'']//g' -e 's/["'\'']$//g') -export DENOM=$(echo "$DENOM" | sed -e 's/^["'\'']//g' -e 's/["'\'']$//g') # Init laconicd config set client chain-id $CHAIN_ID --home $NODE_HOME @@ -45,9 +41,10 @@ laconicd init $MONIKER --chain-id=$CHAIN_ID --home $NODE_HOME # Copy over provided genesis config cp $input_genesis_file $genesis_file_path -# Import private key passed via PVT_KEY +# Import private key laconicd keys import-hex "$KEY_NAME" "$PVT_KEY" --keyring-backend $KEYRING +# Get account address corresponding to the imported key account_address=$(laconicd keys show "$KEY_NAME" --keyring-backend "$KEYRING" | grep 'address:' | awk -F': ' '{print $2}' | xargs) if [ -z "$account_address" ]; then @@ -56,6 +53,7 @@ if [ -z "$account_address" ]; then exit 1 fi +# 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) # Create gentx with staked amount equal to allocated balance