How to run a witness node on the hf25 testnet

in #guide3 years ago (edited)

image.png

Hi ! the testnet phase for HF25 is now in full swing, here's some info on it from @gtg https://peakd.com/@gtg/hf25-public-testnet-reloaded-rc2

One important thing to understand about the testnet is much more lightweight than the main net (because the chain is brand new) so you can actually get it running on a super small machine, to prove my point I'm going to write this tutorial using the 6$ a month doplet (1 core, 25gb storage) from digitalocean. I recommend ubuntu 18.04 LTS, 20.04 is also supported by hive but it can be more tricky depending on the versions of GCC+boost+cmake that are provided with it.

If you participated in the last testnet you will find this guide very similar to the previous one https://peakd.com/hive/@howo/how-to-participate-in-the-tesntets-this-week-full-guide but I felt like making a new one was better than telling you "follow the outdated guide and at step 35 do this instead"

step 1: Build hive or download binaries

download binaries

If you're on a low end hardware compiling may take a while, so it's faster to let someone compile the binaries for you so you can just run them instead.

@gtg offers pre-built binaries at https://gtg.openhive.network/get/testnet/bin/ just download both hived and cli_wallet and you're good to go:

mkdir programs
cd programs
wget https://gtg.openhive.network/get/testnet/bin/cli_wallet-v1.25.0rc2
wget https://gtg.openhive.network/get/testnet/bin/hived-v1.25.0rc2
chmod +x *

This is a hassle-free solution but binaries may not always be available and it's generally better security-wise to compile it yourself.

build hive

If you are running on low end hardware like me, you will probably need to setup some swap to compile hive: https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-18-04/ I personally added 16GB of swap. I don't know how much is actually needed I just figured that it would be enough, feel free to tell me in the comments if you experiment with it.

Let's install the dependencies first:

apt-get install -y \
        autoconf \
        automake \
        autotools-dev \
        build-essential \
        cmake \
        doxygen \
        git \
        libboost-all-dev \
        libyajl-dev \
        libreadline-dev \
        libssl-dev \
        libtool \
        liblz4-tool \
        ncurses-dev \
        python3 \
        python3-dev \
        python3-jinja2 \
        python3-pip \
        libgflags-dev \
        libsnappy-dev \
        zlib1g-dev \
        libbz2-dev \
        liblz4-dev \
        libzstd-dev

Then get hive and compile it, change v1.25.0rc2 to whatever is the current release tag, follow @gtg he is usually the one announcing the release notes, alternatively you can look on https://gitlab.syncad.com/hive/hive/-/tags and look at the most recent tags.

git clone [email protected]:hive/hive.git
cd hive
git checkout v1.25.0rc2
git submodule update --init --recursive
mkdir build
cd build

cmake -DENABLE_COVERAGE_TESTING=ON -DBUILD_HIVE_TESTNET=ON ..

make -j$(nproc) hived cli_wallet

Compiling may take a while if you are on low end hardware it could take up to a few hours if not more, I forgot to measure it when I did it myself so 🤷‍. On high end hardware you can expect 3-5 minutes.

Run the node

I am using the directory structure and binary names that you get when you compile hive so straight copy paste may not work if you use binaries but everything else works the same you just have to use the right paths and right binary names.

Run the node a few seconds and then exit hived like so

./programs/hive/hived -d testnet/

this will create a testnet directory with the default config file.

open the config.ini file

nano testnet/config.ini

replace the config.ini with this one:

# tells the node which seeds he should listen to to get blocks
p2p-seed-node = testnet.openhive.network:2001

# Local http endpoint for webserver requests.
webserver-http-endpoint = 127.0.0.1:8090

# Local websocket endpoint for webserver requests.
webserver-ws-endpoint =127.0.0.1:8091

log-appender = {"appender":"stderr","stream":"std_error"}
log-logger = {"name":"default","level":"info","appender":"stderr"}

backtrace = yes

plugin = webserver p2p json_rpc
plugin = database_api condenser_api

plugin = witness
plugin = rc

plugin = market_history
plugin = market_history_api

plugin = account_history_rocksdb
plugin = account_history_api

plugin = transaction_status
plugin = transaction_status_api

plugin = account_by_key
plugin = account_by_key_api

plugin = reputation
plugin = reputation_api

plugin = block_api network_broadcast_api rc_api

account-history-rocksdb-path = "blockchain/account-history-rocksdb-storage"

shared-file-size = 10G

shared-file-full-threshold = 9500
shared-file-scale-rate = 1000

flush-state-interval = 0

market-history-bucket-size = [15,60,300,3600,86400]
market-history-buckets-per-size = 5760

p2p-endpoint = 0.0.0.0:2001

transaction-status-block-depth = 64000
transaction-status-track-after-block = 100000

webserver-thread-pool-size = 256

Then run hived again, this time we want it to stay up so setup a way for it to persist even if you log out, like screen. I personally use pm2 for the testnets just because it's convenient. This is not optimal for a production setup but it's fine for those testnets. (see https://pm2.keymetrics.io/docs/usage/quick-start/)

for the testnet I run hived like this with pm2:

pm2 start --name testnet ./programs/hived/hived -- -d testnet

It will take some time (a few minutes to a few hours) before you get your blocks.
You can look at https://test.ausbit.dev/ to see what is the head block to get a sense of how far you are.
When you are synched with the testnet and you should see messages like this:

3|hf23     | 1526617ms p2p_plugin.cpp:212            handle_block         ] Got 0 transactions on block 4415 by howo -- Block Time Offset: -382 ms
3|hf23     | 1532618ms p2p_plugin.cpp:212            handle_block         ] Got 0 transactions on block 4416 by howo -- Block Time Offset: -381 ms
3|hf23     | 1538612ms p2p_plugin.cpp:212            handle_block         ] Got 0 transactions on block 4417 by howo -- Block Time Offset: -387 ms
3|hf23     | 1544620ms p2p_plugin.cpp:212            handle_block         ] Got 0 transactions on block 4418 by howo -- Block Time Offset: -379 ms
3|hf23     | 1550615ms p2p_plugin.cpp:212            handle_block         ] Got 0 transactions on block 4419 by howo -- Block Time Offset: -384 ms

now your node is running ! So that's great, but it's not producing.

So you need to setup your witness.

Setting up your witness

cli_wallet

Open up the cli wallet:

./programs/cli_wallet/cli_wallet --server-rpc-endpoint="ws://127.0.0.1:8091"

it'll ask for a password, so execute:

set_password yourpassword

then unlock it using:

unlock yourpassword

Now execute those commands:

import your active key to do various actions, note that the keys on the testnet are the same than the keys on main net (they have been ported) so you can just use your account
import_key 5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n

then generate keys for your witness:
suggest_brain_key

it'll be something like this:

{
  "brain_priv_key": "STRANGE ROADWAY TWASOME MOLER CENTIMO THOFT COMPORT VARIANT OUTSWIM EGGER SCRIBE GLAVER CROWDED DOLLIER AWNED DOPPER",
  "wif_priv_key": "5KJUxvUSdAV6H7LiutRJMVwEVptmoaDhM73Cg1itzYjG8zs7tWF",
  "pub_key": "TST71oeHrdBZEKDG1GaC75VKDaRGcXk2R8htD8J6wkP6p1zDRPzFZ"
}

Save these for later !

Then set yourself as a witness (notice how I used the pub_key generated above)

update_witness "yourusername" "http://example.org" "TST71oeHrdBZEKDG1GaC75VKDaRGcXk2R8htD8J6wkP6p1zDRPzFZ" {"account_creation_fee":"0.000 TESTS","maximum_block_size":65536,"hbd_interest_rate":300} true

then request some test hive via https://hivetestnetfaucet.org/

and power it up, this is important to do even if you already have hp. Because of the power up delay introduced in hf24, your initial HP don't have any effect:

transfer_to_vesting "yourusername" "yourusername" "10.000 TESTS" true

and finally vote for yourself so you get scheduled for blocks. If you don't have stake feel free to request some via https://hivetestnetfaucet.org/

vote_for_witness "yourusername" "yourusername" true true

and we are done with cli_wallet ! but not with the setup.

final config

Open the config one final time to set yourself as a witness by adding these fields:

I use the private key that you generated with the cli above not the one that I put here. I put one here to show that you don't put quotes around the private key.

witness = "yourusername"

# WIF PRIVATE KEY to be used by one or more witnesses or miners
private-key = 5KJUxvUSdAV6H7LiutRJMVwEVptmoaDhM73Cg1itzYjG8zs7tWF

restart the node and you should be producing blocks, the logs should look something like this:

3|hf23     | 2687621ms p2p_plugin.cpp:212            handle_block         ] Got 0 transactions on block 4595 by howo -- Block Time Offset: -378 ms
3|hf23     | 2690613ms witness_plugin.cpp:343        block_production_loo ] Generated block #4596 with timestamp 2020-08-25T19:44:51 at time 2020-08-25T19:44:51

Seed node

Go the extra mile and setup a seed node ! this is quite important as the testnet have very few seed nodes, so it helps a lot if you make one.

Your node is already configured to be a seed node so you just need to open the corresponding port:
(note that this command may vary depending on the firewall setup of your computer)

sudo iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 2001 -j ACCEPT

And now you can communicate the new seed node to everyone. Please post your ip as a comment of that post so that I can update this link to use your seed as well :).

Thank you for reading.

If you liked this writeup, please consider voting for @steempress it's the witness that I co-manage with @fredrikaa:

You can vote for our witness directly using Hivesigner here.

Sort:  

Two nodes notes:
-DLOW_MEMORY_NODE=ON is obsolete (we do that by default, as there's no longer "fat" node that had that setting turned off)
and for testnet it's good to set that:
transaction-status-track-after-block = 46000000
to a way lower number, such as 100000 (otherwise you won't have transaction status available for recent blocks on testnet, where the head block number is much lower)

Thanks ! I wasn't sure if DLOW_MEMORY_NODE was still needed. Good to know for transaction-status-track-after-block, I've updated the guide

178.63.206.84:2001 is currently another seed node if anyone needs one.

I am just/only a simple user, not a developer. I am eagerly waiting for the HF25, hoping that it will increase user interaction. I say thank you to every developer and witness for their work for the Hive blockchain. All the best to everyone.

same here, been following/reading all the recent developments on the hf25. excited to see how this will impact the price of hive and our payout from post and cuarations

photo_2021_05_31_00_00_57.jpg

Huh not true at all. Everyone has an opinion, and the bigger your stake, the louder it is usually, but you can always convince those with larger stake to get behind your thing.

Awesome.

!PIZZA

Connect

Trade


@howo! I sent you a slice of $PIZZA on behalf of @juanvegetarian.

Learn more about $PIZZA Token at hive.pizza