Skip to main content

Airchains

Installation

tip

You should update the MONIKER, WALLET, and PORT variables in the Setting up environment variables section. Make sure the port you specify is not already in use.

Check for ports already in use by visually inspecting the output of the lsof -i -P -n | grep LISTEN command. Almost all Cosmos chain nodes use ports xx317, xx656, xx657, and xx090. Therefore, avoid using ports starting with xx if they are already occupied.

Update OS

sudo apt update && sudo apt upgrade -y

Installation of required packages

sudo apt install curl git wget htop tmux build-essential jq make lz4 gcc unzip jq -y

Installation of go (if you need)

cd ~
VER="1.21.6" # Make sure that this version does not broke any other apps you run!
wget "https://golang.org/dl/go$VER.linux-amd64.tar.gz"
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf "go$VER.linux-amd64.tar.gz"
rm "go$VER.linux-amd64.tar.gz"
[ ! -f ~/.bash_profile ] && touch ~/.bash_profile
echo "export PATH=$PATH:/usr/local/go/bin:~/go/bin" >> ~/.bash_profile
source $HOME/.bash_profile
[ ! -d ~/go/bin ] && mkdir -p ~/go/bin

Setting up environment variables

echo "export WALLET="wallet"" >> $HOME/.bash_profile
echo "export MONIKER="NGSolutionsWASHERE"" >> $HOME/.bash_profile
echo "export AIRCHAINS_CHAIN_ID="junction"" >> $HOME/.bash_profile
echo "export AIRCHAINS_PORT="13"" >> $HOME/.bash_profile
source $HOME/.bash_profile

Downloading and installing node

cd $HOME
wget -O junctiond https://github.com/airchains-network/junction/releases/download/v0.1.0/junctiond
chmod +x junctiond
mv junctiond $HOME/go/bin/

Initializing the node

junctiond init $MONIKER --chain-id $AIRCHAINS_CHAIN_ID
sed -i -e "s|^node *=.*|node = \"tcp://localhost:${AIRCHAINS_PORT}657\"|" $HOME/.junction/config/client.toml

Downloading genesis and addressbook

cd $HOME
curl https://junction.rpc.ngsolutions.xyz/genesis? | jq ".result.genesis" > .junction/config/genesis.json
wget -O $HOME/.junction/config/addrbook.json https://snapshots.ngsolutions.xyz/addrbook/airchains/addrbook.json

Setting seeds and peers

PEERS="11dbcb884666395524db7f5af26a9101aff51982@11dbcb884666395524db7f5af26a9101aff51982:43456,1a91c08b0154512ca28f32a04c6d52b0bc0a5d68@1a91c08b0154512ca28f32a04c6d52b0bc0a5d68:43456,ebaa262c9e6930152a05d66d2880898d330efd5c@ebaa262c9e6930152a05d66d2880898d330efd5c:43456,cc27f4e54a78b950adaf46e5413f92f5d53d2212@cc27f4e54a78b950adaf46e5413f92f5d53d2212:43456,eabd6509b8cce372e42eeb4c62fb530781b42bd8@eabd6509b8cce372e42eeb4c62fb530781b42bd8:63656,e2c7580464314c9d5d6972bef182d964ba39c519@e2c7580464314c9d5d6972bef182d964ba39c519:43456,68e01ac90e591cea46bad76c4fcb59c3bf21c01c@68e01ac90e591cea46bad76c4fcb59c3bf21c01c:43456,dd6d2a51fd1415045f4956e6a4948b9c7fb475e7@dd6d2a51fd1415045f4956e6a4948b9c7fb475e7:43456,56339f22f1d4cc633d7d442e10a714e561148721@56339f22f1d4cc633d7d442e10a714e561148721:43456,d972afc6c6327ba783ed3147dcc29293667cfb70@d972afc6c6327ba783ed3147dcc29293667cfb70:43456"
sed -i -e "s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.junction/config/config.toml

Setting custom ports

Updating ports in app.toml

sed -i.bak -e "s%:1317%:${AIRCHAINS_PORT}317%g;
s%:8080%:${AIRCHAINS_PORT}080%g;
s%:9090%:${AIRCHAINS_PORT}090%g;
s%:9091%:${AIRCHAINS_PORT}091%g;
s%:8545%:${AIRCHAINS_PORT}545%g;
s%:8546%:${AIRCHAINS_PORT}546%g;
s%:6065%:${AIRCHAINS_PORT}065%g" $HOME/.junction/config/app.toml

Updating ports in config.toml

sed -i.bak -e "s%:26658%:${AIRCHAINS_PORT}658%g;
s%:26657%:${AIRCHAINS_PORT}657%g;
s%:6060%:${AIRCHAINS_PORT}060%g;
s%:26656%:${AIRCHAINS_PORT}656%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${AIRCHAINS_PORT}656\"%;
s%:26660%:${AIRCHAINS_PORT}660%g" $HOME/.junction/config/config.toml

Configuring pruning settings

sed -i -e "s/^pruning *=.*/pruning = \"custom\"/" $HOME/.junction/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" $HOME/.junction/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"50\"/" $HOME/.junction/config/app.toml

Setting gas and other configurations

sed -i 's|minimum-gas-prices =.*|minimum-gas-prices = "0.0025ujunction"|g' $HOME/.junction/config/app.toml
sed -i -e "s/prometheus = false/prometheus = true/" $HOME/.junction/config/config.toml
sed -i 's/max_num_inbound_peers =.*/max_num_inbound_peers = 50/g' $HOME/.junction/config/config.toml
sed -i 's/max_num_outbound_peers =.*/max_num_outbound_peers = 50/g' $HOME/.junction/config/config.toml
sed -i -e "s/^indexer *=.*/indexer = \"null\"/" $HOME/.junction/config/config.toml

Creating service file

sudo tee /etc/systemd/system/junctiond.service > /dev/null <<EOF
[Unit]
Description=Airchains Node
After=network-online.target
[Service]
User=$USER
WorkingDirectory=$HOME/.junction
ExecStart=$(which junctiond) start --home $HOME/.junction
Restart=on-failure
RestartSec=5
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF

Snapshot

danger

Important: Back Up Your Validator Key

Before resetting your node, ensure you have a backup of your priv_validator_key.json file. This is especially important if you've already created a validator. Without a backup, resetting the node will result in lost access and require you to create a new validator from scratch.

info

This script creates a copy of your priv_validator_state.json and priv_validator_key.json files. It then copies the original private files back after downloading the snapshot. However, use this script with caution to avoid any potential failures.

  1. Create Backups of Private Files.

    cp $HOME/.junction/data/priv_validator_state.json $HOME/priv_validator_state.json.junction.backup
    cp $HOME/.junction/config/priv_validator_key.json $HOME/priv_validator_key.json.junction.backup
  2. Reset Node and Download Snapshot

    junctiond tendermint unsafe-reset-all --home $HOME/.junction --keep-addr-book
    curl https://snapshots.ngsolutions.xyz/snapshots/junction/snap_junction.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.junction
  3. Restore Backed Up Files

    cp $HOME/priv_validator_state.json.junction.backup $HOME/.junction/data/priv_validator_state.json
    cp $HOME/priv_validator_key.json.junction.backup $HOME/.junction/config/priv_validator_key.json

Enabling and starting the service.

# You need to inspect logs visually after the  to make sure that it is working
sudo systemctl daemon-reload
sudo systemctl enable junctiond
sudo systemctl restart junctiond && sudo journalctl -u junctiond -f

Creating a wallet

You need to create or import a wallet to request test tokens. If you dont have any tokens, you will not be able to create a validator.

# Following command creates a new wallet.
# Copy mnemonics to a safe place
# If you lost your mnemonics you will not be able to recover this wallet.
junctiond keys add $WALLET

# If you want to import a wallet using mnemonics, execute following command and enter your mnemonics
junctiond keys add $WALLET --recover

# Get your keys and their addresses to request faucet
junciond keys list

Creating a validator

Before you begin:

It's crucial to ensure your node is synchronized with the network before attempting to create a validator. This ensures your validator operates with the latest blockchain data.

Checking Synchronization Status:

Use the following snippet to check your node's synchronization status. If the snippet returns false, your node is in sync and ready to proceed. However, if it returns true, your node is still catching up. In that case, please wait until the synchronization completes before creating a validator.

junctiond status | jq -r .sync_info.catching_up

Creating a Validator:

The following snippet will create a validator.json file in your node's home directory. This file stores the details necessary to create your validator. While you can edit the validator.json file later, keep in mind that doing so may incur token fees. Therefore, it's important to ensure the information within the file is accurate before proceeding.

cd $HOME
# Create validator.json file
echo "{
\"pubkey\":{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"$(junctiond comet show-validator | grep -Po '\"key\":\s*\"\K[^"]*')\"},
\"amount\": \"1000000amf\",
\"moniker\": \"NGSolutionsWasHere\",
\"identity\": \"\",
\"website\": \"\",
\"security\": \"\",
\"details\": \"All heil NGSolutions\",
\"commission-rate\": \"0.1\",
\"commission-max-rate\": \"0.2\",
\"commission-max-change-rate\": \"0.01\",
\"min-self-delegation\": \"1\"
}" > .junction/validator.json

Next Steps:

Once you're satisfied with the contents of validator.json, you can proceed with creating the validator using the information stored within the file.

# Create a validator using the JSON configuration
junctiond tx staking create-validator validator.json \
--from $WALLET \
--chain-id $AIRCHAINS_CHAIN_ID \
--fees 200amf

Delegate to yourself

You might need to update number of tokens before executing the following command.

junctiond tx staking delegate \
$(junctiond keys show $WALLET --bech val -a) 1900000amf \
--from $WALLET \
--chain-id $AIRCHAINS_CHAIN_ID \
--fees=5000amf

Deleting the node completely (if you need)

danger

Make sure that you backed up any required files to setup later! Do not lost your validator or wallet!

sudo systemctl stop junctiond
sudo systemctl disable junctiond
sudo rm -rf /etc/systemd/system/junctiond.service
sudo rm $(which junctiond)
sudo rm -rf $HOME/.junction
sed -i "/AIRCHAINS_/d" $HOME/.bash_profile