How to run Waves node on a smartphone
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:
We will install Ubuntu (I will use numbers like  to refer to specific settings on the screenshots) Xenial Xerus  as OS and make separate .img file  because you can move in the future with the image to another smartphone also we can back up the image.
Additionally, we need to install SSH daemon  and disable graphical daemons  (we can save few MB of RAM with it).
Run the image and if we have a connection to the wifi we will see the local IP address of the containered OS . We can use that address to connect via ssh, login and password can also be changed in the settings .
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
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:
dpkg -i waves_0.14.7_all.deb
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:
On the line
345 remove the line:
And add two new:
Step 6. The very last step before starting Waves node — change configuration file with command:
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
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.
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.