Setting Up A Blobber on 0Chain Network

Here is a sequence of videos and corresponding instructions for the process of setting up a blobber on 0chain (betanet) network. This process is subject to change and specific settings will be need to be changed for mainnet in addition to requiring real tokens to be used.

Pre-Requisites

  • Ubuntu 18+ (or similar debian based distro)
  • Dedicated (static) IP address
  • Spare hdd space

NOTE#1: for that majority of these videos I am using a GUI on server because its more convenient. Usually GUIs are not installed on servers. In this instance, for file editing, nano or another command-line based editor is normally used.

NOTE#2: If you are logged in as root then the commands shown should be fine. If however, you are logged in as another user you will need to put sudo before some of these commands.

NOTE#3: This process is for standard ‘vanilla’ installation. It does not cover RHEL Centos flavours of Linux nor is not meant to allow for unusual setups. Please refer to Telegram SP group or community.0chain.net forum for discussion on non-standard issues.

#1 Setting up CLI tools, make, golang and building CLI tools

Install Build Tools (inc make)

apt install build-essential

Install Additional Tools if required (if not using server edition)

apt install git nano jq htop

Setup Golang – As per instructions on https://golang.org/ to get latest but here is process

wget https://golang.org/dl/go1.15.2.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.15.2.linux-amd64.tar.gz
rm go1.15.2.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version

Create .zcn folder

mkdir ~/.zcn

Fetch Zboxcli

git clone https://github.com/0chain/zboxcli.git

Build Zboxcli

cd zboxcli ; make install ; cp zbox ~/.zcn ; cd ..

Fetch Zwalletcli

git clone https://github.com/0chain/zwalletcli.git

Build Zwalletcli

cd zwalletcli ; make install ; cp zwallet ~/.zcn ; cd ..

Go to .zcn folder

cd ~/.zcn

Get Balance/Create Wallet

./zwallet getbalance

or

./zwallet getbalance --wallet walletname.json

Faucet Tokens

./zwallet faucet --input test --methodName pour

 

#2 Install Docker Tools, Fetch Blobber Repo

 

Setup Docker – As per instructions on https://www.docker.com/ to get latest but here is process

sudo apt install docker.io -y
sudo systemctl enable --now docker
docker --version

Setup Docker-Compose – As per instructions on https://www.docker.com/ to get latest but here is process

sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version

Fetch Blobber Repo – As per instructions on https://www.github.com/0chain/blobber

git clone https://github.com/0chain/blobber.git

 

#3 Configure Blobber and Delegate

 

Although the video is in a slightly different order, I recommend the following process:-

Create a wallet for (each) blobber. The keys generated in the wallet json file. You will need the public and private keys to put in the blobber node keys file(s)

Recommended to specify –wallet blobber1.json with zbox and zwallet commands to keep this distinct

Create a wallet to delegate from. We need to specify this in vaidator and blobber config files.

Recommended to specify –wallet delegate.json with zbox and zwallet commands to keep this distinct

Example commands used:-

Go to .zcn folder

cd ~/.zcn

Create blobber wallet

./zwallet getbalance --wallet blobber1.json

Create delegate wallet

./zwallet getbalance --wallet delegate.json

Faucet Tokens

./wallet faucet --input test --methodName pour --wallet delegate.json

Example Wallet JSON

{
"client_id":"1e6b47cf8a71b3e75a1adc0cf3dd5347aea9cb0bd812c9e93ab745872d9b6977",
"client_key":"a35d60b0a7060d2e71b136ae49ef1f034808d9b3c3b6bfbedf90795605e12915c412d764bac8a2b16a9975e1a205351f321229f64aef00a84a07c13ad5782a17",
"keys":[
{"public_key":"a35d60b0a7060d2e71b136ae49ef1f034808d9b3c3b6bfbedf90795605e12915c412d764bac8a2b16a9975e1a205351f321229f64aef00a84a07c13ad5782a17",
"private_key":"8fb8a49b9f985551b08b79ecae2768e65c64155fdd928c8feb1674f0f11f000a"}],
"mnemonics":"join notable arrow ride observe skate below slush exact joy vocal rocket pass behind boss half sweet magic oil eight discover helmet reduce diamond",
"version":"1.0",
"date_created":"2020-10-06 13:54:06.225134277 +0100 BST m=+0.366130385"
}

The client_id, in this example
1e6b47cf8a71b3e75a1adc0cf3dd5347aea9cb0bd812c9e93ab745872d9b6977
is the wallet id. This is used to indentify the delegate wallet

The public key, in this example:-
a35d60b0a7060d2e71b136ae49ef1f034808d9b3c3b6bfbedf90795605e12915c412d764bac8a2b16a9975e1a205351f321229f64aef00a84a07c13ad5782a17
is the first line of the node keys config file

the private key, in this example:-
8fb8a49b9f985551b08b79ecae2768e65c64155fdd928c8feb1674f0f11f000a
is the second line of the node keys config file

Alternatively, you can extract and display the values using jq JSON command line utility:-

DELID=$(jq -r .client_id delegate.json)
B1ID=$(jq -r .client_id blobber1.json)
B1PRIVKEY=$(jq -r .keys[].private_key blobber1.json)
B1PUBKEY=$(jq -r .keys[].public_key blobber1.json)
echo "DELID" $DELID
echo "B1ID" $B1ID
echo "B1PUBKEY" $B1PUBKEY
echo "B1PRIVKEY" $B1PRIVKEY

As per instructions on https://www.github.com/0chain/blobber

Change in docker.local/b0docker-compose.yml (Note my instructions in video showed p0docker-compose.yml but b0docker-compose.yml was one actually edited)

  • Change localhost to Your.IP.ad.dy (or url)
  • custom file paths can also be specified if required

Changes in both config files, config/0chain_blobber.yaml & config/0chain_validator.yaml (on video I may have only showed editing blobber config)

  • Change block_worker from http://198.18.0.98:9091 to http://one.devnet-0chain.net/dns (will change at mainnet)
  • Change service_charge accordingly (maximum is 0.5)
  • Set delegate_wallet to primary wallet id that you will be using to fund this blobber
  • Increase handlers: (per second) rate_limit from 10 to a higher figure depending on setup, (recommended 100 for a high capacity blobber)
  • Also, read_price, write_price, capacity etc. are all configurable in here

Changes in docker.local/keys_config/b0bnode1_keys.txt (for blobber1 – blobber2 would be b0bnode2_ etc.)

<PUBKEY>
<PRIVKEY>
localhost
5051

Make sure port 5051 (505x for multiple blobbers) is not blocked by your firewall!

Setup, Config testnet0 and build blobber(s)

./docker.local/bin/blobber.init.setup.sh
docker network create --driver=bridge --subnet=198.18.0.0/15 --gateway=198.18.0.255 testnet0
./docker.local/bin/build.blobber.sh

Go to blobber folder

cd docker.local/blobber1

Start The Blobber!
(Alternatively, there is a p0blobber.start.sh option for remote image)

../bin/blobber.start_bls.sh

 

#4 Service Provider Lock (Delegate) Tokens

 

Tokens are fauceted and locked to the blobber using zbox sp-lock. Then the blobber should be active and able to accept uploads. Specify in preferred blobbers in config.yaml file

Some of these commands relating to allocation and upload are performed on a local machine using the default wallet (wallet.json) so no –wallet parameter is specified

Go to .zcn folder

cd ~/.zcn

Lock Tokens to Service Provider

./zbox sp-lock --wallet delegate.json --blobber_id <blobber1_id> --tokens XX

Check Locked Tokens of Blobber

./zbox sp-info --wallet blobber1.json

Faucet Tokens –

./zwallet faucet --input test --methodName pour

Create Allocation

./zbox newallocation --lock xx

List Allocations

./zbox listallocations

Read Allocation

./zbox get --allocation <allocationid>

Upload File

./zbox upload --allocation <allocationid> --remotepath /file --localpath file