laconicd-stack/docs/run-first-validator.md
ishavenikar 6733aa7318 Add steps to compress testnet state JSON file (#11)
Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Reviewed-on: #11
Co-authored-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
Co-committed-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
2025-06-04 11:25:23 +00:00

10 KiB

Run First Validator Node

Prerequisites

  • ansible
  • laconic-so
  • LPS distribution Google spreadsheet URL or CSV file path
  • Install gzip using sudo apt install gzip

Export testnet state

  • 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 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 is 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 compressed gzip will be generated at <absolute-path-to-testnet-deployment>/export/testnet-state.gz

Generate mainnet genesis file

  • If mainnet node is to be setup in a new machine, fetch the stack again:

    laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
    
  • Copy over compressed testnet-state.gz file to target machine

  • Extract the testnet-state JSON file

    gzip -dc <path-to-compressed-file>/testnet-state.gz > testnet-state.json
    
    # Remove zip folder
    rm -rf <path-to-compressed-file>/testnet-state.gz
    
  • Generate LPS lockup distribution JSON file

    ~/cerc/laconicd-stack/scripts/generate-lps-lock.sh -i "<lps-distribution-spreadsheet-url-or-file-path>" -d "<destination-folder-for-json-file>"
    
    • This will generate the distribution.json file
  • 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>
    
  • Copy the example variables file:

    cp ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.example.yml ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml
    
  • Run playbook to use exported state for generating mainnet genesis:

    ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/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"
    
  • 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
    

Setup node

  • Copy the example variables file if not already done:

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

    # 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
    # Use the absolute path of generated output directory in the previous steps
    genesis_file: "<absolute-path-to-generated-output-dir>/genesis.json"
    
    # Path to staking-amount.json generated in previous steps
    staking_amount_file: "<absolute-path-to-generated-output-dir>/staking-amount.json"
    
    # Set custom moniker for the node
    cerc_moniker: "LaconicMainnetNode"
    
    # Set desired key name
    key_name: "laconic-validator"
    
  • 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 submit gentx and setup the node:

    ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/setup-first-validator.yml
    
  • For integrating existing TMKMS with laconicd, follow steps below in the machine where TMKMS is setup

  • Set $TMKMS_HOME to the directory path containing TMKMS config files

    # Contents of tmkms config directory
    ls -l $TMKMS_HOME
    drwxrwxr-x 2 ... schema
    drwx------ 2 ... secrets
    drwxrwxr-x 2 ... state
    -rw-rw-r-- 1 ... tmkms.toml
    
  • Update the TMKMS configuration file $TMKMS_HOME/tmkms.toml:

    [[chain]]
    id = "laconic-mainnet"
    key_format = { type = "cosmos-json", account_key_prefix = "laconicpub", consensus_key_prefix = "laconicvalconspub" }
    # Replace <TMKMS_HOME> with absolute path to tmkms config directory
    state_file = "<TMKMS_HOME>/state/priv_validator_state.json"
    
    [[validator]]
    chain_id = "laconic-mainnet"
    # Replace <NODE_IP> with actual IP address of the laconicd node
    addr = "tcp://<NODE_IP>:26659"
    # Replace <TMKMS_HOME> with absolute path to tmkms config directory
    secret_key = "<TMKMS_HOME>/secrets/kms-identity.key"
    protocol_version = "v0.34"
    reconnect = true
    
    [[providers.softsign]]
    key_type = "consensus"
    # Replace <TMKMS_HOME> with absolute path to tmkms config directory
    path = "<TMKMS_HOME>/secrets/priv_validator_key"
    chain_ids = ["laconic-mainnet"]
    
  • Copy your validator key to TMKMS:

    • The validator key in laconicd node deployment is present at $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json

    • Place the validator key file in TMKMS config directory at $TMKMS_HOME/secrets/

    • Import the private validator key into tmkms:

      tmkms softsign import $TMKMS_HOME/secrets/priv_validator_key.json $TMKMS_HOME/secrets/priv_validator_key
      
    • Remove the JSON key file

      rm $TMKMS_HOME/secrets/priv_validator_key.json
      
  • Start TMKMS:

    tmkms start --config $TMKMS_HOME/tmkms.toml
    
    • Expected example output:

       INFO tmkms::commands::start: tmkms 0.14.0 starting up...
       INFO tmkms::keyring: [keyring:softsign] added consensus Ed25519 key: {"@type":"/cosmos.crypto.ed25519.PubKey","key":"T24No1A1FmetNRVCOSg2G2XAKWh97oBXuELdAD6DFgw="}
       INFO tmkms::connection::tcp: KMS node ID: 7f5fd8dae8953e964e7e56edd4700f597ea0d45c
      ERROR tmkms::client: [laconic-mainnet@tcp://localhost:26659] I/O error: Connection refused (os error 111)
      

      NOTE: The errors dissapear once the laconicd node starts

    • Note the pubkey logged at start for comparing later with validator pubkey on chain

  • Enable TMKMS in the laconicd node configuration:

    # Set TMKMS_ENABLED to true in the node's config.env
    echo "TMKMS_ENABLED=true" >> $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/config.env
    
  • Remove the validator key from node deployment as it is no longer required

    rm $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json
    

    NOTE: Store it safely offline in case of an emergency

Run node

  • Command to run node

    laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR start
    
  • Check logs to ensure that node is running:

    laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR logs laconicd -f
    
  • If TMKMS has been configured verify that validator and TMKMS pubkeys match

    • Get validator pubkey on chain

      # Check consensus_pubkey in output
      laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query staking validators -o json | jq .validators'
      
    • Compare it with the pubkey noted from logs in TMKMS

  • 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 $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/genesis.json ~/cerc/laconicd-stack/config/mainnet-genesis.json
    
  • Copy the staking amount file to config folder:

    cp $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/tmp/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