Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
887
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.67 KB | None | 0 0
  1. # Raspberry Pi 3 B/B+ Vertcoin Full Node Installation Guide for Windows
  2.  
  3. `*`
  4. ###### anything marked with an asterisk is an optional step
  5.  
  6. add merged mining with unitus
  7.  
  8. https://github.com/unitusdev/unitus/releases
  9. https://cdn.discordapp.com/attachments/370500771168518155/415547042807676929/Merged-Mining_Guide.pdf
  10.  
  11.  
  12. ##
  13.  
  14. #### Why a Vertcoin Full node?
  15. >Vertcoin is a digital currency supported by a peer-to-peer network. In order to run efficiently and effectively, it needs peers run by different people... and the more the better. [1]
  16.  
  17. >This tutorial will describe how to create a Vertcoin “full node” (a Vertcoin server that contains the full blockchain and propagates transactions throughout the Vertcoin network via peers). This system will not mine for Vertcoins... it will play its part to keep the Vertcoin peer-to-peer network healthy and strong. For a detailed explanation for why it is important to have a healthy Vertcoin peer-to-peer network, read this [article](https://medium.com/@lopp/bitcoin-nodes-how-many-is-enough-9b8e8f6fd2cf) about Bitcoin full nodes. [2]
  18.  
  19. >Also please note this will be a “headless” server... meaning we will not be using a GUI to configure Vertcoin or check to see how things are running. In fact, once the server is set up, you will only interact with it using command line calls over SSH. The idea is to have this full node be simple, low-power, and something that “just runs” in your basement, closet, etc.
  20.  
  21. #### Why a Raspberry Pi?
  22. >Raspberry Pi is an inexpensive computing hardware platform that generates little heat, draws little power, and can run silently 24 hours a day without having to think about it. [1]
  23.  
  24. ## Table of Contents
  25. 1. `Parts List`
  26. 2. `* OPTIONAL: Download and sync Vertcoin Core`
  27. 3. `Format USB Flash Drive`
  28. 4. `Install Raspbian Stretch Lite`
  29. 5. `Copy Blockchain to USB Flash Drive`
  30. 6. `Setup Raspberry Pi`
  31. 7. `Setup USB Flash Drive and Auto-Mount`
  32. 8. `Create vertcoin.conf and soft link to USB Flash Drive`
  33. 9. `Configure firewall to allow Vertcoin Core traffic`
  34. 10. `* OPTIONAL: Setup Unitus Full Node for merged mining with p2pool-vtc`
  35. 11. `* OPTIONAL: Setup p2pool-vtc`
  36.  
  37.  
  38. ##
  39.  
  40.  
  41.  
  42.  
  43. ### 1.) Parts List
  44.  
  45. | Parts | Price | Link |
  46. |--------------------------------------------------------------|------------|---------------------------------------------------------------------------------|
  47. | CanaKit Raspberry Pi 3 B+ | $49.99 USD | https://www.amazon.com/CanaKit-Raspberry-Power-Supply-Listed/dp/B07BC6WH7V/ |
  48. | Samsung 32GB 95MB/s (U1) MicroSD EVO Select Memory Card | $12.99 USD | https://www.amazon.com/Samsung-MicroSD-Adapter-MB-ME32GA-AM/dp/B06XWN9Q99/ |
  49. | SanDisk Ultra Fit 128GB USB 3.0 Flash Drive | $27.49 USD | https://www.amazon.com/SanDisk-Ultra-128GB-Flash-Drive/dp/B01BGTG2A0/ |
  50. | Transcend USB 3.0 SDHC / SDXC / microSDHC / SDXC Card Reader | $9.23 USD | https://www.amazon.com/Transcend-microSDHC-Reader-TS-RDF5K-Black/dp/B009D79VH4/ |
  51. | *OPTIONAL: Zebra Black Ice Case for Raspberry Pi by C4Labs | $14.95 USD | https://www.amazon.com/Zebra-Black-Case-Raspberry-C4labs/dp/B00M6G9YBM/ |
  52.  
  53.  
  54. You may change the USB Flash Drive to match your preference. I highly recommend that a USB Flash Drive (16GB - 128GB) or an External Hard Drive is paired with the Raspberry Pi.
  55.  
  56. The case in the parts list is a personal preference, it is your choice how you wish to protect your Raspberry Pi. The Zebra Black Ice case was chosen for its cut out on the bottom of the case, allowing for the placement of a heatsink on the RAM of the Raspberry Pi.
  57.  
  58.  
  59.  
  60. ## 2.) `* OPTIONAL:` Download and sync Vertcoin Core
  61.  
  62. This step is optional but recommended. [Download](https://github.com/vertcoin-project/vertcoin-core/releases) the latest stable release of Vertcoin Core and launch `vertcoin-qt.exe` to begin the syncing process. I use my desktop PC to sync the blockchain first because it has better specs than a $35 Raspberry Pi. The PC will sync headers, download blocks and verify blocks faster than the Raspberry Pi can.
  63.  
  64. We will use this copy of the blockchain that is syncing to side-load onto our Raspberry Pi later.
  65.  
  66. `Vertcoin Core Download Link: https://github.com/vertcoin-project/vertcoin-core/releases`
  67. `Default Windows Directory (Vertcoin): C:\Users\%USER%\AppData\Roaming\Vertcoin`
  68.  
  69.  
  70.  
  71.  
  72. ## 3.) Format USB Flash Drive
  73.  
  74. >The Vertcoin blockchain is about 4GB today (4/23/2018) which means that a 16GB USB Flash Drive will have more than enough space to store everything we need, but you can easily future proof with a 128GB USB Flash Drive.
  75.  
  76. Insert the USB Flash Drive into your Windows PC. Then access the drive with Windows Explorer `Win+E`, right click on the removable drive you wish to format and `Format...`
  77.  
  78. Format the USB Flash Drive to an `NTFS` File system.
  79.  
  80. This USB Flash Drive will contain our Vertcoin data directory as well as our swap space file. We will give the Raspberry Pi some extra memory to work with we will ensure a swap file large enough to handle the memory demand to bootstrap the blockchain.
  81.  
  82. It is worth mentioning that constantly writing data to the MicroSD card can be damaging, in this guide we will configure the swap file to reside off of the card.
  83.  
  84.  
  85.  
  86. ## 4.) Install Raspbian Stretch Lite
  87.  
  88. I recommend downloading the latest stable version of [Raspbian Stretch Lite](https://www.raspberrypi.org/downloads/raspbian/).
  89.  
  90. We will utilize the software 'Win32 Disk Imager' to format and install Raspbian on the MicroSD card. Please follow the [guide](https://www.raspberrypi.org/documentation/installation/installing-images/windows.md) below for details on installing the Rasbian image to the MicroSD card.
  91.  
  92.  
  93. `Raspberry Pi - Installing Operating System Images Using Windows: https://www.raspberrypi.org/documentation/installation/installing-images/windows.md`
  94.  
  95. Once Win32 Disk Imager is finished writing to the MicroSD card please access the 'boot' partition of the MicroSD card with Windows Explorer `Win+E`. Create a new empty text file named `ssh` like so...
  96.  
  97. ![MicroSD card - ssh](https://i.imgur.com/m14rGdV.png)
  98. This enables SSH access on the Raspberry Pi's first boot sequence. Please safely remove the USB Card Reader / MicroSD card as to ensure the data is not corrupted.
  99.  
  100. ##### Links
  101. `Raspian Download Link: https://www.raspberrypi.org/downloads/raspbian/`
  102. `Win32 Disk Imager Documentation: https://www.raspberrypi.org/documentation/installation/installing-images/windows.md`
  103.  
  104.  
  105. ## 5.) Copy Blockchain to USB Flash Drive
  106. Once Vertcoin Core is finished syncing the blockchain please navigate to the data directory for Vertcoin.
  107.  
  108. `Default Windows Directory (Vertcoin): C:\Users\%USER%\AppData\Roaming\Vertcoin`
  109.  
  110. Create a new folder named `vertcoin` on your USB Flash Drive that was formatted as an `NTFS` file system earlier and copy the folders `blocks` and `chainstate` to the `vertcoin` folder on your USB Flash Drive. This will allow us to side-load the Vertcoin blockchain and bootstrap faster than if we had the Raspberry Pi do all the work.
  111.  
  112. ## 6.) Setup Raspberry Pi
  113.  
  114. Please insert the MicroSD card that was safely removed into the slot located on the bottom of the Raspberry Pi. Connect an Ethernet cable to the Raspberry Pi that has internet access. When you are ready to power on the Pi, plug the power supply in and the Raspberry Pi will immediately begin to boot.
  115.  
  116. We will access our Raspberry Pi through an SSH session on our Windows PC. I like to use `Git Bash` which is included in the Windows [download](https://git-scm.com/downloads) of `Git`.
  117.  
  118. `Git download link: https://git-scm.com/downloads`
  119.  
  120. Open a web browser page and navigate to your router page and identify the `IP` address of the freshly powered on Raspberry Pi. In my case the `IP` address is `192.168.1.2`, please make note of your Raspberry Pi's `IP` address as we will need to use it to login via `SSH`.
  121.  
  122. \# Open `Git Bash` and ...
  123. `~ $ ssh 192.168.1.2 -l pi`
  124. `default password: raspberry`
  125.  
  126. \# Download and install latest system updates
  127. `pi@raspberrypi:~ $ sudo apt-get update ; sudo apt-get upgrade -y`
  128.  
  129.  
  130. \# Remove orphaned packages and clean `apt`
  131. `pi@raspberrypi:~ $ sudo apt-get autoremove ; sudo apt-get autoclean`
  132.  
  133.  
  134. \# Initiate `raspi-config` script
  135. `pi@raspberrypi:~ $ sudo raspi-config`
  136.  
  137. ```
  138. 1.) [8] Update # update raspi-config script first
  139. 2.) [1] Change User Password # change password for current user
  140. 3.) [4] Localization Options #
  141. > [I2] Change Timezone # set your timezone
  142. 4.) [7] Advanced Options #
  143. > [A1] Expand Filesystem # expand filesystem
  144. ```
  145. `<Finish>` and choose to reboot.
  146.  
  147. \# Wait a minute, then log back in via `SSH`
  148. `ssh 192.168.1.2 -l pi`
  149.  
  150. \# Download and install useful software packages
  151. `pi@raspberrypi:~ $ sudo apt-get install git ntfs-3g -y`
  152.  
  153. \# Install `bitcoin` dependencies `https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md`
  154. `pi@raspberrypi:~ $ sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils python3 -y`
  155.  
  156. \# Install `boost` dependencies for `bitcoin`
  157. `pi@raspberrypi:~ $ sudo apt-get install libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev -y`
  158.  
  159. ##
  160.  
  161. \# `* OPTIONAL:` Disable Wireless and Bluetooth
  162. `pi@raspberrypi:~ $ cd /etc/modprobe.d/`
  163.  
  164. \# Create our blacklist file
  165. `pi@raspberrypi:/etc/modprobe.d $ sudo nano raspi-blacklist.conf`
  166.  
  167. ```
  168. # disable wireless
  169. blacklist brcmfmac
  170. blacklist brcmutil
  171.  
  172. # disable bluetooth
  173. blacklist btbcm
  174. blacklist hci_uart
  175. ```
  176. `ctrl+x` to save
  177.  
  178. \# Reboot Raspberry Pi for changes to take effect
  179. `pi@raspberrypi:/etc/modprobe.d $ sudo reboot`
  180.  
  181. \# Wait a minute, then log back in via `SSH`
  182. `ssh 192.168.1.2 -l pi`
  183. ##
  184.  
  185. \# Download latest stable version of vertcoin-core for `ARM` architecture to Raspberry Pi
  186. `pi@raspberrypi:~ $ wget https://github.com/vertcoin-project/vertcoin-core/releases/download/0.12.0/vertcoin-v0.12.0-linux-arm.zip`
  187.  
  188. \# Unzip `vertcoin-v0.12.0-linux-arm.zip`
  189. ```
  190. pi@raspberrypi:~ $ unzip vertcoin-v0.12.0-linux-arm.zip
  191. Archive: vertcoin-v0.12.0-linux-arm.zip
  192. inflating: vertcoin-cli
  193. inflating: vertcoind
  194. inflating: vertcoin-tx
  195. ```
  196. \# Remove `vertcoin-v0.12.0-linux-arm.zip`
  197. `pi@raspberrypi:~ $ rm *.zip`
  198.  
  199. \# Move `vertcoin-cli`, `vertcoind`, `vertcoin-tx` to `/usr/bin/`
  200. `pi@raspberrypi:~ $ sudo mv vertcoin* /usr/bin/`
  201.  
  202.  
  203.  
  204. ## 7.) Setup USB Flash Drive and Auto-Mount
  205.  
  206. Please insert the USB Flash Drive that contains the folders `blocks` and `chainstate` into the Raspberry Pi. We will mount the USB Flash Drive to the Raspberry Pi and configure the device to auto-mount on reboot ensuring the blockchain stays accessible to the Vertcoin daemon after reboot.
  207.  
  208. \# Find your USB Flash Drive
  209. ```
  210. pi@raspberrypi:~ $ sudo blkid
  211. /dev/mmcblk0p1: LABEL="boot" UUID="5DB0-971B" TYPE="vfat" PARTUUID="efbdd15e-01"
  212. /dev/mmcblk0p2: LABEL="rootfs" UUID="060b57a8-62bd-4d48-a471-0d28466d1fbb" TYPE="ext4" PARTUUID="efbdd15e-02"
  213. /dev/mmcblk0: PTUUID="efbdd15e" PTTYPE="dos"
  214. /dev/sda1: UUID="0DC965316518EB7C" TYPE="ntfs" PARTUUID="00e3d476-01"
  215. ```
  216. My USB device appears as `/dev/sda1` which shows a filesystem type of `NTFS`, your device may be listed differently. Please take note of the `/dev/*` information that identifies your USB Flash Drive.
  217.  
  218. \# Make sure a mount point exists for the USB Flash Drive
  219. ```
  220. pi@raspberrypi:~ $ sudo mkdir /mnt
  221. mkdir: cannot create directory ‘/mnt’: File exists
  222. ```
  223. \# Give `/mnt` privileges
  224. `pi@raspberrypi:~ $ sudo chmod 755 /mnt`
  225.  
  226. \# Mount USB Flash Drive to mount point
  227. `pi@raspberrypi:~ $ sudo mount /dev/sda1 /mnt`
  228.  
  229. \# Confirm USB Flash Drive was successfully mounted to `/mnt`
  230. ```
  231. pi@raspberrypi:~ $ ls /mnt/vertcoin/
  232. blocks chainstate
  233. ```
  234. \# Setup `fstab` file to auto-mount the USB Flash Drive on reboot
  235. `pi@raspberrypi:~ $ sudo nano /etc/fstab`
  236. ```
  237. proc /proc proc defaults 0 0
  238. PARTUUID=efbdd15e-01 /boot vfat defaults 0 2
  239. PARTUUID=efbdd15e-02 / ext4 defaults,noatime 0 1
  240.  
  241. # replace /dev/sda1 with your USB device, [tab] between each value
  242. /dev/sda1 /mnt ntfs defaults 0 0
  243.  
  244. # a swapfile is not a swap partition, no line here
  245. # use dphys-swapfile swap[on|off] for that
  246. ```
  247. `ctrl+x` to save
  248.  
  249. \# Reboot to confirm auto-mount is successful
  250. `pi@raspberrypi:~ $ sudo reboot `
  251.  
  252. \# Wait a minute, then log back in via `SSH`
  253. `ssh 192.168.1.2 -l pi`
  254.  
  255. \# Confirm USB Flash Drive auto-mounted
  256. ```
  257. pi@raspberrypi:~ $ ls /mnt/vertcoin
  258. blocks chainstate
  259. ```
  260.  
  261. ## 8.) Create `vertcoin.conf` and soft link to USB Flash Drive
  262.  
  263. \# Change directory to `/mnt/vertcoin`
  264. `pi@raspberrypi:~ $ cd /mnt/vertcoin`
  265.  
  266. \# Create `vertcoin.conf` for Vertcoin Core
  267. `pi@raspberrypi:/mnt/vertcoin $ sudo nano vertcoin.conf`
  268. ```
  269. server=1
  270. rpcuser=node
  271. rpcpassword=yoursecurepasswordgoeshere
  272.  
  273. # makes client run in background
  274. daemon=1
  275.  
  276. # https://jlopp.github.io/bitcoin-core-config-generator/ lopp.net optimizations
  277. dbcache=100
  278. maxorphantx=10
  279. maxmempool=50
  280. maxconnections=40
  281. maxuploadtarget=5000
  282. ```
  283. `ctrl+x` to save
  284.  
  285. ##
  286. `* OPTIONAL:` A quick and easy way to generate a random password is taking the `md5sum` of a file
  287. ```
  288. pi@raspberrypi:/mnt/vertcoin $ touch randomfilename
  289. pi@raspberrypi:/mnt/vertcoin $ md5sum randomfilename
  290. d41d8cd98f00b204e9800998ecf8427e randomfilename
  291.  
  292. # Clean up
  293. pi@raspberrypi:~/.vertcoin $ rm randomfilename
  294. ```
  295. ##
  296.  
  297. \# Change directory back home
  298. ```
  299. pi@raspberrypi:/mnt/vertcoin $ cd
  300. pi@raspberrypi:~ $ pwd
  301. /home/pi
  302. ```
  303. \# Create soft link (symbolic link) connecting `/mnt/vertcoin/` <---> `/home/pi/.vertcoin`
  304. `pi@raspberrypi:~ $ sudo ln -s /mnt/vertcoin/ /home/pi/.vertcoin`
  305.  
  306. \# List all files in home
  307. ```
  308. pi@raspberrypi:~ $ ls -a
  309. . .. .bash_history .bash_logout .bashrc .config .profile .vertcoin .wget-hsts
  310. ```
  311. \# List files in `/home/pi/.vertcoin`, confirm blockchain and `vertcoin.conf` is there
  312. ```
  313. pi@raspberrypi:~ $ ls .vertcoin
  314. blocks chainstate vertcoin.conf
  315. ```
  316.  
  317. #### Create swap file space for Raspberry Pi
  318.  
  319. Here we ensure that `dphys-swapfile` is installed and configured to save the swap file in `/mnt/swap`, allocate `500MB` of swap file space, uncomment `CONF_SWAPFACTOR` and `CONF_MAXSWAP` lines.
  320.  
  321. \# Install `dphys-swapfile`
  322. ```
  323. pi@raspberrypi:~ $ sudo apt-get install dphys-swapfile
  324. Reading package lists... Done
  325. Building dependency tree
  326. Reading state information... Done
  327. dphys-swapfile is already the newest version (20100506-3).
  328. 0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.
  329. ```
  330.  
  331. \# Configure swap file
  332. `pi@raspberrypi:~ $ sudo nano /etc/dphys-swapfile`
  333. ```
  334. # /etc/dphys-swapfile - user settings for dphys-swapfile package
  335. # author Neil Franklin, last modification 2010.05.05
  336. # copyright ETH Zuerich Physics Departement
  337. # use under either modified/non-advertising BSD or GPL license
  338.  
  339. # this file is sourced with . so full normal sh syntax applies
  340.  
  341. # the default settings are added as commented out CONF_*=* lines
  342.  
  343.  
  344. # reconfigure swapfile to reside on /mnt/swap
  345. CONF_SWAPFILE=/mnt/swap
  346.  
  347. # set size to absolute value, leaving empty (default) then uses computed value
  348. # you most likely don't want this, unless you have an special disk situation
  349.  
  350. # set swapsize to 500
  351. CONF_SWAPSIZE=500
  352.  
  353. # set size to computed value, this times RAM size, dynamically adapts,
  354. # guarantees that there is enough swap without wasting disk space on excess
  355. CONF_SWAPFACTOR=2
  356.  
  357. # restrict size (computed and absolute!) to maximally this limit
  358. # can be set to empty for no limit, but beware of filled partitions!
  359. # this is/was a (outdated?) 32bit kernel limit (in MBytes), do not overrun it
  360. # but is also sensible on 64bit to prevent filling /var or even / partition
  361. CONF_MAXSWAP=2048
  362. ```
  363. `ctrl+x` to save
  364.  
  365. \# Restart swap file service
  366. ```
  367. pi@raspberrypi:~ $ sudo /etc/init.d/dphys-swapfile stop
  368. [ ok ] Stopping dphys-swapfile (via systemctl): dphys-swapfile.service.
  369. ```
  370. ```
  371. pi@raspberrypi:~ $ sudo /etc/init.d/dphys-swapfile start
  372. [ ok ] Starting dphys-swapfile (via systemctl): dphys-swapfile.service.
  373. ```
  374.  
  375. #### Setup Vertcoin Core Crontab for auto-start on reboot
  376.  
  377. Here we will configure the `crontab` file to start `vertcoind` as a daemon on reboot and on each hour to ensure `vertcoind` always has a process thats alive. If `vertcoind` is already running when the hourly `crontab` executes it will simply fail to spawn a new process.
  378.  
  379. \# Configure `crontab` file to start `vertcoind` hourly and on reboot
  380.  
  381. `pi@raspberrypi:~ $ crontab -u pi -e`
  382. ```
  383. no crontab for pi - using an empty one
  384.  
  385. Select an editor. To change later, run 'select-editor'.
  386. 1. /bin/ed
  387. 2. /bin/nano <---- easiest
  388. 3. /usr/bin/vim.tiny
  389.  
  390. Choose 1-3 [2]: 2
  391. ----------------------------------------------------------------------
  392. # Edit this file to introduce tasks to be run by cron.
  393. #
  394. # Each task to run has to be defined through a single line
  395. # indicating with different fields when the task will be run
  396. # and what command to run for the task
  397. #
  398. # To define the time you can provide concrete values for
  399. # minute (m), hour (h), day of month (dom), month (mon),
  400. # and day of week (dow) or use '*' in these fields (for 'any').#
  401. # Notice that tasks will be started based on the cron's system
  402. # daemon's notion of time and timezones.
  403. #
  404. # Output of the crontab jobs (including errors) is sent through
  405. # email to the user the crontab file belongs to (unless redirected).
  406. #
  407. # For example, you can run a backup of all your user accounts
  408. # at 5 a.m every week with:
  409. # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
  410. #
  411. # For more information see the manual pages of crontab(5) and cron(8)
  412. #
  413. # m h dom mon dow command
  414.  
  415. @reboot vertcoind -daemon
  416. @hourly vertcoind -daemon
  417. ```
  418. `ctrl+x` to save
  419.  
  420. \# Reboot and confirm `vertcoind` process spawns on reboot
  421. `pi@raspberrypi:~ $ sudo reboot `
  422.  
  423. \# Wait a minute, then log back in via SSH
  424. `ssh 192.168.1.2 -l pi`
  425. ```
  426. pi@raspberrypi:~ $ ps aux | grep vertcoin
  427. pi 406 99.9 9.5 169160 90256 ? Rsl 22:43 1:46 vertcoind -daemon
  428. pi 530 0.0 0.0 4372 560 pts/0 S+ 22:45 0:00 grep --color=auto vertcoin
  429. ```
  430. ##
  431. ### Quick note about blockchain syncing
  432. Vertcoin Core is now synchronizing to the side-loaded blockchain located in `/mnt/` (linked to `/home/pi/.vertcoin`). This process can take ~3-5 hours to sync headers and verify all of the downloaded blocks. You can monitor system resources by issuing the `htop` command and check up on `vertcoind` by issuing the following commands:
  433.  
  434. \# Display output of Vertcoin `debug.log`; `ctrl+c` to stop
  435. `pi@raspberrypi:~ $ tailf .vertcoin/debug.log`
  436.  
  437. \# Show blockchain information
  438. `pi@raspberrypi:~ $ vertcoin-cli getblockchaininfo`
  439.  
  440. \# Show current block
  441. `pi@raspberrypi:~ $ vertcoin-cli getblockcount`
  442.  
  443. ###### You may continue on while `vertcoind` catches up to the blockchain ...
  444.  
  445.  
  446. ## 9.) Configure firewall to allow Vertcoin Core traffic
  447.  
  448. ##### Please note that your `IP` range may be different than what I have listed below. If your router `IP` address is `192.168.1.1` then the instructions above require no alterations. If your `IP` address is something like `192.168.56.1` or `10.0.0.1` then you will need to modify the 'ufw allow from `192.168.1.0/24` to any port 22' to 'ufw allow from `192.168.56.0/24`(...)' or 'ufw allow from `10.0.0.0/24`(...)' respectively.
  449.  
  450. \# Install `UFW`
  451. `pi@raspberrypi:~ $ sudo apt-get install ufw`
  452.  
  453. \# Escalate to `root` and configure `UFW`
  454.  
  455. `pi@raspberrypi:~ $ sudo su`
  456. `root@raspberrypi:/home/pi# ufw default deny incoming`
  457. ```
  458. Default incoming policy changed to 'deny'
  459. (be sure to update your rules accordingly)
  460. ```
  461. `root@raspberrypi:/home/pi# ufw default allow outgoing`
  462. ```
  463. Default outgoing policy changed to 'allow'
  464. (be sure to update your rules accordingly)
  465. ```
  466. `root@raspberrypi:/home/pi# ufw allow from 192.168.1.0/24 to any port 22 comment 'allow SSH from local LAN'`
  467. `root@raspberrypi:/home/pi# ufw allow 5889 comment 'allow vertcoin core'`
  468. `root@raspberrypi:/home/pi# ufw enable`
  469. ```
  470. Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
  471. Firewall is active and enabled on system startup
  472. ```
  473. `root@raspberrypi:/home/pi# systemctl enable ufw`
  474. ```
  475. Synchronizing state of ufw.service with SysV service script with /lib/systemd/systemd-sysv-install.
  476. Executing: /lib/systemd/systemd-sysv-install enable ufw
  477. ```
  478. `root@raspberrypi:/home/pi# ufw status`
  479. ```
  480. Status: active
  481.  
  482. To Action From
  483. -- ------ ----
  484. 22 ALLOW 192.168.1.0/24 # allow SSH from local LAN
  485. 5889 ALLOW Anywhere # allow vertcoin core
  486. 5889 (v6) ALLOW Anywhere (v6) # allow vertcoin core
  487. ```
  488. \# Give up `root`
  489. `root@raspberrypi:/home/pi# exit`
  490.  
  491. Open a browser window and navigate to your router page, from there you can port forward your Raspberry Pi.
  492. `TCP/UDP Port: 5889`
  493.  
  494. ##### This will make your node public, supporting the health of the Vertcoin network by keeping it decentralized and populated with one more node.
  495.  
  496.  
  497.  
  498. ## 10.) `* OPTIONAL:` Setup Unitus Full Node for merged mining with p2pool-vtc
  499.  
  500. A Unitus full node may be setup to allow for merged mining rewards when mining with `p2pool-vtc`. Running two full nodes together on the same Raspberry Pi will mean that you will be storing two blockchains on your USB Flash Drive rather than one, and you will be using more resources on load and at idle. We can modify our `crontab` arguments to allow each process time to load and verify blocks with ample resources.
  501.  
  502. ##### `* OPTIONAL:` Refer back to step [2.) `*OPTIONAL:` Download and sync Vertcoin Core] ; Instead of downloading and syncing Vertcoin Core you will want to download and sync Unitus Core
  503.  
  504. \# Install `bitcoin` dependencies `https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md`
  505. `pi@raspberrypi:~ $ sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils python3 -y`
  506.  
  507. \# Install `boost` dependencies for `bitcoin`
  508. `pi@raspberrypi:~ $ sudo apt-get install libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev -y`
  509.  
  510. \# Install dependencies for `unitus`
  511. `pi@raspberrypi:~ $ sudo apt-get install libminiupnpc-dev libzmq3-dev`
  512.  
  513. \# Clone `unitusdev` repository into `/home/pi/` `https://github.com/unitusdev/unitus`
  514. `pi@raspberrypi:~ $ git clone https://github.com/unitusdev/unitus.git`
  515.  
  516. \# Download Berkley database, build from source and install
  517. ```
  518. # Download and configure BerkleyDB
  519. pi@raspberrypi:~ $ wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz
  520. pi@raspberrypi:~ $ tar -xzvf db-4.8.30.NC.tar.gz
  521. pi@raspberrypi:~ $ cd db-4.8.30.NC/build_unix/
  522. pi@raspberrypi:~/db-4.8.30.NC/build_unix $ ../dist/configure --enable-cxx
  523.  
  524. # This will take ~10 minutes
  525. pi@raspberrypi:~/db-4.8.30.NC/build_unix $ make -j4
  526.  
  527. # Compile and install BerkleyDB
  528. pi@raspberrypi:~/db-4.8.30.NC/build_unix $ sudo make install
  529.  
  530. # Change directories to the cloned git repo in home
  531. pi@raspberrypi:~/db-4.8.30.NC/build_unix $ cd
  532. ```
  533. \# Download and build `arm-linux-gnueabihf` compiler from source so we can compile `ARM` compatible binaries
  534. ```
  535. # Download and install arm-linux-gnueabihf ; This will take ~20 minutes
  536. pi@raspberrypi:~ $ cd unitus/
  537. pi@raspberrypi:~/unitus $ cd depends
  538. pi@raspberrypi:~/unitus/depends $ make HOST=arm-linux-gnueabihf NO_QT=1
  539. pi@raspberrypi:~/unitus/depends $ cd ..
  540. ```
  541. \# Configure `unitus` source and build
  542.  
  543. ```
  544. # Run the autogen.sh to allow for ./configure
  545. pi@raspberrypi:~/unitus $ ./autogen.sh
  546.  
  547. # Configure without GUI, use only static libraries, and minimize memory usage for building
  548. pi@raspberrypi:~/unitus $ ./configure --prefix=$PWD/depends/arm-linux-gnueabihf --without-gui --disable-shared --enable-glibc-back-compat --enable-reduce-exports LDFLAGS=-static-libstdc++ CXXFLAGS="--param ggc-min-expand=1 --param ggc-min-heapsize=32768"
  549.  
  550. # Compile ; This will take ~
  551. pi@raspberrypi:~/unitus $ sudo make clean && make
  552.  
  553. # Move unitus tools to /usr/bin/
  554.  
  555. ```
  556.  
  557. \# Change directory to `/mnt/`
  558. `pi@raspberrypi:~ $ cd /mnt/`
  559.  
  560. \# Create a directory for Unitus Core
  561. `pi@raspberrypi:/mnt $ sudo mkdir unitus`
  562.  
  563. \# Change to the `unitus` directory
  564. `pi@raspberrypi:/mnt $ cd unitus`
  565.  
  566. \# Create `unitus.conf` for Unitus Core
  567. `pi@raspberrypi:/mnt/vertcoin $ sudo nano unitus.conf`
  568. ```
  569. server=1
  570. rpcuser=node
  571. rpcpassword=yoursecurepasswordgoeshere
  572.  
  573. # makes client run in background
  574. daemon=1
  575.  
  576. # https://jlopp.github.io/bitcoin-core-config-generator/ lopp.net optimizations
  577. dbcache=100
  578. maxorphantx=10
  579. maxmempool=50
  580. maxconnections=40
  581. maxuploadtarget=5000
  582. ```
  583. `ctrl+x` to save
  584.  
  585. ##
  586. `* OPTIONAL:` A quick and easy way to generate a random password is taking the `md5sum` of a file
  587. ```
  588. pi@raspberrypi:/mnt/unitus $ touch randomfilename
  589. pi@raspberrypi:/mnt/unitus $ md5sum randomfilename
  590. d41d8cd98f00b204e9800998ecf8427e randomfilename
  591.  
  592. # Clean up
  593. pi@raspberrypi:/mnt/unitus $ rm randomfilename
  594. ```
  595. ##
  596.  
  597. \# Change directory back home
  598. ```
  599. pi@raspberrypi:/mnt/unitus $ cd
  600. pi@raspberrypi:~ $ pwd
  601. /home/pi
  602. ```
  603. \# Create soft link (symbolic link) connecting `/mnt/unitus/` <---> `/home/pi/.unitus`
  604. `pi@raspberrypi:~ $ sudo ln -s /mnt/unitus/ /home/pi/.unitus`
  605.  
  606. \# List all files in home
  607. ```
  608. pi@raspberrypi:~ $ ls -a
  609. . .. .bash_history .bash_logout .bashrc .config .nano .profile .selected_editor .unitus .vertcoin .wget-hsts
  610. ```
  611. \# List files in `/home/pi/.unitus`, confirm our configuration file `unitus.conf` is there
  612. ```
  613. pi@raspberrypi:~ $ ls .unitus
  614. unitus.conf
  615. ```
  616.  
  617. \# We must `poweroff` our Raspberry Pi so we can copy the Unitus blockchain over to the USB Flash Drive
  618. ```
  619. pi@raspberrypi:~ $ vertcoin-cli stop
  620. pi@raspberrypi:~ $ sudo poweroff
  621. ```
  622.  
  623. ##### Copy Unitus Blockchain to USB Flash Drive
  624. Once the Raspberry Pi is off unplug the micro USB power cable from it, then remove the USB Flash Drive from the Pi and insert it into the computer that you synced Unitus Core on. When Unitus Core is finished syncing the blockchain please navigate to the data directory for Unitus.
  625.  
  626. Default Windows Directory (Unitus): C:\Users\%USER%\AppData\Roaming\Unitus
  627.  
  628. Copy the folders `blocks` and `chainstate` to the `unitus` folder on your USB Flash Drive. This will allow us to side-load the Unitus blockchain and bootstrap faster than if we had the Raspberry Pi do all the work. Once you have copied the `blocks` and `chainstate` folders for Unitus to the `unitus` folder on the USB Flash Drive please safely remove it as to make sure we do not corrupt the drive.
  629.  
  630. Place the USB Flash Drive back into the Raspberry Pi and plug the micro USB cable back into the Raspberry Pi. It will begin to boot, return to your `ssh` command window
  631.  
  632. \# Wait a minute, then log back in via `SSH`
  633. `ssh 192.168.1.2 -l pi`
  634.  
  635. \# Confirm the Unitus blockchain is in `/home/pi/.unitus`
  636. ```
  637. pi@raspberrypi:~ $ ls .unitus
  638. blocks chainstate unitus.conf
  639. ```
  640.  
  641. ##### Edit `crontab` file to start Unitus hourly and on reboot to ensure the process is alive
  642. Here we will configure the crontab file to start vertcoind as a daemon on reboot and on each hour to ensure vertcoind always has a process thats alive. If vertcoind is already running when the hourly crontab executes it will simply fail to spawn a new process.
  643.  
  644. \# Configure crontab file to start `unitusd` hourly and on reboot ; sleep `unitusd` for 9 minutes then execute
  645. `pi@raspberrypi:~ $ crontab -u pi -e`
  646. ```
  647. # Edit this file to introduce tasks to be run by cron.
  648. #
  649. # Each task to run has to be defined through a single line
  650. # indicating with different fields when the task will be run
  651. # and what command to run for the task
  652. #
  653. # To define the time you can provide concrete values for
  654. # minute (m), hour (h), day of month (dom), month (mon),
  655. # and day of week (dow) or use '*' in these fields (for 'any').#
  656. # Notice that tasks will be started based on the cron's system
  657. # daemon's notion of time and timezones.
  658. #
  659. # Output of the crontab jobs (including errors) is sent through
  660. # email to the user the crontab file belongs to (unless redirected).
  661. #
  662. # For example, you can run a backup of all your user accounts
  663. # at 5 a.m every week with:
  664. # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
  665. #
  666. # For more information see the manual pages of crontab(5) and cron(8)
  667. #
  668. # m h dom mon dow command
  669.  
  670. @reboot vertcoind -daemon
  671. @hourly vertcoind -daemon
  672. # sleep 9 minutes then start unitus daemon
  673. @reboot sleep 540; unitusd -daemon
  674. ```
  675.  
  676.  
  677. ## 11.) `* OPTIONAL:` Setup p2pool-vtc
  678.  
  679. This section gives you the option of setting up an instance of a Vertcoin P2Pool on the Raspberry Pi to run alongside the `vertcoind` daemon.
  680.  
  681. >P2Pool is a decentralized Bitcoin mining pool that works by creating a peer-to-peer network of miner nodes.
  682.  
  683. >P2Pool creates a new block chain in which the difficulty is adjusted so a new block is found every 30 seconds. The blocks that get into the P2Pool block chain (called the "share chain") are the same blocks that would get into the Bitcoin block chain, only they have a lower difficulty target. Whenever a peer announces a new share found (new block in the P2Pool block chain), it is received by the other peers, and the other peers verify that this block contains payouts for all the previous miners who found a share (and announced it) that made it into the P2Pool share chain. This continues until some peer finds a block that has a difficulty that meets the Bitcoin network's difficulty target. This peer announces this block to the Bitcoin network and miners who have submitted shares for this block are paid in the generation transaction, proportionally to how many shares they have found in the last while. - Unknown author [3]
  684. >
  685. > Decentralized payout pooling solves the problem of centralized mining pools degrading the decentralization of Bitcoin and avoids the risk of hard to detect theft by pool operators.
  686. >
  687. > Miners are configured to connect to a P2Pool node that can be run locally, alongside the miner. P2Pool users must run a full Bitcoin node which serves the purpose of independently validating transactions and the Bitcoin blockchain.
  688. >
  689. > P2Pool nodes work on a chain of shares similar to Bitcoin's blockchain. Each node works on a block that includes payouts to the previous shares' owners and the node itself, which can also result in a share if it meets P2Pool's difficulty.
  690.  
  691. \# Install `p2pool-vtc` dependencies and `python-pip`
  692.  
  693. `pi@raspberrypi:~ $ sudo apt-get install python-rrdtool python-pygame python-scipy python-twisted python-twisted-web python-imaging python-pip`
  694.  
  695. \# Install `bitcoin` dependencies and `libffi-dev`
  696.  
  697. `pi@raspberrypi:~/p2pool-vtc $ sudo apt-get install build-essential libtool autotools-dev automake pkg-config libffi-dev libssl-dev libevent-dev bsdmainutils python3`
  698.  
  699. \# Clone `p2pool-vtc`
  700. ```
  701. pi@raspberrypi:~ $ git clone https://github.com/vertcoin-project/p2pool-vtc.git
  702. Cloning into 'p2pool-vtc'...
  703. remote: Counting objects: 8393, done.
  704. remote: Total 8393 (delta 0), reused 0 (delta 0), pack-reused 8393
  705. Receiving objects: 100% (8393/8393), 2.54 MiB | 0 bytes/s, done.
  706. Resolving deltas: 100% (5611/5611), done.
  707. ```
  708.  
  709. \# Change directory to `p2pool-vtc`
  710. `pi@raspberrypi:~ $ cd p2pool-vtc/`
  711.  
  712. \# Install `requirements.txt` dependencies
  713. `pi@raspberrypi:~/p2pool-vtc $ pip install -r requirements.txt`
  714.  
  715. \# Configure P2Pool
  716. `pi@raspberrypi:~/p2pool-vtc $ cd lyra2re-hash-python/`
  717. `pi@raspberrypi:~/p2pool-vtc/lyra2re-hash-python $ git submodule init`
  718. `pi@raspberrypi:~/p2pool-vtc/lyra2re-hash-python $ git submodule update`
  719. `pi@raspberrypi:~/p2pool-vtc/lyra2re-hash-python $ sudo python setup.py install`
  720.  
  721. \# Download alternate web frontend for P2Pool
  722. `pi@raspberrypi:~/p2pool-vtc/lyra2re-hash-python $ cd`
  723. `pi@raspberrypi:~ $ git clone https://github.com/hardcpp/P2PoolExtendedFrontEnd.git`
  724. `pi@raspberrypi:~ $ cd P2PoolExtendedFrontEnd`
  725.  
  726. \# Move all files in `P2PoolExtendedFrontEnd` to the `web-static` folder in `p2pool-vtc`
  727. `pi@raspberrypi:~/P2PoolExtendedFrontEnd $ mv * /home/pi/p2pool-vtc/web-static/`
  728. `pi@raspberrypi:~/P2PoolExtendedFrontEnd $ cd`
  729.  
  730. \# Clean up
  731. `pi@raspberrypi:~ $ sudo rm -r P2PoolExtendedFrontEnd/`
  732.  
  733.  
  734. #### Network 1 - Firewall Configuration
  735. > If you are a smaller miner with 2 graphics cards or less or are using your CPU, it is recommended to use Network 2. If you are a larger miner with multiple cards and/or a hash rate larger than 100Mh, it is recommended to use Network 1.
  736.  
  737. \# Escalate to `root`
  738. `pi@raspberrypi:~ $ sudo su`
  739. `root@raspberrypi:/home/pi# ufw allow 9346 comment 'allow --network 1 p2p port'`
  740. `root@raspberrypi:/home/pi# ufw allow 9171 comment 'allow --network 1 mining port'`
  741.  
  742. \# Give up `root`
  743. `root@raspberrypi:/home/pi# exit`
  744.  
  745. #### Network 2 - Firewall Configuration
  746. > If you are a smaller miner with 2 graphics cards or less or are using your CPU, it is recommended to use Network 2. If you are a larger miner with multiple cards and/or a hash rate larger than 100Mh, it is recommended to use Network 1.
  747.  
  748. \# Escalate to `root`
  749. `pi@raspberrypi:~ $ sudo su`
  750. `root@raspberrypi:/home/pi# ufw allow 9347 comment 'allow --network 2 p2p port'`
  751. `root@raspberrypi:/home/pi# ufw allow 9181 comment 'allow --network 2 mining port'`
  752.  
  753. \# Give up `root`
  754. `root@raspberrypi:/home/pi# exit`
  755.  
  756. ##
  757.  
  758. #### `* OPTIONAL:` Setup P2Pool bash script for execution on reboot
  759. ###### Note: This walkthrough uses the default settings.
  760. ```
  761. pi@raspberrypi:~/p2pool-vtc $ python run_p2pool.py --help
  762. usage: run_p2pool.py [-h] [--version]
  763. [--net {bitcoin,btcregtest,fastcoin,litecoin,terracoin,vertcoin,vertcoin2}]
  764. [--testnet] [--debug] [-a ADDRESS] [-i NUMADDRESSES]
  765. [-t TIMEADDRESSES] [--datadir DATADIR]
  766. [--logfile LOGFILE] [--web-static WEB_STATIC]
  767. [--merged MERGED_URLS]
  768. [--give-author DONATION_PERCENTAGE] [--iocp]
  769. [--irc-announce] [--no-bugreport] [--p2pool-port PORT]
  770. [-n ADDR[:PORT]] [--disable-upnp] [--max-conns CONNS]
  771. [--outgoing-conns CONNS] [--external-ip ADDR[:PORT]]
  772. [--disable-advertise] [-w PORT or ADDR:PORT]
  773. [-f FEE_PERCENTAGE]
  774. [--miner-share-rate SHARES_PER_MINUTE]
  775. [--address-share-rate SHARES_PER_MINUTE]
  776. [--min-difficulty DIFFICULTY]
  777. [--bitcoind-config-path BITCOIND_CONFIG_PATH]
  778. [--bitcoind-address BITCOIND_ADDRESS]
  779. [--bitcoind-rpc-port BITCOIND_RPC_PORT]
  780. [--bitcoind-rpc-ssl]
  781. [--bitcoind-p2p-port BITCOIND_P2P_PORT]
  782. [BITCOIND_RPCUSERPASS [BITCOIND_RPCUSERPASS ...]]
  783.  
  784. ```
  785.  
  786. #### `* OPTIONAL:` Setup P2Pool bash script for execution on reboot
  787. `pi@raspberrypi:~ $ nano start-p2pool.sh`
  788. ```
  789. #!/bin/bash
  790. #
  791. # run p2pool with pre-configured settings
  792. #
  793. # network 1 = --net vertcoin
  794. # network 2 = --net vertcoin2
  795. #
  796. cd p2pool-vtc
  797. python run_p2pool.py --net vertcoin
  798. ```
  799.  
  800. \# Give execute privileges to `start-p2pool.sh`
  801. `pi@raspberrypi:~ $ chmod +x start-p2pool.sh`
  802.  
  803. \# Configure `crontab` file to execute `start-p2pool.sh` on reboot
  804. `pi@raspberrypi:~ $ crontab -u pi -e`
  805. ```
  806. # Edit this file to introduce tasks to be run by cron.
  807. #
  808. # Each task to run has to be defined through a single line
  809. # indicating with different fields when the task will be run
  810. # and what command to run for the task
  811. #
  812. # To define the time you can provide concrete values for
  813. # minute (m), hour (h), day of month (dom), month (mon),
  814. # and day of week (dow) or use '*' in these fields (for 'any').#
  815. # Notice that tasks will be started based on the cron's system
  816. # daemon's notion of time and timezones.
  817. #
  818. # Output of the crontab jobs (including errors) is sent through
  819. # email to the user the crontab file belongs to (unless redirected).
  820. #
  821. # For example, you can run a backup of all your user accounts
  822. # at 5 a.m every week with:
  823. # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
  824. #
  825. # For more information see the manual pages of crontab(5) and cron(8)
  826. # m h dom mon dow command
  827. @reboot vertcoind -daemon
  828. @hourly vertcoind -daemon
  829.  
  830. # sleep 15 minutes then start p2pool
  831. @reboot sleep 900; /home/pi/start-p2pool.sh
  832. ```
  833. Note: Running P2Pool 15 minutes after reboot allows the Raspberry Pi resources and time to verify, load the blockchain and catch up if needed.
  834.  
  835. \# `* OPTIONAL:` Display output of P2Pool's `debug` log; `ctrl+c` to stop
  836. `pi@raspberrypi:~ $ tailf p2pool-vtc/data/vertcoin/log`
  837.  
  838. #### Documentation
  839. `https://github.com/vertcoin-project/p2pool-vtc`
  840. `https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md`
  841.  
  842. ##
  843.  
  844.  
  845.  
  846. ##
  847. ## Congratulations!
  848. You have successfully setup a full Vertcoin Core node on a Raspberry Pi. Thank you for following along and contributing to the Vertcoin network by helping keep it populated with nodes and distributed. You help give meaning to 'the peoples' coin'!
  849. ```
  850. pi@raspberrypi:~ $ vertcoin-cli getblockchaininfo
  851. {
  852. "chain": "main",
  853. "blocks": 888507,
  854. "headers": 915979,
  855. "bestblockhash": "c56f7d9fbddd4073c68d18e901944dd50cad072b3fa39bbd0047e476b5297898",
  856. "difficulty": 45108.82829895391,
  857. "mediantime": 1520320068,
  858. "verificationprogress": 0.9595547815279806,
  859. "initialblockdownload": true,
  860. "chainwork": "0000000000000000000000000000000000000000000000015f56d79735e934ce",
  861. "size_on_disk": 3240624105,
  862. "pruned": false,
  863. "bip9_softforks": {
  864. "csv": {
  865. "status": "active",
  866. "startTime": 1488326400,
  867. "timeout": 1519862400,
  868. "since": 691488
  869. },
  870. "segwit": {
  871. "status": "active",
  872. "startTime": 1488326400,
  873. "timeout": 1519862400,
  874. "since": 713664
  875. },
  876. "nversionbips": {
  877. "status": "active",
  878. "startTime": 1488326400,
  879. "timeout": 1519862400,
  880. "since": 691488
  881. }
  882. },
  883. "warnings": ""
  884. }
  885. ```
  886.  
  887.  
  888.  
  889. ## References
  890. `[1] How to Create Your Own Bitcoin Full Node With a Raspberry Pi http://www.raspberrypifullnode.com/`
  891. `[2] Jameson Lopp - Bitcoin Nodes, how many is enough? https://medium.com/@lopp/bitcoin-nodes-how-many-is-enough-9b8e8f6fd2cf`
  892. `[3] Bitcoin Wiki - P2Pool https://en.bitcoin.it/wiki/P2Pool`
  893.  
  894. ``
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement