How to build, configure, and mine on Grin’s testnet on Linux

Update: This guide is now outdated. Learn how to get started with Grin here.

Perhaps one of crypto’s most exciting new projects, Grin, has recently launched a testnet on which it is currently mineable. Of course, none of the coins you mine will be valuable to anyone, as they exist simply to test Grin’s underlying network. However, by learning how to mine Grin on its testnet, you’ll be far more prepared than most to begin mining Grin once its mainnet is launched.

What is Grin?

Grin is, in essence, an implementation of the MimbleWimble protocol; a protocol which Grin developers have pioneered. Grin will have privacy by default, giving it full fungibility. It’ll also scale with the number of users and not the number of transactions, resulting in incredible scalability. The best part is, all of these features will be implemented with a certain level of simplicity. A simple design will make it easy to audit and maintain over time.

Perhaps the most interesting part of Grin in the context of cryptocurrency mining, however, is that it utilizes the Cuckoo Cycle proof-of-work algorithm. Cuckoo Cycle is entirely ASIC-resistant, making it perfect for GPU mining. Cuckoo cycle achieves its ASIC-resistance primarily through memory-intensiveness. By using an ASIC-resistant algorithm, the Grin developers hope to encourage mining decentralization.

Without further ado, let’s get started!

Building Grin

The first thing you’ll need to do to get started with mining Grin on the Grin testnet is to build it from source. Please note that this process is rather technical, and is intended for those who are interested in trying out Grin from a very early stage in development.

Prerequisites

Before you get started, be sure to install the prerequisites. Required packages include:

  • Git - to clone the repository
  • cmake 3.2 or greator - Used to compile the mining plugins found in the Cuckoo Miner
  • clang - Used as a dependency by rocksdb and as a datastore by grin
  • Rust 1.21.0 or greator 

To install Git, type the command:

sudo apt-get install git

To install cmake, download the package by clicking here. Go to the directory you downloaded the package to and extract it. Then, open a terminal (if you aren’t using one already) and navigate into the directory of the newly extracted folder. Run the following command to run the bootstrap:

./bootstrap

Be patient; this may take a couple minutes to complete. Once that finishes run the next command:

make

Then:

sudo make install

To install clang, first get updates:

sudo apt-get update

If you’re running Ubuntu 16.04, run the following command:

sudo apt-get install clang-3.8

If you’re running Ubuntu 14.04, run the following command instead:

sudo apt-get install clang-3.5

Lastly, to install Rust, simply run the following command:

curl https://sh.rustup.rs -sSf | sh

To verify the isntall, run:

rustc -V

You should see similar output as the following:

rustc 1.23.0 (766bd11c8 2018-01-01)

Congratulations! You’ve got all the dependencies installed and are now ready to get building.

Build Instructions

First off, run the following command in a terminal to download the github repository:

git clone https://github.com/mimblewimble/grin.git

Then, change directories into the newly downloaded repository:

cd grin

We want to use the Testnet, so run the following command to switch to the Testnet branch:

git checkout milestone/testnet1

Then to finally build:

cargo build

This may take a while, so sit back and relax! Once that’s finished, you’ll have successfully built Grin from source!

Setting the Path

Once you’ve successfully built Grin, you’ll now need to setup and configure a few things. First of all, you’ll want to set the absolute path of the grin repository’s debug folder. To do so, complete the following instructions:

  • Navigate to grin/target/debug via the file explorer
grin
Note that I cloned the github repository within a specific folder, so may absolute path will look different than yours.
  • Right click somewhere in the empty space and select Properties from the menu
  • Copy the directory next to the Location field

  • Open up a terminal and type the following command to show hidden files. Make sure you’re in your $HOME directory:

ls -a

If you see a file titled .bash_login, delete it. Using your favorite text editor, open the .profile file and append the following to the very last line:

export PATH=$PATH:/DIRECTORY YOU COPIED/debug

At this point, you’ll want to log out of your computer and then log back in.

The path is now set. To make sure everything is set up correctly, run the following command in a fresh terminal sessopm:

grin help

You should see output similar to the following:

Note that you should be able to run this command from any file directory in your system and see the above results.

If you run into an error, try setting the path once more, in case you made any mistakes typing it in.

On the other hand, if you’re not running into any errors, you’ve successfully set the path!

Mining

Now that you’ve made it through the mundane parts, it’s finally time to begin mining some blocks! The next few parts may appear to be a bit tedious, but rest assured, if you follow direction carefully enough, you shouldn’t have anything to worry about.

Establishing Basic Execution

To get things up and running, you’ll want to start by simulating a single node on the Grin network. To do so, start by creating a new directory called node1:

mkdir node1

Then, change your working directory to the newly created node1 folder:

cd node1

The node1 directory will be used to run a wallet and create a new blockchain via a server running in mining mode.

The next thing you’ll need to do is copy over your config file from the grin repository you downloaded over to the node1 directory. To do so, utilize the following commands:

cp /DIRECTORY TO GRIN REPOSITORY/grin.toml /DIRECTORY TO NODE1/

If you’re not already, change your active directory to your node1 folder, then run the following command to initialize a wallet:

grin wallet init

Once that’s finished, run the following command to start a wallet server. Replace password with your own pasword.:

grin wallet -p “password” listen

You should see output similar to the following (if you don’t see anything except a blinking cursor, it’s likely that it’s still working. Some thi:

As you can see, the wallet server has started and is now listening on port 13415. As this server is currently occupying the current terminal window, open another window in the same directory and run the following command:

grin server -m run

This command will run a mining server, which will create a .grin database directory in the node1 folder as it begins mining. Allow the mining server to mine a few blocks, then terminate the process (CTRL-C) for both the wallet server and the mining server.

Running a Node on the Testnet

To start running an actual node on the testnet, you’ll need to first create two directories, wallet and server. These directories can be created wherever you wish. Use the mkdir command as shown below:

mkdir wallet

mkdir server

Now, change your active directory to the newly created wallet directory:

cd wallet

Then, type the following command to initialize a wallet:

grin wallet init

You should see sometihing similar to the following:

Next, you’ll need to run a publicly listening wallet receiver. To do so, in the same terminal window, run the following command:

grin wallet -p password listen

Like last time, you may change the password option to a custom password if you wish. In a new terminal window, change your active directory to the server directory you created earlier.

cd server

Next, copy the grim.toml configuration file from the grin repository root to the server directory:

cp /GRIN REPOSITORY DIRECTORY/grin.toml .

Note that the ‘..’ symbols represent backing up a directory, since the directory I’m currently in is in front of the directory I need to navigate to.

Using your favorite text editor, add the following line to the end of the grin.toml file to enable the testnet:

chain_type = “Testnet1”

In the current terminal window, run the following command to begin mining:

grin server -m run

If all is successful, you should see the mining server connect to the wallet receiving daemon. In other words, you should see the mining server start mining blocks, such as the output below:

Mining server (left) Wallet receiving daemon (right)

Congratulations! After all this hard work, you’ve finally begun mining on the testnet! To check your wallet balance, type the following command from your wallet directory:

grin wallet -p password info

Make sure the password you enter matches the password you assigned your wallet earler.

You can also check individual outputs by entering the command:

grin wallet -p password outputs

This command must also be run from the wallet directory.