Skip to main content

Hedgeblock

Endpoints

APIRPCgRPC
hedge.api.kgnodes.xyzhedge.rpc.kgnodes.xyzhedge.grpc.kgnodes.xyz:11094

Explorer: https://explorer.kgnodes.xyz/hedgetestnet

Installation

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 -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="yourmoniker"" >> $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

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
sudo wget -O $HOME/.hedge/config/genesis.json "http://37.120.189.81/hedge_testnet/genesis.json"
sudo wget -O $HOME/.hedge/config/addrbook.json "http://37.120.189.81/hedge_testnet/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

Creating service file

sudo tee /etc/systemd/system/hedged.service > /dev/null <<EOF
[Unit]
Description=Hedged Node
After=network-online.target
[Service]
User=$USER
ExecStart=$(which hedged) start
Restart=always
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF

Enabling and starting the service

sudo systemctl daemon-reload
sudo systemctl enable hedged
sudo systemctl restart hedged && journalctl -u hedged -f --no-hostname -o cat

Snapshot

Make sure to back up your priv_validator_key.json file if you've already created a validator! Resetting your node without a backup will cause you to lose access and require creating a new validator from scratch. Be careful!

The following snippets create a copy of your priv_validator_state.json and priv_validator_key.json files. Then, it copies the old private files back after copying the snapshot files. However, you should execute these commands with caution to prevent any kind of failure!

# If you want to apply this snap after installing the node, first stop the node using following command
systemctl stop hedged

cp $HOME/.hedge/data/priv_validator_state.json $HOME/.hedge/priv_validator_state.json.backup
cp $HOME/.hedge/config/priv_validator_key.json $HOME/.hedge/config/priv_validator_key.key.backup

hedged tendermint unsafe-reset-all --home $HOME/.hedge --keep-addr-book
curl https://snapshot.kgnodes.xyz/snapshot/hedge/snap_hedge.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.hedge


cp $HOME/.hedge/priv_validator_state.json.backup $HOME/.hedge/data/priv_validator_state.json
cp $HOME/.hedge/config/priv_validator_key.json.backup $HOME/.hedge/config/priv_validator_key.key

# If you applied this snap after installing the node, then you can restart your node using following command
# Also visually inspect your logs. Your node is started to work again.

systemctl start 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:

hedged tx staking create-validator \
--amount 1000000uhedge \
--pubkey $(hedged tendermint show-validator) \
--chain-id berberis-1 \
--min-self-delegation 1 \
--commission-max-change-rate 0.01 \
--commission-max-rate 0.2 \
--commission-rate 0.05 \
--moniker "" \
--identity "" \
--details "" \
--website "" \
--security-contact "" \
--from "wallet" \
--fees 500uhedge \
-y

Edit Validator:

hedged tx staking edit-validator \
--chain-id berberis-1 \
--commission-rate 0.05 \
--new-moniker "" \
--identity "" \
--details "" \
--website "" \
--security-contact "" \
--from "wallet" \
--fees 500uhedge \
-y

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

Unjail Validator

hedged tx slashing unjail --from wallet --chain-id=berberis-1 --gas-prices=0.025uhedge --gas-adjustment=1.5 --gas=auto -y 

Deleting the node completely (if you need)

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