BACK THAT HASH UP – AN INTRO TO BITCOIN MINING

in bitcoin •  7 years ago 

Our shot at explaining Bitcoin mining. As always, check out our site to support our work! Feel free to contact us with questions. https://bitconsult.co

Back That Hash Up – An Intro to Bitcoin Mining

The meteoric rise in Bitcoin’s price has helped to push “cryptocurrency mining” into the English Lexicon in 2017, but how many people actually know what mining is? You’ve probably heard that mining uses a lot of electricity, and that it’s very profitable. If you’re tuned into Bitcoin news, you may even know that mining helps secure the Bitcoin network. In this article, we’ll explain how mining works, and how it plays a critical role in Bitcoin.

Block Creation

As you may have learned in our previous post, miners create the blocks that make up the Bitcoin blockchain. These blocks contain Bitcoin transactions and are linked to previous blocks, establishing a “blockchain”.

Miners from all over the world compete to create the next block on the blockchain. Why? If a miner creates a block, they collect a Block Reward as well as all of the fees for the transactions in their block. The current block reward is 12.5 Bitcoin (approximately $96,000), and the average block transaction fees amount to $35,000. A new block is created approximately every ten minutes, so there is a lot of money on the line!

In order to create a block, a miner must be the first to solve a mathematical problem. Solving the problem involves taking the block information (timestamp, information from previous block, etc) as well as a random number, called a “nonce”, and repeatedly hashing the information (while changing the nonce) until a certain answer is found. Hashing is used in encryption, and it effectively takes data (a message, for example), applies a mathematical formula, and produces a jumbled-up string of letters and numbers. Bitcoin mining uses a specific hash function called “SHA-256”. This example shows what happens when you push a sentence through SHA-256.

As you can see, when “I am Satoshi Nakamoto” is put into the SHA-256 hash function, a seemingly random string of letters and numbers is created. If even one letter is changed, the resulting hash comes out completely different.

In order to create a Bitcoin block, the miner needs to apply this hash function to the block information and nonce until a certain condition is satisfied. This condition is defined as a hash result with a certain number of leading zeros, something like this:

0000000000000000009e204f9d82f264d588b80a58c38f0ccd0fc8c6e9b95d18

Miners jam information through SHA-256, changing one value at a time, until the resulting answer has a certain amount of zero’s in front. Crazy right?! Once the miner finds a solution, they relay their block to the network. If their solution comes first, and if their block is valid, they win the block reward and transaction fees. Once the solution is accepted by the network, all miners (including the winner) start looking for a solution to the next block.

Mining Competition

Since mining is so profitable, many companies have been formed that focus specifically on Bitcoin mining. In the early days, anyone with a consumer PC could mine Bitcoin using their computer’s processor. As Bitcoin grew in popularity, miners started using graphics cards (GPU’s) to mine Bitcoin. Multi-GPU mining rigs came next, like Bitconsult’s very own Vertcoin mining rig. Look at that beauty!


This old girl has mined Ethereum, Vertcoin, and BTG

GPU’s can no longer be used to profitably mine Bitcoin, however. Mining competition has led to the creation of Bitcoin Application-Specific Integrated Circuits (ASICs). ASIC’s are integrated circuits designed for a particular use. In Bitcoin’s case, they’re specifically optimized to apply SHA-256 hash functions.

Since new miners start working on Bitcoin every day, it follows that block solutions would be found faster and faster. This would result in many blocks being created per minute, which would effectively flood the market with new Bitcoin, as 12.5 Bitcoin are paid out for every new block. In order to combat this, the Bitcoin protocol has a built in “difficulty adjustment”. As more miners join the network, it becomes harder and harder to find a solution. How does the Bitcoin protocol make solutions harder to find? It simply increases the number of leading zeros required for a valid answer. This has the effect of making the solution exponentially harder to find. Bitcoin difficulty is adjusted approximately every 2 weeks, and it adjusts based on the total mining power, known as “hash power”. The difficulty adjustment ensures that new blocks are created approximately every 10 minutes, creating reliable transaction times and steady Bitcoin inflation.

Mining has become so difficult that ever ASIC miners team up with each other to solve these hash functions. Miners group their resources and split the rewards in communities known as “pools”. Participating in a pool helps miners maintain a steadier stream of income by sharing the mining expenses and splitting the Bitcoin rewards. Currently there are a couple dozen Bitcoin pools, with the largest pool accounting for about 17% of the total Bitcoin Hash power.


Hashpower distribution for Bitcoin

What’s the Point of Mining?

Millions of dollars in electricity and computer hardware is dedicated to Bitcoin mining. The computing power being put into Bitcoin surpassed all of the world’s supercomputers in 2013, and total Bitcoin hashpower has increased exponentially since then.


Bitcoin hashrate is rising exponentially

Is all of this work done strictly to profit miners? How is this a productive use of power?

Securing the Bitcoin Network

Preventing Spam

Bitcoin mining is known as a “Proof-of-Work” (POW) system. POW systems are economic measures designed to deter Denial of Service (DOS) attacks, spam, and other service abuses. You may not realize it, but POW is all around you. POW systems are used by websites and email services. When you type a website into your browser, the web server sends your PC a mathematical problem that is hard to solve but easy to verify (asymmetric). Before receiving access to the site, your PC crunches some numbers and presents an answer to the web server. If your answer is correct, you’re good to go! This all happens on a small scale, costing you a negligible amount of electricity and computing power. If you wanted to attack a website with millions of requests, however, this would cost you some serious resources. It’s important to note that there’s no guaranteed mechanism that prevents attacks. Instead, attackers are economically incentivized not to attack.


We couldn’t pass up the chance to post a nonsense code screenshot

Proof-of-Work Bitcoin mining is not much different. If a miner wanted to, they could choose not to include any transactions in the blocks that they create. If a miner took this approach, they would lose out on tens of thousands of dollars in transaction fees, but they’d effectively be able to hault all Bitcoin transactions until a new block is found. In order to have a sustained impact on the network, however, the malicious miner would need to control a substantial amount of total hashpower. If a miner controlled 50% of hashpower, over time they would win 50% of new blocks. If that miner chose not to include transactions, they could slow down Bitcoin transactions by 50%. As stated earlier, the biggest pool (a conglomeration of miners) controls 17% of hash power.

Creating an Immutable History

The power of Bitcoin lies in its immutable history, which is ensured by its consensus mechanism. Bitcoin is powerful because a huge network of users is constantly validating the history of transactions and agreeing on the state of the network. This results in a public ledger that is visible to all, and does not require storage on a centralized server, or validation by a centralized authority. The implications of this consensus are immense, empowering citizens with financial sovereignty and enabling the decentralized Bitcoin network to prove the fairness of elections, lotteries, asset registries, digital notarization, and more applications.

Bitcoin’s consensus is emergent, meaning that there is no fixed moment that consensus occurs. Instead, consensus is an emergent artifact of the asynchronous interaction of thousands of independent nodes, all following simple rules. These nodes are computers that run a Bitcoin wallet that contains a full copy of the blockchain, usually Bitcoin Core. Nodes verify that transactions and blocks are valid, and that no transactions are double-spent. In addition, the nodes agree to follow the blockchain with the most accumulated Proof-of-Work. This last point is important.

At any time, a miner can cause a fork in the Bitcoin network by mining an off-shoot blockchain. This blockchain would at first be ignored by nodes, as it isn’t the longest chain. However, if a miner (or group of miners) held more than 50% of the total mining hashpower, they could theoretically make the forked chain longer than the original chain.


Blockchain showing a malicious hard fork

If a miner forks from the most recent block, they can create the longest blockchain by having 51% of total hashpower (a “51% Attack”) as they’re 51% likely to win future blocks. However, this only has the effect of the “spam” attack described above. To do any true damage, the attacker would have to go back a couple of blocks in order to “reverse” any recently completed transactions. If the miner goes back a few blocks, it becomes exponentially harder to catch the main chain, and the miner would need more and more hashpower. This problem is analogous to the Gambler’s Ruin problem in mathematics.

For this reason, most important Bitcoin transactions confirm after 6 blocks to ensure that a 51% attack doesn’t put a transaction in jeopardy. In order to attack the Bitcoin network, one would have to coordinate a super majority of the BTC miners, or attack the network with a computer system far larger than any in the known world. This is how mining secures the Bitcoin blockchain.

Conclusion

Mining is an integral part of the Bitcoin Protocol. Miners create blocks, which are necessary to record transactions and build the blockchain. Although Bitcoin Nodes create network consensus, miners play an important role. Bitcoin’s immense hashpower may require a lot of hardware and electricity, but it creates the only persistent, immutable, decentralized consensus network on Earth.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Great! Now I do not have to try and explain it to my friends anymore. I can just link them to this post :D

Haha, that's why I made this website!

  ·  7 years ago Reveal Comment

Nice Article, covers up a lot of things about bitcoin mining.

  ·  7 years ago Reveal Comment

Hi! I am a robot. I just upvoted you! I found similar content that readers might be interested in:
https://bitconsult.co/2017/11/17/back-that-hash-up-an-intro-to-bitcoin-mining/

Congratulations @bitconsult! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes received

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Nice Article. I upvoted your post. Would You Be Kind Enough To Check Out My Profile And Follow Me? https://steemit.com/@zobaer

  ·  7 years ago Reveal Comment
  ·  7 years ago Reveal Comment