Mining in crypto currency and Bitcoin

in #bitcoin7 years ago

Hello Reader,

We've now covered how bitcoin addresses are secured and become acquainted with the blockchain. In this post we are going to learn about the process known as mining which acts to secure the network.

What is bitcoin mining?

Miners are the engine that powers the blockchain. They check transactions are valid and then record them into blocks to be added to the chain.

There are two key questions that mining answers.

Bitcoin uses a peer-to-peer network, with no central authority issuing transactions. As a result, each node is likely to include different transactions in their respective blocks.

(1) How does the network decide which block to add to the chain?

Furthermore, computers are expensive to buy and operate.

(2) Why would anyone spend their resources running a node?

What is proof of work?

In our look at the history of Bitcoin, we came across a key inspiration, Hashcash. This introduced the concept of proof-of-work which is at the heart of mining.

Before a miner can publish its new block to the network, it must first solve a computationally intensive problem. This mechanism is known as proof-of-work.

Proof-of-work requires miners to scan vast amounts of numbers in search of a hash which meets a set condition. A hash takes a large amount of data and converts it into a fixed length value. For Bitcoin, the calculated hash must be lower than a target value in order to be acceptable proof-of-work.

Bitcoin uses the SHA-256 hashing algorithm which results in a 256 bit number from any given data.

Miners first prefix their block header with a number known as a nonce. They then run this through SHA-256 to generate a hash and check if the calculated hash is lower than the target. If it is, great, they have a valid proof-of-work and can broadcast their block. If it isn't, they increment the nonce and repeat the process until they are successful.

It is computationally difficult to find hashes below the target value (typically needing to calculate trillions of hashes per second) . However, it is computationally easy to verify that a proof-of-work is valid with a single calculation.

As soon as a miner identifies a successful hash, it includes the proof-of-work in it's latest block of transactions and broadcasts the block to the network. Other miners receive the block, quickly verify that the proof is valid and then accept the block as the next in their chain.

A miner can't submit a block to the network until it has a valid proof-of-work and so this regulates which miner gets to submit the next block.

Variable difficulty

The Bitcoin network aims to have a new block added to the chain approximately every 10 minutes. This means roughly 6 new blocks are processed each hour and 144 are processed each day.

However, the amount of computational resource that is dedicated to the Bitcoin network is variable. Additionally, advancement in technology means that the computational power dedicated to the task will increase over time.

So how does the network control how frequently miners will find a proof-of-work and thus limit the number of blocks generated?

The answer to this question highlights another part of the genius of the Bitcoin protocol.

A proof-of-work needs to have a hash which is lower than or equal to a target value to be accepted as valid. The lower the target is, the proof-of-work becomes harder to calculate. The target required by the network isn't static, it is variable and is adjusted by the network over time. This target is known as difficulty.

Every 2016 blocks the difficulty is recalculated to a value that would have meant the previous 2016 blocks would have taken two weeks to generate had everyone mined at that difficulty. On average, this is equivalent to one block every ten minutes.

If more miners join the network, the overall processing power increases and the difficulty will be increased in the next cycle. Likewise, if miners leave the network then the difficulty is decreased. Using this mechanism an equilibrium is maintained.

If mining is so difficult and expensive, why would anyone want to waste their resources doing it in the first place?

The miners incentive

The Bitcoin protocol has a hard cap included in it's code which limits the maximum number of Bitcoins that will ever exist to 21 million.

Where do these coins initially come from?

In a traditional currency, a central authority such a bank is responsible for issuing new coins. However, Bitcoin doesn't have a central authority, so it requires a different method of adding coins to the network.

The first transaction a miner includes in their block is a special transaction which creates new coins at an address that they control.

This creates an incentive for miners to support the network and also provides a way for new coins to be distributed into circulation. This steady increase in circulation has parallels to how gold miners gradually mine gold, hence the name, mining.

The Bitcoin network began in January 2009 when the first block, known as the genesis block, was mined by Satoshi Nakamoto. The amount of new coins generated with each block is controlled by code and was initially set to 50 bitcoins per block.

If this never changed, the number of bitcoins would continue to grow forever and would not stop at 21 million. As a result, the number of new bitcoins issued with each block halves every four years (every 210,000 blocks). Bitcoin therefore has a decreasing supply with the full 21 million coins expected to be issued around the year 2140.

If the mining reward decreases and eventually stops, why will people continue to mine?

Transaction fees

The first consideration is that the reward is issued in Bitcoins and not some other currency such as USD. As a result, if the value of one Bitcoin increases, then the value of the mining reward does as well. As there is a fixed supply of bitcoins, it is deflationary, the value of each bitcoin has tended to increase. Although the reward supply has halved twice (now 12.5 bitcoins), the price increase has outstripped this.

However, new coins are just one piece of the puzzle. Each transaction on the network incurs a transaction fee denominated in Bitcoin. Along with the newly issued coins, miners also keep all of the fees for the transactions included in their block. So even when new coins are no longer issued, miners will still be compensated through these fees.

The fees themselves are not static and are the subject of an intense debate in the Bitcoin world. I want to give this topic the attention it deserves so look out for a separate post soon.

That's all for now folks.

Yours, X. 

Sources

Content: Xexr.com

Image: Pixabay.com

Sort:  

How do you feel about Ethereum transitioning to proof of stake, soon?

Hi Kevin - thanks for commenting.

I'd describe my thoughts as cautiously optimistic. I think it would be great for the network in terms of PR around energy usage, but I have genuine concerns about the soundness of the technology and the pending reaction of current ethereum miners. Could we end up with three ethereum chains?

Good question. I wonder what I'll put my rigs to mine. Maybe LBRY?

Coin Marketplace

STEEM 0.28
TRX 0.11
JST 0.034
BTC 66077.75
ETH 3167.77
USDT 1.00
SBD 4.01