Bitcoin Part 2 – Bitcoin Mining
This is part II of my series of blog posts on the topic cryptocurrencies. The first, introductory part can be found here.
Recap – Bitcoin = direct electronic transactions without intermediary
To recap, I explained the main idea behind the Bitcoin protocol, which allows electronic peer-to-peer transactions without an intermediary. In brief, the process works as follows:
- I own a certain amount of Bitcoin. This can be publicly verified, because every Bitcoin transaction since the very first one is entered into a public ledger called the block chain. So I can’t pretend to have more money than I have.
- I can send a certain amount of Bitcoin to a recipient, and I can’t cheat while doing that, because the transaction is publicly broadcast to all nodes in the network.
- I could simultaneously send out more Bitcoins than I have, but the network decides through a process that is a bit like voting (and in reality involves solving a complex math problem) called mining, which transactions are valid and which ones aren’t.
- The transactions that are chosen as valid are entered into the block chain, the public ledger, and become final. And once I’ve depleted my verifiable amount of Bitcoins, I can’t spend more than I have (or double-spending), because everybody knows that I’ve got nothing.
The two key elements in the Bitcoin process are the public ledger, the block chain and the “voting” process called mining, which is actually carried out by the computers forming the nodes of the network in form of solving a complex mathematical problem. I’ll discuss the block chain in the next post, here I’ll focus on mining.
Mining without Shoveling Coal
The key issue that the mining algorithm needs to solve is to ensure that the “voting”/confirmation process is such that nobody with bad intentions can influence it in their favor. And this is exactly what the mining process accomplishes.
Mining denotes the process by which a set of new transactions are confirmed and finalized by appending a record of these transactions to the block chain, the public ledger. It is also the process by which new bit”coins” are minted, thus the term “mining.” New Bitcoins are minted and transactions are confirmed in form of chunks of data, so-called “blocks,” that are appended to the block chain. The Bitcoin algorithm is such that new blocks are discovered roughly every 10 minutes.
Roughly, the process works as follows:
- The Bitcoin network consists of lots of active nodes on which the Bitcoin client is run. When a block is discovered it is added to the block chain, and every node in the network receives information about that new block within fractions of seconds. Roughly speaking, that block also contains a statement with the next computational problem that is to be solved in order to discover the next block.
- People send their as of yet unconfirmed transactions, that is, transaction proposals out into the network, along with a transaction fee. Naturally, because computer transmissions are happening in finite time, not every node will receive all these transactions in the same order. Therefore, the new potential additions to the ledger, the transaction proposals, will not be the same list for every node in the network.
- Meanwhile, the active Bitcoin nodes all start to compute the solution to the problem stated in step 1, whereby there is a certain randomness involved, so that not everybody computes the same thing. I will discuss the mathematical details in a separate blog post.
- After on average 10 minutes, one of the nodes discovers the solution to the problem in step 1 and broadcasts the solution to the network along with its particular copy of the new additions to the ledger.
- The rest of the nodes validate the solution and this particular copy of the new transaction proposals, thereby confirming the transactions that that particular node has received.
- After 100 nodes have confirmed that everything is in order, the lucky (and/or computationally powerful) node that found the solution collects the transaction fees mentioned in step 2, as well as gets a certain amount of newly minted Bitcoins (BTC). This is the incentive for the general public (the nodes) to participate in the network and go through the trouble of validating other people’s transactions.
- And we begin again with step 1.
Why do the miners need to solve a math problem?
The explanation above leaves many open questions, the one in the section header above among them. The math problem is there to insert a certain (but carefully designed) randomness into the process, such that nobody can predict which node will be the one to confirm the next block. This makes it much harder to rig the system. This process is referred to as proof of work. There is one way that the system can be unduly influenced, with a so-called 51% attack, see below.
But why is the algorithm such that a new block is found every 10 minutes, why not faster? If the process were significantly faster, the problem of a fork in the block chain, when multiple nodes discover a solution simultaneously, would be exacerbated. Occasionally it happens in the current scheme that two or more nodes discover a new block at the same time, but the timing of 10 minutes between blocks is enough to avoid a complete forking of the block chain, which would create two or more independent public ledgers. With the current scheme, these forks are usually discovered before a whole new chain can form and contain only one new block. These blocks are removed from the block chain by consensus and are called orphaned blocks.
Another question that arises is: If there are new Bitcoins minted with every block, doesn’t this automatically lead to inflation? No, because the amount of new Bitcoins created in every block halves every 210,000 blocks. At the time of writing (June 2015), 25 new BTC are minted with every block. By 2017, this will be halved to 12.5 BTC per block. The current number of BTC in circulation is shown in the following graph (Data source: Blockchain.info). Eventually, the amount of new BTC will go to 0 and the total amount of BTC will be capped at 21 million BTC. This will happen sometime in 2140, so not anytime soon. By that time, the miners will get only the transaction fees as reward. More info about the 21 million cap can be found here.
Then, the question arises: Couldn’t you buy so much computing power to completely overpower all the other nodes in the system, which would enable you to enter arbitrary amounts into the block chain, which you could confirm yourself and thereby making you infinitely rich? This is called a 51% attack and the Bitcoin equivalent of counterfeiting. In order to take over the Bitcoin network, you’d need at least 51% of the network’s computing power. However, this is increasingly unlikely, since veritable BTC mining farms have been built due to the speculative value of BTC, which at one time was over $1000 per BTC (see graph below, click to enlarge). At that time, it made economic sense to invest heavily in server farms such as the one shown below. However, because the difficulty of the mathematical problem to be solved in order to mine (mint) new blocks (coins) is algorithmically adjusted such that on average only every 10 minutes a new block is found, regardless of how much computing power is thrown at the problem, this arms race led to an exponential increase in the difficulty, as illustrated in the last graph below (click to enlarge). Thus, a 51% attack is unlikely, unless many miners pool together in so-called mining pools. In fact, this is what most people mining BTC do these days, because it is next to impossible for an average person who doesn’t own a supercomputer server farm to mine a block solo, thanks to the increase in difficulty.
This concludes part 2 of my Bitcoin blog series. Stay tuned for part 3, where I will discuss the public ledger, the block chain, and how to read the information contained therein in more detail.