While Isaac Newton is best known as an astronomer and physicist who first formulated the laws of motion and gravitation, his lesser-known fields of study included the occult and alchemy. At the time, alchemy was a popular field of study that involved trying to transform regular metals such as lead or iron into gold. But unlike other common metals which are able to be produced artificially, gold was really difficult to simulate.

As master of the Royal Mint in England, in 1717, Newton brought his knowledge of metallurgy and alchemy to currency, essentially creating the first gold standard with a fixed exchange ratio of gold to silver as well as standardized weights for coins, and tests to determine the purity of gold.

Because gold was impossible to reverse-engineer, it provided an important standardized system of currency, providing a crucial service to society and economics. Like gold, cryptocurrency is also mined, but with computer processing power and electricity rather than pick-axes and shovels that work to secure the network.

Since Bitcoin launched in 2010, it and subsequent cryptocurrencies have been criticized for implementing proof-of-work systems that require a lot of electricity to maintain.

While mining has been the topic of public debate, it plays a key role in securing a blockchain and allowing the network to agree on what new transactions to include. In this article, we’ll take a look at why mining is so important.

The Byzantine General's Problem

byzantine-general.png

Bitcoin created a system for peer-to-peer electronic cash that would be maintained by a decentralized network of nodes without requiring a centralized authority or a trusted third party. To do so, it had to pose a solution to the Byzantine General's Problem.

If I send $15 from my Chase account to my friend's Chase account, the bank subtracts $15 from my account and adds $15 to hers in its accounting ledger. It's a pretty simple process. Since Chase is a massive bank with billions of dollars, I trust that the bank can perform basic addition and subtraction and that my money is safe.

On a decentralized network of computers that anyone can join, you don't know whom to trust. The Byzantine General's Problem is a thought experiment around how to reach a consensus when one or more actors in a network may be corrupt.

Imagine that a group of generals, each of whom controls a battalion of soldiers, is planning to collectively attack a city. The generals are separated in different valleys around the city and have to communicate by courier. They have been encountering heavy resistance and have to decide whether to attack or retreat. It gets worse:

  • The generals need to agree on their actions. If they decide to attack, they also need to include a time to attack.
  • The enemy has forces stationed around the valley and can capture couriers being sent around the valley and alter the messages being sent.
  • Some of the generals may be dishonest and actively collaborating with the enemy to undermine the other generals.

If even one of the generals withholds his forces while the others attack, then the entire army is in peril. The problem is that communications rely on messages being sent through couriers. Since messages are at risk of interception, one of the key problems is the unreliability of communication between the generals. Even if all of the couriers make it through the valley, it's possible that one of the generals is colluding with the enemy and is sending a fraudulent message.

In other words, the Byzantine Generals Problem requires consensus even when you know that some elements are compromised. The Byzantine Generals Problem is a useful way of thinking through the dependability of distributed computing systems, where some elements may fail, and there may not be clear information about which elements have failed.

In cryptocurrencies, you can think of the generals as representing nodes on the network. Since anyone can join the network, there is no way to know in advance whether a node is behaving honestly or not. There needs to be a way to allow nodes on the network to agree that a block is valid, even if some of these nodes are misbehaving.

Proof-of-work mining secures the network through consensus

Bitcoin posed an ingenious answer to the Byzantine General's Problem through proof-of-work mining, which finalizes transactions and secures the network.

To ensure consensus, mining nodes, or generals, need to agree on the same course of action: whether to accept or reject a new block of transactions. The difficulty here is that the system must be constructed in such a way that dishonest nodes won't have an impact on the integrity of the system. Proof-of-work mining does exactly that by validating transactions sent to the network and finalizing them on the blockchain—assuming that 51% of hashpower or more comes from nodes behaving honestly.

It does so in two key ways:

  • The proof-of-work problem is computationally difficult to solve.
  • Once solved, the solution can be easily verified by other full nodes on the network.

The generals in the problem are like mining nodes on the network, which need to agree which new blocks of transactions to add to the network. As with the Byzantine General's Problem, the nodes all need to agree on every message—or transaction—sent to the network. To do so, they rely on proof-of-work mining.

First, when a transaction is broadcast to a node, the node checks that the transaction is valid—for example, that the address sending the transaction has enough money to fulfill it—before relaying it to other nodes on the network. Before these new transactions can be added to the network, miners need to solve a difficult proof-of-work problem that includes a hash of new transactions before the new block can be added.

Solving this problem involves hashing the block of new transactions repeatedly with an arbitrary string, known as a nonce, until the output is below the network's current target level. The only way to find the right output is to try a bunch of different combinations repeatedly. The network's difficulty is adjusted so that it takes roughly 10 minutes to add a new block. At Bitcoin's current difficulty, it takes 26 billion terrahashes (one terrahash = 1 trillion hashes) to solve a new block on the network.

Once the proof-of-work problem is found and the block is solved, the block is sent to other nodes on the network which make sure that it's valid  before adding it to the chain. In exchange for solving this difficult problem, the miner earns a reward. The next block that is added to the network includes a hash of a reference to the previous block in the network, which means that each block that's mined helps increase the security of previous blocks.

0_SxksLCUp1eh_ZuJt.png

Let's say that, as with the Byzantine General's Problem, one of these nodes is corrupted and is actively trying to undermine the network by altering a historical transaction. Since the block that the transaction was in was hashed, changing one transaction means that the attacker needs to compute a new proof-of-work solution for the block. Remember, that means calculating roughly 26 billion terrahashes! To make matters worse, subsequent blocks include a reference to the previous block. To convince the rest of the network to follow his lead, the traitor has to also solve every subsequent block that's been added to the network—faster than new blocks are being added to the network.

Successfully doing so means controlling over 51% of the network's hashpower. Launching such an attack would cost roughly $326,432 per hour today, not including the cost of purchasing the hardware needed to generate this enormous amount of hash power.

Mining Matters

When you mine, you're playing a vital role in securing the network and ensuring that it continues to operate as intended, without the intervention of a bank or a centralized third party. Miners are incentivized to behave honestly within the protocol because it is profitable for them to do so. Work that miners have performed accumulates in the ledger in the longest chain of blocks, helping secure the network over time.