Skip to content

Build Your Own Raspberry Pi Sumcoin Supernode

5053s edited this page Aug 2, 2019 · 14 revisions

Build Your Own Raspberry Pi Sumcoin Supernode

Preface

Sumcoin is built on the Decentralized Bitcoin Protocol. Many references will point to Bitcoin 'how to's' but will work the same way.

LAST UPDATED JUNE 18, 2019

Disclaimer: No guarantee these steps will work 100% of the time. Like all DIY tutorials they make assumptions about things and are subject to external libraries and software being updated or changed. Steps are periodically tested and update these steps for changes or additions, but no guarantee that some troubleshooting won't be needed to get your node up and running.

What Is A Full Node?

A full node is a program that fully validates transactions and blocks. Almost all full nodes also help the network by accepting transactions and blocks from other full nodes, validating those transactions and blocks, and then relaying them to further full nodes.

Most full nodes also serve lightweight clients by allowing them to transmit their transactions to the network and by notifying them when a transaction affects their wallet. If not enough nodes perform this function, clients won’t be able to connect through the peer-to-peer network—they’ll have to use centralized services instead.

Many people and organizations volunteer to run full nodes using spare computing and bandwidth resources—but more volunteers are needed to allow Sumcoin to continue to grow. This document describes how you can help and what helping will cost you.

Costs And Warnings

Running a Sumcoin full node comes with certain costs and can expose you to certain risks. This section will explain those costs and risks so you can decide whether you’re able to help the network.

Special Cases

Miners, businesses, and privacy-conscious users rely on particular behavior from the full nodes they use, so they will often run their own full nodes and take special safety precautions. This document does not cover those precautions—it only describes running a full node to help support the Bitcoin network in general.

Please seek out assistance in the community if you need help setting up your full node correctly to handle high-value and privacy-sensitive tasks. Do your own diligence to ensure who you get help from is ethical, reputable and qualified to assist you.

Secure Your Wallet

It’s possible and safe to run a full node to support the network and use its wallet to store your Sumcoins, but you must take the same precautions you would when using any Sumcoin wallet. Please see the securing your wallet page for more information. Securing your wallet

PRELIMINARIES

This tutorial is to install Sumcoin on a Raspberry Pi 3 b+. These steps will install version 0.16.1.0 If you wish to install 0.8.7.5 (A previous deprecated version) instead, you can find DIY steps here. Options are given to install the GUI and wallet or not. The blockchain is currently around 600.6MBs and so a minimum 16GB microSD card should be used unless the blockchain is to be stored externally (like on a USB drive).

If you run into any Raspberry Pi problems while going through these steps, the Raspberry Pi Docs are a good source for help:

http://www.raspberrypi.org/documentation/

FULL STEPS

  • Assembling the Raspberry Pi
  • Download and Install Raspbian on the microSD card
  • Configuring Raspbian
  • Enlarge Swap File
  • Configure networking on the Raspberry Pi
  • Downloading and installing Sumcoin and dependencies
  • Configure and run Sumcoin
  • Configure home network to sync up with the Sumcoin network
  • Confirm your node is reachable by the network

EQUIPMENT FOR NODE

  • Raspberry Pi 3 b+
  • Case fitting Raspberry Pi 3 B+ form
  • Power supply (micro USB, 5V, at least 2A)
  • USB wifi adapter -or- Ethernet cable for direct connect to your router
  • 32GB MicroSD card (class 10) or larger

PURCHASE OPTIONS

You can find what is needed to build a Sumcoin raspnode for less than $100 on Amazon or Ebay etc.

The CanaKit Raspberry Pi Starter Kit costs $79 (plus tax and shipping) and comes with everything you need except an Ethernet cable (if you wish to cable directly to your router) and it comes with an 32GB microSD instead of the required 16GB.

EQUIPMENT FOR SETUP

  • HDMI cable
  • Monitor with HDMI in or adapters to convert HDMI to your monitor
  • USB keyboard
  • Router and a connection to the Internet
  • Separate PC which needs to be able to read a microSD card

ASSEMBLY

How to assemble your Raspberry Pi will depend on the case purchased. Once assembled, plug in your USB keyboard, HDMI cable to your monitor, and either your USB Wifi adapter or an Ethernet cable going to your router.

The device will automatically power on once you plug in the micro USB power cable.

INSTALLING THE RASPBIAN OS

If your Raspberry Pi came with a microSD card preloaded with NOOBS you can insert the microSD card into your Raspberry Pi, plug in your power cable and it will walk you through your setup. Make sure you select Raspbian as your OS choice, which should be the first on the list. It will take a few minutes to install. Once that is finished, reboot and jump to Raspbian config options.

If you have a brand new microSD card, you will need to download a Raspbian image to your PC and image your microSD card. This tutorial will assume you are using a PC running Microsoft Windows. Instructions for imaging using Mac or Linux can be found in the Raspberry Pi documents:

http://www.raspberrypi.org/documentation/installation/installing-images/README.md

You can find the latest on the Raspberry Pi downloads page:

http://www.raspberrypi.org/downloads/

Or directly download the latest here:

http://downloads.raspberrypi.org/raspbian_latest

Once downloaded, unzip the file. If you don't have an application installed for unzipping files, you can use the open source 7zip:

http://www.7-zip.org/

The unzipped folder will have a large .img file. In order to put this image on your microSD card we'll need to use the open source Win32DiskImager which can be found on sourceforge:

http://sourceforge.net/projects/win32diskimager/

Or directly download the latest here:

http://sourceforge.net/projects/win32diskimager/files/latest/download

Once downloaded run the installer, this will install Win32DiskImager.

Insert your microSD card into your PC. Launch Win32DiskImager. Select the Raspbian .img file as the 'image file' and select your microSD card as your 'device'. Make sure what is selected is your microSD card and nothing else, especially your hard drive. Click 'write'. This will take a few minutes.

Once finished, eject your microSD card. Insert your microSD card into your Raspberry Pi and plug in the power cable and wait while it boots up.

RASPBIAN CONFIG OPTIONS

When you first boot Raspbian you will be prompted with the raspi-config menu shown below:

If you used NOOBS to install Raspbian your file system will already be expanded to fill your full microSD card. However if you installed a Raspbian image you'll need to expand it now.

Select “1 Expand File System" which will expand the file system to fill the card.

OPTIONAL

If you won't be using Sumcoin-Qt (the GUI) then you can run it 'headless' and we can allocate a little more RAM to the CPU.

Select "8 Advanced Options" then select "Memory Split"

Change 64 to 16

Select "OK"

If you want to be able to SSH into your Raspnode, you can enable the SSH server here.

Select "8 Advanced Options" then select "SSH"

Select "Enable"

Change hostname. The default hostname is set to "raspberry". We'll change ours to "raspnode" and the rest of the tutorial will assume this. If you leave yours as "raspberry" or change it to something else, anytime you see the hostname mentioned, use that instead of "raspnode".

Select "8 Advanced Options" then select "Hostname"

Edit the hostname to “raspnode" without quotes (or to your desired hostname)

Select "OK"

Here you can also change the default user (which is "pi") and password (which is "raspberry"). We'll leave these as is for the tutorial. If you change your username, make sure to use that instead of "pi" when it shows up in this tutorial.

You can overclock your Raspberry Pi in order to give it a little more processing power. This may make the initial verification of the blockchain quicker, but is not needed for normal node operations.

Select "7 Overclock"

Choose the desired level of overclocking

Select "OK"

To set your timezone:

Select "4 Internationalisation Options"

Select "Change Timezone"

Go through the selection process to select your timezone, then select "OK"

Once done, select "Finished" and your Raspberry Pi will reboot.

When you get the "login" prompt, enter your username "pi" and it will prompt you for your password. Enter your password (which won't show up) and hit to log in (the password will be "raspberry" if you didn't change it in the raspi-config).

EDITING FILES

We'll be using the command line to edit files. If you are not familiar with a command line this may be a little tricky. Raspbian comes with a few editors. Nano is a relatively friendly editor and this tutorial will use that, but Raspbian also has vi for users who prefer it and can be used instead. If you have not used vi before, you should stick with nano.

For those not familiar with Linux, some actions we take will require root privileges. We get that by using the command “sudo" before our desired command. This will only work if you are logged in as a user with sudo rights, which the default Raspbian user (“pi" in our case) has. Sudo can be set to require a password, but the default Raspbian user should be set to not need one.

You may want to change the default keyboard layout. Edit /etc/default/keyboard

pi@raspnode~$ sudo nano /etc/default/keyboard

Change the line

XKBLAYOUT="gb" to equal your desired country code, so for US keyboard layout change it to

XKBLAYOUT="us" Then save and exit. Reboot to have it take effect. Reboot with

pi@raspnode~$ sudo shutdown -r now

ENLARGE SWAP FILE

  • Preferred File Swap method is on Sumcoin Github

A swap file allows the microCD card to be used as extra memory if needed. It is slower and heavy use will shorten the life of a microSD card. Raspbian defaults to a 100Mb swap file which is not actually needed to build and run Sumcoin under normal operating conditions. However if you are expecting to download the whole blockchain on the raspnode or the blockchain gets significantly behind, the downloading of extra blocks to catch up can exceed the built in memory and cause Sumcoin to crash (possibly corrupting data). Enlarging the swap file by a little bit protects against this possibility.

Engage Swap File

pi@raspnode~$ sudo fallocate -l 2G /swapfile;
pi@raspnode~$ sudo chmod 600 /swapfile;
pi@raspnode~$ sudo mkswap /swapfile;
pi@raspnode~$ sudo swapon /swapfile;

NETWORKING ON THE RASPBERRY PI

If you are using an Ethernet cable and plugging directly into your router and DHCP is turned on, you can plug that in and you should have access to the Internet. You can check by pinging out:

pi@raspnode~$ ping google.com

If you start to see pings you are good. Hit + c to stop the pings. If you are using a wifi adapter and have a password set for your router, there are a few more steps to take. Setting up and troubleshooting wifi on the Raspberry Pi is beyond the scope of this tutorial, so if the basic setup shown here doesn't work, you can reference the Raspberry Pi documentation for help:

http://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

To setup your wifi, edit the file /etc/wpa_supplicant/wpa_supplicant.conf:

pi@raspnode~$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add this to the bottom of the file:

network={
    ssid="<your wifi ssid here>"
    psk="<your wifi password here>"
}

For example, if your wifi network is named myHomeWifi and your wifi password is mySuperSecret then wpa_supplicant.conf should look something like:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1

network={ ssid="myHomeWifi" psk="mySuperSecret" }

Then restart your wifi interface:

pi@raspnode~$ sudo ifdown wlan0
pi@raspnode~$ sudo ifup wlan0

If you need to set a static IP, that is currently out of the scope of this tutorial.

DOWNLOADING SUMCOIN DEPENDENCIES

In order to install Sumcoin we need to install a few tools and software packages. First let's make sure everything is up to date and update it if it isn't:

sudo apt-get update;
sudo apt-get upgrade -y;
sudo apt-get install git;

Dependancies to download and install the packages needed for Sumcoin 0.16.1 - 0.17.1:

sudo apt-get install autoconf libtool libssl-dev libboost-all-dev libminiupnpc-dev -y;

That should take just a couple minutes. If you plan on using sumcoin-qt (the GUI and wallet) then you'll have to install additional dependencies:

sudo apt-get install qt4-dev-tools libprotobuf-dev protobuf-compiler libqrencode-dev -y;
sudo apt-get install -y libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler;
sudo apt-get install -y build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils;

Make a directory to download required files:

pi@raspnode~$ mkdir ~/bin

pi@raspnode~$ cd ~/bin

Sumcoin 0.16.1 and 0.17.1 uses version 4.8 of the Berkeley database so we'll need to download, build, and install that. If you wish to run your Sumcoin node without a wallet, you can skip to Installing Sumcoin.

Download the Berkeley database source code, unzip it, then build the BerkeleyDB.

pi@raspnode~/bin$ wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz

pi@raspnode~/bin$ tar -xzvf db-4.8.30.NC.tar.gz

pi@raspnode~/bin$ cd db-4.8.30.NC/build_unix/

pi@raspnode~/bin/db-4.8.30.NC/build_unix$ ../dist/configure --enable-cxx

pi@raspnode~/bin/db-4.8.30.NC/build_unix$ make -j4

The "make -j4" command should take around 5 minutes to complete. If you get errors, then remove the "-j4" and just execute "make". This will take around 20 minutes.

pi@raspnode~/bin/db-4.8.30.NC/build_unix$ sudo make install

INSTALLING SUMCOIN

Download the Sumcoin 0.16.1 or 0.17.1 source code from github and build it:

pi@raspnode~/bin/db-4.8.30.NC/build_unix$ cd ~/bin
pi@raspnode~/bin$ git clone -b 0.17 https://github.com/sumcoinlabs/sumcoin.git
pi@raspnode~/bin$ cd sumcoin/
pi@raspnode~/bin/sumcoin$ ./autogen.sh

If you plan on using sumcoin-Qt (the GUI and wallet) then use this command:

pi@raspnode~/bin/sumcoin$ ./configure CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include -O2" LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib" --with-gui --enable-upnp-default

If you don't need the sumcoin-Qt (GUI) and will run your raspnode 'headless', then use this command instead:

pi@raspnode~/bin/sumcoin$ ./configure CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include -O2" LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib"

If you don't need the sumcoin-Qt (GUI) and don't need wallet functionality (and so you didn't install the Berkeley DB) then use:

pi@raspnode~/bin/sumcoin$ ./configure --disable-wallet

The '-O2' arguments above are a capital letter O, not the number zero. Make sure there is a space after /include and -O2.

If you want sumcoin to use UPnP to try to automatically forward port 3333 from your router than add "--enable-upnp-default" as another argument for configure.

Once that completes, then run:

pi@raspnode~/bin/sumcoin$ make -j2

The "make -j2" command should take around 60 minutes to complete if running without including the GUI, and around 75 minutes if being run with the GUI. Don't use "-j4" for this build. If you get errors using "-j2", then just run "make" (it will take longer).

pi@raspnode~/bin/sumcoin$ sudo make install

CONFIGURE AND RUN Sumcoin

If you want to run sumcoind, then you'll need to create a config file. First run sumcoind with:

pi@raspnode~/bin/sumcoin/src/qt/$ ./sumcoin-qt

Some text will return that gives you an rpcuser and rpcpassword to use. You don't have to use these, but it is recommended.

Press + c to stop sumcoind and get the prompt back. This will also create the hidden .Sumcoin directory in your home directory which is where you need to add the config file. Create the new file and edit it with:

pi@raspnode~$ cd .sumcoin
pi@raspnode~/.sumcoin$ touch sumcoin.conf

And add in a rpcuser and rpcpassword, it should look something like this if you use the one suggested by Sumcoind:

server=1
daemon=1
rpcuser=Sumcoinrpc
rpcpassword=21Hy2d5kycuoLzWxdJjQoVN1jtL7Q5kzqhHz3ZfuYNCU

SAVE

  • THIS IS JUST AN EXAMPLE, DO NOT USE THIS PASSWORD - you will get robbed!

RUN

Save and exit and now you can run sumcoind with:

Without GUI

pi@raspnode~/bin/sumcoin/src/$ ./sumcoind -server -daemon

Once the desktop has launched, open a terminal window:

RUN GUI

pi@raspnode~/bin/sumcoin/src/qt/$ ./sumcoin-qt

Downloading and verifying the full Sumcoin blockchain on the raspberry pi takes around 2 hours as of June 2019 (a significant reduction from using 0.8.7.5 which took around 6 hours, this is probably due to header first improvements). If you already have a copy of the blockchain on another computer, you can transfer the contents of the Sumcoin data directory (except for wallet.dat, unless you wish to move your wallet over as well) to the .Sumcoin directory.

If you choose to download the full blockchain on your raspnode, be sure to increase the swap size as shown above or you will likely get "bad_alloc" errors and Sumcoin will crash. If this happens, it can corrupt the database, which you'll know if when you try to restart it gets stuck on the "loading wallet" stage. To fix this issue you can run Sumcoin again with the "-reindex" parameter. This will reindex the blockchain so it is sort of like starting over and will take time. Even with an extended swap I have had Sumcoind stop responding and need to be killed and restarted during the downloading of the blockchain. However, after you are caught up, there shouldn't be any more significant issues.

CONFIGURE HOME NETWORK TO SYNC WITH THE Sumcoin NETWORK

In order to act as a supernode and upload blocks to requesting nodes your router will need to forward port 9333 to your raspnode. If you configured Sumcoin with upnp on by default, then Sumcoin will try to tell your router to forward the port automatically. If your router does not support UPnP or you didn't configure Sumcoin with it on, you'll have to forward the port yourself. To do this you'll need your raspnode's IP address which you can get by running ifconfig:

pi@raspnode~$ ifconfig

If you are cabled into your router directly the IP address will be under "eth0", if you are on wifi it will be under "wlan0".

CONFIRM YOUR NODE IS REACHABLE BY THE NETWORK

To confirm that you are seeding the Sumcoin network you can check and see if you have more than 8 connections by running:

pi@raspnode~/bin/sumcoin/src/$ ./sumcoin-cli getinfo
You can’t perform that action at this time.