How To Set Up A Hive Witness Using HIAB At Version 1.24.4

in HiveDevs16 days ago


Used With Permission From @someguy123

Because @someguy123 hasn't written a post about using HIAB I decided to do it, mainly because I use it and always end up referring to discord chats on how to set it up. Much easier to just have it all in one place, and what better place than the chain itself? Im just going over basic setup using snapshots but theres even more functionality(you can replay the server instead of using snapshot, or sync without a blocks_log file) which you can read about here: https://github.com/someguy123/hive-docker.

Server

First thing that you'll need is a server for this. Thanks to the efforts in HF 24, its become quite a bit easier to run I would recommend a Privex server for this because you can pay with Hive and HBD, but because we have a lot of witnesses already on Privex and its important to have our chain be distributed between different datacenter and providers, I would recommend that you find your own.

I run my witness(@hextech) on a server with 16 gigs of RAM and 4 threads for the witness along with 400 GB(320 GB being used right now) on a NVME on Ubuntu 20. Higher ram usage is required during the snapshot import process(reaching about 15.3 GB used).

Setting Up HIAB

I like to update my server as the first thing to do as well as install git and screen.

sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install git -y
sudo apt-get install screen -y

Then we clone the repo.

git clone https://github.com/someguy123/hive-docker.git

And then use it to install docker for you. This shouldn't take too long.

cd hive-docker
./run.sh install_docker

We can then install the latest docker image for the witness with. It will grab whatever is the latest from dockerhub(https://hub.docker.com/r/someguy123/hive/tags).

./run.sh install

The next step is to download the block_log(somewhere around 300 GB around now) as well as the snapshot files. We are going to do this in a screen so we don't need to remain connected while this goes on.

screen -S download
export BC_HTTP_RAW="http://files.privex.io/hive/block_log" 
export RSYNC_BASE="rsync://files.privex.io/hive"
./run.sh fix_blocks

You'll be presented with a screen like this. For downloading the rest of blocks_log, you'll want to say yes (y). This will take a while, depending on the connection speed. The best thing to do is wait.

Screen Shot 20201107 at 5.17.16 PM.png

After that you'll be asked if you want to grab block_log.index as well. Say yes to that as well.

Then you'll get asked about snapshot, again say yes.

Finally you'll be asked about shared_memory.bin, for that say no(n).

While those are downloading, you can move onto the next few steps, I'll let you know where you'll need those files to move on.

CLI Wallet And Keys

Now we are going to want to generate our witness signing keys. You can reuse some keys that you already use, but it's recommended to generate new ones just for signing blocks. To do that, we use the cli_wallet.

We'll be using the remote wallet as our local instance isn't ready yet.

./run.sh remote_wallet

You should get presented with something like this on a fresh install. If it says locked instead of new then you already have a wallet setup(you won't unless you are updating) and you can unlock it and skip the init step.

Screen Shot 20201107 at 5.25.29 PM.png

You can type in set_password to set your password. For example, if I wanted my password to be 123, I'd type in set_password 123 Remember the password as you'll need this to unlock the wallet in the future. You'll want to unlock your wallet after that. Thats as simple as unlock 123. Replace 123 with the password you set.

Once you are unlocked you can use suggest_brain_key to get a public private keypair generated. You'll want to save that as you'll need it in the future. Screen Shot 20201107 at 5.29.09 PM.png

You can exit the wallet by pressing control + D. If you ever forget your password, you can wipe the wallet clean and use a new password. A wallet.json file is generated and stored within the data directory. Just delete that and it'll start the wallet fresh again.

Config

Next we'll need to modify the config file to work with our witness. Its located at data/witness_node_data_dir/config.ini directory. We'll want to modify that.

nano data/witness_node_data_dir/config.ini

Most of the values there are already good. If you want to modify anything go ahead if you know what you are doing.

The place we want to modify is witness = and private-key =. They are already commented out(line begins with #) so we can just go find them and delete the # at the start of the line. For the witness, you'll want to type in the username of the account that the witness will be running under. This value must go in quotes. The private key should be the private key that we generated from the cli wallet. This should not go in quotation marks. Use the image below as an example.

Screen Shot 20201107 at 5.42.17 PM.png

Starting Up

Going on, you'll need to have all the files that we started downloaded earlier ready to go. If not, please finish downloading then continue. While you wait for this to download, some good things to do are write a post about you staring up your witness, voting @hextech for witness and thinking about how you can help benefit the hive ecosystem.

We are going to load in the snap that we got so that we don't need to replay.

./run.sh load_snap privexsnap  

This does take some time, but nowhere near as long as it would take if we had to run a replay. You can monitor what step of the process this is at by using ./run.sh logs.

Once the snapshot loads in, it'll automatically start syncing up to live. You can check the sync progress using ./run.sh monitor. It'll tell you how long it'll take to get synced up. Again this is a time to wait. You'll know that you are live when you see individual blocks being produced in ./run.sh logs. That'll look like this:

Screen Shot 20201107 at 6.58.25 PM.png

The block numbers will be going up by one. Nows the big time, time to enable as a witness.

Enabling Your Witness

Let's enable the witness, you can do so using either the remote wallet or the local one. To use the local wallet, use ./run.sh wallet and remote is ./run.sh remote_wallet.

./run.sh wallet

Unlock the wallet with the password set before using unlock 123 where 123 is the password. We'll want to import in your active key to sign the transaction that we'll be broadcasting. Find the private active_key using your preferred choice. If your private active key is 5KNrHHigj3PRurkm5moaV1XM3gWGrDZJJZCgPRL2FpBLjWy1obg you'd import it by typing in import_key 5KNrHHigj3PRurkm5moaV1XM3gWGrDZJJZCgPRL2FpBLjWy1obg

Now we want to broadcast enabling the witness. Modify the following command to match what you want and type it into the wallet. Replace username with the name of your witness, the https://example.com part with the url you want to use for your witness and STM1111111111111111111111111111111114T1Anm with the public key generated for your private signing key when we first got into the wallet. Following that are your witness parameters, modify them to your liking, but these are the current standard ones being used by witnesses and so it's wise to follow along.

update_witness "username" "https://example.com" "STM1111111111111111111111111111111114T1Anm" {"account_creation_fee":"3.000 HIVE","maximum_block_size":65536,"hbd_interest_rate":0} true

After that gets broadcast, you are up and running as a witness. You can check that you are enabled somewhere like https://peakd.com/me/witnesses. The green ball means that you are enabled. Your version will not report to the version that you are using until you sign your first block so don't worry if it says 0.0.0. Just get the word out there that you are being a witness and get more votes.

Screen Shot 20201107 at 7.09.34 PM.png

I was following along on a fresh server and it took me 2 hours and 15 minutes to get to the point where I could broadcast the enable witness transaction. The latest updates and the work from someguy to make HIAB exist has made it a lot easier to be a witness.

Future & Questions

You'll want to setup a pricefeed and failover script as well. For pricefeed, I recommend someguy's hivefeed-js (can be found here https://github.com/someguy123/hivefeed-js) as well for failover script(watcher by therealwolf works https://github.com/therealwolf42/hive-witness-essentials/tree/master/essentials/watcher)

As time goes on, you'll need to update. The update process might involve a replay or it might not. Hard forks involve a replay and soft forks usually don't. You can get information and ask questions about that in the Privex discord which can be found at http://discord.privex.io/. The server requirements might increase as well and you might need to upgrade that.

If you like what I do, feel free to vote for my witness https://vote.hive.uno/@hextech

Sort:  

Heh, you beat me to it.

Great guide, I've reblogged it so most HIAB users will find it :)

This is honestly awesome and very tempting for me to finally pull the trigger on launching a node myself

Posted using Dapplr

Setting up a node isn't too hard. Its maintaining it and campaigning for votes. Good luck if you decide to take the plunge.

Well, I know for a fact I wouldn't win the popularity contest for votes here (at least not yet) considering the amount of tight-knit mega whales there are - but, I would do it solely for the benefit of the community. I know it'd be a resource drain, but I'd simply ask for donations or just upvotes on posts/client posts to make it work.

Otherwise, I pay and it's cool - that's that. Sometimes, people have to act selflessly for the greater good, and I feel this is one of them (even if in just a very small way).

This is a good run down for HIAB - it's an easy starting point for anyone setting up their own server. I started using @drakos price feed it's simple and reliable https://github.com/Jolly-Pirate/pricefeed

I recommended the one from someguy because I work on it from time to time and so I'm more familiar with it.

Sweet, Ill prob set up a witness sometime soon .. just snowballing myself there

Good luck. Setting up is very easy :) Getting the votes is soooooooo much harder.

Ive heard talk about resetting the witness votes in a future HF

Yup, I would love that since it would push me up since I'm newer :) But it would also mean witnesses actually have to work for their spot and can't sit back and relax like some of the top 50 are doing right now.

might be something to do on some rolling .. I kinda feel the same about delegations

Hive is shit- and Steem's course is soon 50% higher than HIVE's. And are you all still happy here ? You have been lured here by a gang of power obsessed witnesses, who only wanted to enrich themselves and also have been lured here on the chain that is doomed to perdition.

Hive is shit- and Steem's course is soon 50% higher than HIVE's. And are you all still happy here ? You have been lured here by a gang of power obsessed witnesses, who only wanted to enrich themselves and also have been lured here on the chain that is doomed to perdition.

Hive is shit- and Steem's course is soon 50% higher than HIVE's. And are you all still happy here ? You have been lured here by a gang of power obsessed witnesses, who only wanted to enrich themselves and also have been lured here on the chain that is doomed to perdition.

Thanks for this. I'm in the process of running HIAB using Docker Desktop on a Windows 10 Home machine using WLS 2 (thanks @themarkymark).

I'd do a post when its all working.

My machine is quite a beast - 112 Gb RAM with 6/12 core Intel i76800k CPU, 500 Gb NVME SSD & 500 Gb SATA SSD - so I'm thinking of turning this into an API node and then running a witness on a second, lighter machine.

What changes do I need to make to do that?

Loading...

What is the network traffic requirements for a witness node on a monthly basis?

Haven't really measured that. Setting up you'll eat up like 350 GB downloading everything you need. Day to day running is a lot less.

Screen Shot 20201112 at 9.07.15 PM.png

I've attached my network traffic graph for the last hour. I can't really tell how often its being transferred but I'm guessing per second, and using that as an estimate, its about 70 GB/month which really isn't bad at all. (30 kb/sec * 60 sec/min * 60 min/hour * 24/hour/day * 30 day/month).

Do you have a transaction log for how many requests you get during that timeframe.

Witness nodes don't normally handle requests(that'd be the job of a fullnode, but it is possible to take some specific requests which I have my witness node doing for some very small private projects). Witness nodes just get and process blocks and sign blocks when they get assigned to produce a block.

Now that I've got my witness node running I want to be able to take snapshots so I can restart easily in case of computer reboot. How do I do that?

I think you have to stop running it first(I haven't tried it yet) then run ./run.sh dump_snap SNAPSHOTNAME. Then it'll be located within data/witness_node_data_dir/snapshot/ with the name that you chose.