This exercise will walk you through setting up a multi-algorithm cryptominer that uses CPU mining. Mining is the process by which blocks are added to a crypto blockchain and by which transactions are mathematically verified.

Some coins use GPU’s for mining (RavenCoin, VertCoin, Ethereum Classic.)
Other coins uses ASICS (application specific integrated circuits) – Bitcoin, Litecoin, etc.
Still other coins use CPU’s to mine

Monero is a privacy-oriented coin that uses CPU mining.  An established mining pool,  www.moneroocean.stream, has a unique (open-source) mining application that will benchmark a CPU and mine the most profitable coin based on benchmarks.  The mining pool monitors coin prices and mining difficulty, and it can shift the coin your CPU mines based on profitability.

All coins from all algorithms that are mined are exchanged for Monero, and all mining rewards are paid out in Monero coins.

In this lab activity you will:

  • Download the moneroocean xmrig miner binary
  • Configure the miner with a worker name and add the mining wallet address to the configuration file
  • Run the miner and observe the benchmark process
  • Observe which coin is automatically chosen for mining, and the hashrate achieved while the miner binary is running
  • Change the benchmark values (manually) and see the miner change to mine another coin.

On the desktop of your ubuntu laptop:

Right click on the desktop -> open in terminal

Change the user to root.  Type the command:
sudo su

Press ‘enter’. At the prompt for a password, the password is ‘ password ‘ in all lower case

 

Create a new directory for our mining binary and config file by typing the command:
mkdir mining

Press ‘enter’.
Change directory into the newly created mining folder by typing the command:
cd miner

Now we will download the miner binary/executable.  Copy and paste this command into the command-line terminal window:
wget https://github.com/MoneroOcean/xmrig/releases/download/v6.16.4-mo1/xmrig-v6.16.4-mo1-lin64-compat.tar.gz 

The file will download.
Then we extract the binary:
tar -zxvf *.gz

We will be left with an xmrig file, and a config.json file

Make a copy of the config file in case we make an error:
cp config.json config.json.bkup (enter)

edit the config file.  We will use a simple command-line file editor called Nano. Type this command into the terminal window:

nano config.json (enter)

use the arrows to navigate the file in commandline mode.
You will find two lines:
“url”
“user”
“pass”

The “url” field has a default value of:
“gulf.moneroocean.stream:10128”
-This value needs to be changed to “gulf.moneroocean.stream:10001”

The “user” field, where the default value is “YOUR_WALLET_ADDRESS_HERE” — paste the below referenced wallet address in this field.   It is important to leave the ” marks on the beginning and end of the wallet.

address:  42hNfFoNDdsdDBWmnTt9TD3KsNpdfiY91WxEWC7Mj81j4jDPQ16iTgb2y2bSMfSMgX6gmuAJg6NRnWk4HSkmQWR7V4VnKXL

The “pass” field, where the default value is “x” needs to be replaced with a unique worker name to identify this particular machine/mining instance.
See below screenshot for example:

When finished editing:   ctrl+x (at the same time) Nano will prompt to save the file and exit.  Click Y to save and click enter to confirm the config.json filename.

Now, we are ready to start mining.  The first time the miner software runs, it will perform a benchmark of the system.

To launch the miner:
sudo ./xmrig

The miner will start benchmarks and will take several minutes.  You will likely hear the fans spin up, and you will feel the laptop get warm.  This is normal, expected, and not dangerous.

When the benchmarks are finished, you will see a message on the screen saying “ALGO PERFORMANCE CALIBRATION COMPLETE”

The miner will then start actively mining the most profitable algorithm.  In this example case, that is using the rx/0 algorithm, which equates to Monero (which uses a RandomX hashing algorithm).

Pressing the ‘c’ key in the active mining terminal will show the active connection status as well as the current mining algorithm.  Most likely it will be rx/0, which is RandomX algorithm, used to mine the Monero coin.

Now that mining is underway, you can open a browser window and go to http://www.moneroocean.stream

In the “Your Monero Address” – paste the wallet address that you entered in your config.json file:
address:  42hNfFoNDdsdDBWmnTt9TD3KsNpdfiY91WxEWC7Mj81j4jDPQ16iTgb2y2bSMfSMgX6gmuAJg6NRnWk4HSkmQWR7V4VnKXL

It may take a few minutes, but you should see your miner active, denoted by the unique ID you gave your miner during configuration.

At this point, we will force our miner to change to a different algorithm and observe the miner software change.

Right click on the desktop – “Open in Terminal”
sudo su  (and provide the password, which is still ” password ”

Make sure to adjust the two terminal windows so that both are visible on the screen at the same time.

In the newly-opened terminal window that is not mining, type these commands:
cd mining (enter)
nano config.json (enter)

Scroll down to the bottom part of the file.  We are looking for the section labeled “algo-perf”, which stands for algorithm performance:

Scroll down to the line that says “cn-heavy/xhv”: XXXXXXXXXXX
In front of the listed benchmark value, add 9999.


This will artificially inflate the benchmark for the Cryptonight-Heavy/Haven mining algorithm.
Making this change will force the back-end math to calculate that the Haven coin, which uses the cn-heavy/xhv algorithm, the preferred coin due to the newly calculated higher profitability.

After you have made the change, save the file and exit the editor:
ctrl +x to exit,  press Y to confirm the save operation, and hit enter to confirm the filename.

IMMEDIATELY, you should see the mining application say that there is a configuration change and a reload of the configuration file

A configuration change does not force the miner to push the new configuration values to the mining pool.  Only disconnecting and reconnecting from the pool will do that.   We will force the miner to stop and restart:

In the active miner window, press CTRL+C


press the UP arrow,  this will recall the last command executed
press enter to re-launch the mining application with the new config.  We can see that the miner is now mining cn-heavy/xhv, which is the algorithm for Haven coin.

Unfortunately, we aren’t able to actually modify cryptocurrency values in real time, so we must reload the miner to push our modified benchmarks to the mining pool for calculation and handling.  In the real world, system benchmarks generally don’t ever change meaningfully.  The changing of coin values and the back-end calculations result in different coins being automatically specified by API based on previously-submitted benchmarks

This concludes the exercise.  Congrats!

——————————————————————————————

Further information:   When Lambo?

If you navigate to www.moneroocean.stream, and click the COINS banner on the bottom right, you will see a table like this.  What’s it mean?  Great question!

At moneroocean, there is a “pay” hashrate and an “actual” hashrate.  Your actual hashrate is how fast your miner is hashing on any given algorithm.  Not all algorithms hash at the same speed due to mathematical differences.   For example:

P50 laptops in this exercise hash rx/0 (Monero) at around 2300 hashes/second
P50 laptops in this exercise hash argon2/chukwav2 algorithm (Turtle Coin) at around 3300 hashes/second.

But when left to the calculations, the P50 will actively mine rx/0 (Monero coin).  Why?

Because monero has a higher price right now than turtle coin.  Even though turtle coin is “easier” for the laptop to mine, mining Monero is more profitable even though it’s mined at a slower speed.  Each submitted unit of work is worth more money.

The pool lists a “profitability” metric in the table.   Every miner’s actual hashrate, along with algorithm, is submitted to the pool for calculation and conversion to an equalized “pay hashrate” which uses math to convert any given algorithm’s “actual hashrate” to an equivalent value of rx/0 Monero hashrate.

Let’s go back to our P50:
Mining rx/0 — our actual hashrate is 2300.  If we look at the table, we see that the “Profit” column for rx/0 is 100%, and it always will be since this pool normalizes pay hashrate on the actual rx0 hashrate.

Actual hashrate * profit percentage = pay hashrate
2300 *100% = 2300 *1 = 2300

Mining argon2/chukwav2 — our actual hashrate is 3295.  If we look at the table, we see that the “Profit” column for argon2/chukwav2 is 19%.

actual hashrate * profit percentage = pay hashrate
3295 * 19% = 3295 *.19 = 626

A pay hashrate of 626 (for argon2/chukwav2) is for sure lower than a pay hashrate of 2300 (for rx/0), so that explains why our miner software would choose to mine rx/0 rather than argon2/chukwav2 algorithm.

The pay hashrate calculations and profit percentages are based on data pulled from cryptocurrency exchanges, where crypto coins are bought and sold.  As the markets change, the updated prices are pulled into the mining pool for re-evaluation (in real time)