Update playbook, scripts and readme to use public key while creating gentx
This commit is contained in:
parent
8166dee68c
commit
9bb5aa0bef
@ -5,6 +5,63 @@
|
||||
- [ansible](playbooks/README.md#ansible-installation)
|
||||
- [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install)
|
||||
|
||||
## Setup Validator Node
|
||||
|
||||
- Run these steps in a machine where the mainnet node is to be run
|
||||
|
||||
- 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
|
||||
|
||||
- Copy the example variables file:
|
||||
|
||||
```bash
|
||||
cp ~/cerc/laconicd-stack/playbooks/validator/validator-vars.example.yml ~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml
|
||||
```
|
||||
|
||||
- Update `~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml` with required values:
|
||||
|
||||
```bash
|
||||
# Set custom moniker for the node
|
||||
cerc_moniker: "<your-moniker>"
|
||||
|
||||
# Set is_setup to true
|
||||
is_setup: true
|
||||
```
|
||||
|
||||
- Keep rest of the values empty
|
||||
|
||||
- Export the data directory and mainnet deployment directory as environment variables:
|
||||
|
||||
```bash
|
||||
# Parent directory where the deployment directory will live
|
||||
export DATA_DIRECTORY=
|
||||
|
||||
# Set mainnet deployment directory
|
||||
# for eg: mainnet-laconicd-deployment
|
||||
export MAINNET_DEPLOYMENT_DIR=
|
||||
```
|
||||
|
||||
- Run ansible playbook to set up your validator node:
|
||||
|
||||
```bash
|
||||
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/run-validator.yml
|
||||
```
|
||||
|
||||
- Get the public key of your node:
|
||||
|
||||
```bash
|
||||
docker run -it \
|
||||
-v ./$MAINNET_DEPLOYMENT_DIR/data/laconicd-data:/root/.laconicd \
|
||||
cerc/laconicd:local bash -c "laconicd tendermint show-validator"
|
||||
```
|
||||
|
||||
NOTE: This public key is required in next step to generate the genesis file
|
||||
|
||||
## Generate mainnet genesis file
|
||||
|
||||
- Get your private key from testnet deployment:
|
||||
@ -13,7 +70,7 @@
|
||||
laconic-so deployment --dir <testnet-deployment-dir> exec laconicd "laconicd keys export <key-name> --unarmored-hex --unsafe"
|
||||
```
|
||||
|
||||
NOTE: Store this key securely as it is needed in later steps
|
||||
NOTE: Store this private key securely as it is needed in later steps
|
||||
|
||||
- Stop the node for SAPO testnet:
|
||||
|
||||
@ -35,12 +92,6 @@
|
||||
|
||||
- The file will be generated in `<absolute-path-to-testnet-deployment>/export/testnet-state.json`
|
||||
|
||||
- If mainnet node is to be setup in a new machine, fetch the stack again:
|
||||
|
||||
```bash
|
||||
laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
|
||||
```
|
||||
|
||||
- Copy over the exported `testnet-state.json` file to target machine
|
||||
|
||||
- Copy over the LPS lockup distribution `distribution.json` file to target machine
|
||||
@ -51,6 +102,13 @@
|
||||
export EXPORTED_STATE_PATH=<absolute-path-to-exported-testnet-state-json>
|
||||
export LPS_DISTRIBUTION_PATH=<absolute-path-to-distribution-json>
|
||||
export EARLY_SUPPORTS_ACC_ADDR=<account-address-controlled-by-laconic-foundation>
|
||||
|
||||
# Parent directory where the deployment directory will live
|
||||
export DATA_DIRECTORY=
|
||||
|
||||
# Set mainnet deployment directory
|
||||
# for eg: mainnet-laconicd-deployment
|
||||
export MAINNET_DEPLOYMENT_DIR=
|
||||
```
|
||||
|
||||
- Copy the example variables file:
|
||||
@ -59,6 +117,16 @@
|
||||
cp ~/cerc/laconicd-stack/playbooks/generate-genesis/generate-genesis-vars.example.yml ~/cerc/laconicd-stack/playbooks/generate-genesis/generate-genesis-vars.yml
|
||||
```
|
||||
|
||||
- Edit `~/cerc/laconicd-stack/playbooks/generate-genesis/generate-genesis-vars.yml` with required values:
|
||||
|
||||
```bash
|
||||
# Set same moniker as set above
|
||||
cerc_moniker: "<your-moniker>"
|
||||
|
||||
# Use the public key exported in previous step (make sure to wrap it with single quotes [''])
|
||||
validator_pub_key: '<public-key-of-your-node>'
|
||||
```
|
||||
|
||||
- Run playbook to use exported state for generating mainnet genesis:
|
||||
|
||||
```bash
|
||||
@ -82,30 +150,16 @@
|
||||
|
||||
## Run node
|
||||
|
||||
- Run these steps in a separate machine where the mainnet node is to be run
|
||||
|
||||
- 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
|
||||
|
||||
- Copy the example variables file:
|
||||
|
||||
```bash
|
||||
cp ~/cerc/laconicd-stack/playbooks/validator/validator-vars.example.yml ~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml
|
||||
```
|
||||
- Run these steps in a machine where the mainnet node is setup
|
||||
|
||||
- Update `~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml` with required values:
|
||||
|
||||
```bash
|
||||
# Set custom moniker for the node
|
||||
cerc_moniker: "<your-moniker>"
|
||||
|
||||
# Set path to genesis file
|
||||
genesis_file: "<path-to-generated-genesis-file>"
|
||||
|
||||
# Set is_setup to false
|
||||
is_setup: false
|
||||
```
|
||||
|
||||
- Keep rest of the values empty
|
||||
@ -121,7 +175,7 @@
|
||||
export MAINNET_DEPLOYMENT_DIR=
|
||||
```
|
||||
|
||||
- Run ansible playbook to set up and start your validator node:
|
||||
- Run ansible playbook to start your validator node:
|
||||
|
||||
```bash
|
||||
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/run-validator.yml
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# Variables used by generate-genesis.yml
|
||||
cerc_moniker: "LaconicMainnetNode"
|
||||
cerc_moniker: ""
|
||||
cerc_chain_id: "laconic-mainnet"
|
||||
key_name: "laconic-validator"
|
||||
validator_pub_key: ""
|
||||
|
||||
@ -71,13 +71,13 @@
|
||||
|
||||
- name: Copy staking amount file to laconicd-data tmp directory
|
||||
copy:
|
||||
src: "output/staking-amount.json"
|
||||
src: "{{ lookup('env', 'PWD') }}/output/staking-amount.json"
|
||||
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/staking-amount.json"
|
||||
mode: '0644'
|
||||
|
||||
- name: Copy genesis file to laconicd-data tmp directory
|
||||
copy:
|
||||
src: "output/genesis.json"
|
||||
src: "{{ lookup('env', 'PWD') }}/output/genesis.json"
|
||||
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/genesis.json"
|
||||
mode: '0644'
|
||||
|
||||
@ -103,11 +103,14 @@
|
||||
-e "KEY_NAME={{ key_name }}" \
|
||||
-e "CERC_MONIKER={{ cerc_moniker }}" \
|
||||
-e "CERC_CHAIN_ID={{ cerc_chain_id }}" \
|
||||
-e "VALIDATOR_PUB_KEY={{ validator_pub_key | to_json }}" \
|
||||
cerc/laconicd:local bash -c "/scripts/create-and-collect-gentx.sh"
|
||||
|
||||
- name: Update genesis file in output
|
||||
shell: |
|
||||
cp {{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/config/genesis.json output/genesis.json
|
||||
copy:
|
||||
src: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/config/genesis.json"
|
||||
dest: "{{ lookup('env', 'PWD') }}/output/genesis.json"
|
||||
mode: '0644'
|
||||
|
||||
- name: Clear tmp directory
|
||||
file:
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
msg: >-
|
||||
Required key files are not defined.
|
||||
Please set genesis_file in validator-vars.yml.
|
||||
when: not genesis_file
|
||||
when: not genesis_file and not is_setup
|
||||
|
||||
- name: Fetch laconicd stack
|
||||
shell: laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
|
||||
@ -38,14 +38,17 @@
|
||||
- name: Create deployment spec file
|
||||
shell: |
|
||||
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd deploy init --output {{ spec_file }}
|
||||
when: is_setup
|
||||
|
||||
- name: Replace network section in spec_file
|
||||
shell: >
|
||||
yq eval '(.network) = load("{{ spec_template }}").network' -i {{ spec_file }}
|
||||
when: is_setup
|
||||
|
||||
- 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 }}
|
||||
when: is_setup
|
||||
|
||||
- name: Create config.env
|
||||
copy:
|
||||
@ -56,6 +59,7 @@
|
||||
CERC_PEERS: "{{ cerc_peers }}"
|
||||
MIN_GAS_PRICE: "{{ min_gas_price }}"
|
||||
CERC_LOGLEVEL: "{{ cerc_loglevel }}"
|
||||
IS_SETUP: "{{ is_setup }}"
|
||||
mode: '0777'
|
||||
|
||||
- name: Ensure tmp directory exists inside laconicd-data
|
||||
@ -63,12 +67,14 @@
|
||||
path: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
when: not is_setup
|
||||
|
||||
- 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'
|
||||
when: not is_setup
|
||||
|
||||
- name: Run validator node
|
||||
shell: |
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
cerc_chain_id: "laconic-mainnet"
|
||||
min_gas_price: 0.001
|
||||
cerc_loglevel: "info"
|
||||
is_setup: false
|
||||
cerc_moniker: ""
|
||||
genesis_file: ""
|
||||
staking_amount_file: ""
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
services:
|
||||
laconicd:
|
||||
restart: unless-stopped
|
||||
restart: on-failure
|
||||
image: cerc/laconicd:local
|
||||
command: ["bash", "-c", "/opt/run-laconicd.sh"]
|
||||
environment:
|
||||
@ -9,6 +9,7 @@ services:
|
||||
CERC_PEERS: ${CERC_PEERS}
|
||||
MIN_GAS_PRICE: ${MIN_GAS_PRICE:-0.001}
|
||||
CERC_LOGLEVEL: ${CERC_LOGLEVEL:-info}
|
||||
IS_SETUP: ${IS_SETUP:-false}
|
||||
volumes:
|
||||
- laconicd-data:/root/.laconicd
|
||||
- ../config/mainnet-laconicd/run-laconicd.sh:/opt/run-laconicd.sh
|
||||
|
||||
@ -22,6 +22,11 @@ if [ -z "$KEY_NAME" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$VALIDATOR_PUB_KEY" ]; then
|
||||
echo "VALIDATOR_PUB_KEY environment variable not set, exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
input_genesis_file=$NODE_HOME/tmp/genesis.json
|
||||
if [ ! -f ${input_genesis_file} ]; then
|
||||
echo "Genesis file not provided, exiting..."
|
||||
@ -64,7 +69,7 @@ fi
|
||||
stake_amount=$(jq -r '.common_staking_amount' "$staking_amount_file")
|
||||
|
||||
# Create gentx with staked amount equal to allocated balance
|
||||
laconicd genesis gentx $KEY_NAME $stake_amount$DENOM --chain-id $CHAIN_ID --keyring-backend $KEYRING
|
||||
laconicd genesis gentx $KEY_NAME $stake_amount$DENOM --chain-id $CHAIN_ID --keyring-backend $KEYRING --pubkey "$VALIDATOR_PUB_KEY"
|
||||
|
||||
# Collect the gentx and validate
|
||||
laconicd genesis collect-gentxs
|
||||
|
||||
@ -9,7 +9,7 @@ set -e
|
||||
NODE_HOME=/root/.laconicd
|
||||
|
||||
input_genesis_file=$NODE_HOME/tmp/genesis.json
|
||||
if [ ! -f ${input_genesis_file} ]; then
|
||||
if [ ! -f ${input_genesis_file} && [ "$IS_SETUP" = "False" ] ]; then
|
||||
echo "Genesis file not provided, exiting..."
|
||||
exit 1
|
||||
fi
|
||||
@ -33,6 +33,13 @@ else
|
||||
echo "Node data dir $NODE_HOME/data already exists, skipping initialization..."
|
||||
fi
|
||||
|
||||
echo "IS_SETUP: $IS_SETUP"
|
||||
|
||||
if [ "$IS_SETUP" = "True" ]; then
|
||||
echo "IS_SETUP is true, skipping genesis file setup..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Use provided config files
|
||||
cp $input_genesis_file $NODE_HOME/config/genesis.json
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user