Scavenger mining on Android using Termux

Mon, Oct 8, 2018 in tutorial using tags android , scavenger , mining

This is a quick guide to get scavenger mining Burstcoin on an Android device. Root is not inherently required, but it is necessary if you want to mount external (USB) disks.

1. Install and setup your Termux environment

First we will need to install Termux to give us a more standardized Linux environment. It is optionally available on F-Droid. Once installed and running, I recommend updating your local repositories and setting up storage access. This is necessary if you want to access the contents of your internal storage/sdcard from within Termux.

$ pkg update
$ termux-setup-storage

It may also be helpful to setup sshd to allow you to enter the remaining commands from a desktop. Keep in mind Termux only allows public key authentication and it uses port 8022. If you do not want to use ssh, you can proceed with the rest of the guide entering the commands on your phone’s keyboard instead.

$ pkg install openssh
$ echo "ssh-rsa AAAAB3N..." >> ~/.ssh/authorized_keys
$ sshd

If setup correctly you can now connect from your desktop over SSH:

$ ssh 192.168.1.65 -p 8022
Welcome to Termux!

Wiki:            https://wiki.termux.com
Community forum: https://termux.com/community
IRC channel:     #termux on freenode
Gitter chat:     https://gitter.im/termux/termux
Mailing list:    [email protected]

Search packages:   pkg search <query>
Install a package: pkg install <package>
Upgrade packages:  pkg upgrade
Learn more:        pkg help
$

2. Setup Its Pointless repository and necessary dependencies

We will need some dependencies for scavenger, including git and a nightly build of rust. Start by installing git and wget:

$ pkg install git wget

Now we need to install the its-pointless repository, and install the necessary rust packages from it:

$ wget https://its-pointless.github.io/setup-pointless-repo.sh
$ bash setup-pointless-repo.sh
$ pkg install rustc rustc-nightly cargo

After installation we must load a script to switch our rust environment to nightly. This needs to be done every time a new terminal is opened, it may be worthwhile to add the command to your rc.

$ source $PREFIX/etc/profile.d/rust-nightly.sh

We should now have rustc nightly installed:

$ rustc -V
rustc 1.31.0-nightly

3. Download and build scavenger

Clone the latest master of scavenger and cd to it:

$ git clone https://github.com/PoC-Consortium/scavenger.git
Cloning into 'scavenger'...
remote: Enumerating objects: 86, done.
remote: Counting objects: 100% (86/86), done.
remote: Compressing objects: 100% (55/55), done.
remote: Total 1172 (delta 48), reused 57 (delta 31), pack-reused 1086
Receiving objects: 100% (1172/1172), 2.42 MiB | 8.95 MiB/s, done.
Resolving deltas: 100% (844/844), done.
$ cd scavenger/

We should now be able to build scavenger. This can be done with or without NEON extensions. NEON will, in theory, give better CPU performance. However on some higher end cores, it is possible NEON will be slower. Experiment with both to find what works best for your use case.

Building without NEON:

$ cargo build --release

Building with NEON:

$ cargo build --release --features=neon

On first build this will take some time to complete. After building you can edit your config.yaml. You will at minimum need to update your pool URL, set the paths to your plot files, and disable CPU thread pinning and direct I/O. The changes I made to the default config.yaml are:

plot_dirs:
  - '/data/data/com.termux/files/home/storage/shared/plots/'
url: 'http://192.168.1.72:8121' # set to your pool
hdd_use_direct_io: false
cpu_worker_thread_count: 16

After copying plots to the ‘plots’ directory of internal storage, we can start mining!

$ target/release/scavenger 
15:55:49 [INFO]  Scavenger v.1.6.0
15:55:49 [INFO]  SIMD extensions: NEON
15:55:49 [INFO]  path=/data/data/com.termux/files/home/storage/shared/plots/, files=1, size=0.0954 TiB
15:55:49 [INFO]  plot files loaded: total drives=1, total capacity=0.0954 TiB
15:55:49 [INFO]  CPU-worker: 16, GPU-worker: 0
15:55:49 [INFO]  new block: height=542878, scoop=428                                             
15:55:49 [INFO]  round finished: roundtime=72ms, speed=339.08MiB/s