# Install und, Cosmovisor and optionally Sync using statesync


This guide is for fresh node installations. For existing nodes migrating to cosmovisor, please see the Migrations documentation.

Combining cosmovisor and statesync, it is possible to sync the chain in a short amount of time. Additionally, installing and configuring cosmovisor will make future updates much simpler.

This guide will cover both a full sync from genesis, and also configuring statesync.

# 1. Download the genesis version of und, initialise & configure

Fist, download the und version for genesis:

mkdir -p $HOME/tmp && cd $HOME/tmp
wget https://github.com/unification-com/mainchain/releases/download/1.5.1/und_v1.5.1_linux_x86_64.tar.gz
tar -zxvf und_v1.5.1_linux_x86_64.tar.gz

Initialise the node

./und init [NODE_MONIKER]

Download genesis.json


Please ensure you download the correct genesis for the network you would like to join! Remember to change the output directory in the command below if you are using something other than the default $HOME/.und_mainchain directory!

To spin up your new node, download the latest genesis.json for the network you would like to join:

    Get the seed nodes


    Please ensure you get the correct seed node information for the network you would like to join! Remember to change the directory if you are using something other than the default $HOME/.und_mainchain directory! For this guide, we are using /mnt/disks/data/.und_mainchain for the node's home directory.

    Your node will need to know at least one seed node in order to join the network and begin P2P communication with other nodes in the network. The latest seed information will always be available at each network's respective Github repo:

    Go to the repo for the network you are connecting to and copy one or more of the seed nodes (you only need the [email protected]:port)

    Edit your node configuration file using nano:

    nano /path/to/.und_mainchain/config/config.toml

    Hit Ctrl+W, type [p2p] (including the square brackets) and hit return - this will take you to the [p2p] section of the config file, which begins with:

    ##### peer to peer configuration options #####

    Find the seeds = "" variable about 12 lines below, and add the seed node information between the double quotes (comma separated, no spaces if more than one). For example:

    seeds = "[email protected]:port"

    Set gas-prices

    It is good practice to set the minimum-gas-prices value in $HOME/.und_mainchain/config/app.toml, in order to protect your full node from spam transactions. This should be set as a decimal value in nund, and the recommended value is currently 25.0nund. This means your node will ignore any Txs with a gas price below this value. To do so, open up $HOME/.und_mainchain/config/app.toml in a text editor, and set minimum-gas-prices

    nano $HOME/.und_mainchain/config/app.toml


    minimum-gas-prices = ""

    To, for example:

    minimum-gas-prices = "25.0nund"

    Hit Ctrl+X followed by y and then return to save the file and exit nano.

    # 2. Install & Configure Cosmovisor

    Next, install cosmovisor

    mkdir $HOME/tmp && cd $HOME/tmp
    wget https://github.com/cosmos/cosmos-sdk/releases/download/cosmovisor%2Fv1.2.0/cosmovisor-v1.2.0-linux-amd64.tar.gz
    tar -zxvf cosmovisor-v1.2.0-linux-amd64.tar.gz
    sudo mv cosmovisor /usr/local/bin/cosmovisor

    # 2.1 Set up cosmovisor directory structure

    Create the directory structure for the und binaries and updates

    # und v1.5.1 -> genesis:

    mkdir -p $HOME/tmp && cd $HOME/tmp
    wget https://github.com/unification-com/mainchain/releases/download/1.5.1/und_v1.5.1_linux_x86_64.tar.gz
    tar -zxvf und_v1.5.1_linux_x86_64.tar.gz
    mkdir -p $HOME/.und_mainchain/cosmovisor/genesis/bin
    mv und $HOME/.und_mainchain/cosmovisor/genesis/bin
    $HOME/.und_mainchain/cosmovisor/genesis/bin/und version --log_level=""

    # und v1.6.x -> 1-init_ibc update


    Upgrade plan names for und v1.6.x:
    MainNet: 1-init_ibc
    TestNet: 1-ibc

    The upgrade plan name determines the directory path that und v1.6.x will be installed in!


      Skip to section 2.2 Create cosmovisor environment file below if you intend to run a full chain sync from genesis!

      Create the upgrade-info.json:

        # 2.2 Create cosmovisor environment file

        Create an environment variable file which will load into the systemd service, modifying /FULL/PATH/TO/ as required:

        tee $HOME/.und_mainchain/cosmovisor/UND_COSMOVISOR_ENV > /dev/null <<EOF

        # 2.3 Point Cosmovisor to the latest und


        Skip to section 3. Set up the systemd service below if you intend to run a full chain sync from genesis!

        Next, cosmovisor's current link needs to point to the latest version of und, e.g.:

        cd $HOME/.und_mainchain/cosmovisor
        rm current

          # 3. Set up the systemd service

          Create a systemd service file, replacing USERNAME as required:

          sudo tee /etc/systemd/system/und.service > /dev/null <<EOF
          Description=Unification Mainchain Node 
          ExecStart=/usr/local/bin/cosmovisor run start

          Reload systemd:

          sudo systemctl daemon-reload

          # 4. Configure and test statesync


          Skip to the section 5. Start the systemd service if you intend to run a full sync from genesis!

          Cosmos SDK >= 0.42, which is used by the latest und software, can use State Syncing from Snapshots to quickly sync your node from a safe checkpoint. This potentially reduces the sync time to no more than an hour or so, and in most cases mere minutes.

          Setting this up requires a few more steps

          1. Run the following command to get the latest block hash and height:

            Example output:

            1. Using the output from the above command, configure [statesync] section in .und_mainchain/config.toml:
            enable = true
            rpc_servers = "TWO_RPC_NODES"
            trust_height = 1052423
            trust_hash = "820275B5EE63EDA2923886A01C0B1196A7CE1D96A89FA0D774942999C6698AAC"
            trust_period = "168h0m0s"
            discovery_time = "30s"
            temp_dir = ""
            chunk_request_timeout = "60s"
            chunk_fetchers = "4"

            The rpc_servers requires two RPC nodes for verification. Replace TWO_RPC_NODES with:


              rpc_servers = "sync1.unification.io:26657,sync2.unification.io:26657"

              Or any RPC servers of your choice for the target network.

              1. Start your node
              und start --home=/path/to/.und_mainchain

              you should start seeing the following:

              11:53AM INF Discovered new snapshot format=1 hash="V0���&�U1�J0�yP4A%�/���GŽ@\x05�<�j" height=1051600 module=statesync

              After a few seconds (or at most, minutes), you should see your node start downloading the blocks:

              11:56AM INF received proposal module=consensus proposal={"Type":32,"block_id":{"hash":"632E122ADDF385954FB8598FEE7D89EB09D7E93746FB36D2F12DECFEB7F07D9E","parts":{"hash":"E8246C504B9BC14275874A90C95E6AA035678302AD3BF9269B6F253B04C038BE","total":1}},"height":1052494,"pol_round":-1,"round":0,"signature":"HYJz0rV7o6bNm7za82sj1Az1rV25qVkLh9Y4s0K95nf86uVq+YmuDIf3LtIP7pDfFEYErxNVyeSplPGh7IVHDQ==","timestamp":"2022-05-19T10:56:03.273030584Z"}
              11:56AM INF received complete proposal block hash=632E122ADDF385954FB8598FEE7D89EB09D7E93746FB36D2F12DECFEB7F07D9E height=1052494 module=consensus
              11:56AM INF finalizing commit of block hash=632E122ADDF385954FB8598FEE7D89EB09D7E93746FB36D2F12DECFEB7F07D9E height=1052494 module=consensus num_txs=0 root=7EC77102840743503BD71FD89F60FD0B912DD0DE27575408B6AD67990CE4A6B8
              11:56AM INF executed block height=1052494 module=state num_invalid_txs=0 num_valid_txs=0
              11:56AM INF commit synced commit=436F6D6D697449447B5B3234312031333020323235203834203837203234372031303220323820323435203234382032372032303920313432203133372031303620353920343520323220323020313737203135342032303320323338203136352030203231322034392031383620313638203433203839203233395D3A3130304634457D
              11:56AM INF committed state app_hash=F182E15457F7661CF5F81BD18E896A3B2D1614B19ACBEEA500D431BAA82B59EF height=1052494 module=state num_txs=0
              11:56AM INF indexed block height=1052494 module=txindex

              Hit ctrl+c to stop und

              # 5. Start the systemd service

              Start the und as a background service:

              sudo systemctl start und
              sudo journalctl -u und -f