Unearthing bitcoin: How does bitcoin mining work?
Though it can be a tricky concept to wrap your head around, mining is key to understanding crypto
- What is the purpose of bitcoin mining?
- How proof-of-work works
- The Byzantine Generals Problem, explained
- How profitable is bitcoin mining?
- The ASICs take over
- Does proof-of-work get a bad rep?
- Mining example
First introduced by the elusive Satoshi Nakamoto in 2009, bitcoin mining has gone from a peculiar basement exercise to a global operation performed by major corporations, and even national governments.
Despite being a critical component of the $775bn cryptocurrency sector, bitcoin mining remains a difficult concept to grasp for many. What is bitcoin mining and how does bitcoin mining work? Can anyone be a bitcoin miner, and if so, how profitable is it?
Grab a pickaxe, put on your hard hat and join us as we dig deep into the world of bitcoin mining.
What is the purpose of bitcoin mining?
As a currency with a maximum supply of 21 million coins, bitcoin is a finite resource, a bit like gold. Like any finite resource, the value of bitcoin is proportional to its scarcity; an inflated supply leads to reduced value. Because of this, circulating supply needs to be managed.
But wait, bitcoin is decentralised, right? If no one is in control of bitcoin, how can circulation be managed? Nakamoto was aware of this issue when he (or possibly she) first developed bitcoin, so he implemented a protocol called proof-of-work (PoW), which would allow computers from across the world to contribute to the operation of the bitcoin network.
As a reward for these contributions, a predetermined rate of bitcoins would be minted and sent to these computers fro their efforts. Thus, a new type of mining was born, not of precious real-world minerals, but of digital representations of value, unearthed not by shovels, but by central processing units.
How proof-of-work works
Proof-of-work (PoW) sits at the heart of how bitcoin mining works. Though popularised by bitcoin, PoW was conceptualised by the American computer scientist Cynthia Dwork as far back as 1993, before being formalised in an essay in 1999 by the computer security researcher Markus Jakobsson and Ari Juels, a professor at Cornell University, Proofs of Work and Bread Pudding Protocols, which actually coined the term “proof of work.
Since bitcoin is a decentralised network (called a blockchain), it cannot rely on a single entity such as a bank for record-keeping. Therefore, a method of consensus on the network must be achieved in another way. Enter PoW.
In basic terms, PoW is a computation performed by the computers connected to the bitcoin blockchain. Each bitcoin transaction needs to be validated by a PoW computation in order to be processed. Since these computations are what keep the bitcoin ledger accurate (ie the balances of each bitcoin holder are properly recorded), it is necessary to make sure these miners are behaving properly. That is why PoW mining is both incredibly difficult, and incredibly rewarding.
When a computer successfully performs a PoW function, it is rewarded with a payout, just like a miner is rewarded for all the hard work digging up gold, which is why it is referred to as “bitcoin mining”. PoW mining is a competitive and controversial process, because of the very high levels of energy required to perform the process.
The Byzantine Generals Problem, explained
Several divisions of the Byzantine army are camped outside an enemy city, poised to attack. Each division has its own general. They can only communicate with each other via a messenger to decide a plan of attack. But what if some are traitors, who are attempting to prevent a consensus of attack?
You are probably wondering what this has to do with bitcoin mining, but the Byzantine Generals Problem (described by Leslie Lamport, Robert Shostak and Marshall Pease in a 1982 paper of the same name, following work done for NASA on fault-tolerant computing) is an allegory fundamental to understanding the importance of proof-of-work in a decentralised blockchain network like bitcoin.
Without a centralised decision-making body, how can the blockchain know that the miners are acting properly? The truth is, it cannot. Bitcoin has a fault tolerance of 50%, meaning that as long as the majority of miners are acting in good faith, the blockchain will continue to operate. The Byzantine Fault Tolerance (BFT) of any blockchain system does not just protect against malicious behaviour. If a cluster of mining nodes suddenly goes offline, or is corrupted in some other way, BFT safeguards the wider network.
One would assume that an attacking army would need a higher fault tolerance than 50%, but whether that is sufficient for bitcoin’s security remains an ongoing debate. Although bitcoin has yet to suffer a 51% attack, Vertcoin’s PoW network was compromised twice in 2019, causing an estimated $100,000 in damages to users.
How profitable is bitcoin mining?
Bitcoin pays out 6.25 BTC for each block approved by a miner, which occurs every 10 minutes. When bitcoin reached an all-time high of $68,789 on 10 November 2021, each mining reward amounted to $429,987. Energy consumption and infrastructure costs need to be taken into account when evaluating take-home profit, however.
A report by the data centre infrastructure management firm Sunbird found that a mining farm in Dalian, China spends an average of $1.17m in energy costs per month, though an average mining reward of 750 BTC ($30.7m) per month surely makes it all worthwhile.
Since electricity is the primary outgoing expense for operating a mining farm, enterprising miners continue to seek out innovative sources of cheap power to run their rigs. In a development ripped straight from the pages of a science fictiuon novel, El Salvador’s president, Nayib Bukele, recently announced plans to build a “bitcoin city” at the base of the country's Conchagua volcano, tapping into geothermal energy to power the city in a “very cheap, 100% clean, 100% renewable” way.
Mining rewards are halved every four years. The next halving is due on 27 April 2024, when rewards will be halved from 6.25 BTC per block to 3.125 BTC per block. There is deflationary logic here. Based on the assumption that bitcoin will alway rise in value (granted, that is a big assumption), the dollar value of these rewards does not necessarily reduce every halving. Halving keeps circulating volume down, thus putting downward pressure on inflation.
So far, 90% of all bitcoins have been mined. That might sound like the mining pits are close to running out, but given the nature of halving, the process is set to continue until at least 2140.
The ASICs take over
“Proof-of-work is essentially one-CPU-one-vote.” That is how Nakamoto expressed his vision in the 2009 white paper. Today, that reality could not be further from the truth. Instead of each user having equal voting weight on the PoW network, massive server farms of Application-Specific Integrated Circuit (ASIC) mining rigs have rendered the home computer effectively useless for mining bitcoin.
ASICs are simply purpose-built computers with massive processing power. Since ASICs are designed to perform one function only, they are highly optimised and efficient. In the case of bitcoin mining, an ASIC chip is specifically designed to perform the SHA-265 hashing function.
As bitcoin becomes increasingly harder to mine, miners need more and more processing power to remain competitive. Just having one ASIC running in your basement does not cut it.
Take the Enigma facility, strategically built by Genesis Mining in Iceland to take advantage of the cold climate. From a distance, what look to be a town’s worth of large steel poultry barns are instead crammed with thousands upon thousands of ASICs, working around the clock to mine bitcoin.
Such is the reality of bitcoin mining in 2022, thrown into the spotlight by artist Lisa Barnard’s eye-opening photography series. Rather than a democratic “one-CPU-one-vote” process, bitcoin mining has instead become the playground of a rarified few.
The ASICs arms race has had some profound consequences. A report in 2021 by the data centre software company Sunbird suggested that bitcoin mining accounded for 0.55% of all energy consumed globally; roughly equivalent to one million transatlantic flights, or Sweden’s total energy output.
Does proof-of-work get a bad rep?
The proof-of-work (PoW) mining method is generally cited as the cause of bitcoin’s resource-sapping nature. But it could be more accurate to point the blame at the SHA-256 hashing algorithm instead.
The SHA-256 algorithm makes solving the equations necessary to validate bitcoin transactions incredibly difficult. Mining difficulty is an important metric used to keep block times at a stable 10 minutes. Like a vicious cycle, this mining difficulty is constantly increasing, spurred on by more and more ASICs vying for mining rewards. A new all-time difficulty high was reached on 21 January 2022.
But there are other ways to go about PoW validation. BitcoinZ, for instance, is a PoW cryptocurrency using an ASIC-resistant algorithm called ZHash. ZHash makes mining on ASICs virtually impossible. Instead, the algorithm is performed most easily on vanilla CPUs, thus keeping BitcoinZ closer to Nakamoto’s “one-CPU-one-vote” philosophy.
Although ASIC-resistant algorithms have proved to be effective, ASIC resistance is a game of defence, since ASIC designers are constantly producing workarounds. While numerous hard forks of bitcoin – Monero is another example – have implemented ASIC-resistant algorithms to maintain a democratic PoW community, bitcoin’s ASIC arms race is likely here to stay.
The screenshot below shows a block mined at 3:37pm GMT on 17 March 2022. The hash number is the unique block identifier. The height shows that this block was the 727,763rd bitcoin block to be processed since the 2009 genesis block. The block was mined by AntPool, a China-based bitcoin mining company.
The block contained 2,866 individual bitcoin transactions with a total value of more than 9,982 BTC. Difficulty is represented in a numerical value, while the merkle root, from the “merkle tree”, a “hashtag tree” concept patented by the Americal computer scientist Ralph Merkle, is used to trace the transaction back to previous blocks in the sequence.
Nonce (number only used once) is the answer to the equation that the miner had to solve to validate the block.
As revolutionary as it is, bitcoin’s negative impact on the environment is much discussed. Compounding the issue, PoW mining is also highly inefficient. Unlike other consensus methods, PoW mining is essentially a race to the finish line, encouraged by the promise of digital gold.
But while a race only has one winner, you have to compete to stand a chance. In the case of bitcoin mining, that means thousands of incredibly powerful machines generating tonnes of CO2 emissions running simultaneously, even though only one miner validates the block in the end.
There are many alternatives to PoW mining. Ethereum is poised to switch from PoW to proof-of-stake (PoS) at some point in 2022. PoS is a far more efficient method of consensus that relies on monetary bondage rather than processing power.
But even within the PoW method, alternatives to bitcoin’s SHA-256 algorithm have proved to be more efficient and democratic. Whether bitcoin ever goes through a major overhaul of its energy-intensive mining process remains to be seen.
It takes ten minutes to validate a bitcoin block, generating a mining reward of 6.25 BTC.
Mining rewards went as high as $429,987 per block in November 2021. As of 17 March 2022, rewards were approximately $256,000 per block. Profit is contingent on your energy and infrastructure costs, and the trading value of bitcoin. Mining farms typically operate in regions with cheap electricity and desirable weather conditions.
The legality of bitcoin mining varies by country. In most cases, bitcoin mining is legal. In some countries, including Ukraine and China, bitcoin mining is a legal grey area. Kosovo banned bitcoin mining in January 2022, citing concerns over energy consumption.