How to setup a Klever node

How to setup a Klever node
Klever Finance is a trusted permissioned blockchain network for the emerging decentralized economy, providing a safer, faster and smarter cryptocurrency experience for all users globally to enter and thrive.

This is the official description Klever Finance at their web.

Nowadays there are a lot of devlopments around crypto. Every day, a handful of projects start, why we think Klever is interesting?

Klever has been born strong from beginning: token, blockchain, mobile app, wallet, exchange. That is a nice foundation to build decentralized apps.

To run a node you need at least this hardware:

  • At least a quad core cpu (not too old)
  • At least 8 GB of ram
  • A fast ssd with at lease 200 GB free space
  • 100 mbps, stable, Internet connection
  • GNU/Linux or Mac OS. Select your flavour.                                              

If you are Windows guy, WSL2 (Windows Services for Linux) is also supported.

Whatever you choose, you also will need Docker engine to run a Klever node.

First step is to deploy latest docker (tip: avoid using root account, just create a regular user just for this):

docker pull kleverapp/klever-go-testnet:latest

Next step is getting a wallet. Lets first create a directory to host it

cd $HOME
mkdir wallet

And now we tell docker to populate that directory with the wallet:

docker run -it --rm --user "$(id -u):$(id -g)" ‌‌-v $(pwd)/wallet:/opt/klever-blockchain ‌‌--entrypoint=/usr/local/bin/operator ‌‌kleverapp/klever-go-testnet:latest account create

Your wallet should be generated with the previous command. You can always check your wallet public key with this other command:

docker run -it --rm --user "$(id -u):$(id -g)" ‌‌-v $(pwd)/wallet:/opt/klever-blockchain ‌‌--entrypoint=/usr/local/bin/operator ‌‌kleverapp/klever-go-testnet:latest account address

We have a wallet now. Ok, let's run a node. First, we are going to create a proper directory tree

cd $HOME
mkdir -p $(pwd)/node/config $(pwd)/node/db $(pwd)/node/logs

Now, let´s download genesis file

curl -k https://backup.testnet.klever.finance/config.testnet.100008.tar.gz | tar -xz -C ./node
Tip: this is just a testnet, but still, always is a good idea to check the checksum of everything downloaded from the net.

Next step is to run a command inside the docker container to create wallets for validators. The data is then sent to the directory created previously.

docker run -it --rm -v $(pwd)/node/config:/opt/klever-blockchain --user "$(id -u):$(id -g)" --entrypoint='' kleverapp/klever-go-testnet:latest keygenerator

To start fast with our new shiny node, is a good idea to download a backup of the chain:

curl -k https://backup.testnet.klever.finance/kleverchain.latest.tar.gz | tar -xz -C ./node
Tip: If you desire, select a fixed port for p2p traffic in $HOME/klever/node/config.toml . Open that p2p port (tcp) to Internet.

We are set. Let's run our node!

docker run -it --rm --user "$(id -u):$(id -g)" --name klever-node -v $(pwd)/node/config:/opt/klever-blockchain/config/node -v $(pwd)/node/db:/opt/klever-blockchain/db -v $(pwd)/node/logs:/opt/klever-blockchain/logs --network=host --entrypoint=/usr/local/bin/validator kleverapp/klever-go-testnet:latest '--log-save' '--rest-api-interface=0.0.0.0:8080'

This node software has a really nice TUI (Terminal User interface):

Ok, we have our node running. Check logs to see if everything is working properly, good peer connectivity. Also check that API port (8080) is only available for you & your monitoring enviroment.

We have checked that our first execution has been sucessful. Let's then run the node in the background, adding -d parameter to docker. You can check logs of a background docker

docker logs -f --tail 50 klever-node

If you need to stop a node (not too much time!!!), run this

docker stop klever-node

To make a backup of the database folder, stop the node with the previous command and run this:

tar -czvf backup_current_date.tar.gz $(pwd)/node/db
Tip: just use gz compression. Your node should be stopped as minimum as possible. You always can compress with a stronger compressor once you have the .tar.gz. zstd is a nice tradeoff between speed and size. If you are hardcore (like me) about size, try with  xz / zpaq / cmix

Sometimes, new versions of Klever are released. Just stop your running node, make a backup (just in case) and then upgrade your bits:

docker pull kleverapp/klever-go-testnet:latest