laconicd-stack/docs/run-first-validator.md

7.4 KiB

Run First Validator Node

Prerequisites

Setup Validator Node

  • Run these steps in a machine where the mainnet node is to be run

  • Fetch the stack:

    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:

    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:

    # 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:

    # 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:

    ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/run-validator.yml
    
  • Get the public key of your node:

    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:

    laconic-so deployment --dir <testnet-deployment-dir> exec laconicd "laconicd keys export <key-name> --unarmored-hex --unsafe"
    

    NOTE: Store this private key securely as it is needed in later steps

  • Stop the node for SAPO testnet:

    laconic-so deployment --dir <testnet-deployment-dir> stop
    
  • Fetch the stack in machine where the testnet chain node was running:

    laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
    
  • Run script to export state from testnet chain:

    ~/cerc/laconicd-stack/scripts/export-testnet-state.sh <absolute-path-to-testnet-deployment>
    
    • The file will be generated in <absolute-path-to-testnet-deployment>/export/testnet-state.json
  • Copy over the exported testnet-state.json file to target machine

  • Copy over the LPS lockup distribution distribution.json file to target machine

  • Set envs:

    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:

    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:

    # 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:

    ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/generate-genesis/generate-genesis.yml -e "exported_state_path=$EXPORTED_STATE_PATH" -e "lps_distribution_path=$LPS_DISTRIBUTION_PATH" -e "early_supports_acc_address=$EARLY_SUPPORTS_ACC_ADDR"
    
    • Input private key of the existing account that was exported in previous steps when prompted
  • Genesis file will be generated in output directory along with a file specifying the staking amount

    # List files in output directory - genesis.json and staking-amount.json
    ls -l output
    
  • Copy over the generated genesis file and staking amount file to the machine where the node is to be run

    • The genesis file will be used to start the node

    • Once the node is running we will publish the genesis file, staking amount file and node address so that it is available to other validators

Run node

  • Run these steps in a machine where the mainnet node is setup

  • Update ~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml with required values:

    # 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
  • Export the data directory and mainnet deployment directory as environment variables:

    # 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 start your validator node:

    ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/run-validator.yml
    
  • Check logs to ensure that node is running:

    laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR logs laconicd -f
    
  • Check bonds list to confirm that testnet state was transferred properly:

    laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query bond list'
    
  • Check alps and alnt tokens total supply:

    laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query bank total-supply'
    
  • Query the lps_lockup account and view distribution:

    laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query auth module-account lps_lockup'
    
  • Query the lps_lockup and early supports accounts balances:

    lockup_account_address=$(laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query auth module-account lps_lockup -o json | jq -r .account.value.base_account.address')
    laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd "laconicd query bank balances $lockup_account_address"
    
    laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd "laconicd query bank balances $EARLY_SUPPORTS_ACC_ADDR"
    

Publish required artifacts

  • Copy the genesis file to config folder:

    cp <absolute-path-to-generated-output-dir>/genesis.json  ~/cerc/laconicd-stack/config/mainnet-genesis.json
    
  • Copy the staking amount file to config folder:

    cp <absolute-path-to-generated-output-dir>/staking-amount.json ~/cerc/laconicd-stack/config/staking-amount.json
    
  • Get your node's address:

    laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'echo $(laconicd cometbft show-node-id)@YOUR_PUBLIC_IP_ADDRESS:26656'
    
  • Add your node's address to node-addresses.yml

  • Submit a PR with this genesis file, staking amount file and node address so that it is available to other validators