# Run First Validator Node ## Prerequisites - [ansible](playbooks/README.md#ansible-installation) - [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install) - 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: ```bash laconic-so deployment --dir exec laconicd "laconicd keys export --unarmored-hex --unsafe" ``` NOTE: Store this key securely as it is needed in later steps - Stop the node for SAPO testnet: ```bash laconic-so deployment --dir stop ``` - Fetch the stack in machine where the testnet chain node is running: ```bash laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull ``` - Run script to export state from testnet chain: ```bash ~/cerc/laconicd-stack/scripts/export-testnet-state.sh ``` - The compressed gzip will be generated at `/export/testnet-state.gz` ## Generate mainnet genesis file - 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 compressed `testnet-state.gz` file to target machine - Extract the testnet-state JSON file ``` gzip -dc /testnet-state.gz > testnet-state.json # Remove zip folder rm -rf /testnet-state.gz ``` - Generate LPS lockup distribution JSON file ```bash ~/cerc/laconicd-stack/scripts/generate-lps-lock.sh -i "" -d "" ``` - This will generate the `distribution.json` file - Copy over the LPS lockup distribution `distribution.json` file to target machine - Set envs: ```bash export EXPORTED_STATE_PATH= export LPS_DISTRIBUTION_PATH= export EARLY_SUPPORTS_ACC_ADDR= ``` - Copy the example variables file: ```bash 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: ```bash 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 ```bash # 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: ```bash 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: ```bash # Use the private key of the existing account that was exported in previous steps pvt_key: "" # Path to the generated mainnet genesis file # Use the absolute path of generated output directory in the previous steps genesis_file: "/genesis.json" # Path to staking-amount.json generated in previous steps staking_amount_file: "/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: ```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 submit gentx and setup the node: ```bash ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/setup-first-validator.yml ``` ### Setup TMKMS (Optional but Recommended) - 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 ```bash # 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`: ```toml [[chain]] id = "laconic-mainnet" key_format = { type = "cosmos-json", account_key_prefix = "laconicpub", consensus_key_prefix = "laconicvalconspub" } # Replace with absolute path to tmkms config directory state_file = "/state/priv_validator_state.json" [[validator]] chain_id = "laconic-mainnet" # Replace with actual IP address of the laconicd node addr = "tcp://:26659" # Replace with absolute path to tmkms config directory secret_key = "/secrets/kms-identity.key" protocol_version = "v0.34" reconnect = true [[providers.softsign]] key_type = "consensus" # Replace with absolute path to tmkms config directory path = "/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: ```bash tmkms softsign import $TMKMS_HOME/secrets/priv_validator_key.json $TMKMS_HOME/secrets/priv_validator_key ``` - Remove the JSON key file ```bash rm $TMKMS_HOME/secrets/priv_validator_key.json ``` - Start TMKMS: ```bash tmkms start --config $TMKMS_HOME/tmkms.toml ``` - Expected example output: ```bash 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: ```bash # 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 ```bash 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 ```bash laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR start ``` - Check logs to ensure that node is running: ```bash 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 ```bash # 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: ```bash laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query bond list' ``` - Check `alps` and `alnt` tokens total supply: ```bash laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query bank total-supply' ``` - Query the `lps_lockup` account and view distribution: ```bash 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: ```bash 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](./config) folder: ```bash 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](./config) folder: ```bash 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: ```bash 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](./node-addresses.yml) - Submit a PR with this genesis file, staking amount file and node address so that it is available to other validators