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!

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now