From b3eb260ccd8258a9a37f47904c37f8fdf01b04ab Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Mon, 9 Jun 2025 18:45:08 +0530 Subject: [PATCH 1/6] Remove creating deployment while generating gentx --- docs/run-first-validator.md | 13 ++++- playbooks/first-validator/build-laconicd.yml | 13 +++++ .../first-validator/generate-genesis.yml | 57 +++++++++---------- .../create-and-collect-gentx.sh | 8 +-- 4 files changed, 53 insertions(+), 38 deletions(-) create mode 100644 playbooks/first-validator/build-laconicd.yml diff --git a/docs/run-first-validator.md b/docs/run-first-validator.md index df223c9..99fc5e1 100644 --- a/docs/run-first-validator.md +++ b/docs/run-first-validator.md @@ -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: diff --git a/playbooks/first-validator/build-laconicd.yml b/playbooks/first-validator/build-laconicd.yml new file mode 100644 index 0000000..1b8d146 --- /dev/null +++ b/playbooks/first-validator/build-laconicd.yml @@ -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" diff --git a/playbooks/first-validator/generate-genesis.yml b/playbooks/first-validator/generate-genesis.yml index c464615..6245ca0 100644 --- a/playbooks/first-validator/generate-genesis.yml +++ b/playbooks/first-validator/generate-genesis.yml @@ -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 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 5693d6d..b6e8a51 100755 --- a/stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh +++ b/stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh @@ -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 -- 2.54.0 From 0e68b002bdc854eac2b3c4fc63cbfdb6a766504a Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Mon, 9 Jun 2025 19:14:44 +0530 Subject: [PATCH 2/6] Remove creating deployment while sending create-validator tx --- docs/run-first-validator.md | 8 ++- docs/run-validator.md | 16 ++++++ .../build-laconicd.yml | 2 +- playbooks/validator/create-validator.yml | 57 ++----------------- .../mainnet-laconicd/create-validator.sh | 13 ++++- 5 files changed, 39 insertions(+), 57 deletions(-) rename playbooks/{first-validator => validator}/build-laconicd.yml (92%) diff --git a/docs/run-first-validator.md b/docs/run-first-validator.md index 99fc5e1..4b64e67 100644 --- a/docs/run-first-validator.md +++ b/docs/run-first-validator.md @@ -57,10 +57,16 @@ - Run the following steps in the machine where genesis file is to be generated +- Fetch Stack: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull + ``` + - Run playbook to build laconicd container: ```bash - ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/build-laconicd.yml + ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/build-laconicd.yml ``` ## Export testnet state diff --git a/docs/run-validator.md b/docs/run-validator.md index 30bce96..b3a3b9c 100644 --- a/docs/run-validator.md +++ b/docs/run-validator.md @@ -137,6 +137,22 @@ echo "TMKMS_ENABLED=true" >> $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/config.env ``` +## Build Laconicd to create validator + +- Run the following steps in the machine from where the create-validator transaction is to be signed + +- Fetch Stack: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull + ``` + +- Run playbook to build laconicd container: + + ```bash + ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/build-laconicd.yml + ``` + ## Start Node - Start the laconicd node: diff --git a/playbooks/first-validator/build-laconicd.yml b/playbooks/validator/build-laconicd.yml similarity index 92% rename from playbooks/first-validator/build-laconicd.yml rename to playbooks/validator/build-laconicd.yml index 1b8d146..de87497 100644 --- a/playbooks/first-validator/build-laconicd.yml +++ b/playbooks/validator/build-laconicd.yml @@ -1,5 +1,5 @@ --- -- name: Generate Mainnet Genesis File +- name: Build Laconicd hosts: localhost connection: local tasks: diff --git a/playbooks/validator/create-validator.yml b/playbooks/validator/create-validator.yml index 734f3d4..e38d4e9 100644 --- a/playbooks/validator/create-validator.yml +++ b/playbooks/validator/create-validator.yml @@ -5,7 +5,7 @@ - validator-vars.yml vars: data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}" - mainnet_deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}" + create_validator_dir: "{{data_directory}}/create-validator" spec_file: "{{data_directory}}/laconicd-validator-spec.yml" tasks: - name: Fail if DATA_DIRECTORY or MAINNET_DEPLOYMENT_DIR env vars are not set @@ -22,46 +22,16 @@ Please set staking_amount_file in validator-vars.yml. when: not staking_amount_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: 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 }}" - 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" + path: "{{create_validator_dir}}/tmp" state: directory 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" + dest: "{{create_validator_dir}}/tmp/staking-amount.json" mode: '0644' - name: Prompt for validator private key @@ -77,28 +47,10 @@ msg: "Private key is required for creating the gentx." when: private_key_input.user_input | default('') | trim == '' - - name: Import private key in laconicd - shell: | - docker run -i \ - -v {{ data_directory }}/{{ mainnet_deployment_dir }}/data/laconicd-data:/root/.laconicd \ - --network=host \ - cerc/laconicd:local \ - laconicd keys import-hex {{ key_name }} {{ private_key_input.user_input }} --keyring-backend test \ - - - name: Get the key information - shell: | - docker run -i \ - -v {{ data_directory }}/{{ mainnet_deployment_dir }}/data/laconicd-data:/root/.laconicd \ - --network=host \ - cerc/laconicd:local \ - laconicd keys show {{ key_name }} --keyring-backend test - register: key_info - - name: Run create-validator script shell: | docker run -i \ - -v {{ data_directory }}/{{ mainnet_deployment_dir }}/data/laconicd-data:/root/.laconicd \ - -v {{ data_directory }}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/staking-amount.json:/scripts/staking-amount.json \ + -v {{create_validator_dir}}:/root/create-validator \ -v ~/cerc/laconicd-stack/stack-orchestrator/config/mainnet-laconicd/create-validator.sh:/scripts/create-validator.sh \ -e "KEY_NAME={{ key_name }}" \ -e "NODE_URL={{ node_url }}" \ @@ -106,6 +58,7 @@ -e "CERC_CHAIN_ID={{ cerc_chain_id }}" \ -e "MIN_GAS_PRICE={{ min_gas_price }}" \ -e "VALIDATOR_PUB_KEY={{ validator_pub_key | to_json }}" \ + -e "PVT_KEY={{ private_key_input.user_input }}" \ --network=host \ cerc/laconicd:local \ sh -c "/scripts/create-validator.sh" diff --git a/stack-orchestrator/config/mainnet-laconicd/create-validator.sh b/stack-orchestrator/config/mainnet-laconicd/create-validator.sh index 2b90d90..e1a856d 100755 --- a/stack-orchestrator/config/mainnet-laconicd/create-validator.sh +++ b/stack-orchestrator/config/mainnet-laconicd/create-validator.sh @@ -3,10 +3,10 @@ set -e DENOM=alnt -NODE_HOME=/root/.laconicd +CREATE_VALIDATOR_DIR=/root/create-validator KEYRING="test" -staking_amount_file="$NODE_HOME/tmp/staking-amount.json" +staking_amount_file="$CREATE_VALIDATOR_DIR/tmp/staking-amount.json" if [ ! -f "$staking_amount_file" ]; then echo "staking-amount.json file not provided, exiting..." exit 1 @@ -32,11 +32,18 @@ if [ -z "$VALIDATOR_PUB_KEY" ]; then exit 1 fi +if [ -z "$PVT_KEY" ]; then + echo "PVT_KEY environment variable not set, exiting..." + exit 1 +fi + +laconicd keys import-hex "$KEY_NAME" "$PVT_KEY" --keyring-backend test + # Set staking amount stake_amount=$(jq -r '.common_staking_amount' "$staking_amount_file") # Create validator.json file -validator_json="$NODE_HOME/tmp/validator.json" +validator_json="$CREATE_VALIDATOR_DIR/tmp/validator.json" cat > "$validator_json" << EOF { "pubkey": $VALIDATOR_PUB_KEY, -- 2.54.0 From f27b1eb61919d64feddafc86c1a76f63840a64dd Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Tue, 10 Jun 2025 09:29:09 +0530 Subject: [PATCH 3/6] Add playbook variable to control force rebuild --- docs/run-first-validator.md | 23 ++++--------------- docs/run-validator.md | 23 ++++--------------- .../first-validator/setup-first-validator.yml | 6 ++--- playbooks/validator/build-laconicd.yml | 16 +++++++------ playbooks/validator/setup-validator.yml | 6 ++--- 5 files changed, 23 insertions(+), 51 deletions(-) diff --git a/docs/run-first-validator.md b/docs/run-first-validator.md index 4b64e67..da49e89 100644 --- a/docs/run-first-validator.md +++ b/docs/run-first-validator.md @@ -6,6 +6,11 @@ - [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install) - LPS distribution Google spreadsheet URL or CSV file path - Install `zstd` using `sudo apt install zstd` +- laconicd-stack + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull + ``` ## Setup node @@ -57,12 +62,6 @@ - Run the following steps in the machine where genesis file is to be generated -- Fetch Stack: - - ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull - ``` - - Run playbook to build laconicd container: ```bash @@ -87,12 +86,6 @@ laconic-so deployment --dir stop ``` -- 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: ```bash @@ -105,12 +98,6 @@ - Run the following steps in secure machine separate from the one where the node is setup -- Fetch the stack: - - ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull - ``` - - Copy over compressed `testnet-state.zst` file to target machine - Set envs: diff --git a/docs/run-validator.md b/docs/run-validator.md index b3a3b9c..03613db 100644 --- a/docs/run-validator.md +++ b/docs/run-validator.md @@ -4,6 +4,11 @@ - [ansible](playbooks/README.md#ansible-installation) - [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install) +- laconicd-stack + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull + ``` ## Setup Node @@ -23,12 +28,6 @@ laconic-so deployment --dir stop ``` -- Fetch the stack: - - ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull - ``` - This command clones the entire repository into the `~/cerc` folder, which includes the genesis file published by the first validator. - Copy the example variables file: @@ -141,12 +140,6 @@ - Run the following steps in the machine from where the create-validator transaction is to be signed -- Fetch Stack: - - ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull - ``` - - Run playbook to build laconicd container: ```bash @@ -179,12 +172,6 @@ - Run these steps in a secure machine separate from the one where the node is setup -- Fetch the stack: - - ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull - ``` - This command clones the entire repository into the `~/cerc` folder, which includes the genesis file published by the first validator. - Copy the example variables file: diff --git a/playbooks/first-validator/setup-first-validator.yml b/playbooks/first-validator/setup-first-validator.yml index 3c32bff..830684d 100644 --- a/playbooks/first-validator/setup-first-validator.yml +++ b/playbooks/first-validator/setup-first-validator.yml @@ -8,6 +8,7 @@ mainnet_deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}" spec_file: "{{data_directory}}/laconicd-spec.yml" spec_template: "./templates/specs/spec-template.yml.j2" + build_args: "{{ '--force-rebuild' if (lookup('env', 'FORCE_REBUILD') | default(omit, true)) not in [ 'false', 'False', '0' ] else '' }}" tasks: - name: Fail if DATA_DIRECTORY or MAINNET_DEPLOYMENT_DIR env vars are not set fail: @@ -16,9 +17,6 @@ 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 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 @@ -26,7 +24,7 @@ - name: Build container images shell: | - laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers --force-rebuild + laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers {{ build_args }} - name: Create deployment spec file shell: | diff --git a/playbooks/validator/build-laconicd.yml b/playbooks/validator/build-laconicd.yml index de87497..3aeefbe 100644 --- a/playbooks/validator/build-laconicd.yml +++ b/playbooks/validator/build-laconicd.yml @@ -2,12 +2,14 @@ - name: Build Laconicd hosts: localhost connection: local + vars: + build_args: "{{ '--force-rebuild' if (lookup('env', 'FORCE_REBUILD') | default(omit, true)) not in [ 'false', 'False', '0' ] else '' }}" tasks: - - name: Fetch repositories - ansible.builtin.shell: - cmd: "laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd setup-repositories --git-ssh --pull" + - name: Setup required repositories + shell: > + 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" + - name: Build container images + shell: | + laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers {{ build_args }} diff --git a/playbooks/validator/setup-validator.yml b/playbooks/validator/setup-validator.yml index 703016c..79ac21c 100644 --- a/playbooks/validator/setup-validator.yml +++ b/playbooks/validator/setup-validator.yml @@ -8,6 +8,7 @@ mainnet_deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}" spec_file: "{{data_directory}}/laconicd-validator-spec.yml" spec_template: "./templates/specs/spec-template.yml.j2" + build_args: "{{ '--force-rebuild' if (lookup('env', 'FORCE_REBUILD') | default(omit, true)) not in [ 'false', 'False', '0' ] else '' }}" tasks: - name: Fail if DATA_DIRECTORY or MAINNET_DEPLOYMENT_DIR env vars are not set fail: @@ -23,9 +24,6 @@ Please set genesis_file and staking_amount_file in validator-vars.yml. when: not genesis_file or not staking_amount_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 @@ -33,7 +31,7 @@ - name: Build container images shell: | - laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers --force-rebuild + laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers {{ build_args }} - name: Create deployment spec file shell: | -- 2.54.0 From 6e9a82d6d2d909c2c370a0ff2b633029e353e5cb Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Tue, 10 Jun 2025 11:31:58 +0530 Subject: [PATCH 4/6] Update README instructions for running validator nodes --- README.md | 14 ++++- docs/run-first-validator.md | 51 ++++++++++------ docs/run-validator.md | 60 ++++++++++++------- .../first-validator/generate-genesis.yml | 13 +--- 4 files changed, 85 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index 7e1229f..71402e1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ # laconicd-stack -- Follow [run-first-validator.md](docs/run-first-validator.md) to run the first validator node -- Follow [cosmos-multisig-app playbook](./playbooks/cosmos-multisig-app/README.md) to run the Cosmos Multisig app -- Follow [run-validator.md](docs/run-validator.md) to run subsequent validator nodes +- This stack is used for running nodes to launch Laconic mainnet chain + +- It allows you to export SAPO testnet state and start mainnet nodes + +- To launch Laconic mainnet, follow these steps: + + - **Run the First Validator Node:** Begin by setting up and running the initial validator node as detailed in [run-first-validator.md](docs/run-first-validator.md) + + - **Deploy Cosmos Multisig App:** Integrate and run the Cosmos Multisig app using the playbook available at [cosmos-multisig-app playbook](./playbooks/cosmos-multisig-app/README.md) + + - **Run Subsequent Validator Nodes:** Run subsequent validator nodes by following the instructions in [run-validator.md](docs/run-validator.md) diff --git a/docs/run-first-validator.md b/docs/run-first-validator.md index da49e89..b5cb7ac 100644 --- a/docs/run-first-validator.md +++ b/docs/run-first-validator.md @@ -2,14 +2,37 @@ ## Prerequisites -- [ansible](playbooks/README.md#ansible-installation) -- [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install) -- LPS distribution Google spreadsheet URL or CSV file path -- Install `zstd` using `sudo apt install zstd` -- laconicd-stack +- Machine 1: Where the SAPO testnet is running + + - Install `zstd` using `sudo apt install zstd` + +- Machine 2: Where the genesis file is to be generated + + - Install `zstd` using `sudo apt install zstd` + + - LPS distribution Google spreadsheet URL or CSV file path + +- Machine 3: Where the first validator node is to be setup + +- Following tools are required in all machines: + + - [ansible](playbooks/README.md#ansible-installation) + - [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install) + + - laconicd-stack + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull + ``` + +## Build laconicd to generate genesis file + +- Run the following steps in a secure machine separate from the one where the node is to be setup + +- Run playbook to build laconicd container: ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull + ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/build-laconicd.yml ``` ## Setup node @@ -58,16 +81,6 @@ 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/validator/build-laconicd.yml - ``` - ## Export testnet state - Run the following steps in machine where the testnet node is running @@ -96,7 +109,7 @@ ## Generate mainnet genesis file -- Run the following steps in secure machine separate from the one where the node is setup +- Run the following steps in machine where [the genesis file is to be generated](#build-laconicd-to-generate-genesis-file) - Copy over compressed `testnet-state.zst` file to target machine @@ -140,8 +153,10 @@ - Edit `~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml` with required values: + NOTE: Use the public key exported in [previous step](#setup-node) + ```bash - # Use the public key exported in previous step (make sure to wrap it with single quotes ['']) + # Make sure to wrap it with single quotes ('') validator_pub_key: '' ``` diff --git a/docs/run-validator.md b/docs/run-validator.md index 03613db..6b00f48 100644 --- a/docs/run-validator.md +++ b/docs/run-validator.md @@ -2,17 +2,33 @@ ## Prerequisites -- [ansible](playbooks/README.md#ansible-installation) -- [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install) -- laconicd-stack +- Machine 1: Where the SAPO testnet is running + +- Machine 2: Where the validator node is to be setup + + - Fetch laconicd-stack: ```bash laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull ``` -## Setup Node +- Machine 3: Where the create-validator transaction is to be signed -- Run the following steps in the machine where the validator node is to be setup + - Fetch laconicd-stack: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull + ``` + +- Following tools are required in all machines: + + - [ansible](playbooks/README.md#ansible-installation) + + - [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install) + +## Stop SAPO testnet node + +- Run the following steps in machine where the testnet node is running - Get your private key from testnet deployment: @@ -20,7 +36,7 @@ laconic-so deployment --dir exec laconicd "laconicd keys export --unarmored-hex --unsafe" ``` - NOTE: Store this key securely as it is needed in later steps + NOTE: Store this key securely as it is needed in [later steps](#create-validator) - Stop the node for SAPO testnet: @@ -28,7 +44,19 @@ laconic-so deployment --dir stop ``` - This command clones the entire repository into the `~/cerc` folder, which includes the genesis file published by the first validator. +## Build laconicd to create validator + +- Run the following steps in a secure machine separate from the one where the node is to be setup + +- Run playbook to build laconicd container: + + ```bash + ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/build-laconicd.yml + ``` + +## Setup Node + +- Run the following steps in the machine where the validator node is to be setup - Copy the example variables file: @@ -136,16 +164,6 @@ echo "TMKMS_ENABLED=true" >> $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/config.env ``` -## Build Laconicd to create validator - -- Run the following steps in the machine from where the create-validator transaction is to be signed - -- Run playbook to build laconicd container: - - ```bash - ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/build-laconicd.yml - ``` - ## Start Node - Start the laconicd node: @@ -170,7 +188,7 @@ ## Create Validator -- Run these steps in a secure machine separate from the one where the node is setup +- Run these steps in a machine from where [the create-validator transaction is to be signed](#build-laconicd-to-create-validator) This command clones the entire repository into the `~/cerc` folder, which includes the genesis file published by the first validator. @@ -182,11 +200,13 @@ - Update `~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml` with required values: + NOTE: Use the public key exported in [previous step](#start-node) + ```bash # Same moniker as set above cerc_moniker: "" - # Use the public key exported in previous step (make sure to wrap it with single quotes ['']) + # Make sure to wrap it with single quotes ('') validator_pub_key: '' # Set the public IP address of the machine where your node is running @@ -206,7 +226,7 @@ ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/create-validator.yml ``` - - Input private key of the existing account that was exported in previous steps when prompted + - Input private key of the existing account that was exported in [previous steps](#stop-sapo-testnet-node) when prompted - Run the following commands in the machine where the validator node is setup diff --git a/playbooks/first-validator/generate-genesis.yml b/playbooks/first-validator/generate-genesis.yml index 6245ca0..2ac9306 100644 --- a/playbooks/first-validator/generate-genesis.yml +++ b/playbooks/first-validator/generate-genesis.yml @@ -16,16 +16,10 @@ Please export both DATA_DIRECTORY before running the playbook. when: lookup('env', 'DATA_DIRECTORY') == '' - - name: Copy exported testnet state file - ansible.builtin.copy: - src: "{{ exported_state_path }}" - dest: "~/cerc/laconicd-stack/testnet-state.json" - remote_src: true # Set to true if exported_state_path is on the target host - - block: - name: Run script to generate genesis file ansible.builtin.shell: - cmd: "CHAIN_ID={{ cerc_chain_id }} EARLY_SUPPORTS_ACC_ADDRESS={{ early_supports_acc_address }} {{ ansible_env.HOME }}/cerc/laconicd-stack/scripts/generate-mainnet-genesis.sh {{ ansible_env.HOME }}/cerc/laconicd-stack/testnet-state.json {{ lps_distribution_path }}" + cmd: "CHAIN_ID={{ cerc_chain_id }} EARLY_SUPPORTS_ACC_ADDRESS={{ early_supports_acc_address }} {{ ansible_env.HOME }}/cerc/laconicd-stack/scripts/generate-mainnet-genesis.sh {{ exported_state_path }} {{ lps_distribution_path }}" chdir: "{{ lookup('env', 'PWD') }}" always: - name: Clean up temporary genesis directory @@ -33,11 +27,6 @@ path: "{{ ansible_env.HOME }}/cerc/laconicd-stack/playbooks/first-validator/mainnet-genesis" state: absent - - name: Remove temporary copied state file - ansible.builtin.file: - path: "~/cerc/laconicd-stack/testnet-state.json" - state: absent - - name: Display genesis file location ansible.builtin.debug: msg: "Mainnet genesis file generated at output/genesis.json" -- 2.54.0 From 885171d32805aac331c21d87de1919545c805eab Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Tue, 10 Jun 2025 11:55:28 +0530 Subject: [PATCH 5/6] Restructure prerequisites in docs --- docs/run-first-validator.md | 16 +++++++------- docs/run-validator.md | 44 ++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/docs/run-first-validator.md b/docs/run-first-validator.md index b5cb7ac..a3d6b4c 100644 --- a/docs/run-first-validator.md +++ b/docs/run-first-validator.md @@ -2,18 +2,18 @@ ## Prerequisites -- Machine 1: Where the SAPO testnet is running +- Machine 1: Where the SAPO testnet node is already running - Install `zstd` using `sudo apt install zstd` -- Machine 2: Where the genesis file is to be generated +- Machine 2: Where the mainnet first validator node is to be setup + +- Machine 3: Where the genesis file is to be generated - Install `zstd` using `sudo apt install zstd` - LPS distribution Google spreadsheet URL or CSV file path -- Machine 3: Where the first validator node is to be setup - - Following tools are required in all machines: - [ansible](playbooks/README.md#ansible-installation) @@ -27,7 +27,7 @@ ## Build laconicd to generate genesis file -- Run the following steps in a secure machine separate from the one where the node is to be setup +- Run the following steps in a secure machine (machine 3) separate from the one where the node is to be setup (machine 2) - Run playbook to build laconicd container: @@ -83,7 +83,7 @@ ## Export testnet state -- Run the following steps in machine where the testnet node is running +- Run the following steps in machine where the testnet node is already running (machine 1) - Get your private key from testnet deployment: @@ -109,7 +109,7 @@ ## Generate mainnet genesis file -- Run the following steps in machine where [the genesis file is to be generated](#build-laconicd-to-generate-genesis-file) +- Run the following steps in machine where [the genesis file is to be generated (machine 3)](#build-laconicd-to-generate-genesis-file) - Copy over compressed `testnet-state.zst` file to target machine @@ -177,7 +177,7 @@ ## Run node -- Run the following steps in the machine where the mainnet node is setup +- Run the following steps in the machine where the mainnet node is setup (machine 2) ### Setup TMKMS (Optional but Recommended) diff --git a/docs/run-validator.md b/docs/run-validator.md index 6b00f48..697e8e1 100644 --- a/docs/run-validator.md +++ b/docs/run-validator.md @@ -2,33 +2,31 @@ ## Prerequisites -- Machine 1: Where the SAPO testnet is running +- Machine 1: Where the SAPO testnet node is already running -- Machine 2: Where the validator node is to be setup +- Machine 2: Where the mainnet validator node is to be setup - - Fetch laconicd-stack: - - ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull - ``` - -- Machine 3: Where the create-validator transaction is to be signed - - - Fetch laconicd-stack: - - ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull - ``` - -- Following tools are required in all machines: + - laconicd-stack - [ansible](playbooks/README.md#ansible-installation) - - [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install) +- Machine 3: Where the create-validator transaction is to be signed + + - laconicd-stack + + - [ansible](playbooks/README.md#ansible-installation) + +- [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install) is required in all machines + +- To fetch laconicd-stack: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull + ``` ## Stop SAPO testnet node -- Run the following steps in machine where the testnet node is running +- Run the following steps in machine where the testnet node is already running (machine 1) - Get your private key from testnet deployment: @@ -46,7 +44,7 @@ ## Build laconicd to create validator -- Run the following steps in a secure machine separate from the one where the node is to be setup +- Run the following steps in a secure machine (machine 3) separate from the one where the node is to be setup (machine 2) - Run playbook to build laconicd container: @@ -56,7 +54,7 @@ ## Setup Node -- Run the following steps in the machine where the validator node is to be setup +- Run the following steps in the machine where the validator node is to be setup (machine 2) - Copy the example variables file: @@ -188,7 +186,7 @@ ## Create Validator -- Run these steps in a machine from where [the create-validator transaction is to be signed](#build-laconicd-to-create-validator) +- Run these steps in a machine from where [the create-validator transaction is to be signed (machine 3)](#build-laconicd-to-create-validator) This command clones the entire repository into the `~/cerc` folder, which includes the genesis file published by the first validator. @@ -228,7 +226,7 @@ - Input private key of the existing account that was exported in [previous steps](#stop-sapo-testnet-node) when prompted -- Run the following commands in the machine where the validator node is setup +- Run the following commands in the machine where the validator node is running (machine 2) - Check the validator list: -- 2.54.0 From f37d0ad776941d492f569b25282c7c6e76be5eb0 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Tue, 10 Jun 2025 15:30:45 +0530 Subject: [PATCH 6/6] Update steps for publishing artifacts --- docs/run-first-validator.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/docs/run-first-validator.md b/docs/run-first-validator.md index a3d6b4c..72dc128 100644 --- a/docs/run-first-validator.md +++ b/docs/run-first-validator.md @@ -37,7 +37,7 @@ ## Setup node -- Run the following steps in the machine where the mainnet node is to be setup +- Run the following steps in the machine where the mainnet node is to be setup (machine 2) - Copy the example variables file if not already done: @@ -79,7 +79,7 @@ cerc/laconicd:local bash -c "laconicd tendermint show-validator" ``` - NOTE: This public key is required in next step to generate the genesis file + NOTE: This public key is required in [next step to generate the genesis file](#generate-mainnet-genesis-file) ## Export testnet state @@ -333,19 +333,21 @@ ## Publish required artifacts -- Copy the genesis file to [config](./config) folder: +- Run the following steps in machine where the genesis file and staking amount files are generated (machine 3) - ```bash - cp $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/genesis.json ~/cerc/laconicd-stack/config/mainnet-genesis.json - ``` + - Copy the genesis file to [config](./config) folder: -- Copy the staking amount file to [config](./config) folder: + ```bash + cp $DATA_DIRECTORY/output/genesis.json ~/cerc/laconicd-stack/config/mainnet-genesis.json + ``` - ```bash - cp $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/tmp/staking-amount.json ~/cerc/laconicd-stack/config/staking-amount.json - ``` + - Copy the staking amount file to [config](./config) folder: -- Get your node's address: + ```bash + cp $DATA_DIRECTORY/output/staking-amount.json ~/cerc/laconicd-stack/config/staking-amount.json + ``` + +- Get your node's address by running following command in the machine where the mainnet node is running (machine 2): ```bash laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'echo $(laconicd cometbft show-node-id)@YOUR_PUBLIC_IP_ADDRESS:26656' -- 2.54.0