Let’s talk about the process of Bitcoin mining. Do you know this knowledge?

Let’s talk about the process of Bitcoin mining. Do you know this knowledge?

This is the end of the popular science album on Bitcoin mining. After the first two articles, I believe that readers have a certain understanding of the process of Bitcoin transactions and block generation. So what is their relationship with "mining"?

We know that in the Bitcoin network, there are many mining nodes and miners involved in creating new Bitcoin blocks. If multiple mining nodes create blocks of the same height , whose block should be determined to be more legitimate? Bitcoin introduces the PoW (Proof of Work) consensus mechanism, which uses mining to compete for the right to record new blocks. Whoever gets the right to record new blocks will create legal new blocks. The purpose of mining is to win the right to record and confirm new blocks and transactions . So how do mining nodes and miners work together to complete mining?

Miners crack mining tasks

After the mining node creates the reserve block, it sends the block header data of the reserve block to the miner. After receiving the mining task, the miner will increment the random number in the block header. Each time it is adjusted, the hash value of the block header will be calculated using the SHA256 algorithm in accordance with the Bitcoin protocol. If the hash value of the block header is greater than the target hash, the random number will continue to be changed until the hash value of the block header is less than or equal to the target hash ( or the mining node finds that the new block has been mined by other nodes, in which case it will abandon the original mining task, construct a new reserve block, and restart mining).

Mining nodes verify blocks and extend local blockchain

When a miner finds a random number that can make the hash value of the prepared block header smaller than the target hash value, the mining result will be reported to the mining node immediately. After receiving the information, the mining node will immediately reorganize the block according to the information reported by the miner and verify the block . After verification, the mining node saves the new block to the node local database and adds it to the node local blockchain.

The verification information of the block includes:

  • Whether the block header is legal (block header hash ≤ TargetHash);

  • Whether the MerkleRoot hash of the block header is consistent with the MerkleRoot hash of the transaction data in the block (to verify whether the transaction has been tampered with);

  • Whether the first transaction in the transaction data is a Coinbase transaction;

  • Whether each transaction in the block is legal, etc.

Broadcast new blocks to the entire network

After the mining node saves the new block locally, it broadcasts the mining result to the Bitcoin network simultaneously. Since the block size of the entire block is large, the block header of the new block is generally broadcast first. After receiving the broadcast, other nodes first verify the block header information. After the verification is passed, the node will first create an index of the new block in its local block index library. After receiving all the information of the new block, the node verifies the transaction information and the MerkleRoot hash of the block header. After the verification is passed, the node enters the transaction information into the new block and extends the local blockchain. At this point, the broadcast and verification of the new block are completed, and the mining node starts mining the next block.

Some characteristics of current mining

Cluster Mining - Mining Pool:

As for Bitcoin mining, in theory, anyone can build their own Bitcoin mining node and participate in mining. They can even manually verify the block header hash, crack the mining task, and compete for the right to keep accounts.

However, the blogger mentioned in the previous article that according to the current mining difficulty, even using the current mainstream mining machines, it would theoretically take 42 years to find a new block that meets the requirements of the Bitcoin network. If an ordinary PC or manual calculation is used, it would take tens of thousands or even millions of years.

Therefore, the economic benefits of mining alone for ordinary miners are too low, and they may mine until their machines are scrapped and they still cannot earn a penny. Mining pools came into being under such circumstances. A large number of miners connect their mining machines to mining pools, obtain mining tasks from the mining nodes of the mining pools, and mine collectively. In this way, new blocks can be mined in a relatively short period of time and block rewards can be obtained. The mining pool distributes mining income according to the contribution of each miner in the mining process. All miners can obtain mining income in real time and make a return on investment or secondary investment.

In the mining tasks actually received by the miner, TargetHash is much larger than the TargetHash required by the Bitcoin network:

The process of mining with mining pools and miners follows the above process. The mining machine communicates with the mining pool through the network and requests mining tasks. The mining pool sends the mining tasks (including block headers and other data) to the mining machine. The mining machine changes the random number of the block header and verifies the block hash. The random number that meets the requirements of the mining task TargetHash will be submitted to the mining pool in the format of the mining protocol. The mining pool calculates the income based on the mining results submitted by the mining machine.

It should be noted that if the TargetHash in the mining task issued to the miner is the TargetHash of the Bitcoin network at this time, then this TargetHash is too small, and the miner is basically unable to find a random number that meets the requirements and submit the mining results, and it is impossible to obtain mining income.

Therefore, the mining task sent by the mining pool to the mining machine contains a separate piece of information: the initial mining difficulty . This is a value much lower than the mining difficulty of the entire network, corresponding to a larger TargetHash. Under this difficulty, the mining machine can find a random number that meets the requirements in a shorter time and submit more mining results to the mining pool.

The mining pool computing power is different from the local computing power of the mining machine:

When talking about mining, there is always a term that cannot be avoided: computing power . What exactly is computing power?

The computing power is actually the speed at which miners verify the hash value of the block header. After obtaining a mining task, the mining machine will increment the random number of the block header according to the information of the mining task. Every time the random number is adjusted, the hash value of the block header is verified. It can be seen that the only factor that limits the mining speed of the mining machine is the speed at which it verifies the hash value of the block header, so there is the indicator of " computing power ".

At present, the computing power unit of conventional Bitcoin mining machines is TH/s, which means that 1T hashes can be verified per second, 1T=1×103G=1×106M=1×109K=1×1012 times.

Friends who have mining experience will find that there is always a difference between the computing power displayed locally on the mining machine and the computing power displayed by the mining pool. This is because the computing power displayed locally on the mining machine is the speed at which the mining machine verifies the hash, which is only related to the performance of the mining machine. Regardless of whether a random number that meets the requirements of the mining task is found, the local computing power of the mining machine always exists. The computing power displayed by the mining machine in the mining pool is different. It is calculated by the mining pool according to the mining results actually submitted by the mining machine. If the mining machine is unlucky and fails to find a random number that meets the requirements of the mining task for a long time, it cannot submit mining results to the mining pool, and the computing power of the mining machine in the mining pool will be reduced.

However, as time goes on, the impact of luck on the mining machine's ability to crack mining tasks will decrease, and the average computing power of the mining pool for a longer period of time will not be much different from the local computing power of the mining machine.

The above is the basic knowledge of Bitcoin mining. If you can understand these three articles, I believe readers will have a preliminary understanding of Bitcoin mining. If you want to discuss more mining issues with the blogger, welcome to follow the WeChat public account "Xianhua Mining", and you can also learn more about the mining knowledge updated by the blogger in a more timely manner.

Several knowledge points involved in the article: Block height : also called Block Height, equivalent to the block number, its value is equal to the number of all blocks before this block in the blockchain. The first block of the blockchain is the genesis block, with a block height of 0, the second block with a block height of 1, the third block with a block height of 2, and so on. The total number of blocks in the blockchain is the block height of the latest block + 1. PoW : The full name is Proof of Work, and the Chinese name is Proof of Work. It is a method used by the Bitcoin network to solve the problem of Bitcoin new block confirmation. In the Bitcoin network, everyone can participate in the creation of new blocks. The PoW mechanism stipulates that whoever can find a new block with a block header hash value less than the TargetHash specified by the Bitcoin network in the shortest time has the right to record the formal new block . Bookkeeping rights : The Bitcoin blockchain is essentially a large chain ledger. Each block on the chain is a book that records the Bitcoin transaction information that occurred on the blockchain. Therefore, we regard the process of creating a new block as a bookkeeping process. The right to record accounts, as the name suggests, is the right to record transaction ledgers, that is, the right to create formal new blocks on the Bitcoin blockchain.

References:

  1. Mining implementation: https://blog.csdn.net/ztemt_sw2/article/details/80958087

  2. Block Height: https://www.investopedia.com/terms/b/block-height.asp

  3. Proof of Work: https://en.wikipedia.org/wiki/Proof_of_work


<<:  The rise of overseas mining: the United States builds factories in batches, and Malaysia becomes a paradise for stealing electricity

>>:  Babbitt Exclusive | The case involved more than 100 million yuan! The police revealed how the country's first "digital currency arbitrage case" was solved

Recommend

What does a good woman's palm look like?

Super perfect marriage 1. Keep water in your palm...

Coin Zone Trends: Bitcoin Price Trends Based on Big Data This Week (2016-10-18)

Trading on the exchange is sluggish and there are...

People with crooked noses have bad fortunes.

Often, we can analyze a person's condition mo...

Will getting fat bring good luck?

Metaphysics is most concerned with yin and yang a...

Kezi's facial features

Kezi's facial features In physiognomy, the ve...

How to tell when to get married by palmistry

In life, some people get married and have childre...

Regulating Bitcoin Miners? Experts Give U.S. Congress a Bad Idea

On September 4, according to foreign media CoinDe...

Is it correct to predict fortune based on appearance?

Is it correct to predict fortune based on appeara...

U.S. Justice Department holds high-level blockchain conference in San Francisco

Today, the U.S. Department of Justice (DOJ) held ...

Several aspects that are very important for work and family

Many times, we say that it is important to find a...

Will Ethereum Make a Comeback in 2025?

Ethereum enthusiasts predict that ETH will see a ...