scrobble.life
Blockchain Wizardry

Hive Node Setup for the Smart, the Dumb, and the Lazy.

Hive consensus node - simple way

Requirements:

Hardware: x86-64, 32GB RAM, 1TB fast storage (SSD / NVMe) Software: Ubuntu 22.04 LTS

Assumptions:

We act as user hive with uid 1000 and HOME=/home/hive We use screen for convenience. We use /home/hive/datadir as a data dir for our node.

Use cases:

Simple, yet versatile configuration that can be used to spawn a node that serves as a:

seed

Take part in a P2P network. By default listen at publicly available TCP port 2001.

witness

Witnesses, a.k.a. block producers play an essential role on Hive. In this case, you don’t want to open webserver ports to the public or enable non-essential plugins such as account_history. Make sure that you set values for witness and private-key.

exchange

Exchanges need to track account history entries for a list of accounts they use for deposits and withdrawals. For that reason such accounts have to be specified in config files (see example entries). Each time you add a new account to be tracked, you have to perform a replay.

personal wallet

You might want to have a node for personal needs to handle your accounts. Configure it just like the exchange, except you will track your own account(s).

basic API

A consensus node has a basic, yet powerful API. It can return useful information about the current state of the blockchain, track the head block, return blocks with get_block API, and broadcast transactions, which might be just good enough to handle some bots or apps.

Prepare directory tree

mkdir -pv ~/datadir/{blockchain,snapshot} ~/bin

Use example config file

wget https://gtg.openhive.network/get/snapshot/exchange/example-exchange-config.ini -O ~/datadir/config.ini

Get hived and cli_wallet binaries

wget https://gtg.openhive.network/get/bin/hived-1.27.6 -nc -P ~/bin
wget https://gtg.openhive.network/get/bin/cli_wallet-1.27.6 -nc -P ~/bin
chmod u+x ~/bin/{hived,cli_wallet}-1.27.6

Run hived

Of course you need to make sure it won’t be killed when you disconnect (use screen, or configure it as a service), make sure that the configuration fits your needs (tracking accounts, bind ports to public interfaces or to localhost, etc.)

~/bin/hived-1.27.6 -d /home/hive/datadir

That’s it.

It will start sync process during which /home/hive/datadir/blockchain/block_log and /home/hive/datadir/blockchain/block_log.artifacts will be created and updated as it will sync and process blocks coming from the Hive p2p network. As the blocks are processed the current state is being saved in the /home/hive/datadir/blockchain/shared_memory.bin file. If you track account history then there’s also /home/hive/datadir/blockchain/account-history-rocksdb-storage which is RocksDB storage with account history data.

Optional steps and improvements

Use tmpfs for shared_memory.bin file

It’s worth mentioning that /home/hive/datadir/blockchain/shared_memory.bin will be heavily accessed for read/write. Placing this file on tmpfs will speed up resync and replay, and will reduce I/O on the storage. The disadvantage is that it will not survive the reboot. You also need to have enough RAM / swap. To use tmpfs, uncomment this line in config.ini file:

# shared-file-dir = "/run/hive"

And prepare that location for storing shared_memory.bin file:

sudo mkdir /run/hive
sudo chown -Rc hive:hive /run/hive
sudo mount -o remount,size=30G /run

Use existing block_log

If you already have a block_log file you can use it to speed up the process. In such a case place it in ~/datadir/blockchain and use --replay. You can use a block_log from another instance you run or download from public sources (see: https://gtg.openhive.network/get/blockchain ) You can safely reuse block_log from older versions.

wget https://gtg.openhive.network/get/blockchain/block_log -nc -P ~/datadir/blockchain
wget https://gtg.openhive.network/get/blockchain/block_log.artifacts -nc -P ~/datadir/blockchain

Please note that the block_log is roughly 500GB, downloading it could take a significant amount of time (6-12 hours even with a decent network connection)

Use a snapshot

Snapshot can apply the state of the blockchain that was generated on a different machine. It’s tightly bound to the version that was used to generate it and the exact configuration (used plugins, etc.). Make sure that you have lbzip2 installed (sudo apt install lbzip2). Regular bzip2 will also work, but lbzip2 makes use of all available CPU threads. To use snapshot you also need a block_log that is at least as fresh at snapshot itself.

wget https://gtg.openhive.network/get/snapshot/exchange/latest.tar.bz2 -O - | lbzip2 -dc | tar xvC /home/hive/datadir/snapshot

When using snapshot use --load-snapshot=latest (where the ‘latest’ is the name of the snapshot)

TL;DR: Complete optimized recipe

screen -q # start the screen manager

mkdir -pv ~/datadir/{blockchain,snapshot} ~/bin

sudo mkdir /run/hive
sudo chown -Rc hive:hive /run/hive
sudo mount -o remount,size=30G /run

wget https://gtg.openhive.network/get/blockchain/block_log -nc -P ~/datadir/blockchain
wget https://gtg.openhive.network/get/blockchain/block_log.artifacts -nc -P ~/datadir/blockchain
wget https://gtg.openhive.network/get/snapshot/exchange/latest.tar.bz2 -O - | lbzip2 -dc | tar xvC /home/hive/datadir/snapshot
wget https://gtg.openhive.network/get/bin/hived-1.27.6 -nc -P ~/bin
wget https://gtg.openhive.network/get/bin/cli_wallet-1.27.6 -nc -P ~/bin
wget https://gtg.openhive.network/get/snapshot/exchange/example-exchange-config.ini -O ~/datadir/config.ini

sed -i '/^# shared-file-dir/s/^# //' ~/datadir/config.ini # enable tmpfs location
chmod u+x ~/bin/{hived,cli_wallet}-1.27.6

~/bin/hived-1.27.6 -d /home/hive/datadir --load-snapshot=latest

Upgrading from previous version

If your instance is already configured this way, then upgrade is very easy:

rm -rf /home/hived/datadir/snapshot/latest
wget https://gtg.openhive.network/get/bin/hived-1.27.6 -nc -P ~/bin
wget https://gtg.openhive.network/get/bin/cli_wallet-1.27.6 -nc -P ~/bin
chmod u+x ~/bin/{hived,cli_wallet}-1.27.6
wget https://gtg.openhive.network/get/snapshot/exchange/latest.tar.bz2 -O - | lbzip2 -dc | tar xvC /home/hive/datadir/snapshot

Stop current instance and start with new binary:

~/bin/hived-1.27.6 -d /home/hive/datadir --load-snapshot=latest

Estimated times:

Sync (from scratch) - 36h Replay (if you already have a block_log) - 18h Load from snapshot (if you already have a block_log) - 1h

Congratulations, you have your Hive node running!

Comments · 19

  • @assassyn(64)· 366d

    Hey,

    I am trying to deploy witness on my local NAS. The only problem I have is wit the ram, how required is 32gb can it run on 16gb ?

  • @apshamilton(73)· 729d

    I'm trying to get a Hive witness node up and running on a local machine (Intel i5 8400 64G RAM 1 Tb NVMe & 500Gb NVMe). I downloaded @gtg's blocklog and ran replay. It created a blocklog index that expanded to 462Gb and ate all the space on the 1Tb NVMe.

    Is this supposed to happen? Can I move the index to the 2nd 500Gb NVMe which is empty?

    I'm using @someguy123's Hive in a Box

  • @magicmonk(80)· 830d

    Genius article - I should learn to follow it one day

  • @hivebuzz(74)· 831d

    Congratulations @gtg! Your post has been a top performer on the Hive blockchain and you have been rewarded with this rare badge

    Post with the highest payout of the week.

    You can view your badges on your board and compare yourself to others in the Ranking If you no longer want to receive notifications, reply to this comment with the word STOP

  • @xplosive(72)· 833d

    Please note that the block_log is roughly 500GB, downloading it could take a significant amount of time (6-12 hours even with a decent network connection)

    Seeing this, maybe it is better to have more than 1 TB storage. People often store and run multiple things on their servers.

  • @wanderingmoon(63)· 833d

    This is very helpful and hopefully will help more people to become witness's/node operators. !LUV

  • @ajorundon(63)· 834d

    I'm glad people be doing all this but me. I do not want to blow my heads up trying to comprehend this post. It really amazing some commenters find it easy and useful. Kudos

  • Thanks. I followed all the steps. Once they finally got the flames under control and I was allowed to gather whatever I could salvage, people wanted answers. So I quickly pulled this post up and started reading it out loud. Even they understood.

  • @sacra97(77)· 834d

    Thank you for the instructions

  • @unbiasedwriter(75)· 835d

    Thank you for the instructions :) Very useful indeed if I ever want to setup a Hive node :)

  • @thelogicaldude(75)· 835d

    Thanks, been looking into running a witness node. Now I just need the machine.

  • @mr-press(40)· 835d

    I have zero knowledge about this. lol

  • @rafzat(71)· 835d

    This now looks very easy Kudos to you for your hard work!

  • @themarkymark(81)· 835d

    I recommend using a named session with screen as well as logging the session.

    screen -S witness -L -Logfile witness.log
    

    You can then use my monitorwitness script to know if it falls behind,

    https://github.com/officiallymarky/monitorwitness

  • @hivebuzz(74)· 835d

    Congratulations @gtg! Your post has been a top performer on the Hive blockchain and you have been rewarded with this rare badge

    Post with the highest payout of the day.

    You can view your badges on your board and compare yourself to others in the Ranking If you no longer want to receive notifications, reply to this comment with the word STOP

  • @miosha(68)· 836d

    sudo mount -o remount,size=30G /run

    Why 30G though? Isn't it enough to be of the size of shared_memory.bin? In that case setting both the size of shm and ram-disk to 22G should still have decent margin (4-5G).

    downloading it could take a significant amount of time (6-12 hours even with a decent network connection)

    12 hours is only a bit less than syncing from scratch through p2p, so downloading in that case is not a viable solution 😁

    /home/hive/datadir/blockchain/block_log and /home/hive/datadir/blockchain/block_log.artifacts will be created

    So, I guess the version supporting split block log is the next one, right?

  • @chibuzorwisdom(53)· 836d

    Thank you so much for this step by step guide. I have longed to get the one that is written like this.

    This looks easy and smart, I have reblogged it for reference purposes.

    I will revisit it once I purchase a server for the set-up. Thank you once again.

  • @mipiano(81)· 836d

    Congratulations, you have your Hive node running!

    Thank you, this was very easy and quick - I didn't even wait for 36 hours and this congratulation arrived 😜

  • @bitcoinflood(80)· 836d

    Alright this looks rather easy and now I'm going to be honest I'm seriously thinking about launching one and learning from people such as yourself. I used to run a number of nodes years ago for other blockchains. Thanks for the deets!