Add playbook and steps for sending create-validator tx

This commit is contained in:
Nabarun 2025-05-14 16:26:30 +05:30
parent 1de4a3dc3e
commit 1df3ab2500
7 changed files with 176 additions and 2 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
*-deployment *-deployment
*-spec.yml *-spec.yml
# Validator playbook vars
playbooks/validator/validator-vars.yml

50
playbooks/README.md Normal file
View File

@ -0,0 +1,50 @@
# playbooks
## 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:
```
LANG="en_US.UTF-8"
```
- Reboot your system or log out and log back in to apply the changes
- Reference: <https://udhayakumarc.medium.com/error-ansible-requires-the-locale-encoding-to-be-utf-8-detected-iso8859-1-6da808387f7d>
- Verify ansible installation by running the following command:
```bash
ansible --version
# ansible [core 2.17.2]
```
- Install `sshpass` used for automating SSH password authentication
```bash
sudo apt-get install sshpass
```

View File

@ -0,0 +1,67 @@
# validator
This directory contains playbooks for setting up and managing a validator on the Laconic chain. There are two main playbooks:
* `create-validator.yml` - Creates a validator on an already running node
* (Coming soon) `setup-validator.yml` - Sets up and runs a validator node
## Prerequisites
- [Ansible](../README.md#ansible-installation)
- [Stack orchestrator](https://git.vdb.to/cerc-io/testnet-ops/src/branch/main/stack-orchestrator-setup)
- Private key or mnemonic of validator account from previous testnet
- Use <https://wallet.laconic.com>
## Configuration
* Set the required environment variables:
```bash
export DATA_DIRECTORY=/path/to/deployment/parent/directory
export DEPLOYMENT_DIR=validator-laconicd-deployment
```
* Copy the example variables file and edit it:
```bash
cp validator-vars.example.yml validator-vars.yml
```
* Edit `validator-vars.yml` to set your validator parameters:
```yaml
# Chain configuration
cerc_moniker: "YourValidatorName" # Your validator's name
cerc_chain_id: "laconic-mainnet" # Chain ID
# TODO: Add persistent peer addresses
cerc_peers: "" # Comma-separated list of peers
```
## Creating a Validator
To create a validator:
* Make sure your validator node is running and synced
<!-- TODO: Add playbook and steps for setting up and running validator node -->
* Set key name used for importing validator account
```bash
export KEY_NAME=<key-name>
```
* Run the create-validator playbook:
```bash
ansible-playbook playbooks/validator/create-validator.yml
```
## Verification
After running the playbook, you can verify your validator was created by:
* Check the validator list:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$DEPLOYMENT_DIR exec laconicd 'laconicd query staking validators'
```
* Check your validator's details:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$DEPLOYMENT_DIR exec laconicd 'laconicd query staking validator $(laconicd keys show validator --bech val -a)'
```

View File

@ -0,0 +1,27 @@
---
- name: Create validator on running chain
hosts: localhost
vars_files:
- validator-vars.yml
vars:
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
deployment_dir: "{{ lookup('env', 'DEPLOYMENT_DIR') }}"
key_name: "{{ lookup('env', 'KEY_NAME') }}"
tasks:
- name: Fail if DATA_DIRECTORY or DEPLOYMENT_DIR env vars are not set
fail:
msg: >-
Required environment variables are not set.
Please export both DATA_DIRECTORY and DEPLOYMENT_DIR before running the playbook.
when: lookup('env', 'DATA_DIRECTORY') == '' or lookup('env', 'DEPLOYMENT_DIR') == ''
- name: Fail if neither pvt_key nor mnemonic is set
fail:
msg: >-
Neither private key (pvt_key) nor mnemonic is set in validator-vars.yml.
Please set one of them to create the validator.
when: not pvt_key and not mnemonic
- name: Run create-validator script
shell: |
laconic-so deployment --dir {{data_directory}}/{{deployment_dir}} exec laconicd "export KEY_NAME={{ key_name }} /scripts/create-validator.sh"

View File

@ -0,0 +1,6 @@
# Chain configuration
cerc_moniker:
cerc_chain_id: "laconic-mainnet"
cerc_peers: # Comma-separated list of peers
min_gas_price: 0.001
cerc_loglevel: "info"

View File

@ -4,14 +4,15 @@ services:
image: cerc/laconicd:local image: cerc/laconicd:local
command: ["bash", "-c", "/opt/run-laconicd.sh"] command: ["bash", "-c", "/opt/run-laconicd.sh"]
environment: environment:
CERC_MONIKER: ${CERC_MONIKER:-TestnetNode} CERC_MONIKER: ${CERC_MONIKER}
CERC_CHAIN_ID: ${CERC_CHAIN_ID:-laconic_9000-1} CERC_CHAIN_ID: ${CERC_CHAIN_ID:-laconic-mainnet}
CERC_PEERS: ${CERC_PEERS} CERC_PEERS: ${CERC_PEERS}
MIN_GAS_PRICE: ${MIN_GAS_PRICE:-0.001} MIN_GAS_PRICE: ${MIN_GAS_PRICE:-0.001}
CERC_LOGLEVEL: ${CERC_LOGLEVEL:-info} CERC_LOGLEVEL: ${CERC_LOGLEVEL:-info}
volumes: volumes:
- laconicd-data:/root/.laconicd - laconicd-data:/root/.laconicd
- ../config/mainnet-laconicd/run-laconicd.sh:/opt/run-laconicd.sh - ../config/mainnet-laconicd/run-laconicd.sh:/opt/run-laconicd.sh
- ../config/mainnet-laconicd/create-validator.sh:/scripts/create-validator.sh
ports: ports:
- "6060" - "6060"
- "26657" - "26657"

View File

@ -0,0 +1,20 @@
#!/bin/bash
set -e
DENOM=alnt
# Create validator with fixed parameters
laconicd tx staking create-validator \
--amount 900000000$DENOM \
--pubkey $(laconicd tendermint show-validator) \
--moniker "$CERC_MONIKER" \
--chain-id "$CERC_CHAIN_ID" \
--commission-rate 0.0 \
--commission-max-rate 0.0 \
--commission-max-change-rate 0.0 \
--min-self-delegation 1 \
--gas auto \
--gas-adjustment 1.5 \
--gas-prices $MIN_GAS_PRICE$DENOM \
--from $KEY_NAME \
--yes