It Runs on the Blockchain

As you've probably heard, Bitcoin is based on a blockchain, but what does that mean? And what is Bitcoin mining? What do they mean when they say Bitcoin is decentralized? These are important questions that many; even some that use or own Bitcoin, don't always know the answers to. With this article we attempt to answer them, without going too deeply into technical details. Our aim is to help the average person get a good grasp of the relevant concepts, without requiring any specialized knowledge.





The Blockchain

Although the idea of a blockchain existed before Bitcoin, it was Satoshi Nakamoto's improvements on the concept that made it popular. The blockchain is simply a record-keeping system, or ledger. It contains a structured record of all transactions ever executed on the network. Blockchains get their name from the fact that they are composed of blocks, structured in succession to form a chain. Each block is just a bundle of transactions that are processed and added to the ledger together.

Blocks are sorted in a way that corresponds to the order in which they were added to the blockchain. To know the right sequence, blocks contain information that link them to the one that comes before them. The result is a chain of blocks, constituting a public ledger of transactions. As users perform more transactions; they are bundled together in new blocks, and added at the end of the chain. This makes the blockchain longer, the more time passes.

You might have heard that Bitcoin is a decentralized network. We say it is decentralized because the responsibility to bundle transactions into blocks, and add new blocks to the blockchain, does not rely on a central authority. Instead, a peer-to-peer network of nodes is in charge of the tasks of maintaining and updating the blockchain, with each node containing a full copy of the blockchain. Bitcoin was designed to make it possible for any person anywhere to participate in this process. This is one of Bitcoin's strongest points, and one of the main reasons it is so popular today.



Block Size

In Bitcoin, blocks have a limit to how many transactions they can contain. This is commonly known as block size, and for Bitcoin it has been set as 1 megabyte. Because of this limit, blocks cannot contain more transactions than would fit it in 1 megabyte of data.

You might be wondering why a block limit is necessary at all, as it seems to limit how many transactions the network can process. This is a controversial issue, as there are trade-offs to setting block size larger or smaller. For our purposes it is perhaps enough to say that bigger blocks would allow to increase the number of transactions per second that the network can process, at the cost of decentralization. Decentralization decreases with block size, because larger blocks make it more expensive to operate a node in the network.

You could say that the block size limit exists to preserve decentralization. However, to what degree decentralization can be preserved with different block sizes is not part of the scope of this article. It is however a much debated topic, with many online resources available to help understand the key ideas.


Mining Nodes

The process of bundling up transactions in blocks, and adding the blocks to the blockchain is called mining. Miners group transactions into blocks, and then broadcast the blocks to the network so that other nodes verify them. To be considered valid, a new block must contain what is called Proof of Work. Proof of Work is the result of a mathematical calculation that the miner had to perform in order to add it to the block before broadcasting it. Nodes on the network can then easily verify that the result is correct, which means that the block is valid. Thanks to Proof of Work, Bitcoin ensures that all transactions contained in the blockchain are valid without requiring the supervision of any central authority.

Because performing these calculations consumes resources, Bitcoin offers an economic incentive to miners so that they keep doing their essential work. This comes in the form of a block reward. When a miner solves a block, they are rewarded with a few Bitcoins as compensation for the work done. The Bitcoins that miners receive this way did not exist before. This is the only mechanism that allows to create new Bitcoin. The name mining comes from the fact that the process is analogous to the extraction of gold from the Earth. New Bitcoin is created after the mining process, the same way gold mining introduces new gold into the market.






Consensus

Since block validation is a distributed process, there could be synchronicity problems. For example, two miners might solve a block more or less at the same time, and add it to their copy of the blockchain. Since these blocks contain the necessary Proof of Work, they are both considered valid by the network. This effectively creates two different valid versions of the blockchain. After that, other miners might decide to add newly mined blocks to one or the other version, depending on which one they received first. This situation could continue indefinitely from here, which is why a consensus mechanism is needed. The blockchain needs an automatic way to select which of the competing blockchains is valid.

The solution Satoshi Nakamoto implemented for this problem was choosing the longest blockchain. These competing chains might remain of equal length for some time, but eventually one of them will accumulate more blocks than the other. When this happens, all nodes switch to this version as the valid one. After that, miners will add blocks only to the blockchain selected as valid.

Because of these possible temporary conflicts, a transaction is considered to be more final the more blocks are added to the blockchain after it is confirmed by a miner. Each new block added to that version of the blockchain is called a "confirmation". For Bitcoin, 3 confirmations are usually considered enough for a transaction to be final. That is because it is extremely unlikely that two versions of the blockchain compete for longer than 3 newly added blocks without one of them being identified as longer and selected as valid.




Block Time

We mentioned that for a block to be valid, miners need to find the solution to a mathematical problem. However if the difficulty of solving this problem remained constant; solutions would be found faster and faster the more miners join the network. Because blocks need to be broadcast to other nodes and then validated, it is necessary that solving blocks takes enough for these processes to take place. To achieve this, Bitcoin automatically adjusts how difficult it is to solve a block so that it always takes more or less the same amount of time.

But how to select how much time on average it should take for a block to be solved? As we saw before, when two miners solve two different blocks more or less simultaneously, two different versions of the blockchain might temporarily compete. The longer the block time, the more unlikely it is for this event to happen. Longer times also reduce the number of blocks added on top of two competing blockchain versions, reducing the number of confirmations needed for a transaction to be final. However, long block times have drawbacks as well. If block time is set too long, Bitcoin users would have to wait a long time for the network to confirm their transactions. This waiting time negatively affects usability, as ideally transactions should be final as early as possible.

For Bitcoin, the target block time is 10 minutes. That is, Bitcoin will adjust the difficulty of solving blocks so that they are solved on average every 10 minutes.



Mining Difficulty

As we have just seen, Bitcoin automatically modifies difficulty in order to keep stable the time it takes to solve a block. Every 2016 blocks, a new difficulty adjustment takes place. Adjustments are calculated on the basis of how long it took on average to solve a block in the previous 2016 blocks. The adjustment will try to make it so that blocks are solved in 10 minutes on average again. For instance, if the average time to solve blocks was 9 minutes, Bitcoin will make it more difficult to solve the next 2016 so that it takes longer on average.

Difficulty adjustments help keep the network stable, but they also affect mining profitability. As difficulty increases, profitability decreases, forcing some miners to deactivate their machines. The effect is that only the most efficient miners using the cheapest sources of energy survive long-term. Moreover, this also puts a limit to how many miners can join the network and stay profitable.



Hashrate

Hashrate is a measure of the computational power of a Bitcoin mining machine. The higher the hashrate, the faster a machine is expected to solve a block. If a machine has too low hashrate, it will not be able to solve blocks fast enough for the rewards to compensate electricity costs. For a while after Bitcoin was created, a personal computer's CPU or GPU was enough to mine a few Bitcoins. However, with time new machines were created with a much higher hashrate. As they joined the network, mining difficulty increased to the point that it is not profitable anymore to mine Bitcoin without specialized hardware.

The total hashrate of the network is calculated by adding together the hashrate of all machines mining Bitcoin at a given time. Hashrate is positively correlated with Bitcoin difficulty. As more machines and more efficient ones start mining, the time it takes for one of them to solve a block is shorter than the target of 10 minutes. With the next adjustment, difficulty is increased to get block times back on target. Concordantly, when machines leave the network, it takes longer for a miner to solve a block, and difficulty has to decrease.



Network Security

The higher the total hashrate of the network, the more secure it is considered. The higher the hashrate, the more difficult it becomes for a single entity to control more than 50% of it. If an entity were able to obtain this share of the hashrate, it would be possible for them to attack the network. As they solve blocks faster than the rest of the nodes combined, their version of the blockchain would always be longer than the ones produced by the others. This would allow them to monopolize the creation and addition of new blocks, and it is what is known as a 51% attack.

There is a number of things an attacker could achieve with this power. They could start adding empty blocks to the blockchain, leaving all transactions unprocessed. They could also perform a transaction and then roll it back. For instance, pay for something with Bitcoin, then revert the transaction to get the Bitcoin back. This is commonly known as a double-spend.

Bitcoin prevents this kind of attack by making it economically unreasonable. The higher the hashrate, the more expensive it is to take possession of 50% of it. With current levels, it is practically impossible, as they would have to essentially buy the entire production of new mining machines for more than a year. Moreover, such an attempt would doubtlessly be detected, and measures could be taken to prevent it. But there are economic incentives beyond all these costs and risks. If someone does control such a large proportion of the hashrate, why not profit from the immense Bitcoin revenue it would generate, instead of trying to attack the network?

Nevertheless, an event of this kind can be disruptive, which makes it important for the hashrate to stay at healthy levels.






The Halving

Part of what makes Bitcoin so attractive is that there can never exist more than 21 million coins. If block rewards were constant, the same amount of Bitcoin would be created every day, eventually surpassing any limit. This would make impossible the goal to keep the supply limited to a specific amount. That is why block rewards periodically decrease. Every 210,000 blocks mined, block rewards experience a 50% reduction. Rewards are reduced like this every 4 years, and is a much anticipated occasion known as the Halving.

Because of the drastic decrease in mining rewards, the Halving severely affects mining profitability. Mining revenue is severely reduced, while mining costs remain stable. For mining machines with a low hash rate, or for miners located in places with expensive electricity costs, mining rewards might not be enough to make the operation profitable anymore. When this happens, these machines have to be disconnected. As miners leave the network, it starts to take longer to solve blocks, and difficulty needs to adjust to make block solving easier. Then, after some time, a new balance is reached.

Halving events will keep happening roughly every 4 years until the year 2140. At that point, coin supply will reach the target of 21 million Bitcoin, and solving new blocks will not reward miners with new coins.





Transaction Fees

Fortunately block rewards are not the only source of revenue for Bitcoin miners. If this were the case, there would be no economic incentive to continue mining after block rewards are phased out. Moreover, the ever-sinking block rewards would force to disconnect more and more mining machines. This would reduce the hashrate, and with it the security of the network.

Before a transaction is added to a block and then the block to the blockchain, we say that the transaction is in the mempool. This means that the transaction is being sent from one node to another, looking for a miner to process it. As we mentioned before, the number of transactions per block is limited, and so is the number of blocks processed in a given day. With such a limit, transactions compete with each other to be added to a block. Ultimately it is the miners who choose which transactions are added to the blocks they create. This brings us to the second revenue source for miners: transaction fees.

When someone sends a Bitcoin transaction, a part of the Bitcoin is used to reward the miners for processing it. This part is called transaction fee, and users may set it as high as they want. Since miners choose which transactions to add to a block, they will generally select the ones paying the highest fee. During times with low traffic, transaction fees are pretty low and they do not contribute significantly to mining profitability. However, as adoption deepens and Bitcoin traffic keeps growing, fees constitute an increasing share of mining revenue. Eventually, transaction fees will constitute the main source of revenue for miners.







Mining Pools

As more and more miners have joined the network, eventually it became extremely unlikely for one of them to find a block. With one every 10 minutes, can only solve approximately 144 blocks every day. At the same time, block rewards have grown immensely in value, as Bitcoin price has continued to increase over the years. However, with millions of people mining Bitcoin, they would have to control a significant amount of the hashrate if they expect to solve a block within their lifetime. Because of the elevated cost of the machines, the existing probability of earning a huge reward is not enough to justify the investment. This is why mining pools were created.

Mining pools combine the mining power of many miners. Together, they can expect to solve a block with reasonable frequency. Whenever they solve a block, they distribute the reward proportionally to their hashrate contribution. This way, small miners with a low hashrate can still earn daily rewards, without having to solve a block themselves. Thanks to that, they make it possible for many people to participate. There is however an important drawback. Mining pools concentrate power in fewer entities, which might have varying degrees of decentralization.





Mining Profitability

Now that we know what Bitcoin mining is, we can take a closer look at the economics. For mining to be profitable, revenue needs to more than compensate costs and investment. Mining income comes from block rewards and transaction fees, with block rewards making the largest contribution. However, both of these components are denominated in Bitcoin, and Bitcoin is known to fluctuate significantly in value. What are then the implications for Bitcoin miners?

When Bitcoin price increases, the fiat value of block rewards and transaction fees increases as well. Costs on the other hand are denominated in local currency, and they are entirely indifferent to Bitcoin price changes. Miners are then able to keep more of the value they extract, after paying electricity costs and any other cost they might incur. On the other hand price decreases reduce profit margins, while again costs remain the same. The effect is similar to the one caused by mining difficulty adjustments. However, price fluctuations are typically more sudden, which makes it problematic to accurately calculate profit expectations.

Additionally, Bitcoin mining can require a sizable investment, as mining machines can be quite costly. Miners have the hope that the rewards they obtain are enough to amortize the machines before they inevitably become obsolete or break down. As we have seen, price fluctuations and difficulty increases prompted by new mining machines can make this tricky. Because of this, mining margins need to be enough to pay back the investment in as few years as possible. To ensure it, they will seek the cheapest possible energy sources, or even install their own.

Time to Mine!

Hopefully you know now how Bitcoin works and understand some of the basic concepts. Now you're ready to take the next step and get your own mining operation going. If you have more questions feel free to join our community on Discord:

https://discord.gg/TMnKF3rZ9x

Or join StakeCube to gain access to easy and low-cost Bitcoin mining by buying participations in our mining pool:

https://stakecube.net/app/minecube/


› See More: How Bitcoin works.