Remove creating deployment while generating gentx

This commit is contained in:
Shreerang Kale 2025-06-09 18:45:08 +05:30
parent 44ab959af5
commit b3eb260ccd
4 changed files with 53 additions and 38 deletions

View File

@ -53,6 +53,16 @@
NOTE: This public key is required in next step to generate the genesis file
## Build Laconicd to generate genesis file
- Run the following steps in the machine where genesis file is to be generated
- Run playbook to build laconicd container:
```bash
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/build-laconicd.yml
```
## Export testnet state
- Run the following steps in machine where the testnet node is running
@ -110,9 +120,6 @@
# Parent directory where the deployment directory will live
export DATA_DIRECTORY=
# Set mainnet deployment directory
export MAINNET_DEPLOYMENT_DIR=mainnet-laconicd-deployment
```
- Extract the testnet-state JSON file:

View File

@ -0,0 +1,13 @@
---
- name: Generate Mainnet Genesis File
hosts: localhost
connection: local
tasks:
- name: Fetch repositories
ansible.builtin.shell:
cmd: "laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd setup-repositories --git-ssh --pull"
# TODO: Add a flag to control force rebuild
- name: Build containers
ansible.builtin.shell:
cmd: "laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers --force-rebuild"

View File

@ -5,25 +5,16 @@
- first-validator-vars.yml
vars:
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
mainnet_deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}"
gentx_genesis_dir: "{{data_directory}}/generate-gentx-genesis"
spec_file: "{{data_directory}}/laconicd-spec.yml"
connection: local
tasks:
- name: Fail if DATA_DIRECTORY or MAINNET_DEPLOYMENT_DIR env vars are not set
- name: Fail if DATA_DIRECTORY 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: Fetch repositories
ansible.builtin.shell:
cmd: "laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd setup-repositories --git-ssh --pull"
# TODO: Add a flag to control force rebuild
- name: Build containers
ansible.builtin.shell:
cmd: "laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers --force-rebuild"
Please export both DATA_DIRECTORY before running the playbook.
when: lookup('env', 'DATA_DIRECTORY') == ''
- name: Copy exported testnet state file
ansible.builtin.copy:
@ -55,30 +46,34 @@
ansible.builtin.debug:
msg: "Staking amount written to output/staking-amount.json"
- name: Create deployment spec file
shell: |
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd deploy init --output {{ 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: Ensure tmp directory exists inside laconicd-data
- name: Create data directory
file:
path: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp"
path: "{{ gentx_genesis_dir }}"
state: directory
mode: '0755'
- name: Copy staking amount file to laconicd-data tmp directory
- name: Ensure tmp directory exists inside gentx genesis directory
file:
path: "{{gentx_genesis_dir}}/tmp"
state: directory
mode: '0755'
- name: Ensure output directory exists inside gentx genesis directory
file:
path: "{{gentx_genesis_dir}}/output"
state: directory
mode: '0755'
- name: Copy staking amount file to gentx genesis tmp directory
copy:
src: "{{ lookup('env', 'PWD') }}/output/staking-amount.json"
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/staking-amount.json"
dest: "{{gentx_genesis_dir}}/tmp/staking-amount.json"
mode: '0644'
- name: Copy genesis file to laconicd-data tmp directory
- name: Copy genesis file to gentx genesis tmp directory
copy:
src: "{{ lookup('env', 'PWD') }}/output/genesis.json"
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/genesis.json"
dest: "{{gentx_genesis_dir}}/tmp/genesis.json"
mode: '0644'
- name: Prompt for validator private key
@ -97,8 +92,8 @@
- name: Run script to create and collect gentx
shell: |
docker run -i \
-v {{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data:/root/.laconicd \
-v {{data_directory}}/{{ mainnet_deployment_dir }}/config/mainnet-laconicd:/scripts \
-v {{gentx_genesis_dir}}:/root/generate-gentx-genesis \
-v ~/cerc/laconicd-stack/stack-orchestrator/config/mainnet-laconicd:/scripts \
-e "PVT_KEY={{ private_key_input.user_input }}" \
-e "KEY_NAME={{ key_name }}" \
-e "CERC_MONIKER={{ cerc_moniker }}" \
@ -108,11 +103,11 @@
- name: Update genesis file in output
copy:
src: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/config/genesis.json"
src: "{{gentx_genesis_dir}}/output/genesis.json"
dest: "{{ lookup('env', 'PWD') }}/output/genesis.json"
mode: '0644'
- name: Clear tmp directory
file:
path: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp"
path: "{{gentx_genesis_dir}}/tmp"
state: absent

View File

@ -3,6 +3,7 @@
set -e
NODE_HOME=/root/.laconicd
GENTX_DIR=/root/generate-gentx-genesis
genesis_file_path=$NODE_HOME/config/genesis.json
KEYRING="test"
@ -26,13 +27,13 @@ if [ -z "$VALIDATOR_PUB_KEY" ]; then
exit 1
fi
input_genesis_file=$NODE_HOME/tmp/genesis.json
input_genesis_file=$GENTX_DIR/tmp/genesis.json
if [ ! -f ${input_genesis_file} ]; then
echo "Genesis file not provided, exiting..."
exit 1
fi
staking_amount_file="$NODE_HOME/tmp/staking-amount.json"
staking_amount_file="$GENTX_DIR/tmp/staking-amount.json"
if [ ! -f "$staking_amount_file" ]; then
echo "staking-amount.json file not provided, exiting..."
exit 1
@ -79,5 +80,4 @@ laconicd genesis validate
chmod 777 $genesis_file_path
# Clear tmp directory
rm -rf $NODE_HOME/tmp
cp $genesis_file_path $GENTX_DIR/output