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.