Add playbook to run subsequent validator nodes

This commit is contained in:
Shreerang Kale 2025-05-15 10:15:39 +05:30
parent 1154cfd0bc
commit 2fe2623c62
5 changed files with 95 additions and 6 deletions

View File

@ -54,7 +54,6 @@
CERC_CHAIN_ID: "{{ cerc_chain_id }}"
MIN_GAS_PRICE: "{{ min_gas_price }}"
CERC_LOGLEVEL: "{{ cerc_loglevel }}"
KEY_NAME: "{{ key_name }}"
mode: '0777'
- name: Ensure tmp directory exists inside laconicd-data

View File

@ -0,0 +1,74 @@
---
- name: Run mainnet validator node
hosts: localhost
vars_files:
- validator-vars.yml
vars:
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
mainnet_deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}"
spec_file: "{{data_directory}}/laconicd-spec.yml"
spec_template: "./templates/specs/spec-template.yml.j2"
tasks:
- name: Fail if DATA_DIRECTORY or MAINNET_DEPLOYMENT_DIR env vars are not set
fail:
msg: >-
Required environment variables are not set.
Please export both DATA_DIRECTORY and MAINNET_DEPLOYMENT_DIR before running the playbook.
when: lookup('env', 'DATA_DIRECTORY') == '' or lookup('env', 'MAINNET_DEPLOYMENT_DIR') == ''
- name: Fail if required key files are not defined
fail:
msg: >-
Required key files are not defined.
Please set genesis_file in validator-vars.yml.
when: not genesis_file
- name: Fetch laconicd stack
shell: laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
- name: Setup required repositories
shell: >
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd
setup-repositories --git-ssh --pull
- name: Build container images
shell: |
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers
- name: Create deployment spec file
shell: |
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd deploy init --output {{ spec_file }}
- name: Replace network section in spec_file
shell: >
yq eval '(.network) = load("{{ spec_template }}").network' -i {{ spec_file }}
- name: Create deployment from spec file
shell: |
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd deploy create --spec-file {{ spec_file }} --deployment-dir {{data_directory}}/{{ mainnet_deployment_dir }}
- name: Create config.env
copy:
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/config.env"
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 }}"
mode: '0777'
- name: Ensure tmp directory exists inside laconicd-data
file:
path: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp"
state: directory
mode: '0755'
- name: Copy genesis file to laconicd-data tmp directory
copy:
src: "{{ genesis_file }}"
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/genesis.json"
mode: '0644'
- name: Run validator node
shell: |
laconic-so deployment --dir {{data_directory}}/{{ mainnet_deployment_dir }} start

View File

@ -0,0 +1,9 @@
network:
ports:
laconicd:
- '6060:6060'
- '26657:26657'
- '26656:26656'
- '9473:9473'
- '9090:9090'
- '1317:1317'

View File

@ -0,0 +1,6 @@
cerc_moniker: "MainnetNode"
cerc_chain_id: "laconic-mainnet"
min_gas_price: 0.001
cerc_loglevel: "info"
genesis_file: ""
cerc_peers: ""

View File

@ -7,13 +7,13 @@
## Generate mainnet genesis file
- Fetch the stack in machine where the testnet chain node is running
- Fetch the stack in machine where the testnet chain node is running:
```bash
laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
```
- Run script to export state from testnet chain
- Run script to export state from testnet chain:
```bash
~/cerc/laconicd-stack/scripts/export-testnet-state.sh <path-to-testnet-deployment>
@ -21,7 +21,7 @@
- The file will be generated in `<path-to-testnet-deployment>/export/testnet-state.json`
- If mainnet node will be setup in new machine, fetch the stack again
- If mainnet node will be setup in new machine, fetch the stack again:
```bash
laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
@ -29,14 +29,14 @@
- Copy over the exported `testnet-state.json` file to target machine
- Set envs
- Set envs:
```bash
export EXPORTED_STATE_PATH=<absolute-path-to-exported-testnet-state-json>
export EARLY_SUPPORTS_ACC_ADDR=<account-address-controlled-by-laconic-foundation>
```
- Run playbook to use exported state for generating mainnet genesis
- Run playbook to use exported state for generating mainnet genesis:
```bash
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/generate-genesis.yml -e "exported_state_path=$EXPORTED_STATE_PATH" -e "early_supports_acc_address=$EARLY_SUPPORTS_ACC_ADDR"
@ -54,6 +54,7 @@
<!-- TODO: Add steps to get private key of validator account from laconic testnet -->
- Copy the example variables file:
```bash
cp ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.example.yml ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml
```