Bitcoin Basics – Part One – Mining Basics

by Albert Szmigielski

Mining serves different purposes in Bitcoin.
Miners verify transactions, by making sure they are valid. Then they include these transaction in a newly created block. This is how the blockchain gets extended, miners add new blocks on top of it. Then there is the securing the blockchain function. The more processing power miners have the more difficult it is for someone to mount an attack against the Bitcoin network.

Finding a new block.

The terminology around this varies, some people say finding a new block, others refer to it as solving a new block. All the miners compete against each other in finding new blocks. They are motivated by the rewards they get when they do find one and it gets accepted by other miners. The rewards are composed of the block creation reward and all the transaction fees included in the block. The block creation reward currently stands at 25 BTC. When we hit block number 420,000 the rewards will halve to 12.5 BTC, the rewards halve every 210,000 blocks (roughly four years), until they run out around the year 2140. The second part of the reward are the transaction fees, currently they do not amount to a large amount, but this may change in the future.

Finding a new block requires a miner to assemble a candidate block. A candidate block contains the hash of the previous block, some transactions including the very important coinbase transaction that creates the bitcoins for the block reward, and a nonce – a 32 bit integer. Then the miner repeatedly hashes the candidate block increasing the nonce each time to get a different hash. The desired hash is a number that is smaller than a predetermined threshold – the threshold is called the difficulty. Here’s where some confusion arises for newcomers to Bitcoin. We say that the difficulty increases and that the hash must be above that threshold. But at the same time some people say that the hash must be a smaller number. Both statements are correct, when the difficulty goes up this means that the hash we are looking for is a smaller number. This is because a valid hash to a block comes from a set of possible numbers. In order to make the mining puzzle more difficult the set of numbers is made smaller, therefore the hash of the block must be smaller in order to be accepted. So, there is not just one valid hash to a block, there is a set of them; miners race to find any of these numbers in that set. Here it is worthwhile mentioning that the mining problem is sometimes called a puzzle, or a hash-puzzle, or a mathematical puzzle, or simply a mathematical problem.

Once a miner finds a valid hash, that is a hash smaller than the required threshold, they want to broadcast that block to the network so that they are the first to find it. Other miners check over the block to make sure it is valid. There are transaction checks, they check the hash, and they check if the block is on top of the last accepted valid block. Once other miners accept the block the race starts again. A new candidate block is constructed and miners begin the work to try to find a valid hash for that block.

Difficulty

The original designer(s) of Bitcoin chose 10 minutes as the block creation time. On average new blocks are added to the blockchain every 10 minutes. This interval was chosen as a compromise between different factors that we will not get into here. In order to maintain this 10 minute interval a difficulty parameter was introduced. As more miners join the Bitcoin network they would find new blocks faster and faster. The difficulty parameter, which is recalculated every 2016 blocks (2 weeks), maintains on average the 10 minute block creation time. If miners find blocks too fast the difficulty will increase, if the average time of block creation is more than 10 minutes the difficulty will decrease.

Hash Rate

The network hash rate is the combined hash rate of all miners on the network. This is a calculated number, as opposed to a measured number. The hash rate is affected by a couple of factors. First it is affected by the price of bitcoin in fiat currency. If bitcoins are more valuable, more miners will join the network in order to reap the profits that come from finding blocks. The other factor is mining hardware performance, over the years mining hardware has steadily improved its performance thereby adding to the network’s hash rate.

Leave a Reply

Your email address will not be published. Required fields are marked *