Monero Mining: What Makes RandomX So Special

Published:
By Diego Salazar
On November 30th, 2019, Monero had its semiannual hard fork, with the most anticipated change being a switch from the old PoW algorithm, cryptonight, to the completely new, internally developed one, RandomX. The Monero community believes RandomX is a big step toward egalitarian mining, but let’s dig deeper to see if that’s the case.

Purpose

In order to judge whether RandomX is an improvement, we must first understand what the purpose of mining is. Mining secures a blockchain from double spends via Nakamoto Consensus. The exact intricacies of how it does this are beyond the scope of this article, but they can be learned from many different sources around the internet. What matters is that the security comes from hashes generated by computers (miners), in competition with one another to find the mathematical solution necessary to create another block. As they do this, they add new transactions to the blockchain. In return for their work (hashes) they are compensated with newly minted coins.

There are a number of issues that can occur with this setup, and they require proper incentives to work correctly, but we’re going to focus in on one particular problem that might arise. If mining is supposed to be a competition, what happens when one miner gains an advantage?

Background

For context, let’s talk a bit about mining hardware. Miners use computers to do the work, but we all know that not every computer is made equally. Some computers are powerful enough to run AI networks or intense games, while others struggle with even simple tasks. These differences in computing power also affect the rate hash rate, or the rate at which they look for block solutions.

But even these differences between computers pale in comparison to the hash rates of specialized hardware, otherwise known as Application Specific Integrated Circuits (ASICs), which outclass regular computers by several order of magnitude.

Let’s take some time to explore what makes ASICs so powerful. Imagine all computers as falling somewhere on a spectrum, which ranges from being able to do many things, but nothing well, to doing only one thing, but doing it very well. CPUs and ASICs are on opposite ends of this spectrum.

CPUs that are in all standard computers are on the first end. They can do many things, like browse the web, play games, or render video, but not do any of them particularly well. But this flexibility comes at the cost of efficiency.

ASICs are on the other end, where they can just one thing, but do it at an incredible rate. They can only perform one mathematical function, but because they can ignore everything else, the performance gains are astronomical. This efficiency however, does come at the cost of flexibility, so if the function changes even slightly – an example is x + y = z changes to 2x + y = z – then the ASIC will cease to function altogether.

Not everyone owns an ASIC, but everyone does own computers. This can lead to an unfair advantage.

A fun analogy

If this still is confusing, perhaps the following analogy will help. Imagine a lottery where one thousand dollars is awarded every hour, and this lottery allows you to print your own tickets! You start printing as many tickets as you can on your home printer, which can print one ticket per second. After subtracting electricity and ink costs, you see that you can still make a profit, even if you only win the lottery once every few weeks.

Over time, you expand your operation until you have an entire room dedicated to printers. 20 in all. Everything is fine...until one fateful day.

There’s big news. Someone has invented a new kind of printer. It can only print lottery tickets. It can’t print pictures, or office documents, or do double sided printing. Only lottery tickets. But it can print them at a rate of 1000 tickets per second. You look in your little printer room. 20 printers. You need 980 more printers just to keep up with ONE of these monster printers, and if someone has two…?

You sadly exit the lottery game as you can no longer justify the electricity and ink costs.

But wait! A couple of weeks later there’s more news! The design of the ticket has changed. Now the numbers, which used to be on the top, are now on the bottom. The new monster printers are so inflexible they can’t do it. They could only make the previous design. It’s not long before you’re once again happily printing away. At least until someone makes a new monster printer for the new design.

RandomX

Where does RandomX fit into all of this? It seeks to even out the advantage by ASICs by making ASICs very difficult to make. It does this by requiring miners to make and execute random code in place of hashing based off of an algorithm.

It may be confusing how this actually helps anything, so let’s go back to our printer analogy. Remember what happened when the design changed? The old monster printers become obsolete every night, and new ones had to be developed with the new design in mind. What would happen if every new lottery prize ticket, had to adhere to a new design standard for every new jackpot?

Creating a new monster printer would become incredibly difficult. You can’t just plan on one ticket design anymore. Since the design is random, the monster printer makers would have to add color capabilities, ways to print different lettering and borders and shapes and more. In short, the machine they ended up inventing would be a standard, regular printer. Just like everyone else has.

By simply implementing this randomness in the ticket design, we substantially reduced the great advantage gained from specialized hardware. RandomX does the same, but with mining.

In this way, the advantages gained by a select few affluent people is minimized, as if they invest in creating “ASICs” for mining RandomX, they will actually merely invent stronger, better CPUs, which benefits the world at large.

This means the little guy with his 20 ticket printers is back in the game. He may still have a harder time since these wealthy individuals can still buy more printers than him, but at least now he’s not outclassed by orders of magnitude simply from one machine. He’s competitive in his small way.

Knowing that even the little guy can be competitive in mining Monero, we encourage everyone to give it a spin, either in the Monero GUI wallet, which has support for solo mining, or by downloading community maintained software. It’s easy, competitive, and open to all.

Further reading