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), Ubuntu 20.04lts server recommended
- 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)
sudo apt install build-essential
Install Additional Tools if required (if not using server edition)
sudo 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.17.linux-amd64.tar.gz sudo tar -C /usr/local -xzf go1.17.linux-amd64.tar.gz rm go1.17.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 ..
Get network config (if required)
cp zboxcli/network/one.yaml ~/.zcn/config.yaml
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://docs.docker.com/compose/install/ to get latest but here is process
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/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 https://beta.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)
* You should read this article before this step, if you want to mount physical hard drives to the created blobber paths *
./docker.local/bin/blobber.init.setup.sh
sudo docker network create --driver=bridge --subnet=198.18.0.0/15 --gateway=198.18.0.255 testnet0 sudo ./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)
sudo ../bin/blobber.start_bls.sh
#4 Service Provider Lock (Delegate) Tokens
NOTE:
When 0wallet app is released, this tutorial will be updated with a workflow that uses 0wallet app for token delegation. It is not recommended for users to use command line for these tasks with real tokens due to security risks of unprotected wallets.
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
Faucet a bunch of tokens to Delegate Wallet
for f in {1..50} ; do ./zwallet faucet --wallet delegate.json --methodName pour --input test ; done
Lock Tokens to Service Provider
./zbox sp-lock --wallet delegate.json --blobber_id $B1ID --tokens 50
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
#5 Configure SSL (No Video yet)
As Per instructions at https://github.com/0chain/blobber/blob/master/https/README.md
NOTE:
This assumes you have no other http(s) services already running on this server (via Apache, NGINX, Web Panel etc. running on ports 80 & 443). If you do, you will need to manually adjust and apply these for your particular environment.
Go to https folder
cd ~/blobber/https
Edit docker-compose.yml
nano docker-compose.yml
Replace <your_email>, <your_domain> with your email and domain. Ensure you have an A type record for your domain and ip address set up with your domain name service provider.
Deploy nginx and certbot using the following command
docker-compose up -d
Check certbot logs and see if certificate is generated. You will find “Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live//fullchain.pem” in the logs if the certificate is generated properly.
docker logs -f https_certbot_1
Edit /conf.d/nginx.conf to uncomment required locations in config for port 80. Uncomment all lines in server config for port 443 and comment locations which are not required. Don’t forget to replace <your_domain> with your domain.
nano ./conf.d/nginx.conf
e.g. Lines with bold are changes including uncommenting (removing #)
server { listen [::]:80; listen 80; location ~ /.well-known/acme-challenge { allow all; root /var/www/certbot; } location /blobber51/ { proxy_pass http://blobber1_blobber_1:5051/; } } server { listen [::]:443 ssl http2; listen 443 ssl http2; server_name <your_domain>; # # SSL code ssl_certificate /etc/nginx/ssl/live/<your_domain>/fullchain.pem; ssl_certificate_key /etc/nginx/ssl/live/<your_domain>/privkey.pem; # root /var/www/html; location /blobber51/ { proxy_pass http://blobber1_blobber_1:5051/; } }
Restart docker compose and you will be able to access blobbers over https.
docker-compose restart