Start mining Vertcoin on Linux

2017/11/16

Update: - 2017/12/1: I finally came around to write at least a few words to the installation of a local p2pool for Vertcoin. Thank you u/_bh_ for your feedback on this post.

In this post I want to show you how to start mining Vertcoin on a Linux machine.

What is Vertcoin?

Vertcoin is an ASIC-resistant crypto-currency that has been around since 2014 and has seen a considerable rise in market capacity and value since early 2017.

Getting started

First, you have to download a wallet to be able to receive Vertcoin. I recommend the core wallet available from the official GitHub page.
You can either download a release archive or clone the repository with git. Both possibilities require that you build the software yourself. But don’t worry, I’m going to provide step by step instructions for this.

Install core wallet

  1. Install the dependencies listed here
   ~ $ sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils
   ~ $ sudo apt-get install libboost-all-dev
   ~ $ sudo apt-get install libzmq3-dev
   ~ $ sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler 
   ~ $ sudo apt-get install libqrencode-dev

Update: You probably have to install an older version of the BerkleyDatabase. The easiest way to accomplish this is to run these commands in your terminal:

   ~ $ sudo apt-get install software-properties-common  
   ~ $ sudo add-apt-repository ppa:bitcoin/bitcoin 
   ~ $ sudo apt-get update  
   ~ $ sudo apt-get install libdb4.8-dev libdb4.8++-dev
  1. Download the sources from https://github.com/vertcoin/vertcoin/releases

    ~ $ wget https://github.com/vertcoin/vertcoin/archive/v0.11.1.0.tar.gz
    
  2. Extract the archive

    ~ $ tar xvzf v0.11.1.0.tar.gz
    
  3. Go into the new directory and start building the wallet

    ~ $ cd v0.11.1.0
    ~/v0.11.1.0 $ ./autogen.sh
    ~/v0.11.1.0 $ ./configure --with-gui
    ~/v0.11.1.0 $ make
    ~/v0.11.1.0 $ sudo make install
    
  4. We want to use the wallet for our own mining pool later on, so we have to configure it to accept a connection from the pool. For that, look for the hidden folder .vertcoin in your home directory (create it, if it doesn’t exist) and put the following lines in the file vertcoin.conf:

    server=1
    rpcuser=user
    rpcpassword=anypassword
    
  5. Start the wallet and let it sync the blockchain (~2.2GB)

    ~ $ vertcoin-qt
    

While your wallet is recreating the entire transaction history of Vertcoin, you can go ahead and build the mining software.

Install ccminer

I assume you’re using a Nvidia GPU for mining, since that’s the one with best support for now. The actual mining process uses the CUDA cores and thus you have to have the proprietary nvidia driver and the cuda toolkit installed. I’m not going to describe the installation process for those in this blog post, there are already a plethora of tutorials available for this.

So let’s get straight to the biscuits: Once again, the Linux user is left of with a source code archive and has to figure out by herself what she has to do.

  1. Download ccminer from the github repository at https://github.com/tpruvot/ccminer/archive/2.2.2-tpruvot.tar.gz

    ~ $ wget https://github.com/tpruvot/ccminer/archive/2.2.2-tpruvot.tar.gz
    
  2. Extract the archive

    ~ $ tar xvzf 2.2.2-tpruvot.tar.gz
    
  3. Enter the new folder and modify Makefile.am according to the GPU in your PC

    ~ $ cd 2.2.2-tpruvot
    ~/2.2.2-tpruvot $ nano Makefile.am
    

The file has a few lines that look like this originally:

ccminer_LDADD += -lcuda
nvcc_ARCH = -gencode=arch=compute_50,code=\"sm_50,compute_50\"
nvcc_ARCH += -gencode=arch=compute_52,code=\"sm_52,compute_52\"
#nvcc_ARCH += -gencode=arch=compute_35,code=\"sm_35,compute_35\"
#nvcc_ARCH += -gencode=arch=compute_30,code=\"sm_30,compute_30\"
#nvcc_ARCH += -gencode=arch=compute_20,code=\"sm_21,compute_20\"

nvcc_FLAGS = $(nvcc_ARCH) @CUDA_INCLUDES@ -I. @CUDA_CFLAGS@

Every line starting with nvcc_ARCH represents one (in digits: 1) GPU. If you only have a single card in your PC, put a # in front of all lines with nvcc_ARCH except the first one. Then change the number 50 to the correct number according to https://github.com/tpruvot/ccminer/wiki/Compatibility. (The same steps are described on this page).

I own a gtx 1050ti, so I change the lines to this:

ccminer_LDADD += -lcuda
nvcc_ARCH = -gencode=arch=compute_61,code=\"sm_61,compute_61\"
#nvcc_ARCH += -gencode=arch=compute_52,code=\"sm_52,compute_52\"
#nvcc_ARCH += -gencode=arch=compute_35,code=\"sm_35,compute_35\"
#nvcc_ARCH += -gencode=arch=compute_30,code=\"sm_30,compute_30\"
#nvcc_ARCH += -gencode=arch=compute_20,code=\"sm_21,compute_20\"

nvcc_FLAGS = $(nvcc_ARCH) @CUDA_INCLUDES@ -I. @CUDA_CFLAGS@
  1. Now you can start the build process by calling build.sh

    ~/2.2.2-tpruvot $ ./build.sh
    

    If the process fails with an error, which happened to me, here’s a solution that worked in my case, but ymmv:

    • Open the file Makefile.am again and remove the following lines:
      # This object does not use cuda device code but call the different kernels (autotune)
      scrypt/salsa_kernel.o: scrypt/salsa_kernel.cu
        $(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_20,code=\"sm_21,compute_20\" -o $@ -c $<
          
      # These kernels are for older devices (SM)
          
      scrypt/test_kernel.o: scrypt/test_kernel.cu
        $(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_20,code=\"sm_20,compute_20\" -o $@ -c $<
          
      scrypt/fermi_kernel.o: scrypt/fermi_kernel.cu
        $(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_20,code=\"sm_21,compute_20\" -o $@ -c $<
          
      scrypt/kepler_kernel.o: scrypt/kepler_kernel.cu
        $(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_30,code=\"sm_30,compute_30\" -o $@ -c $<
          
      scrypt/nv_kernel.o: scrypt/nv_kernel.cu
        $(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_30,code=\"sm_30,compute_30\" -o $@ -c $<
          
      scrypt/titan_kernel.o: scrypt/titan_kernel.cu
        $(NVCC) $(nvcc_FLAGS) -gencode=arch=compute_35,code=\"sm_35,compute_35\" -o $@ -c $<
    
  2. You can now start mining Vertcoin on any pool you like. Just enter the address of the pool, the port and a Vertcoin receiving address you own into the command below. The password usually doesn’t matter in this case. You can generate a receiving address on the Receive tab in your Vertcoin wallet.

    ~/2.2.2-tpruvot $ ./ccminer -a lyra2v2 -o stratum+tcp://<ADDRESS_OF_POOL>:<PORT> -u <YOUR_VTC_RECEIVE_ADDR> -p <ANY_PASSWORD_IT_DOESNT_MATTER>
    

Setting up your own P2Pool node

To actually receive Vertcoin from mining, the easiest way is to join a mining pool and combine your GPU power with other people’s power. That way you can expect a small but constant payout of Vertcoins. The most profitable pool for single GPU miners is actually hosting your own P2Pool node and mining on that one.

Here’s how to do this.

  1. Use git to clone the project on your local harddrive

    ~ $ git clone https://github.com/vertcoin/p2pool-vtc.git
    

    (You can install git by running sudo apt install git)

  2. Go into the new folder and download all dependencies

    ~ $ cd p2pool-vtc
    ~/p2pool-vtc $ pip install -r requirements.txt
    

    Depending on your OS, you might have to change the last command to sudo -H pip install -r requirements

  3. Install the Lyra2v2 module

    ~/p2pool-vtc $ cd lyra2re-hash-python
    ~/p2pool-vtc/lyra2re-hash-python $ git submodule init
    ~/p2pool-vtc/lyra2re-hash-python $ git submodule update
    ~/p2pool-vtc/lyra2re-hash-python $ sudo python setup.py install
    ~/p2pool-vtc/lyra2re-hash-python $ cd ../
    
  4. With this you should be able to start your local pool.
    Replace <USER> and <PASSWORD> with the values from rpcuser and rpcpassword in ~/.vertcoin/vertcoin.conf:

    ~/p2pool-vtc $ python run_p2pool.py --net vertcoin2 -a <YOUR_VTC_RECIEVE_ADDRESS> --give-author xxx --fee xxx <USER> <PASSWORD>
    
  5. Now you can start ccminer and point it to your local p2pool running at
    127.0.0.1 on port 9181. For that start a new shell and go to the ccminer directory (if you followed my tutorial, it’s the folder named 2.2.2-tpruvot). Replace <YOUR_VTC_RECEIVE_ADDR> with a receiving address from your vertcoin-qt wallet.

    ~ $ cd 2.2.2-tpruvot
    ~/2.2.2-tpruvot $ ./ccminer -a lyra2v2 -o stratum+tcp://127.0.0.1:9181 -u <YOUR_VTC_RECEIVE_ADDR> -p <ANY_PASSWORD_IT_DOESNT_MATTER>
    

To be continued:

  1. Describe wallet installation
  2. Describe ccminer installation
  3. Describe local P2Pool installation
  4. ???
  5. Profit!

If you liked this tutorial, you can buy me a drink by donating some VTC to VmopwLohPZnWqb7pMUT2ZH29diogAnEqga or BTC to 3JZarpMiw56ArjrjAb9GXjMjtbzx8BgzC3