Skip to content

Instantly share code, notes, and snippets.

@skynode
Created April 20, 2021 05:32
Show Gist options
  • Save skynode/46794843ebaf8955a00134b1a2521cc4 to your computer and use it in GitHub Desktop.
Save skynode/46794843ebaf8955a00134b1a2521cc4 to your computer and use it in GitHub Desktop.
Running a Handshake Full Node on the Windows Subsystem for Linux

Introduction

Handshake is a new open-source project that aims to fully decouple the allocation of Internet root namespaces otherwise known as Top-Level Domains (TLDs) from centralized control systems. It uses Merkle Tree technology (popularly called "blockchains") to maintain a globally distributed database system that follows a strict protocol for the management of TLDs and allocates eligible TLDs through a Vickery auction mechanism. TLD eligibility is determined by modulo-based computation with a Blake2b/SHA3 hash of the TLD.

This article take a dive into the technical details of running a full node on the Handshake network using the Ubuntu Linux distribution that leverages the Windows Subsystem for Linux (WSL).

Activate the Windows Subsystem for Linux

If you don't have this module activated on your Windows machine, it's something you'd have to do to proceed with the remainder of this manual. To activate:

  • Go to the Turn Windows features on or off application window from the Control Panel.

  • Scroll down the list to Windows Subsystem for Linux and check its box. If you're on the Windows OS Build 2004, you may opt for the improved version of WSL (version 2). For this, you will need to activate the Virtual Machine Platform component (which came with OS Build Version 1809) located in the current window. Check its box and click OK to apply all the new changes. Alternatively, you can do these on the PowerShell CLI (as an Administrator) using the following commands. As already stated, the second command below only applies if you have OS Build 1809:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart

Install Ubuntu on Windows

  • Open the Microsoft Store app on your Windows 10 device and search for Ubuntu. You should see a list of versions of the distro displayed in the dropdown. I'd recommend selecting one of the explicit versions (one of Ubuntu 16.04 or 18.04) since that leaves you in charge of distro updates. Selecting the versionless one ("Ubuntu") means you will always have the latest LTS version but upgrades will be handled through the Windows Update framework. Click Get to download and install whatever you choose.

  • Once the installation is complete, launch the Ubuntu command line window from either:

    • the Start Menu or
    • PowerShell using the wsl command

Set your UNIX username and password from the prompt that is displayed. Run the following commands to download and update the Ubuntu package lists and dependencies from the remote repositories

sudo apt update

sudo apt upgrade

Set up Environment and Dependencies

  • Nodejs (version 10+) will be required to correctly install and run your full node. A good version manager for Node on Linux distros is nvm. The following commands will download and run the nvm install script on your machine:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

After the download is complete and you've restarted your shell, install any Node version greater than v10. I'm installing v12.16.1:

nvm install v12.16.1

Confirm your installation:

node --version
  • The unbound DNS resolver is used by the hsd daemon to optimize DNS resolution according to IETF privacy and security standards and also works as a fall-back resolver for hsd. Let's quickly grab that:
sudo apt install unbound
  • Next, let's ensure python3 and its dependencies are available in our new distro. These will be required (as dependencies) when node modules utilize the node-gyp package to compile native Node Addons (usually written in C/C++):
sudo apt install python3-pip

Install and Configure the Handshake Daemon

  • Now we're ready to clone and install hsd. Run:
git clone git://github.com/handshake-org/hsd.git

Change into the directory you installed hsd in and run:

npm install --production
  • Now you're ready to run your full node:
./bin/hsd
  • Let's now generate an API key for running and accessing our full node using the bcrypto Nodejs Addon. cd into your hsd directory and run the following command. You can shutdown your node (Ctrl + C) to continue with this step:
node -e "bcrypto=require('bcrypto');\
console.log(bcrypto.random.randomBytes(32).toString('hex'))"
  • After your first run, the daemon should create a .hsd folder in your home directory. Verify that this is the case by running ls- a from your home directory.

  • Inside the .hsd folder, create a file with name hsd.conf if it doesn't exist yet. This file will hold your full node's configuration parameters:

touch hsd.conf

echo "http-host: 0.0.0.0" >> hsd.conf

echo "api-key: <your-generated-api-key>" >> hsd.conf
  • Also make sure to grab hs-client which exists as a node module and will function as a multi-protocol client for hsd, supporting Http, Websocket and RPC communications with your node:
npm install --global hs-client
  • Consider using the tmux Linux utility to minimize the hsd process to the background. But first, the process needs to be started from a tmux session:
tmux
./bin/hsd

Then use Ctrl B D to minimize the process. To put it back in view, use tmux attach. You can use tmux list-sessions to see all your tmux sessions.

Wrap Up

In this article, I have described how you would run a Handshake full node software on an Ubuntu distro on the Windows Subsystem for Linux on a Windows 10 machine. If you have any questions or comments, do not hesitate to reach out to me on twitter or shoot me a quick email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment