Understanding cryptocurrency: Detailed Introductions on Cryptocurrency Mining

No Comments 1408 Views0


Understanding cryptocurrency Detailed Introductions on Cryptocurrency Mining

This article mainly aims to explain the principle and process of cryptocurrency mining for the newbies. For the specific mining tutorial, please refer to: https://www.eastshoremining.com/tour/

 

Cryptocurrency Mining and Mining Worker

The blockchain is made up of many nodes. For the sake of node synchronization, every new block should not be added too fast. Imagine that you have just synchronized a block and got ready to generate the next one, then new blocks have been generated in other nodes, so you are forced to give up halfway for synchronization once again. Since new block always follows the former one, you can only generate the next block after the latest one. That’s say, you have no choice but to conduct synchronization immediately once getting the signal.

Therefore, the creator of the blockchain, Nakamoto Satoshi (which is a pseudonym, whose real identity is still unknown) deliberately made new blocks difficult to be added. His design is that every 10 minutes, the entire network can generate a new block, six in an hour.

This rate of new blocks generating was due to deliberate massive calculation instead of command, which means that the effective hashrate of current block can be obtained only through extremely massive calculation to add the new block into the blockchain. It’s impossible to accelerate the speed due to large amount of calculation.

This process is known as mining because it is very difficult to obtain the effective hash value, just like finding a qualified sand in the deserts all over the world. The machine that calculates the hash value is called miner and the person who operates the miner is called mining worker.

 

Difficulty

People may feel doubtful why the mining is so difficult since it’s just a hash value calculated in computer. After all, computers are good at calculating. How come it’s so hard?

That’s because not any hash value will do except the suitable one to be accepted by the blockchain. Due to such a demanding condition, most of the hash values cannot meet the requirements and must be recalculated.

Since each block contains a value of difficulty, which determines how hard the hash calculation is. For example, the value of difficulty of the 100,000th block is 14484.16236122. Or we can also simply understand the difficulty as: how long it will take to obtain one block.

The formula to calculate the value of difficulty: difficulty value = maximum target value / current target value

Then what is the target value: the target value is the hash generated by the current block to prove the workload of the mining workers. The head hash of the block being mined must be smaller than the target value, so that the data block can be successfully mined.

The current target value refers to the reference indicator to the head hash generated by the current data block. The maximum target value is a fixed value: 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.

Only the hash value smaller than the target value will be valid, otherwise it must be recalculated. Since the target value is very small and the chance of obtaining smaller hash will be extremely difficult, possibly only one out of 1 billion. That’s why the mining activity is so difficult and slow.

The hash of current block is uniquely determined by the head. To repeatedly calculate the hash in the same block means that the head must be constantly changed, otherwise it is impossible to obtain a different hash. All the characteristic values in the head are fixed. In order to realize the changes in the head, Nakamoto Satoshi has added an item called Nonce.

Nonce is a random value and the mining workers only intend to guess the value so that the hash in the head is smaller than the target value to be accepted by the blockchain. It’s very hard to guess the Nonce value and people can only try one by one. According to the protocol, Nonce is a 32-bit binary value, which can be as much as 2.147 billion. The Nonce value of the 100000th block is 274148111, which means the worker can only get one valid Nonce value after having calculated 274 million times from the number 0.

If being lucky, people may find valid Nonce in a while, if not, they may have no harvest even after 2.147 billion times of calculation, which means it’s impossible to find the valid one in current block. Then, the protocol will allow the workers to change the block to start new calculations.

 

Dynamic Adjustment

Just as the aforesaid discussion, the mining activity is random, so nobody can guarantee one block will be produced within exactly ten minutes. Sometimes it takes only one minute while sometimes as long as several hours. In general, with the improvement of hardware equipment and the number of miners, the calculation speed will certainly be faster and faster.

In order to keep the output rate constant at ten minutes, Nakamoto Satoshi also designed a dynamic adjustment mechanism for the difficulty. According to the mechanism, the difficulty is adjusted every two weeks (2016 blocks). If the block generation speed is 9 minutes averagely in the past two weeks, it means 10% faster than the legal speed, so the difficulty will be increased by 10% correspondingly; if the average generation speed is 11 minutes, which means 10% lower than the legal speed, then the difficulty will be decreased by 10% correspondingly.

The higher difficulty (the smaller target value) makes the mining more and more difficult.

However, some people may ask that how the difficulty will be adjusted since the blockchain is decentralized? The difficulty adjustment is automatically and independently conducted in every full node. The difficulty of all the nodes in every 2,016 blocks will be adjusted. The calculation of difficulty adjustment is determined by comparing the time length spending on the latest 2,016 blocks with 20,160 minutes (two weeks, that is, the time length for these blocks expected to be generated every 10 minutes). The difficulty is adjusted according to the ratio of the actual time length to the expected time length (may be harder or easier). To make it easier to understand, the difficulty will be higher if the network finds the block generation rate is less than 10 minutes and vice versa.

The formula can be described as follows:

New Difficulty = Old Difficulty * (Actual Time of Last 2016 Blocks / 20160 minutes)

 

Worker’s Income

Since the mining is not easy, why some people are still willing to be mining workers? Take bitcoin as an example.

First, the mining workers are indispensable for the confirmation of transaction.

Second, according to bitcoin protocol, the workers who have mined new blocks will be rewarded. It was 50 bitcoins at first (in 2008) which will be halved every four years, and currently it’s 12.5 bitcoins. That’s also the supply mechanism for bitcoin and all the new bitcoins in circulation are just generated in this way.

It’s obvious that since the reward is halved every four years and bitcoin can be split to eight decimal places, the workers will not receive any rewards by 2140 and the number of bitcoins will also stop increasing. At that moment, the worker’s income will completely depend on the transaction fees.

The so-called transaction fee refers to the commission the workers draw from each transaction, and the specific amount is determined by the payer. Of course, the payer can refuse to pay any commission, but in that case, nobody would like to process the transaction and it will not be accepted by the blockchain. The workers will naturally deal with the transactions with the highest commission.

At present, due to large number of transactions, the commission has also risen correspondingly. The total commission for more than 2,000 transactions in a block can be as many as 3 to 10 bitcoins. For the ones with low commissions, it is most likely that the transaction has not been confirmed even after a whole week.

The reward of 12.5 bitcoins from the block as well as the commission is quite considerable. Based on the current price, it’s equivalent to about 750,000 RMB. Just imagine the one who is lucky enough to obtain a block within a few minutes and get a lot of money, no wonder so people are eager for the mining.

 

Summary

In a word, the reason why the mining workers exist is that the current income is higher than the cost. It’s human nature to pursue profits.

 

Appendix

EastShore’s series of tutorials on the basics of cryptocurrency:

 

Leave a Reply