The idea to write this article arose after one my small tweet, here it is:

I got a lot of questions about details of the project. In the tweet, you can find a link to the video with a description of how it works:

In this small article, I want to talk in details about our researches and experiments with Waves Node.

A full node on a smartphone — WHY?

Before we go deeper in technical details let me explain why we experiment with blockchain node and try to run it on a smartphone.

Blockchains are mostly about DISINTERMEDIATION and TRUSTLESS. Bitcoin as the first blockchain ever gave us important ability to make Web 3.0 applications we don’t have to trust. We can check every signature, every transaction and be sure that nobody tries to cheat. We achieve it because we can download the whole story of transactions and validate all of them.

It’s been a while since bitcoin release and now we want to use blockchain applications on our cell phones, and in a perfect world, even with limitations of cell phones, we do not want to trust to anybody. There are mobile applications for different blockchains and almost all of them send transactions to some public nodes. That blockchain nodes can be down or just reject users transaction, not so trustless as we’d like to see. That was the reason to start experimenting with Waves blockchain full node on a smartphone.

With Proof-of-Work it is hard to process blocks even on usual PC, not to mention smartphones with their hardware. Yes, there are few proof-of-work projects like ERGO which require just a few Kb of data to synchronize the network and begin processing blocks in a trustless manner. Here is an interesting paper about their approach. But in Waves we have Proof-of-Stake and there are no special requirements for hardware and we thought it would be interesting to run a full node on a smartphone. Maybe in future, somebody from our great community will implement mobile app which will work with the node and send transactions and blocks directly to other nodes in the network.

And the last, but not the least reason to run Waves node on a cell phone is fun 🙃, of course, engineers need some fun in their job and the author of the project Sergei Shiktarev had a lot of fun with it!

How to run blockchain node on a smartphone

The first thing we need to run a node is a smartphone on Android with ROOT privileges. We found LG with 3GB of RAM, CPU Snapdragon 800 and memory card slot. The size of Waves blockchain is about 30GB, so a memory card slot is not required if there are more than 40 GB of internal memory. If you have to use SD card check that it can handle not less than 80 MB/s read-write speed and up to 3000 IOPS.

Next, we installed Linux Deploy app from Google Play. The application creates a disk image on a flash card, mounts it and installs an OS distribution. Applications of the new system are run in a chroot environment and working together with the Android platform. All changes made on the device are reversible, i.e. the application and components can be removed completely. Installation of a distribution is done by downloading files from official mirrors online over the internet. The application requires superuser rights (ROOT) and we used SuperSU Pro to get ROOT access:

Android app for ROOT privileges

We will install Ubuntu (I will use numbers like [1] to refer to specific settings on the screenshots) Xenial Xerus [2] as OS and make separate .img file [3] because you can move in the future with the image to another smartphone also we can back up the image.

OS version and installation type settings

Additionally, we need to install SSH daemon [1] and disable graphical daemons [2] (we can save few MB of RAM with it).

Enabling SSH daemon and disabling Graphical

Run the image and if we have a connection to the wifi we will see the local IP address of the containered OS [1]. We can use that address to connect via ssh, login and password can also be changed in the settings [2].

Inside guest OS

Now we will use only SSH connection to the guest OS on the phone.

Step 1. First of all, let’s update the list of packages:

sudo apt update

Step 2. And install the necessary software:

sudo apt install software-properties-common vim wget screen libleveldb-java libleveldb-api-java

software-properties-common — is necessary to add java repository

— is necessary to add java repository libleveldb-java libleveldb-api-java — waves node has built-in x64 compatible leveldb libraries, but they won’t work on ARM CPU, so we have to install these two libraries.

Step 3. Now we can install java:

sudo add-apt-repository -y ppa:webupd8team/java

sudo apt-get update

sudo apt-get -y install oracle-java8-installer

Step 4. Download the latest version of Waves Node as a *.deb package and install it:

Step 5. On usual virtual machine it is enough to run a node, but on the phone, we have to make a few more steps. First of all, we have to replace built-in leveldb libraries:

vim /usr/bin/waves

On the line 345 remove the line:

$lib_dir/org.ethereum.leveldbjni-all-1.18.3.jar

And add two new:

/usr/share/java/leveldb-api.jar

/usr/share/java/leveldb.jar

Step 6. The very last step before starting Waves node — change configuration file with command:

vim /etc/waves/local.conf

You can find more details about waves configuration file in the documentation.

Final step. Everything is ready to go, let’s start our node on the phone:

screen -S waves

waves /etc/waves/waves.conf

And it works! Node is running and will start an initial synchronization process — download the whole blockchain. It may take a few days, unfortunately, we can’t import state, because of differences in leveldb library.

Waves node running of the phone

Conclusion

Further experiments have shown that performance of the phone hardware sometimes is not enough to process transactions without lags. But there is an option to improve the performance — we have to format the SD card in ext(2,3,4) file system. We will get rid of the Android FUSE layer, which has some overhead and slows down the node.

Happy experiments!