How do I run a TurtleCoin node on PI?

How do I run a TurtleCoin node on PI?

In the Reflecting Back: Getting that slow-hash to work on aarch64 we have shared our journey to get TurtleCoin to work on SBCs, such as Raspberry PI, Orange PI or Rock64 boards.

Today, you can read how to set up your own at home.

First, you need a suitable single-board ARM computer. Yes, you can use 64 Raspberry PI 3b(+), and we know these are quite popular among you folks. However, it is not the most suitable hardware.

We run DeroGold and TurtleCoin public nodes on a Rock64 4GB and on an OrangePI 3 boards respectively.

Apart from a suitable board, you will need a good-quality, fast and reliable USB FlashDrive, such as SanDisk Ultra Fit USB 3.1 Flash Drive. We use the 128 GB version that gives us enough breathing room for the coin blockchain to grow.

For both boards, grab the Linux OS of your choice. We recommend to either use Armbian, or in case of OrangePI you can grab the legacy-kernel Ubuntu Server 16.04 supplied by the manufacturer of these boards.

Once you have your OS flashed to a microSD card or emmc (both boards come optionally with EMMC storage, which we recommed you to use for long-term, production use) and your board booted up and networking set up, start with updating the system:

sudo apt update
sudo apt upgrade

Create a partition and file system on your 128GB USB Flash Drive. Find out the device name /dev/sdX, use fdisk to create a new partition and create a new file system.

fdisk -l

In our case the device name is /dev/sda, we will create a /dev/sda1 primary partition on it.

fdisk /dev/sda

Now we will create the file system.

mke2fs -t ext4 -O ^has_journal /dev/sda1

We will add the new file system to /etc/fstab to mount at each boot of your node. First we will find out the UUID of the /dev/sda1 device.

blkid

Our partition has the UUID 57f8f4bc-abf4-655f-bf67-946fc0f9f25b. We will use it to mount in the /etc/fstab

Mount the file system before using of course.

mount /dev/sda1 /root/.TurtleCoin

Now that we have the storage ready for TurtleCoin blockchain, we will download the latest release of the TurtleCoin daemon for aarch64 platform. You can download the latest release from TurtleCoin Github. To download the file directly to your directory, use wget.

root@OrangePi:~# wget https://github.com/turtlecoin/turtlecoin/releases/download/v0.14.0/turtlecoin-v0.14.0-aarch64.tar.gz --no-check-certificate

Un-GZ-tar the archive using tar xvzf command and cd into the turtlecoin directory.

tar xvzf turtlecoin-v0.14.0-aarch64.tar.gz

In the TurtleCoin directory run wget to download the latest Checkpoints.

wget https://github.com/turtlecoin/checkpoints/raw/master/checkpoints.csv --no-check-certificate

Run the daemon for the first time, load checkpoints for faster blockchain sync. This step could take very long when done from scratch, at the time of writing, TurtleCoin blockchain height (block number) is 1447359. Depending on your internet connection, this could take 1-3 days.

Please note in the command below, we set the TurtleCoin log file location from the default TurtleCoin working directory to the directory where we store blockchain on the USB FlashDrive. It is not necessary to do this if you use EMMC storage to run your operating system, however, if you use microSD card, this is highly adviseable to prevent wearing out your microSD card over the next months you will run your node.

./TurtleCoind --log-file /root/.TurtleCoin/TurtleCoind.log --load-checkpoints checkpoints.csv 

Come back in a few days. Check regularly.

Alternatively, if you don’t want to wait for the blockchain sync from scratch, and in case you already run your node on your laptop or a computer, just copy the .TurtleCoin directory with the blockchain to the Flash Drive USB drive.

Once you have a fully synced blockchain, stop the TurtleCoin daemon by typing exit and wait for it to stop fully.

If you want to run you TurtleCoin node as a public node for serving other user’s wallets (and earning some extra TRTL in transaction fees), open the port 11898 on your firewall and start the TurtleCoin daemon with the following parameters. If you are on your home broadband and need to connect externally, you need to find out your external IP address. How to do this is out of scope of this article, and surely Google will help you.

In the example below, change the <your TRTL address> with your actual TurtleCoin wallet address to recieve TRTL and specify your desired transaction fee. In our example, we charge 19 TRTL fee (must be specified in TRTL atomic units, which is 2 decimal places, therefore 1900 shells = 19 TRTL)

nohup ./TurtleCoind --data-dir /root/.TurtleCoin --log-file /root/.TurtleCoin/TurtleCoind.log --log-level 2 --enable-blockexplorer --rpc-bind-ip 0.0.0.0 --rpc-bind-port 11898 --p2p-bind-ip 127.0.0.0 --p2p-bind-port 11897 --fee-address <your TRTL address> --fee-amount 1900 &

This example allows only TRTL wallet connections via RPC, and does not allow other nodes to connect to your node for blockchain synchronization via peer-to-peer connection.

In order to improve high-availability of your node and almost “plug & forget”, you may want to install turtlecoin-ha scripts and PM2. How to do this is described in the Readme in the TurtleCoin-ha repo in the TurtleCoin GitHub.

You can now connect with the wallet of your choice to your own TurtleCoin node running on Pi!

Reflecting back: getting that slow-hash to work aarch64

Reflecting back: getting that slow-hash to work aarch64

When we started experimenting with the ARM-based SBCs, such as Pine/Rok64, OrangePI, BananaPI, Odroid boxes and many other boards, we had an ultimate dream.

How good it would be to run a TurtleCoin node on a small, energy-efficient harware. How cool it would be to expand this to literally any other cryptonight-based coin?

The inspiration came to us from CASA, who do RaspberryPI-based node for Bitcoin.

However, at the time of our first experiments around June 2018, TurtleCoin and any other cryptonight-based privacy coins would segfault on a aarch64 ARM platform. According to our tests on OrangePI One Plus and Rock64 boards, this was including Monero, however, Monero guys at the time of experimenting and debugging in January 2019 would deny it.

The problem, in short, was in slow-hash part of the code and the scartchpad size. The scrachpad size is bigger in most cryptonight variants compared to the size of L1/L2 cache. The scratchpad would not fit to the cache and hence segfault. The trick was to add FORCE_USE_HEAP to the preprocessor, so that the slow-hash routines would run properly on ARM architecture.

We cannot give enough credit and kudos here to IBURNMYCD, ZPALMTREE, RASHED and THINKPOL for our hours and hours together on a Discord chat to debug, investigate and fix this issue. Additionally, we are thankful to MorrocanMalinois’ comment in the Monero Github chat who pointed us to the right direction.

Whilst Monero guys claimed they ran Monero daemon on various aarch64 platforms for years with no problem, this was not what we saw for at least the three boards we tested: Rock64, Rock64 Pro, OrangePI One Plus. When performing our own tests, we saw Monero code (latest release as of mid-January 2019) segfaulting on Linux ARM/aarch64 platform the similar way TurtleCoin did. Adding FORCE_USE_HEAP to the Monero’s slow-hash code fixed the problem same way it dit for TurtleCoin.

Resolving this issue opened the endless possibilities for anyone to run their own TurtleCoin (or other cryptonight-based privacy coins) at home.

The purpose of this article here is to document the investigation and fix we at TurtleCoin did and why we were so keen to get this issue sorted.

In one of our next posts, we will show you how to run your own TurtleCoin node at home.

For the more adventurous of you, we tested to run a public node on Rock64 and OrangePI 3 boards.

What about minig on Raspberry 3B(+)?

What about minig on Raspberry 3B(+)?

This post is a short follow up to our previous article on mining cryptonight-turtle algo coins with SBCs (OrangePI One Plus).

The good news is yes, if you have got a Raspberry 3B(+), you can mine TurtleCoin (or other coins based on the cryptonight-turtle algo, as well as other cryptonight variants) on your Raspberry 3B (or 3B+).

Note however, that just because you can do this, it may not be the most efficient thing to do. Additionally, we are famously known for not doing anything with Raspberries. There are better boards, fully Open Sourced. We discussed this in our other post. If you still want to do it, just follow our tips here.

Firstly, you will need a full 64-bit system. Many folks contacted me on Discord quite a few times asking me why xmrig binaries from your github repo fork do not work.

It is most likely your system is not full 64-bit – it has loaded a 64bit kernel, but uses 32bit user space. How to find out that this is the problem you have? On your command prompt do

file /bin/bash

If it returns anything similar to the following, stop right here.

/bin/bash: ELF 32-bit LSB executable, ARM, EABI5 version 1 

Head over the to get a full 64bit system for your Raspberry. There are number of options, at the time of writing we knew at least about the following:

Now that you have your system sorted, you can decide to either build xmrig for your board from source, for that, just follow the xmrig readme guide on their github repo for building on your system.

Alternatively, you can download aarch64 binaries compiled for ARM architecture from my forked xmrig repo on github.

In order for the compiled binaries to work, you need to install the following packages:

  • libuv1-dev
  • libmicrohttpd-dev
  • libssl-dev

If you got this far, now you should have a working xmrig verion on your Raspberry Pi 3B(+). Happy mining.

How Can I Mine On My Orange pi?

How Can I Mine On My Orange pi?

We have heard this question quite frequently on TurtleCoin Discord chat. This is our initial guide to give you a head start on sustainable, best performing SBC mining, focused on OrangePI One Plus board. This board is at the time of writing this post most likely the most efficient hardware to mine on.

Overview and background

A bit of a background on where and when we started at Cuvée with this project. We have first explored the topic of mining on an SBC around December 2017. TurtleCoin was very new back then, so we tried mining Bytecoin and Monero first. It worked. However, with these coins focus and philosophy, this undertaking was only good for a thought experiment.

Over the course of time, we have evaluated many SBC Boards for mining (and other purposes), including (not a comprehensive list):

  • OrangePI PC (H3)
  • Orange PI Zero Plus (H5)
  • Orange PI One Plus (H6)
  • Orange PI 3 (H6)
  • Rock64 (RK3328)
  • BananaPI M3

We have heard from other community memebers on TurtleCoin Discord to test Raspberry PI 3b+ and Nvidia Jetson Nano (both tested and xmrig mining software adapted by @thinkpol). We believe the Nvidia Jetson Nano could be a hidden gem, we will cover this in a separate blog post.

Out of all the tests with mining throughout TurtleCoin (and other coins) algorithms, the Orange PI One Plus stands out (at the time of writing) as a clear winner. We recommend you start your journey with this board.

Why? At the current TurtleCoin algo (crytponight-turtle), you can achiveve around 600 – 700 hashes per second (h/s). Some community members took it to the extreme and achieve consistently 750 h/s. Simple maths. If you buy 10 boards, these will give you anything between 6 – 7.5 kh/s at a power consumption of about 50 watts.

Preparing your set up

There are number of things you will need if you take mining with OrangePI One Plus seriously. In order to be effective with it, you will need more than one board. We will losely describe our first set up we did with 10 boards.

For you to get started, you will need the following:

  • Orange PI One plus in the required quatity (ideally to start with 10x)
  • 16-port (at least) Ethernet Gigabit Switch
  • Network Cables
  • Power cables for Orange PI One Plus (either USB to microUSB, or USB to barrel plug of the required specification)
  • USB Power Adapters or Charging USB Hub (2x 5-port with output of 2A per 5V port at least)
  • microSD cards (8GB or 16GB whichever you can get cheaper, no need to go for more storage for mining)
  • Heat sinks for the H6 chip on the OrangePI
  • Spacers to mount the OrangePI Boards together (2×5 tower set up)
  • 80 – 100mm 12V fans (2x) with USB plugs to ensure airflow between the boards
  • Internet connection / home broadband router to connect the Gigabit Switch for your boards

That’s it for the list of hardware. At the bottom of this blog post, we show you examples and links for the components we use.

Mostly, we order from AliExpress. Over the 3 years of sourcing in China, we developed a network of trusted producers, suppliers and resellers that we never encountered any problem with. Going forward, we will open our own e-shop with all the required components to server UK, EU (and possibly US/Canada) customers. We keep you updated on this.

Once you have all ready, just do the following steps:

  • Put heatsinks to the H6 chip on your OrangePI One Plus boards
  • Mount them together to 2×5 towers using spacers
  • Connect your gigabit ethernet switch to your home broadband switch
  • Connect all the OrangePI One Plus boards with the gigabit ethernet switch
  • Plug all the microUSB or barrel plug power cables to the boards
  • Mount (glue) your fans to the side of each tower
  • Plug your Charging USB hubs to the power
  • Do not power up the boards yet

Setting it all up – getting the board running

Now that you have your components in place, it is time for us to start the real work.

Take out your microSD cards. Get your favourite OS for the OrangePI One Plus board. At the time of writing, there are two images available:

While the Armbian will be a great choice when Mainline kernel support for the Allwinner H6 chip is ready, for the purpose of mining, the official OrangePI Ubuntu 16.04 BETA with legacy kernel does a good job as well.

Download the image and write it to the microSD card using your favourite tool. For the UNIX hard liners, there is no better tool than DD, for everyone else, tools such as Etcher will do just fine.

Once you have the OS image ready, insert the microSD to your Orange PI One Plus boards and power them up.

Shortly, these should be up and running. If your home / work environment allows for DHCP, all the boards should have obtained a DHCP address.

Please note the OrangePI One Plus boards come all with same MAC address from the factory. You need to assign each board a different MAC address. In produtions versions, Armbian does this for you at the boot time. All other systems, either modify the boot enviroment (outside of scope of this article), or fire these boards one by one and edit the /etc/network/interfaces.d/eth0 file and add:

hwaddress ether 00:01:04:1b:2C:1F

The MAC address above is only an example. Pick your own. Different one for each board.

If you need to set up static addresses, there are lots of examples on how to do this for a Ubuntu/Debian-like systems, just google it.

With the MAC addresses and networking sorted, you should be in the position to connect to your boards via ssh now.

For Armbian, the default login is root / 1234, for OrangePI Ubuntu, the default login is root / orangepi.

We cannot stress more the importance to change those default passwords at the first login.

Installing & running the xmrig miner

With you now possibly logged in to the system, we will now install and configure your miner from scratch.

First, update your system.

sudo apt update
sudo apt upgrade

Second, prepare your system to compile xmrig using GCC-8 / g++-8 and install other build pre-requisites.

sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt update
sudo apt install aptitude -y
sudo aptitude install -y build-essential g++-8 gcc-8 git cmake libuv1-dev libmicrohttpd-dev libssl-dev
export CC=gcc-8
export CXX=g++-8
git clone https://github.com/xmrig/xmrig.git
cd xmrig
mkdir build
cd build
cmake ..
make

This should compile your xmrig binary in the xmrig/build directory.

In most cases, there is no need to add any extra flags for CMAKE. At least we did not need to do this for our 50+ OrangePI boards we set up at the time of writing. Some community members will swear use this or that and you gain extra few hashes. We leave up to you to experiment.

In our experience, all the SBCs we tested (see the list above in Overview section of this post), this generic step by step guide works all boards we tested. This is however, not true for Raspberry PIs. Look elsewhere for Raspberry PI guides – main caviat being you need a true 64bit system for a Raspbperry board – some of the systems have 64bit kernel, but not the user space. In our view, as much we admire these boards for education purpose, we do not use them for our own or customer projects. And we definitely do not recommend any Raspberry for mining.

Now, we will run your miner for the first time. Go the the $HOME/xmrig/build directory and run the following command:

./xmrig -a cryptonight-turtle -o publicnode.ydns.eu:3333 -u <your TRTL wallet address> --donate-level 1

If all went well (there is no reason why it should not!), you should see something similar to the following on your terminal screen:

Congratulations. Your miner is now up and running. If you want to leave it running without you having have to keep logged onto the system via ssh, just run the following command:

nohup ./xmrig -a cryptonight-turtle -o publicnode.ydns.eu:3333 -u <your TRTL wallet address> --donate-level 1 &

This will keep your xmrig miner up and running on the background after you log out from the system.

Important: Choose whichever TurtleCoin mining pool you like. The one we mention here is our own CuvéeARM TurtleCoin pool that runs on OrangePI.

Repeat this for all your boards (in our example case 10 boards) to get you the fantastic hash rate of 7.4kh/s at a maximum power consumption of 50 watts.

Happy TurtleCoin mining!

Appendix A – What and where to buy

OrangePI One Plus on Aliexpress. Shop served by the Shenzen Xunlong Ltd., the company behind OrangePI.

OrangePI One Plus

Flat Ethernet Cables from Aliexpress. We love them for saving space.

Flat Ethernet Cables.

Orico 5x port USB charging hub from Aliexpress. These power most of our set-ups.

Orico charging hub

Heat sinks from Aliexpress. We buy these in bulk, best we found for our boards.

Heat sinks

Box full of spacers from Aliexpress. There is never enough of these!

Box with spacers.

We will add other items that we find useful going forward, most likely these will end up in a separate post.

The Future of Computing Is Distributed

The Future of Computing Is Distributed

Well back in 2015, we started experimenting with Single Board Computers based on the ARM architecture. We were evaluating multiple use case scenarios: TV iPlayers, Video streaming, Distributed Storage clusters, IoT Sensors applications, managing production lines and many more.

It wasn’t until about end of 2017 when an idea of exploring the possibilities of those boards in the Crypto World. Over the past 1.5 years, we tortured these boards as miners, TurtleCoin (and a few other coins) public and private nodes and recently even a TurtleCoin mining pool.

We have gained plenty of experience from these Proof of Concepts, many resulted in very positive and surprising results.

We took these boards in the crypto world probably as far as no-one other did until now. Here in this place, we will share with you our knowledge: what we did, what we used, what worked, what did not.

How far we take this new site remains to be seen. There are a few ideas around providing SBCs as a service (the new fancy word for hosting) for your projects, whatever these might be. We will definitely try to push SBC boards as far in the crypto use cases as we can, predominantly based on TurtleCoin, which we consider our friendly home 🙂

Why?

We believe the future of the computing is small computing units, distributed. Forget big datacenters, hyperconverged and all that nonsense.

OrangePI One Plus: The First Look

OrangePI One Plus: The First Look

Reposting one of our earlier posts written in February 2018 when OrangePI One Plus board from Shenzen Xunlong was hot new off the prodution line.

Expanding on our experience with single-board computers that we can use for our embedded solutions, we have ordered the new OrangePI One Plus from Steven Zhao’s Shenzhen Xunlong Software CO.,Limited company.

We placed the order via AliExpress on 3rd of January 2018 – and voila – the package arrived at our office yesterday (19th February 2018).

We have ordered two OrangePI One Plus boards with Allwiner H6 (ARM Cortex A-53 Quad Core 64 bit SoC and equipped with 1GB LPDDR which is shared with GPU. You can find full specifications in the following website:

http://www.orangepi.org/OrangePiOneplus/

OrangePI official website.

In the picture below, you can see the single-board computer layout.

First impressions, the board is incredibly smaller compared with the OrangePI PC H3 boards that we used in the past. The build quality is very good, so after few minutes of visual inspection of the board, it is time to do something with it.

Initially, we have ordered these boards to evaluate a TV solution that we are prototyping. However, for this specific board, we wanted to try out the Ubuntu Linux build for this H6 board that is available for download from the following official OrangePI website:

http://www.orangepi.org/downloadresources/

In the future, we plan to build our own distribution for the H6-based boards that will better suit our needs in production-line management & industrial applications.

We downloaded the Ubuntu Server image from the OrangePI website, and used Etcher to flash the image onto an micro-SD card.

The system booted up nicely and picked up an IP address via DHCP. We logged in using the default root / orangepi username and password and started exploring.

The Ubuntu server seems to contain a bare minimum components, so expect you will need to install / add number of packages as per your use cases & requirements.

root@OrangePi:~# uname -a
Linux OrangePi 3.10.65 #35 SMP PREEMPT Tue Jan 23 18:13:02 CST 2018 aarch64 aarch64 aarch64 GNU/Linux

As a first step, we installed RaspberryPI Monitor (RPImonitor) and adapted it to suit the H6 board. No major changes were required compared to H3 configuration. The only problem seemed to be the temperature reading, which translated the 40 degrees Celsius as 0.04. It was an easy fix, it only required to remove the post-processing rule to divide the temperature by 1000 in the /etc/rpimonitor/templates configuration file(s). Once RPImonitor installed and running, you can check the health of your system at http://localhost:8888 (or http://<your_ip_address>:8888).

In the picture below you can see data from our OrangePI One Plus running cpuminer, that’s why the CPU and temperature values are so high. Idle system with a passive heatsink showed temperature of about 35 degrees Celsius.

As a second step, we installed LAMP, that is Apache2, MySql database and PHP. There is plenty of information on the web on how to do this, so we skip the details, just show the results. You can check http://<your_ip_address>/ to see Apache server up and running, and for example by creating index.php containing the phpinfo() function to see if PHP is working with your Apache web server. Similar test you can do to connect with MySql from a PHP file, see example of the code of the picture below.

Point to the file in your browser (in our example the file name was phpdbtest.php (placed in the html root of the Apache web server) and it gives us a successful result.

LAMP stack is now installed successfully on our OrangePI One Plus system, so now we can move to the next step.

As a last step, we wanted to see how much load our OrangePI One Plus board can bear, therefore we decided to get, compile and run cpuminer to mine some Monero. As you can see, we have the miner running, and with both passive heatsink and active fan, we get a hash rate of about 12H/s and SoC temperature about 65C.

root@OrangePi:~/cpuminer-multi# ps -ef |grep cpum
root 15169 15144 99 00:38 pts/0 2-18:32:17 ./cpuminer -a cryptonight -o stratum+tcp://bcn.pool.minergate.com:45550 -u xxx@xxxx.xxx -p x

Overall, we are impressed by OrangePI One Plus board, and certainly we will use it in our embedded systems. In the next few days, we will be testing the H6 accelerated graphics capabilities to finish off one of our proof of concepts. Also, we plan to test the GPIO interface.