Building and Running a full Grin Node (Grin++) on Android

BIG NOTES: the node is still unstable. I will keep this thread up to date. Do not waste your time trying to do this on Windows. The target for now is Android 10.

The first thing that we need is the Android NDK. The Android NDK is a toolset that lets you embed components that make use of native code in your Android applications. Grin++ is written in the almighty C++ therefore we could use the Android NDK to build this little baby. At this moment we will need to download the NDK from the Canary (or Dev) Channel because it is a mess to update the toolchain for the stable release, if anyone is able to do it, please let me know commenting this post.

vcpkg

vcpkg is a command-line package manager for C++. It greatly simplifies the acquisition and installation of third-party libraries on Windows, Linux, and macOS. If your project uses third-party libraries, we recommend that you use vcpkg to install them. vcpkg supports both open-source and proprietary libraries. Installing this tool is as easy as this:

$ sudo apt-get update
$ sudo apt-get install build-essential tar curl zip unzip
$ git clone https://github.com/microsoft/vcpkg
$ cd vcpkg
$ bash bootstrap-vcpkg.sh
$ ./vcpkg integrate install

Android ADB

Android Debug Bridge (adb) is a versatile command-line tool that lets you communicate with a device. The adb command facilitates a variety of device actions, such as installing and debugging apps, and it provides access to a Unix shell that you can use to run a variety of commands on a device.Install Android ADB using this guide https://androidmore.com/install-adb-fastboot-linux/

Downloading the Latest build of the Android NDK.

Go the Android CI Branch Grid and pick the latest build:

AndroidNDK

Now download the zip file of more than 1GB of course:

Extract the zip file into your preferred folder.

Show Time!!! :call_me_hand:

I wrote a bash script to simplify the process:

cd /home/david/Projects/
git clone https://github.com/GrinPlusPlus/GrinPlusPlus
cd GrinPlusPlus
git checkout android-arm64

vcpkg install --overlay-triplets=vcpkg/custom_triplets --triplet arm64-android-static --debug mio && \
vcpkg install --overlay-triplets=vcpkg/custom_triplets --triplet arm64-android-static --debug libuuid && \
vcpkg install --overlay-triplets=vcpkg/custom_triplets --triplet arm64-android-static --debug fmt && \
vcpkg install --overlay-triplets=vcpkg/custom_triplets --triplet arm64-android-static --debug asio && \
vcpkg install --overlay-triplets=vcpkg/custom_triplets --triplet arm64-android-static --debug zlib && \
vcpkg install --overlay-triplets=vcpkg/custom_triplets --overlay-ports=vcpkg/custom_ports --triplet arm64-android-static --debug minizip && \
vcpkg install --overlay-triplets=vcpkg/custom_triplets --overlay-ports=vcpkg/custom_ports --triplet arm64-android-static --debug secp256k1-zkp && \
vcpkg install --overlay-triplets=vcpkg/custom_triplets --overlay-ports=vcpkg/custom_ports --triplet arm64-android-static --debug rocksdb && \
vcpkg install --overlay-triplets=vcpkg/custom_triplets --overlay-ports=vcpkg/custom_ports --triplet arm64-android-static --debug civetweb && \
vcpkg install --overlay-triplets=vcpkg/custom_triplets --overlay-ports=vcpkg/custom_ports --triplet arm64-android-static --debug roaring && \
vcpkg install --overlay-triplets=vcpkg/custom_triplets --overlay-ports=vcpkg/custom_ports --triplet arm64-android-static --debug libsodium

export NDK=/home/david/Android/Sdk/ndk/canary
export API=29
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
export TARGET=aarch64-linux-android
export AR=$TOOLCHAIN/bin/$TARGET-ar
export AS=$TOOLCHAIN/bin/$TARGET-as
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
export LD=$TOOLCHAIN/bin/$TARGET-ld
export RANLIB=$TOOLCHAIN/bin/$TARGET-ranlib
export STRIP=$TOOLCHAIN/bin/$TARGET-strip

rm -Rf /home/david/Projects/GrinPlusPlus/build && mkdir /home/david/Projects/GrinPlusPlus/build && \
cmake -S /home/david/Projects/GrinPlusPlus -B /home/david/Projects/GrinPlusPlus/build -G Ninja \
      -D CMAKE_BUILD_TYPE=Release -D GRINPP_TESTS=OFF -D GRINPP_TOOLS=OFF \
      -D CMAKE_MAKE_PROGRAM=/home/david/Tools/vcpkg/downloads/tools/ninja-1.10.0-linux/ninja \
      -D CMAKE_TOOLCHAIN_FILE=/home/david/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=arm64-android-static
cmake --build /home/david/Projects/GrinPlusPlus/build

*** If you want to do it by yourself, please update the paths.

Running Grin++

Now, we need Termux or any other Terminal for Android or we can run it using ADB after copying the binary into your device, your device needs to the Developer Mode enabled; then use this command to copy the binary into the android device: adb push build/GrinNode /sdcard/Download. If you’re using the Termux you need to move the binary into the Termux directory.

What’s Next?!

After getting a stable build, this will be packaged into the Android App, the branch will remains even with the master branch. Stay tuned!

14 Likes

Grin++ (full node) is running now on Android, and it is actually really stable now.

I will continue working on connecting the APK with the Node. You can find the binary here: https://keybase.pub/dtavarez/android/ but also the code is here: https://github.com/GrinPlusPlus/GrinPlusPlus/tree/android-arm64

11 Likes

Cool, finally there will be some use for the 8-12GB RAM most mid-high end phones have nowadays.

Small update:

Note: I’m currently testing the apk using the binary for Android 9.0

5 Likes

It worked great. I could send and receive. After shutting it down overnight it resynced to network in seconds

4 Likes

It’s fair to say that the initial sync could take between 25 and 40 minutes depending on the device :sweat_smile: therefore I’m working on adding a disclaimer in the app before starting to sync the first time.

Is there any incentives to run fullnode?

Your own privacy and sovereignty.

1 Like

Okay… So altruism… :+1:

If privacy and self-sovereignty aren’t important to you, then what got you interested in grin?

1 Like

Privacy and sovereignity are two things that important indeed. In practice I am more interested in how I can directly buy goods from abroad with widely accepted purchasing methods such as paypal, visa, and so on without expensive transaction fees, without third parties, fourths and so on, without having to bother to convert various currencies.

In these days, there are very few cryptocurrencies that have clear reasons why they were created, most of which are just spinning around investing or holding value assets or speculation with no clear use. But the incentive to run nodes for grin should be considered as part of sovereignity itself, encouraging many people to get alternative income with a simple mechanism, not from a mechanism regulated by the government, in which case it is clearly in favor of capitalists. $GRIN can function as universal basic income for people around the world. This will encourage people from all over the country to use it, making $GRIN an honest currency reference and a strong network to be used anywhere.

So did you get a little $GRIN today? Have you mine a little $GRIN today? So you can live tomorrow. Guess something like that.

People all over the world are not that interested in advanced technology. They live because they follow the existing trends. But if there is a way that can keep them safe tomorrow, to provide for their livelihoods, they will surely participate.

You also won’t get the same welfare in every country. World leaders are only interested in giving money to the capitalists, while we are scrambling to get that money every day.

Do you know Andrew Yang? I think I fit his idea of ​​Universal Basic Income and $GRIN could take a position to help this be applied worldwide in practical terms, not just theory.

His brilliant idea does require a lot of money, but at least one day it can be done. And of course $GRIN will get the world attention.

1 Like

Indeed it is an interesting notion to create a universal base income using monetary supply/inflation. I do not think Grin can facilitate this purpose although its properties such as linear supply might make Grin more stable in price and fair to both early and late addopters.
In practice I think a governament controlled cryptocurrency with fixed supply/inflation percentage (e.g. 4% money supply each year relative to the toal amount of this currency available), used as basic income which is equally dispersed among the population, would be very intersting. This itself would also inheritently create more financial equality since poor people get as much basic income as rich people, while the inflation rate avoid the rich from making themselves to wealthy since their money inflates.

Thinking at all about financial systems like this, thinking about basic income and limitations of the current financial systems and possible solutions, such as Grin, means you are among kindred spirits in the Grin community.

Sorry, I realize this is totally oftopic :sweat_smile:
back to Grin++ on Android.

2 Likes