Raspberry Pi - Project 06 (DIY Mining Pool and How-To Mine VTC)

Raspberry Pi - Project 06 (DIY Mining Pool and How-To Mine VTC)

By Mynima | Hobbyist Mining | 25 Apr 2020


I my previous Raspberry Pi Project post we looked into how to set up our own node. This gave an opportunity to support the network and understand an integral part of the decentralization process. This time we'll go a step further than build a P2Pool mining pool that links into our node and provides a platform for mining using our own node.

Before we being it is important to understand (briefly, I'll try not to butcher this) what a P2Pool is, and how we can set it up. A short explanation is that we're going to set up another blockchain that runs along side the normal chain that is mined at a lower difficulty level. This second chain is also shared with many other nodes and acts as a ledger of all the contributing shares. When a block for the second chain is mined at a difficulty above that of the main chain then effectively that solution is used to complete the block on the main chain. At this point we can show by the contribution of blocks in the side (or share) chain all the miners who contributed to mining this block and therefore can distribute the block reward fairly among those contributors. This process is actually one of the most decentralized ways of mining coins and prevents the need/cost of large mining pools since we all work on a decentralized side chain together.

As we begin setting up the P2Pool there are a few prerequisites. This guide assume the following:

Finally, 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). This is provided for educational purposes only.


1. Setting up the P2Pool

First off the bat we need to download some dependencies for the P2Pool and Bitcoind, but while we're at it lets do a Pi update as well.

#Pi Updates
sudo apt-get update
sudo apt-get upgrade

#Dependancies
sudo apt-get install python-rrdtool python-pygame python-scipy python-twisted python-twisted-web python-pip -y
sudo apt-get install build-essential libtool autotools-dev automake pkg-config libffi-dev libssl-dev libevent-dev bsdmainutils python3 -y

 

 Next we're going to go get the P2Pool zip file, download, extract and then install it.

#Get/Extract
wget "https://github.com/vertcoin-project/p2pool-vtc/archive/v2.0.0.zip"
unzip v2.0.0.zip

#Move to the folder and Install
cd p2pool-vtc-2.0.0/
sudo pip2 install -r requirements.txt
sudo python setup.py install

 

Then we're going to add a front-end to the P2Pool and then move it into the P2Pool

#Drop back to the main folder and download front-end
cd
git clone https://github.com/hardcpp/P2PoolExtendedFrontEnd.git

#Move over to P2Pool folders and clean up
sudo mv ./P2PoolExtendedFrontEnd/* /home/pi/p2pool-vtc-2.0.0/web-static/
sudo rm -r P2PoolExtendedFrontEnd/

2. Configuring the P2Pool

So now we have the P2Pool installed and set up now we need to configure it so that connections can be made. We can do this by adding acceptations to our UFW (Uncomplicated Firewall) that was used when setting up our node. We also at this time need to make sure to forward the ports 9346 and 9171 for our Raspberry Pi, the best place to find out how to do this on your own router is here: https://portforward.com/router.htm.

#Set up UFW acceptions
sudo ufw allow 9346 comment 'P2Pool P2P Port (Network1)'
sudo ufw allow 9171 comment 'P2Pool Mining Port (Network1)'

 

With our ports forward and allowed for the firewall we can check the status of the ufw and make sure everything looks right this is done by executing the following command, you should see something like the image afterwards.

sudo ufw status verbose

ufw

If you want to check your ports are open then you can use https://ping.eu/port-chk/ as an easy way to do this.


3. Starting the pool

Now that we've set up the P2Pool we need to start it up. To do this we're going to write a simple script that will check if our node is running and if not will tell you to start it up. Otherwise it will execute the startup of the P2Pool.

First open up the text editor with:

sudo nano p2pool_vtc_start.sh

 

Then Copy the following, but replace "yourvertcoinaddressgoeshere" with a Vertcoin address from you desktop Vertcoin wallet.

#!/bin/bash
#
# run p2pool with pre-configured settings
#
# network 1 = --net vertcoin
#

if pgrep -x "vertcoind" >/dev/null;
then

cd p2pool-vtc-2.0.0
python run_p2pool.py --net vertcoin -a yourvertcoinaddressgoeshere --max-conns 8 --outgoing-conns 4

else
  /bin/echo "Vertcoin Daemon is not Running. Type 'vertcoind &' to start"
fi

 

Once the above is added to the text editor we need to 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 use it to start the P2Pool.

sudo chmod +x ~/p2pool_vtc_start.sh

 

All being well you will be able to start the P2Pool by executing the script "~/p2pool_vtc_start.sh". I would recommend doing this on your tight VNC desktop as it will mean you don't need to keep the putty shell open on your desktop to see what is going on. Your command window will show the following information; the first image on start up, and the second is the communication between your Pi and the P2Pool, indicating any shares found by your pool, the pool/local hashrate and shares on the side chain.

Pool1

Pool2


3. Mining to our own pool

So we've managed to set up our P2Pool successfully, let's mine! We’re going to use our GPU on another computer to do this. First of all we need to get some mining software, for this example we'll use TeamRedMiner. You can download this from here: https://github.com/todxx/teamredminer. Once you've downloaded the latest version make sure that you extract it to a safe location. After extraction check that you have the "teamredminer.exe" file in the folder, if you don't then add an exception for the location you're extracting to in your virus software (often miners get intercepted by over zealous virus scanners) and extract it again.

Finally, we're going to create a .bat file the the name "start_VTC_P2Pool.bat", you can do this by modifying one of the example BAT files in the folder or creating a .txt file and renaming the file extension to .bat. Into the BAT file we're going to add the following:

teamredminer.exe -a lyra2rev3 -o stratum+tcp://<Your.IP.Address>:9171 -u <Your.VTC.Address> -p x

We need to replace "<Your.IP.Address>" with your global IP address (get it here: https://ping.eu/port-chk/ if you don't know it already). Then we're replace "<Your.VTC.Address>" with the address where you want your mining rewards to pay out. Save and close this .bat and then double click it to start after a few mins you should start to see something like this.

mining

Congratulations!! You've successfully set up a P2Pool and are mining to it!

In the time that I was writing this last section a block was found and therefore my shares (the share chain) were counted. This meant that I got a payout (whoop whoop), if you are using the VTC wallet it will look like this when you receive a payout:

payout


4. Status Updates

So if you remember earlier in the setup we said that we were adding a front end to the mining pool this means we can easily check our stats there (from any device). All we need to do is go to our favorite browser #BRAVE and type in the following to the address bar "<Your.Global.IP.Address>:9171" (e.g. xx.xxxx.xxx.xxx:9171). You'll be taken to a tidy little stats page where you can dig into your P2Pool stats that looks like this.

pool_stat

 

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

 

Donations Welcome (VTC):

39yj21xDrJrn3d1NJGBYyjgUiNhnUgBwmJ

 


Refs:

https://github.com/vertcoin-project/VertDocs/blob/master/docs/FullNodes/raspberry-pi.md

How do you rate this article?


91

3

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.