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,