Blockchain and Mining: A Beginners Introduction
Mining cryptocurrencies has been around since the first days of Bitcoin, and while it may seem somewhat outdated given the recent rise in proof-of-stake blockchains, it is no less sophisticated.
For those coming from the Cardano (or any PoS) ecosystem, it may be tempting to forget about proof-of-work (PoW) altogether. That's almost certainly a mistake, since they are two solutions to the same problems, and each have their own advantages.
Because of that, we decided it would help to offer even more insight that you won't get on traditional crypto-finance websites: technical deep dives.
We realize even a cursory glance at the protocols which govern blockchain ecosystems might be intimidating for the average investor, but doing so can yield a serious advantage in choosing long-term investments.
Our goal is to make it as digestible as possible, so we've decided to do a beginners introduction into 3 main areas you may have heard about:
- What is Blockchain?
- What is Proof-of-Work?
- What is Mining?
What is Blockchain?
In the most basic terms, blockchain is a decentralized immutable database. If it helps, blockchain technology can visually be thought-of as a chain of data (called blocks) all linked together; that is, they all reference the block that came before them. This is why we call it a block "chain".
Within each of these blocks, there is an arbitrary amount of transaction data, and the size and scale is determined by the blockchain's protocol (a protocol is just a fancy word for a programmed rule set).
While the block size is static and unchangeable in blockchains like Bitcoin and Litecoin, Ethereum and the Autolykos protocol from Ergo allow this size to be dynamic.
Now, data in each block is permanent once added to the chain. If you were to remove a block, you would effectively break the chain of data. Furthermore, blocks are only added to the chain if more than 50% of the computers (called nodes) on the network agree.
This is why blockchain is so powerful — all the data is immutable, meaning that it cannot be changed or removed. It can only be updated through a new block in the chain, since to change existing data would effectively break the chain.
Now, what's to stop a bad actor from adding whatever data they want to the chain? As an example, picture a double-spend (more money is spent than exists). This of course would cause considerable problems, and degrade trust in the blockchain (which is what blockchain is all about).
First, you need at least 51% of all nodes to agree on the double-spend. One could theoretically do this through what's called a 51%-attack, so how has the longest running blockchain (Bitcoin) been able to avoid this for so long?
By making it difficult.
What is Proof-of-Work?
Proof-of-Work (PoW) is a term to describe a system in which enough computing power is required to deter frivolous activities (such as spam email or DDoS attacks), but not so much work so as to make the system unfeasible to operate.
Believe it or not, PoW has been around for some time, but was first introduced by Hal Finney in 2004 as a way to secure digital money.
Eventually, Bitcoin utilized this idea to create the network we know and love today, first using it in 2009. Finney was also (fittingly) the first receiver of a Bitcoin transaction.
The method through which this "work" is performed is by computers processing algorithms, where nodes follow set instructions within the algorithm to verify transactions. This takes a definable amount of computing power, and from here you get the concept of "working" to perform an action.
Albeit power and time consuming, this process allows for blockchains to create a barrier-to-entry for node participants. The process of participating in this process, is what we call mining.
What is Mining?
In essence, mining can be explained as follows: when given a set of transaction data and a puzzle by the blockchain's consensus protocol, a node's GPU will first validate those transactions, and then process as many solutions to the puzzle as possible.
Meanwhile, all other nodes on the network are doing the same thing; all in a race to find the puzzle solution first, and be rewarded with adding the data to the blockchain and receiving a cryptocurrency payout.
Each blockchain has its own type of puzzle, and knowing this puzzle allows you to choose the most efficient GPU(s) for the task of mining.
Understanding this, of course, gives you an advantage. Instead of just throwing a miner on whatever machine you own (and hoping you'll earn some crypto), you'll be able to determine with some accuracy the actual return-on-investment (ROI) of any number of GPUs and configurations.
There's even tools out there that calculate this information for you, and we will go in-depth on this in a future article for those looking to get up and running.
Understanding the Puzzle
So what does the puzzle actually look like? This is where we get into the protocols of the blockchain. A protocol is just a set of rules that the blockchain follows, and one of those rules is called the consensus protocol.
Ergo uses Autolykos, while Bitcoin and Ethereum both use variations of their own. The name is less important than the algorithm that describes the protocol.
In most cases, each block's data is passed through a hash function, which is a computational mechanism for taking any amount of data and converting it to a predictable, static size in the form of a string, such as the following (which, if you're curious, is the hash of a block on the Ergo blockchain):
The same data will always produce the same hash, but the hash doesn't reveal anything about the data itself.
To give a more concrete example, imagine that Bob sends Alice 10 $ERG. This transaction data (and a collection of other transactions sitting in a queue, called the mempool) are passed through a hash function that returns a string of random characters like above.
The proof-of-work concept is introduced when the network assigns a random integer to each block (called a nonce). This makes the hash string as unique as the random integer, effectively adding a "puzzle" to the network.
Miners who try to confirm the block with their own generated hash have to then also include this random integer in their block data.
Miners achieve this by using GPUs to try all sorts of combinations with random nonces to see if their solution (or hash string) matches the network's version. If a miner generates the same hash as the blockchain, and at least 51% of all other nodes on the network confirm that hash (usually through a verification algorithm that is much faster), the miner then gets the right to confirm that block on the network and add it to the chain.
In return, the miner gets rewarded in the blockchain's native cryptocurrency; in our case, $ERG. Everyone then begins working on the next block, and the cycle continues.
But what determines the process by which nodes find the correct hash? This of course should be fair and randomized across the nodes. This is where the consensus protocol comes in. Remember we said earlier that a protocol is a set of rules?
Well, another word for that is an algorithm.
Yep, that's right; the consensus protocol is basically just a set of algorithms that nodes on the network execute. The blockchain gives each node instructions on how to find the hash, so that all nodes are performing the same work.
Now that you understand the foundation of what mining is, understanding a core concept in mining — called hash-rate — becomes much more obvious.
Remember, the network assigns each block (or group of transactions) a random number, called a nonce. Your goal as a miner is to guess which number that is (by running the protocol's algorithms), and see if your generated hash can be verified first by the majority of the network.
Why does this prove that you spent computation resources?
Because the only way to guess this number is to try hundreds of different numbers every single second. Put another way, you need to mine a certain number of hashes every second, and these are generated by running the protocol's algorithm.
With this in mind, you can measure your computational power and chances of confirming a block by looking at your GPU's hash-rate, usually detailed as hashes-per-second, or h/s. Higher hash-rates are denoted normally, such as MH/s which translates to 1-million hashes-per-second, and so on.
Most networks will give you calculators to allow miners to determine their likely rewards based on their hash-rate. Ergo makes this really easy with their online calculator.
Furthermore, as the network grows, the difficulty of the algorithm usually increases. This is why Bitcoin has its own network hash-rate that varies, and so does Ergo (currently around 5.17 TH/s). This is important, because the higher the hash-rate, the more secure it becomes, and the more work it requires to contribute a block.
In all, proof-of-work as a consensus protocol is tried and true. The main issues with speed and computing power are usually balanced by increased security and flexibility.
As we'll show in future articles, Ergo is a unique PoW blockchain that introduces some radically different and novel approaches to proof-of-work using both Autolykos as a consensus protocol, a governance solution to solve Ethereum woes, and a superior accounting model to that of Bitcoin.