laconicd-stack/docs/demo.md

16 KiB

demo

Prerequisites

  • ansible
  • laconic-so
  • tmkms
    • Install with softsign feature
      cargo install tmkms --features=softsign --version=0.14.0
      
  • testnet-state.json (exported testnet state)
  • distribution.json (JSON containing the lps_lockup distribution)

Steps

  • In current working directory demo, keep exported testnet-state.json and distribution.json file from prerequisites

  • Fetch stack:

    laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
    
  • Export current working directory

    export CWD=$(pwd)
    
  • Set envs:

    export EXPORTED_STATE_PATH=$CWD/testnet-state.json
    export LPS_DISTRIBUTION_PATH=$CWD/distribution.json
    
    # Test address that does not exist on testnet chain
    export EARLY_SUPPORTS_ACC_ADDR=laconic1gwytamfk3m5n0gsawh5vpwxkwd3vapmvzpp6nz
    
  • 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 -v -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
    
  • Set env for key of account with balance in testnet:

    export FIRST_ACCOUNT_KEY=<KEY_OF_ACCOUNT_WITH_BALANCE_IN_TESTNET>
    
  • Create and populate first-validator-vars.yml:

    cat > ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml << EOL
    # Use a private key of an existing account with balance in testnet
    pvt_key: $FIRST_ACCOUNT_KEY
    
    # Path to the generated mainnet genesis file
    # Use the absolute path of generated output directory in the previous steps
    genesis_file: "$CWD/output/genesis.json"
    
    # Path to staking-amount.json generated in previous steps
    staking_amount_file: "$CWD/output/staking-amount.json"
    
    # Set custom moniker for the node
    cerc_moniker: "LaconicMainnet"
    # Set desired key name
    key_name: "laconic-validator"
    
    cerc_chain_id: "laconic-mainnet"
    min_gas_price: 0.001
    cerc_loglevel: "info"
    key_name: "laconic-validator"
    EOL
    
  • Export the data directory and mainnet deployment directory as environment variables:

    # Parent directory where the deployment directory will live
    export DATA_DIRECTORY=$CWD
    
    # Set mainnet deployment directory
    export MAINNET_DEPLOYMENT_DIR=mainnet-laconicd-deployment
    
  • Run ansible playbook to submit gentx and setup the node:

    ansible-playbook -v -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/setup-first-validator.yml
    
  • Create tmks config directory for first validator node

    tmkms init ./tmkms-first-node
    
  • Update the TMKMS configuration file ./tmkms-first-node/tmkms.toml:

    cat > ./tmkms-first-node/tmkms.toml << EOL
    [[chain]]
    id = "laconic-mainnet"
    key_format = { type = "cosmos-json", account_key_prefix = "laconicpub", consensus_key_prefix = "laconicvalconspub" }
    state_file = "$CWD/tmkms-first-node/state/priv_validator_state.json"
    
    [[validator]]
    chain_id = "laconic-mainnet"
    addr = "tcp://localhost:26659"
    secret_key = "$CWD/tmkms-first-node/secrets/kms-identity.key"
    protocol_version = "v0.34"
    reconnect = true
    
    [[providers.softsign]]
    key_type = "consensus"
    path = "$CWD/tmkms-first-node/secrets/priv_validator_key"
    chain_ids = ["laconic-mainnet"]
    EOL
    
  • Import the private validator key into tmkms:

    tmkms softsign import $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json $CWD/tmkms-first-node/secrets/priv_validator_key
    
  • Start TMKMS:

    tmkms start --config $CWD/tmkms-first-node/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

  • In a new terminal export envs

    export CWD=$(pwd)
    export DATA_DIRECTORY=$CWD
    export MAINNET_DEPLOYMENT_DIR=mainnet-laconicd-deployment
    
    # Test address that does not exist on testnet chain
    export EARLY_SUPPORTS_ACC_ADDR=laconic1gwytamfk3m5n0gsawh5vpwxkwd3vapmvzpp6nz
    
  • Enable TMKMS in the laconicd node configuration:

    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
    
  • Run the first validator 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
    
    • The chain will start running after some time.
  • 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"
    
  • 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
    
  • Copy the example variables file:

    cp ~/cerc/laconicd-stack/playbooks/validator/validator-vars.example.yml ~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml
    
  • Check first validator node address using:

    laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'echo $(laconicd cometbft show-node-id)@host.docker.internal:26656'
    
  • Update cerc_peers in ~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml:

    cerc_moniker: "LaconicMainnetNode-2"
    
    cerc_peers: "<node-id>@host.docker.internal:26656"
    
  • Export the data directory and mainnet deployment directory as environment variables:

    # Parent directory where the deployment directory will live
    export DATA_DIRECTORY=$CWD
    
    # Set mainnet deployment directory
    export MAINNET_DEPLOYMENT_DIR=mainnet-validator-deployment
    
  • Update port mappings in ~/cerc/laconicd-stack/playbooks/validator/templates/specs/spec-template.yml.j2 to avoid port conflicts with first validator node:

    network:
      ports:
        laconicd:
          - '3060:6060'
          - '36659:26659'
          - '36657:26657'
          - '36656:26656'
          - '3473:9473'
          - '3090:9090'
          - '3317:1317'
    
  • Run ansible playbook to set up your validator node deployment:

    ansible-playbook -v -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/setup-validator.yml
    
  • Create tmks config directory for second validator node

    tmkms init ./tmkms-second-node
    
  • Update the TMKMS configuration file ./tmkms-second-node/tmkms.toml:

    cat > ./tmkms-second-node/tmkms.toml << EOL
    [[chain]]
    id = "laconic-mainnet"
    key_format = { type = "cosmos-json", account_key_prefix = "laconicpub", consensus_key_prefix = "laconicvalconspub" }
    state_file = "$CWD/tmkms-second-node/state/priv_validator_state.json"
    
    [[validator]]
    chain_id = "laconic-mainnet"
    addr = "tcp://localhost:36659"
    secret_key = "$CWD/tmkms-second-node/secrets/kms-identity.key"
    protocol_version = "v0.34"
    reconnect = true
    
    [[providers.softsign]]
    key_type = "consensus"
    path = "$CWD/tmkms-second-node/secrets/priv_validator_key"
    chain_ids = ["laconic-mainnet"]
    EOL
    
  • Import the private validator key into tmkms:

    tmkms softsign import $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json $CWD/tmkms-second-node/secrets/priv_validator_key
    
  • Start TMKMS:

    tmkms start --config $CWD/tmkms-second-node/tmkms.toml
    
  • In a new terminal export envs

    export CWD=$(pwd)
    export DATA_DIRECTORY=$CWD
    export MAINNET_DEPLOYMENT_DIR=mainnet-validator-deployment
    
  • Enable TMKMS in the laconicd node configuration:

    echo "TMKMS_ENABLED=true" >> $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/config.env
    
  • Start the 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
    
  • Export required env vars for creating validator:

    # private key of another existing account with balance
    export PVT_KEY=<private-key-in-hex-format>
    
    # desired key name
    export KEY_NAME=validator-2
    
  • Run ansible playbook to create validator on running chain:

    ansible-playbook -v -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/create-validator.yml
    
  • Check the validator list:

    laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query staking validators'
    
  • 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
    
  • Copy the example variables file for cosmos-multisig app playbook:

    cp ~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/cosmos-multisig-vars.example.yml ~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/cosmos-multisig-vars.yml
    
    • Update env values in cosmos-multisig-vars.yml with your node RPC URL

      next_public_node_addresses: '["http://localhost:26657"]'
      node_rest_endpoint: 'http://localhost:1317'
      next_public_is_http_enabled: true
      
  • Set envs:

    # Set multisig app deployment directory
    export MULTISIG_DEPLOYMENT_DIR=cosmos-multisig-deployment
    # Set path to custom network JSON file
    export NETWORK_JSON_PATH=~/cerc/laconicd-stack/config/network.json
    
    # Set network mode to host so that browser app and backend can use the same node localhost RPC URL
    export USE_HOST_NETWORK=host
    
    # Set local host URL for dgraph server
    export DGRAPH_URL=http://localhost:8080/graphql
    
  • Run playbook to setup cosmos multisig app

    ansible-playbook -v -i localhost, -c local ~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/cosmos-multisig-app-start.yml
    
  • Check logs to ensure that the app is running:

    laconic-so deployment --dir $DATA_DIRECTORY/$MULTISIG_DEPLOYMENT_DIR logs -f
    
  • The app will be running on http://localhost:7000/laconic

Create a multisig with both the validator accounts

  • On opening the app, a prompt will be shown to add laconic network to you Keplr wallet. Click on Approve

  • Go to home and click on I don't have a multisig

  • Add the addresses of your validators as member 1 and member 2

  • Set the threshold to 2 out of 2 members (Both the validators should sign the TX to broadcast it)

  • Click on Submit and Create multisig

Create and sign transaction

  • Add accounts in Keplr wallet for signing the transaction

    • Open Keplr wallet and click on the user icon in the top right corner

    • Click on Add wallet, then select Import an existing wallet and go to Use recovery phrase or private key

    • Select the Private key tab and then paste the private key of the validator account and click on import

    • Set a name for the wallet (used when connecting wallet to app for signing transaction) and click on next

    • Search for Laconic network and select it, then click on Save

    • Follow the above steps for the second validator account

  • Send fund to the generated multisig address using Keplr

    • Open Keplr wallet and select the account from which you wish to transfer the funds to the multisig address

    • Search and laconic and select the network. Select Send and paste the multisig address and set amount to 0.000000000001 (1000000alnt)

  • Go to home, paste your multisig address and click on Use this multisig

  • You will see the multisig members and holdings for the address

  • Click on Create new transaction and then click on Bank Send under Add New Msg

  • Enter the recipient address ( Eg: laconic1n4wa366kh0zxndwyq3kkse9ulz9jv9xukx3hy4), amount to be transfered and memo (optional)

  • Click on create transaction

  • Go back to the multisig info page and scroll down to the Transactions section

  • Click on Verify identity and connect the app to your validator account in the Keplr wallet

  • After approving the connection, you will see the list of transactions created by your multisig

  • Click on your transaction and under Choose wallet to sign, click on connect Keplr

  • After connecting the wallet, click on Sign transaction and approve the transaction

  • Go back to multisig info page, switch to the second validator account in Keplr wallet and repeat the same process to sign the transaction with the second validator account

  • Once the transaction is signed by both the validators, click on Broadcast Transaction

  • Confirm funds transfer by checking balance of recipient address

    laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd "laconicd query bank balances laconic1n4wa366kh0zxndwyq3kkse9ulz9jv9xukx3hy4"
    

Cleanup

  • Remove deployments and other config files

    rm -rf *-spec.yml *-deployment tmkms-* output