An update on Hive for the masses, by the masses - using mass market PCs for Hive nodes.
My witness node on WSL2 on a Windows 10 Home PC has been running for 5 days now, almost flawlessly, and this morning signed its first block. I was very lucky to catch it almost real time.
As usual with doing something that's never been done before, there were a few tweaks and teething difficulties which I had to work out the solutions for.
I'm sharing them here for benefit of others who want to set up witness nodes on Windows 10 Home PCs.
WSL2 Clock Drift
After my witness had been running for a few days I started to notice red exceptions in the logs that referred to blocks being old.
I also noticed that the block offset times had increased from a few hundred milliseconds to close to 5000 milliseconds.
@deathwing suggested that my system clock was off.
I tried synching my Windows clock with an internet time server but it didn't fix the problem
So I did some research and discovered that WSL2 is subject to time drift problems, especially when the host Windows 10 is suspended or resumed.
But the initial fix is quite simple. Just enter the following commands in Ubuntu to resynch the WSL2 clock.
sudo apt install ntpdate
sudo ntpdate -sb time.nist.gov
But I didn't want to have to do this manually every day or so - there had to be a way to automate it.
I did some further research. Crontab can be used to automate Linux tasks that need to be run on a regular interval
The problem with automating commands that require a sudo via crontab is that you have to find the location of the command's file so you can provide the full path in crontab - a task I don't know how to do quickly and easily.
I discovered a better solution.
I turns out that WSL 2 commands can be run as bash or batch file commands in Windows and you can specify the user (including root)
So I wrote a simple Windows batch file which included the command
wsl -u root sh -C "ntpdate -sb time.nist.gov"
I then used Windows Task Scheduler to run this twice a day.
Clock drift solved.
Automated Snapshots - Essential for Windows PCs
One of the great new features of Hive HF 24 is the ability to save a snapshot of a Hive node and then relaunch quickly from that snapshot.
It avoids the need for the dreaded replay of the blockchain, which can take around 18 hours on an average machine.
Replays times are pretty linear with CPU single core speed, so slower CPUs will take longer and 32 core server chips won't help - it is single core performance that counts.
I loaded up my Hive witness node originally from a Privex snapshot as part of @someguy123's HIAB.
But that snapshot was more than a week old when I used it and took about 1 hour 20 minutes to load up.
I wanted to take my own regular snapshots so I always have a recent snapshot to restart from and to allow me to quickly get a backup witness node running.
This is particularly important because, as @themarkymark points out, Windows 10 has this annoying habit of forcing updates on users and rebooting your computer without permission.
This can be handled by regularly updating your Windows 10 PC in a controlled fashion and taking a snapshot just before going through the update process.
I just tested the speed of a restart from a 24 hour old snapshot and my witness node was up and running in 14 minutes from typing the command:
In order to automate the process I used crontab in Ubuntu.
My crontab configuration now runs snapshots 3 times a week and deletes the oldest snapshot to save SSD space.
As there is a risk of corruption every time you stop Hived, this process ensures you've always got two good snapshots.
I've also used a crontab function that allows an automatic snapshot load every time the computer is rebooted.
Currently that is using the Sunday snapshot but I'll write a script soon to make it use the latest one.
My crontab config now looks like this:
m h dom mon dow command
40 14 * * 0 /home/apshamilton/hive-docker/data/witness_node_data_dir/snapshot rm -r sundaysnapshot
40 14 * * 3 /home/apshamilton/hive-docker/data/witness_node_data_dir/snapshot rm -r wednesdaysnapshot
40 14 * * 5 /home/apshamilton/hive-docker/data/witness_node_data_dir/snapshot rm -r fridaysnapshot
45 14 * * 0,3,5 /home/apshamilton/hive-docker/run.sh stop
46 14 * * 0 /home/apshamilton/hive-docker/run.sh dumpsnap sundaysnapshot
46 14 * * 3 /home/apshamilton/hive-docker/run.sh dumpsnap wednesdaysnapshot
46 14 * * 5 /home/apshamilton/hive-docker/run.sh dumpsnap fridaysnapshot
47 14 * * * /home/apshamilton/hive-docker/run.sh logs
@reboot /home/apshamilton/hive-docker/run.sh load_snap sundaysnapshot
Automated snapshots done.
I now feel that I've overcome the initial and potential issues with using Windows 10 Home to run a Hive Witness Node.
The machine running the Witness node has proved very stable running other software that needs a high level of uptime.
It is a high end consumer motherboard using the X99 chipset and an Intel i7 6800k CPU (12/6 core) with 96Gb RAM, Radeon Pro Duo GPU and 500Gb NVME, 500Gb SATA and 1TB HDD. A typical 3-4 year old high-end gaming PC (apart from the massive RAM).
I now have the ability to re-start very quickly from a reboot forced by Windows or needed for other reasons.
I will soon be setting up a witness / seed node on a machine using a B365 motherboard and i5 8400 CPU (6 core) and then plan on upgrading the 6800k machine to an API node.
I'll keep posting updates on Hive for the Masses - Hive Nodes on Windows 10 Home PCs.
Please vote for my Hive witness. (KeyChain or HiveSigner)