Add prompt to get private key

This commit is contained in:
Shreerang Kale 2025-05-19 10:55:06 +05:30
parent 3d7ba45796
commit a4cb808c96
6 changed files with 30 additions and 23 deletions

View File

@ -75,9 +75,6 @@
- Export required env vars: - Export required env vars:
```bash ```bash
# private key of the existing account
export PVT_KEY=<private-key-in-hex-format>
# desired key name # desired key name
export KEY_NAME=<key-name> export KEY_NAME=<key-name>
@ -92,6 +89,8 @@
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/create-validator.yml ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/create-validator.yml
``` ```
- Input private key of the existing account when prompted
- Check the validator list: - Check the validator list:
```bash ```bash

View File

@ -83,9 +83,6 @@
- Update `~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml` with required values: - Update `~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml` with required values:
```bash ```bash
# Use the private key of the existing account that was exported in previous steps
pvt_key: "<private-key>"
# Path to the generated mainnet genesis file # Path to the generated mainnet genesis file
# Use the absolute path of generated output directory in the previous steps # Use the absolute path of generated output directory in the previous steps
genesis_file: "<absolute-path-to-generated-output-dir>/genesis.json" genesis_file: "<absolute-path-to-generated-output-dir>/genesis.json"
@ -117,6 +114,8 @@
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/run-first-validator.yml ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/run-first-validator.yml
``` ```
- Input private key of the existing account that was exported in previous steps when prompted
- Check logs to ensure that node is running: - Check logs to ensure that node is running:
```bash ```bash

View File

@ -74,9 +74,6 @@
- Export required env vars: - Export required env vars:
```bash ```bash
# Use the private key of the existing account that was exported in previous steps
export PVT_KEY=<private-key-in-hex-format>
# desired key name # desired key name
export KEY_NAME=<key-name> export KEY_NAME=<key-name>
@ -91,6 +88,8 @@
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/create-validator.yml 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
- Check the validator list: - Check the validator list:
```bash ```bash

View File

@ -3,6 +3,5 @@ cerc_chain_id: "laconic-mainnet"
min_gas_price: 0.001 min_gas_price: 0.001
cerc_loglevel: "info" cerc_loglevel: "info"
key_name: "laconic-validator" key_name: "laconic-validator"
pvt_key: ""
genesis_file: "" genesis_file: ""
staking_amount_file: "" staking_amount_file: ""

View File

@ -75,19 +75,25 @@
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/genesis.json" dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/genesis.json"
mode: '0644' mode: '0644'
- name: Fail if pvt_key is not set - name: Prompt for validator private key
vars:
private_key_prompt: "Please enter your validator private key: "
pause:
prompt: "{{ private_key_prompt }}"
echo: no
register: private_key_input
- name: Fail if private key is not provided
fail: fail:
msg: >- msg: "Private key is required for creating the gentx."
Private key (pvt_key) is not set in first-validator-vars.yml. when: private_key_input.user_input | default('') | trim == ''
This is required for creating the gentx.
when: not pvt_key
- name: Run script to create and collect gentx - name: Run script to create and collect gentx
shell: | shell: |
docker run -i \ docker run -i \
-v {{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data:/root/.laconicd \ -v {{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data:/root/.laconicd \
-v {{data_directory}}/{{ mainnet_deployment_dir }}/config/mainnet-laconicd:/scripts \ -v {{data_directory}}/{{ mainnet_deployment_dir }}/config/mainnet-laconicd:/scripts \
-e "PVT_KEY={{ pvt_key }}" \ -e "PVT_KEY={{ private_key_input.user_input }}" \
-e "KEY_NAME={{ key_name }}" \ -e "KEY_NAME={{ key_name }}" \
-e "CERC_MONIKER={{ cerc_moniker }}" \ -e "CERC_MONIKER={{ cerc_moniker }}" \
-e "CERC_CHAIN_ID={{ cerc_chain_id }}" \ -e "CERC_CHAIN_ID={{ cerc_chain_id }}" \

View File

@ -5,7 +5,6 @@
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}" data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}" deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}"
key_name: "{{ lookup('env', 'KEY_NAME') }}" key_name: "{{ lookup('env', 'KEY_NAME') }}"
pvt_key: "{{ lookup('env', 'PVT_KEY') }}"
tasks: tasks:
- name: Fail if DATA_DIRECTORY or MAINNET_DEPLOYMENT_DIR env vars are not set - name: Fail if DATA_DIRECTORY or MAINNET_DEPLOYMENT_DIR env vars are not set
fail: fail:
@ -14,16 +13,22 @@
Please export both DATA_DIRECTORY and MAINNET_DEPLOYMENT_DIR before running the playbook. Please export both DATA_DIRECTORY and MAINNET_DEPLOYMENT_DIR before running the playbook.
when: lookup('env', 'DATA_DIRECTORY') == '' or lookup('env', 'MAINNET_DEPLOYMENT_DIR') == '' when: lookup('env', 'DATA_DIRECTORY') == '' or lookup('env', 'MAINNET_DEPLOYMENT_DIR') == ''
- name: Fail if pvt_key is not set - name: Prompt for validator private key
vars:
private_key_prompt: "Please enter your validator private key: "
pause:
prompt: "{{ private_key_prompt }}"
echo: no
register: private_key_input
- name: Fail if private key is not provided
fail: fail:
msg: >- msg: "Private key is required for creating the gentx."
Neither private key (pvt_key) is set. when: private_key_input.user_input | default('') | trim == ''
Please export PVT_KEY.
when: not pvt_key
- name: Import private key in laconicd - name: Import private key in laconicd
shell: | shell: |
laconic-so deployment --dir {{ data_directory }}/{{ deployment_dir }} exec laconicd "laconicd keys import-hex {{ key_name }} {{ pvt_key }} --keyring-backend test" laconic-so deployment --dir {{ data_directory }}/{{ deployment_dir }} exec laconicd "laconicd keys import-hex {{ key_name }} {{ private_key_input.user_input }} --keyring-backend test"
- name: Run create-validator script - name: Run create-validator script
shell: | shell: |