Raspberry Pi - Project 03 (RVN Node for Beginners')

Raspberry Pi - Project 03 (RVN Node for Beginners')

By Mynima | Hobbyist Mining | 24 Mar 2020


Introduction

For anyone interested in my mining blog posts (with GPUs and specific coin, then they can be found here). For this post we're going deviate a little bit from the direct mining of coins to supporting the network and decentralization. We're going to run our own Ravencoin (RVN) node.

Before I begin there are a couple of things to remember; I take no responsibility for any issues you run into if you try this at home (be smart, download any software at your own risk).

As we dive into the guide I recommend if you've not already set up your raspberry pi then follow my precursor setup guide first then come back: https://www.publish0x.com/hobbyist-mining/crypto-pi-project-01-beginners-set-up-guide-xnmvmw.

 

So what is a node?

Well, we often talk about one of the benefits of cryptocurrency as being 'decentralized', meaning that with no-one single entity being in control there is no need for a trust based model. Instead, the ledger (or blockchain) is shared by everyone on the network allowing agreement to be reached by all on the validity of the transactions. If you think of mining as the process of adding to the chain, running a node is the process by which the chain is distributed and secured (the record keeping).

Why are nodes important?

Well as eluded to above, the more people you have running nodes better your blockchain distribution and as a result the more secure and robust it is. If you believe in a project and can run a node this is one of the best ways to support your project because you help to protect the network and therefore protect your financial investments (if any).

Anyway enough of the what and why, lets move on to the "how?".

Many thanks to the guide on the Raven wiki, the information below is a trimmed down (to essentials) and slightly modified version of this. I am in the process of writing the whole lot into a single script to make it even easier to do and will follow up with that addition as soon as I get chance.  


1. Before you start

There are a few bit of information we're going to need throughout this so I thought it best get this done first.

  • The release version of the wallet: https://github.com/RavenProject/Ravencoin/releases (currently for this tutorial v3.3.2.0)
  • Your local IP address for the computer you're using to connect to your Pi, you can get this by logging into your router
  • Your local IP address of you Pi

Also, since we're already looking at our router we need to set up some port forwarding rules that we'll need later. Find your router on here: https://portforward.com/router.htm and then follow the steps. The ports we'll see to forward are for your Raspberry Pi IP address (you just got this above) and the port of interest will be 8767-8767.


2. Downloading the latest release from GitHub

If you're doing this at a later date and 3.3.2.0 isn't the latest version then replace it in the commands below and and it should work if the version is available.

cd ~/
wget https://github.com/RavenProject/Ravencoin/releases/download/v3.3.2/raven-3.3.2.0-arm-linux-gnueabihf.tar.gz
tar -xvzf raven-3.3.2.0-arm-linux-gnueabihf.tar.gz

3. Location

Put binaries into default local user binary location to allow access from anywhere

sudo cp ./raven-3.3.2.0/bin/* /usr/local/bin

4. Speeding up the blockchain download

Now at this stage we could easily just start the daemon and it will go ahead and beginning downloading the blockchain. This will take quite a long time, so we can actually go and get ourselves a copy and use that first. Fortunately, Ravenland (who's process we're following here) set up a downloadable copy of the chain back in 2019 which is a solid starting point.

So we'll download it, unzip it and finally delete the zipped file to save a little space

wget http://bootstrap.ravenland.org/blockchain.tar.gz
tar -xvzf bootstrap.tar.gz
rm bootstrap.tar.gz #deleting to save space

5. Configuring

Next we'll need to update the configure file so it works a little better with the raspberry Pi we can do this by using the non text editor from the terminal by entering

touch ~/.raven/raven.conf
nano ~/.raven/raven.conf

In the editor we'll need to add/update the following information:

server=1
upnp=1
dbcache=800
maxmempool=50
disablewallet=1
logips=1
maxconnections=40
prune=42000
maxuploadtarget=5000

The most important bits here are; 'server=1' to allow for incoming connections and 'prune=42000' which allows the pi to look back of the last x MB of the blocks. Note that if you have a smaller SD care you'll want to reduce this prune argument to something more in line with the size of your card. I'm using a 400GB card so left it as this.

Once you've added this to the text editor press CTRL-O and then ENTER to save, followed by CTRL-X to return to the normal terminal line.


6. Starting/stopping the Node and checking the status

Now all that is left to do is to start up our node by tying:

ravend &

If you want to stop it then use the following:

raven-cli stop

Once started the chain will continue to catch up. The downside of running the node on the Pi is it is difficult to see where you're up to as it runs in the background. As such we can create a little script to help us with this.

First we need to create a file and then access it through the text editor:

touch ~/check_status.sh
nano ~/check_status.sh

Then copy over the following:

#!/bin/bash
if pgrep -x "ravend" >/dev/null;
then
  count=$(/usr/local/bin/raven-cli getblockcount);
  /bin/echo "block count: $count";
  hash=$(/usr/local/bin/raven-cli getblockhash $count);
  /bin/echo "block hash: $hash";
  t=$(/usr/local/bin/raven-cli getblock "$hash" | grep '"time"' | awk '{print $2}' | sed -e 's/,$//g');
  /bin/echo "block timestamp is: $t";
  cur_t=$(date +%s);
  diff_t=$[$cur_t - $t];
  /bin/echo -n "Difference is: ";
  /bin/echo $diff_t | /usr/bin/awk '{printf "%d days, %d:%d:%d\n",$1/(60*60*24),$1/(60*60)%24,$1%(60*60)/60,$1%60}';
else
  /bin/echo "Raven Daemon is not Running. Type 'ravend &' to start"
fi

The first if statement will check if you already have the process running. If it is then it will provide you with information on the block, the hash, the timestamp and how far behind you are. Otherwise, it let you know what to type to start it running.

Press CTRL-O and then ENTER to save, followed by CTRL-X to return to the normal terminal line. We then need to make the file executable so we can call it to check our status.

chmod +x ~/check_status.sh

Finally, with it ready to go we can simply type the following into our terminal and see where we're up to.

~/check_status.sh

If it is running you'll get something like section 'A' below, otherwise if it not running you'll get section 'B'

running


7. Security and Network Support

Next we need to look at a few additional steps so that we can communicate with the Ravencoin network and also protect our Pi from malicious activity. To do this we need to do the following:

  • a) First we open up the ports we need:
sudo iptables -A INPUT -p tcp --dport 8767 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 8767 -j ACCEPT
  • b) Now we need set up a security firewall to limit traffic (for this we can use uncomplicated firewall, ufw)
sudo apt-get install ufw
  • c) We can now add rules to the firewall to accept/limit traffic. Commands in the order that they appear below:
    • This allows, but limits SSH access
    • This allows all access from your local PC, TightVNC wont work without it
    • This allows communication with the Ravencoin network on port 8767
    • This starts your firewall
sudo ufw limit ssh
sudo ufw allow from <You PCs local IP address>
sudo ufw allow 8767 comment 'Ravencoin'
sudo ufw enable
  • d) Next we want to make it a bit more difficult and prevent brute force (trying all possible password combinations), this blocks after 5 failed attempts 
sudo apt install fail2ban
  • e) Finally, we want to check everything looks right. Commands in the order that they appear below:
    • This will show us all the rules set up for the firewall
    • This will show us the ban list
    • This will show us the status of our connections on port 87
sudo ufw status verbose
sudo fail2ban-client status
netstat | grep :8767

security

If you run into any issues setting up ufw then you can also use the following commands to help clean things up for a fresh go. Commands in the order that they appear below:

  • This will get the status and list rules by number
  • This will delete the rule specified by number
  • This will remove all rules and reset
  • This will allow all connections from specific IP/port
  • This will allow connection to specific port from a specific IP
sudo ufw status numbered
sudo ufw delete <number>
sudo ufw reset
sudo ufw allow <ip address or port>
sudo ufw allow from <ip address> to any port <port>

 

That is it Congratulations!! You're running your own Ravencoin Node.

 

Hope you enjoyed the guide, good luck y'all!

 

 

Donations Welcome (RVN):

RX3DageouRRct7AkhAXDRfqjN4hZZVx9dZ

How do you rate this article?


108

2

Mynima
Mynima

Hobby miner and Crypto interested programmer. https://mynima.github.io/


Hobbyist Mining
Hobbyist Mining

Mining: Tips and how-to guides from one beginner to another.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.