Skip to main content

Hedgeblock

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.5" # Make sure that this version does not broke any other apps you run!
wget "https://golang.org/dl/go$VER.linux-amd64.tar.gz"
rm -rf /usr/local/go
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 HEDGE_CHAIN_ID="berberis-1"" >> $HOME/.bash_profile
echo "export HEDGE_PORT="11"" >> $HOME/.bash_profile
source $HOME/.bash_profile

Downloading and installing node

info

If you have any other node that requires a different version of libwasmvm, you may break it! For instance, MANTRA chain requires libawasm v1.3.1. Please be careful!

cd $HOME
wget -O hedged https://github.com/hedgeblock/testnets/releases/download/v0.1.0/hedged_linux_amd64_v0.1.0 &&\
chmod +x hedged &&\
if [ ! -d "$HOME/go/bin" ]; then
mkdir -p $HOME/go/bin
fi
mv $HOME/hedged $HOME/go/bin
set -eux; \
wget -O /lib/libwasmvm.x86_64.so https://github.com/CosmWasm/wasmvm/releases/download/v1.3.0/libwasmvm.x86_64.so

Initializing the node

hedged init $MONIKER --chain-id $HEDGE_CHAIN_ID
sed -i -e "s|^node *=.*|node = \"tcp://localhost:${HEDGE_PORT}657\"|" $HOME/.hedge/config/client.toml

Downloading genesis and addressbook

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

Setting seeds and peers

PEERS="e7aff3d8f642b693f1619218e37ba86dc4c09549@e7aff3d8f642b693f1619218e37ba86dc4c09549:26656,94a344d15dbb4a2510f91c48a877c1a2ae038107@94a344d15dbb4a2510f91c48a877c1a2ae038107:27656,eb4a3c7cd6baa8d249d8f8300004f9eb85bb13c7@eb4a3c7cd6baa8d249d8f8300004f9eb85bb13c7:12656,70f7dc74d3b6afa12b988d61707229e8e191d9a2@70f7dc74d3b6afa12b988d61707229e8e191d9a2:55656,a5ce7811bc2a19e20b7ce1da0635f738ed9969ac@a5ce7811bc2a19e20b7ce1da0635f738ed9969ac:26656,b2a0bfb93d98e62802ec21eac60eaf11f17354d8@b2a0bfb93d98e62802ec21eac60eaf11f17354d8:11856,7717ea3ed671e0da76ba35a05a9c7c24c8176f83@7717ea3ed671e0da76ba35a05a9c7c24c8176f83:2656,ade303649081d98ab8ab0287530afee607d5b95b@ade303649081d98ab8ab0287530afee607d5b95b:26656,e2d9a1e7d0c5283316094d4d9f289a29d9712b89@e2d9a1e7d0c5283316094d4d9f289a29d9712b89:11856,dfec7fba6ed36a9e46d70d59dd4d038e3f9d4cfc@dfec7fba6ed36a9e46d70d59dd4d038e3f9d4cfc:11856"
sed -i -e "s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.hedge/config/config.toml

Setting custom ports

Updating ports in app.toml

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

Updating ports in config.toml

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

Configuring pruning settings

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

Setting gas and other configurations

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

Creating service file

tee /etc/systemd/system/hedged.service > /dev/null <<EOF
[Unit]
Description=Hedgeblock Node
After=network-online.target
[Service]
User=$USER
WorkingDirectory=$HOME/.hedge
ExecStart=$(which hedged) start --home $HOME/.hedge
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/.hedge/data/priv_validator_state.json $HOME/priv_validator_state.json.hedge.backup
    cp $HOME/.hedge/config/priv_validator_key.json $HOME/priv_validator_key.json.hedge.backup
  2. Reset Node and Download Snapshot

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

    cp $HOME/priv_validator_state.json.hedge.backup $HOME/.hedge/data/priv_validator_state.json
    cp $HOME/priv_validator_key.json.hedge.backup $HOME/.hedge/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 hedged
sudo systemctl restart hedged && journalctl -u hedged -f --no-hostname -o cat

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.
hedged keys add $WALLET

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

# Get your keys and their addresses to request faucet
hedged 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.

hedged 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\":\"$(hedged comet show-validator | grep -Po '\"key\":\s*\"\K[^"]*')\"},
\"amount\": \"1000000uhedge\",
\"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\"
}" > .hedge/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
hedged tx staking create-validator validator.json \
--from $WALLET \
--chain-id $HEDGE_CHAIN_ID \
--fees 500uhedge

Delegate to yourself

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

hedged tx staking delegate \
$(hedged keys show $WALLET --bech val -a) 2000000uhedge \
--from $WALLET \
--chain-id $HEDGE_CHAIN_ID \
--fees=500uhedge

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 hedged
sudo systemctl disable hedged
rm -rf /etc/systemd/system/hedged.service
rm $(which hedged)
rm -rf $HOME/.hedge
sed -i "/hedge_/d" $HOME/.bash_profile