Mining Explained: What Is It And How Does It Work?
Understanding Decentralized Consensus
One of the biggest difficulties in a decentralized system regulated by a network of peer-to-peer nodes is to to transact with one another by completely eliminating the need for trust between parties. Unlike conventional banking and payment systems, Bitcoin is based on the decentralization of trust: rather than depending on a central authority, trust is transferred to many decentralised, anonymous members of the network.
The main problem of reaching consensus in a distributed system is authenticate of transactions and prevent double-spending. The absence of a centralized authority in a blockchain system, infact, determines the need to achieve a widespread agreement – or decentralized consensus – on the state of the ledger between all parties in the system, for ensuring all nodes in the network agree on a single chain of transaction history, despite malicious components of the system failing or propagating incorrect information to other peers.
To solve this issue, the digital ledger technology behind many cryptocurrencies uses the Proof-of-Work (PoW) algorithm, capable of solving the so-called Byzantine Generals Problem. PoW consensus mechanism, therefore, prevents malicious nodes from forging data or (in the case of cryptocurrencies) from spending the same coin twice, also referred to as the double-spending attack.
What is mining?
Crypto mining does not involve any picks or shovels. Instead, the term refers to a verification and currency creation process that is essential to the Bitcoin ecosystem.
The Bitcoin system of trust is based on computation. Blockchain has been designed in a way that every block carries an extremely complicated and resource-intensive math puzzle along with it that is called nonce and based on a cryptographic hash. The goal of mining is to find a value for the nonce that generates a block header hash. Solving the problem is known as mining and it is imperative in order to add transactions to the block and grow the chain.
So mining is a decentralized security mechanism that is the basis for P2P digital cash, by which transactions are validated and cleared. Powerful computers race one another to process transactions, solving complex mathematical problems that require quintillions of numerical guesses a second. As a reward for this authentication service, miners receive newly minted coins and transaction fees from all the transactions included in the block.
Mining, therefore, provides a financial incentive to keep the computers running, while simultaneously implements the monetary supply and aligns the actions of miners with the security of the network without a central authority. But it also serves to secure the Bitcoin system against fraudulent transactions or transactions spending the same amount of Bitcoin more than once, known as a double-spend.
Therefore, mining is the mechanism that:
- maintains and secures the Bitcoin system by verifying transactions;
- creates a way to issue more currency and incentivizes more Bitcoin mining;
- enables the emergence of network-wide consensus without a central authority.
How does mining works?
A transaction transmitted across the network is not verified until it becomes part of the global distributed ledger, the blockchain. When you make a Bitcoin payment, the transaction message is sent to the network, and passed around all the network participants (called ‘nodes’). At this point the transaction is ‘unconfirmed’ or ‘unverified’, which means the nodes have seen that the payment has been initiated, but not yet included in the blockchain ledger.
Every ten minutes on average, miners receive the latest batch of transaction data and generate a new block header that contains:
- the list of transactions and a nonce or random guess;
- a unique identifier to the block (this is the result of the mathematical puzzle);
- a previous block reference.
This is the information miners will use to solve the hash puzzle and add a block transaction.
As miners build a new block, they add the unverified transactions from this pool to a new block and then specialized computers perform the calculations (a cryptographic hash algorithm based on the SHA-256 hashing function) required to verify and record every new Bitcoin transaction to prove the validity of that new block and ensure that the blockchain is secure.
Miners must solve the hash puzzle by finding the hash below a given target through the difficulty requirement. The target, stored in the header, is expressed as a 67-digit number that will determine the mining difficulty based on the number of miners competing to solve a hash function. The mining node will need to test billions or trillions of nonce values before a nonce is found that satisfies the requirement.
The solution to the problem – called Proof-of-Work because the first miner to prove that they have done the “work” of solving a complex equation earns the right to process the newest block of Bitcoin transactions – is included in the new block and acts as proof that the miner expended significant computing effort. The process is what is called ‘mining’.
The amount of newly created Bitcoin a miner can add to a block decreases approximately every four years (or precisely every 210,000 blocks). It started at 50 Bitcoin per block in January of 2009 and then decreased exponentially until approximately the year 2140 when all Bitcoin (20.99999998 million) will have been issued. After 2140, no new Bitcoins will be issued.
The competition to solve the challenging Proof-of-Work algorithm to earn the right to record transactions on the blockchain and getting paid for it is the basis for Bitcoin’s security model and the invention that makes Bitcoin special. It verifies and secures the blockchain, which allows cryptocurrencies to function as a peer-to-peer decentralized network without any need for oversight from a third party. And it creates the incentive for miners to contribute their computing power to the network.
- Andreas M. Antonopoulos, Mastering Bitcoin. Unlocking digital cryptocurrencies, Sebastopol, O’Reilly Media, Inc., 2014.
- Philip Boucher, How blockchain technology could change our lives, Bruxelles, EU Scientific Foresight Unit (STOA), 2017