In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "what are the two mining methods of block chain". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. let's study and learn "what are the two mining methods of block chain"?
The evolution of mining is not only the evolution process of hardware, but also the evolution process of software, especially the improvement process of software and hardware docking protocol. This paper focuses on the logic design and technical implementation of several core protocols related to mining.
1. Setgenerate protocol
Setgenerate protocol interface represents the era of CPU mining.
In his paper, Satoshi Nakamoto described the ideal digital democracy concept of "1 CPU 1 Vote". In the original version, mining was provided on the client side, and mining on the client side is very simple. Of course, mining can only be done at the end of synchronous data. At present, many shanzhai coins with low computing power still use client-side mining directly, and there are two ways to start mining:
Set the gen=1 in the configuration file, then start the client, and the node will start mining on its own.
After the client is started, the mining is controlled by RPC interface setgenerate.
If you use the classic QT client, click the "help" menu, open the "debugging window", enter the following command in the "console": setgenerate true 2, and then enter, the client will start mining, followed by the number of mining lines, if you want to close mining, use the following command in the console: setgenerate false, you can use the getmininginfo command to view the mining situation.
The process of node mining is also very simple:
Construct the block, initialize the fields of the block head, calculate the Hash and verify the block, if it is unqualified, the nNonce will increase itself, and then calculate and verify it, and so on. In the era of CPU mining, the 4-byte search space provided by nNonce is fully sufficient (4 bytes is 4G possible, and the SHA256D computing power of single-core CPU operation is generally about 2m). In fact, nNonce only traverses two bytes and returns to the reconstruction block.
2. Getwork protocol
Getwork protocol represents the era of GPU mining, and the demand mainly comes from the separation of mining program and node client, and the separation of block chain data and mining components.
Direct mining using client nodes requires synchronous complete block chain, and data and programs are closely integrated, that is, if there are multiple computers for mining, each computer needs to synchronize a separate copy of block chain data. In fact, this is not necessary, for miners, at least one complete node is needed. At the same time, the arrival of the era of GPU mining also requires a protocol to interact with the client node.
The core design idea of getwork is:
The block is constructed by the node client, and then the block head data is handed over to the external mining program, which traverses the nNonce for mining, which is verified and delivered back to the node client, and then broadcast to the whole network after verification by the node client.
As mentioned earlier, the block header has a total of 80 bytes, and since there is no block chain data and transaction pool to be confirmed, the four fields nVersion,hashPrevBlock,nBits and hashMerkleRoot with a total of 72 bytes must be provided by the node client. The main purpose of the mining program is to incrementally traverse the nNonce, and fine-tune the nTime field if necessary.
For the graphics card GPU, in fact, there is no need to worry about the lack of 4-byte search space in nNonce, and after the mining program gets a piece of data from the node client, it should not work too long, otherwise it is very likely that this block has been dug by others, and continued digging can only do useless work, although for bitcoin, it is designed to be a block every 10 minutes. A good strategy should also re-apply for new mining data from the node within seconds. For graphics cards, the computing power of running SHA256D is generally between 200Mbps 1G MagneOnce to provide 4G search space, that is to say, no matter how good the graphics card is, it can support about 4 seconds, adjust nTime once, and dig 4 seconds again, which is more than enough time.
The node provides the RPC interface getwork, which has an optional parameter. If it does not take a parameter, it applies for mining data. If it takes a parameter, it submits the excavated block data.
Call getwork without parameters, and the returned data is as follows:
Data field
A total of 128bytes (80 block header bytes + 48 complete bytes), because SHA256 will split the input data into fixed-length slices, each slice 64 bytes, the total input length must be an integral multiple of 64 bytes, the input length generally does not meet the requirements, then complete the data at the end of the metadata according to certain rules. In fact, for mining, the completion data is fixed, there is no need to provide, external mining software can be completed by itself. You don't even need to provide the nNonce field, and data only needs to provide at least the first 76 bytes. The nTime field is also essential, and the external mining program needs to adjust the nTime with reference to the block time provided by the node.
Target field
That is, the current block difficulty target value, using small head byte order, needs to be flipped before it can be used.
In fact, for the external mining program, there are two fields data and target can mine normally, but the getwork agreement fully considers all kinds of circumstances, tries to help the external mining program to do what it can, and provides two additional fields. The idea is that the data field returns complete data.
Midstate field
As mentioned above, SHA256 splits the input data. After the miner gets the data data, the first shard (the first 64 bytes) is fixed. Midstate is the first shard calculation result, and the node helps to calculate it.
Therefore, with the help of the midstate field, the external mining program can mine normally with even 44 bytes of data: 32 bytes of midstate + the remaining 12 (76-64) bytes of data from the first slice.
Hash2 field
Bitcoin mining needs to execute SHA256 twice in a row, the first execution result is 32 bytes, and another 32 bytes of data is needed to make up 64 bytes as input for the second execution of SHA256. Hash2 is the completion of data, in the same way, hash2 is also fixed.
After digging up the qualified block, the external mining program calls the getwork interface again to submit the modified data field to the node client. The node client requires that the data returned must also be 128 bytes.
Every time there is no external parameter to call a getwork, the node client constructs a new block. Before returning the data, the new block is completely saved in memory, and the hashMerkleRoot is used as the unique identifier. The node uses a Map to store all the constructed blocks, and when the next block has been dug up by others, it immediately empties the Map.
After getwork receives a parameter, it first extracts hashMerkleRoot from the parameter, finds the previously saved block in Map, and then extracts nNonce and nTime from the parameter to fill the corresponding fields of the block to verify the block. If the difficulty meets the requirements, it means that a block is dug and the node broadcasts it to the whole network.
Getwork protocol is the earliest version of mining protocol, which realizes the separation of nodes and mining. The classic GPU mining drivers cgminer and sgminer, and cpuminer all use getwork protocol for mining. Getwork + cgminer has always been a very classic cooperation, and many new algorithms have been quickly transplanted to cgminer when they were introduced. Even now, with the exception of BTC and LTC, many other competing currencies are still using the getwork protocol for mining. After the emergence of mining machines, the mining speed has been greatly improved, and the current computing power of bitcoin mining machines has reached the level of 10T/ seconds. However, getwork only provides 32 bytes of 4G search space for external mining programs. if the getwork protocol continues to be used, the mining machine needs to call the RPC interface frequently, which is obviously not feasible. Today, both BTC and LTC nodes have disabled the getwork protocol and moved to a newer and more efficient getblocktemplate protocol.
3. Getblocktemplate protocol
The getblocktemplate agreement was born in mid-2012, when the mining pool had already emerged. The mining pool uses getblocktemplate protocol to interact with node client, and stratum protocol to interact with miners, which is the most typical mining pool construction mode.
Compared with getwork, the biggest difference of * * getblocktemplate protocol is that getblocktemplate protocol allows miners to construct blocks themselves. * * in this way, the node and mining are completely separated. For getwork, the blockchain is dark, and getwork knows nothing about it. He only knows how to modify the 4 bytes of the data field. For getblocktemplate, the whole blockchain is transparent, and getblocktemplate holds all the information related to mining on the blockchain, including the trading pool to be confirmed, and getblocktemplate can choose the transactions included in the block.
Getblocktemplate is not immutable after being developed, and the client has been upgraded and changed in subsequent releases, mainly to add some fields, but the core philosophy and core fields remain the same. At present, the data returned by the bitcoin client is as follows. Considering the space limit, only one transaction data is retained in the transaction field (transactions). In fact, according to the current actual situation, there are tens of thousands of transactions in the transaction pool to be confirmed in real time. At present, the blocks are basically full (1m capacity limit), plus additional information, so there is about 1.5m data returned each time getblocktemplate is called, compared to hundreds of bytes of getwork. It's not the same as that.
Let's briefly analyze several core fields. The three fields Version,Previousblockhash,Bits refer to the block version number and the previous block Hash, respectively. For difficulty, miners can directly fill in the corresponding field of the block header.
Transactions, transaction set, not only gives the hexadecimal data of each transaction, but also gives hash, transaction fee and other information. Coinbaseaux, if you have information that you want to write to the blockchain, put it in this field, similar to Satoshi Nakamoto's Genesis Manifesto.
Coinbasevalue, dig up the maximum return value of the next block, including issuing new coins and transaction fees. If the miner contains all transactions in the Transactions field, you can directly use this value as coinbase output.
* * the target value of Target**, block difficulty.
Mintime refers to the minimum timestamp of the next block, and Curtime refers to the current time. These two times are used as references for miners to adjust the nTime field.
Height, the next block difficulty. The current protocol stipulates that this value should be written to the specified location of the coinbase.
After the miners get the data, the mining steps are as follows:
Building a coinbase transaction involves fields such as Coinbaseaux,Coinbasevalue,Transactions,Height, and of course the most important thing is to specify a revenue address.
Build the hashMerkleRoot, put the coinbase in front of the transaction list contained in the transactions field, and then perform the SHA256D operation on the adjacent transaction pairs, and finally construct the Merkle tree of the transaction. Because coinbase has many bytes for miners to play with, and transaction lists can be changed or added or deleted at will, the space for hashMerkleRoot values can be considered almost infinite. In fact, the main goal of getblocktemplate protocol design is to give miners access to this huge search space.
Construct the block head, and fill the corresponding fields of the block head with Version,Previousblockhash,Bits and Curtime respectively. The nNonce field can be set to 0 by default.
Mining, miners can design their own mining strategies in the search space provided by nNonce,nTime,hashMerkleRoot.
Hand in the data, when the miners dig a block, immediately use the submitblock interface to submit the block complete data to the node client, which is verified and broadcast by the node client.
* * it should be noted that * * like the getwork mining adopted by GPU mentioned above, although getblocktemplate provides a huge search space for miners, miners should not dig for too long with a request for data, but should cycle to the node to request the latest block and latest transaction information in a timely manner to improve mining profits.
4 、 POOL
* * there are two ways of mining, one is called SOLO mining, the other is to go to the mining pool to dig ore. * * as mentioned earlier, starting CPU mining directly at the node client and directly connecting the node client mining by getwork+cgminer-driven graphics cards are all SOLO mining. SOLO is like buying a lottery ticket and not winning easily. If you win the lottery, you will own all the profits. Going to the mining pool for mining is like buying a lottery ticket. If we pay for it together, we can buy a bunch of lottery tickets. After winning the lottery, the income will be distributed according to the contribution ratio.
In theory, the mining machine can use the getblocktemplate protocol to link the node client SOLO to mine, but in fact, no miner will do that. At the time of writing this article, Bitcoin has a computing power of 1600ppb in the whole network, while the current most advanced mining machine has a computing power of about 10T. In this way, the probability of a single miner SOLO digging a block is less than 16 1/10000. Miners (people) invest real gold and silver to buy mining machines and pay electricity bills, and will not make such risky investments. Obviously, it is more appropriate to invest in the pool to dig the mine in order to reduce the risk and obtain a stable income. Therefore, the emergence of ore pools is inevitable and can not be eliminated, regardless of whether or not to destroy the decentralization principle of the system.
The core work of the mining pool is to assign tasks to the miners, count the workload and distribute the income. The mining pool divides the blocks into many less difficult tasks and sends them to the miners for calculation. After completing a task, the miners submit the workload to the mining pool, which is called a share. If the difficulty of the block of the whole network requires that the first 70 bits of the Hash operation result are all 0, then the task assigned to the miners by the mine pool may only require that the first 30 bits be 0 (adjusted according to the miner's arithmetic power), and the miners will hand in the share after completing the designated difficulty task, and then check whether the top 70 bits happen to be 0 on the basis of meeting the first 30 bits.
The mining pool will assign different difficulty tasks according to the calculation power of each miner. How can the mine pool judge the calculation power of the miners in order to assign the appropriate task difficulty? The adjustment idea is the same as the difficulty of bitcoin blocks. The mining pool needs to rely on the miner's share rate. The pool hopes that each miner will be assigned enough tasks to allow the miner to calculate for a certain amount of time, for example, 1 second. If the miner completes several tasks in a second, it means that the current difficulty given to the miner is lower and needs to be increased, and vice versa. In this way, after a period of adjustment, the mining pool can assign reasonable difficulty to the miners and calculate the calculation power of the miners.
The mining pool has always been a contradiction. There is no doubt that the mining pool is centralized. As shown in the picture above, the computing power of the whole network is concentrated in the hands of several mining pools. Although thousands of nodes of the network are online at the same time, only a few clicks of the mining pool link have the right to vote. Other nodes can only exercise the right of supervision. The pool once again puts the miners in the "dark", and the miners once again know nothing about the blockchain, they only know how to complete the task assigned by the pool.
With regard to the mining pool, there is another small interlude. When the mine pool first appeared, the opposition was particularly strong, and many people were pessimistic that the mine pool would eventually lead to the concentration of computing power, endanger the security of the system, and even kill Bitcoin. So someone designed and implemented the P2P mining pool, trying to de-centralize the "clustered mining", and the code is also open source, but because the efficiency is far less than the centralized mining pool can not attract too much computing power, the so-called ideal is very plump, the reality is very bony.
Several more mature open source mining pool projects are recommended, which can be studied by interested readers:
PHP-MPOS, a very classic mining pool in the early days, is very stable and is used the most, especially the counterfeit coin mining pool, which uses Stratum Ming protocol and source code address at the back end.
Node-open-mining-portal, supports multi-currency mining, source code address
Powerpool, supports mixed mining, source code address
There are many problems to be considered in running a mining pool, for example, in order to get the most timely network-wide information, the mining pool is generally connected to several network nodes, and preferably distributed in several continents of the earth. In addition, increasing the block rate, reducing the isolated block rate and reducing the empty block rate are the core technical issues of the mining pool, so this paper can not be discussed one by one, and then only one problem is discussed in detail, that is, the specific working mode of cooperation between the mining pool and miners-- stratum agreement.
5. Stratum protocol
The mining pool interacts with the network node through the getblocktemplate protocol to obtain the latest information of the block chain and interacts with the miners through the stratum protocol. In addition, in order to enable the software that previously used the getwork protocol to mine the mine, the mining pool generally supports the getwork protocol through the hierarchical mining agent mechanism (Stratum mining proxy). It should be noted that when the mining pool first appeared, the graphics card mining was still the main force, and getwork was very convenient to use. in addition, some of the early FPGA mining machines were realized by getwork. Stratum and the mining pool communicate with TCP, and the data is encapsulated in JSON format.
Let's start with a few questions left behind by getblocktemplate:
* * miner-driven: * * in the getblocktemplate protocol, miners still take the initiative to call the RPC API through HTTP to apply for mining data from nodes, which means that miners cannot be informed of the latest changes in the network block in time, resulting in a loss of computing power.
Data load: as mentioned above, a normal getblocktemplate call node now sends back about 1.5m of data, in which the main data is the transaction list, and the miners and the mining pool need to exchange data frequently. Obviously, miners cannot be given so much information every time they are assigned work. In addition, the huge memory demand will greatly affect the mining machine performance and increase the cost.
The Stratum protocol completely solves the above problems.
The Stratum agreement adopts the way of actively assigning tasks, that is to say, the mining pool can assign new tasks to miners at any time. For miners, if they receive a new task assigned by the mining pool, they should immediately and unconditionally turn to the new task; miners can also take the initiative to apply for new tasks with the mining pool.
Now the core problem is how to make miners get more search space. If only miners can change nNonce and nTime fields according to getwork protocol, the amount of interactive data is very small, but this search space is certainly not enough. If you want to increase the search space, you can only work on hashMerkleroot. If you let the miners construct their own coinbase, the problem of search space will be solved, but at the cost of handing over all the transactions contained in the block to the miners before they can construct the Merkleroot of the transaction list, which is more stressful for the miners and higher for the bandwidth requirements of the mine pool.
Stratum protocol cleverly solves this problem, and the successful implementation can not only increase enough search space for miners, but also need to interact with a small amount of data, which is also the most innovative aspect of Stratum protocol.
Let's review the block header's six fields of 80 bytes. This is critical. The three fields of nVersion,nBits,hashPrevBlock are fixed, and the two fields of nNonce,nTime can be changed by miners now. The only way to increase the search space is from hashMerkleroot, which can't be bypassed. The Stratum protocol allows miners to construct their own coinbase transactions, the scriptSig field of coinbase has many bytes for miners to fill freely, and the change in coinbase means a change in hashMerkleroot. It is not necessary to construct hashMerkleroot from coinbase. As shown in the above figure, if the block will contain 13 transactions, the mining pool will first process the 13 transactions, and finally, as long as the 4 black spots (Hash values) in the diagram are delivered to the miners, and the information needed to construct the coinbase is delivered to the miners, the miners can construct the hashMerkleroot themselves (the green dots in the figure are all calculated by the miners themselves. When merging Hash in pairs Specifies that the hash value represented by the next black dot is always on the right. In this way, if the block contains N transactions, the pool can be condensed into log2 (N) hash values and delivered to the miner, which greatly reduces the amount of data that the pool interacts with the miner.
The Stratum protocol strictly defines the interface data structure and interaction logic of the interaction between the miner and the mine pool, as follows:
1. Miner subscription task
Start the mining machine and use the mining.subscribe method to link the ore pool
Returning data is very important. Miners need local records, which are used throughout the mining process, where: b4b6693b72a50c7116db18d6497cac52: specify the initial difficulty for miners, ae6812eb4cd7735a302a8a9dd95cf71f: Subscription account ID 08000002: scientific name Extranonce1, used to construct coinbase transaction 4: scientific name Extranonce2_size, that is, the length of Extranonce2, where 4 bytes of Extranonce1 are specified, and Extranonce2 is very important for mining. The increased search space is here. Now, we have at least 8 bytes of search space. That is, 4 bytes of nNonce and 4 bytes of Extranonce2.
two。 Mining pool authorization
Register an account in the mine pool, add miners, and the mine pool allows each account to add any number of miners, with different names to distinguish. Miners use the mining.authorize method to apply for authorization, and only miners authorized by the pool can receive the pool assignment.
3. Pool assignment task
Each of the above field information is necessary, where: bf: task number ID, each task has a unique identifier
Hash value of the previous block, hashPrevBlock:
4d16b6f85af6e2198f44ae2a6de67f78487ae5611b77c6c0440b921e00000000:
The scientific name coinb1, which constructs the first part of the sequence data of coinbase:
01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff20020862062f503253482f04b8864e5008
The scientific name coinb2, which constructs the second part of the sequence data of coinbase:
072f736c7573682f000000000100f2052a010000001976a914d23fcdf86f7e756a64a7a9688ef9903327048ed988ac00000000
The scientific name merkle_branch, the compressed representation of the transaction list, that is, the black spot in the figure above:
["76cffd68bba7ea661512b68ec6414438191b08aaeaec23608de26ac87820cbd02016", "e5a796c0b88fe695949a3e7b0b7b1948a327b2f28c5dbe8f36f0a18f96b2ffef2016"]
00000002: block version number, nVersion 1c2ac4af: block difficulty nBits 504e86b9: current timestamp, nTime has the above information, plus the previously obtained Extranonce1 and Extranonce2_size, you can mine.
4. Digging ore
Construct coinbase transaction
The information used includes Coinb1, Extranonce1, Extranonce2_size, and Coinb2. The construction is simple:
Coinbase=Coinb1 + Extranonce1 + Extranonce2 + Coinb2
Why is this possible? because the mining pool has done a lot of work for miners, the mining pool has constructed coinbase transactions, which are serialized and divided into coinb1 and coinb2,coinb1 and coinb2 at specified locations, such as coinb1 contains block height, coinb2 contains information such as miners' income address and income amount, but these information is of no importance to miners, and the place where miners dig is only 4 bytes of Extranonce2. In addition, Extranonce1 is the specified information of the pool writing block. Generally speaking, each pool will write its own pool information, such as the pool name or domain name. Based on this information, we calculate the computing power proportion of each pool in the whole network.
Build Merkleroot
Using coinbase and merkle_branch, construct the hashMerkleroot field as shown above.
Build block head
Fill in the remaining 5 fields, and now the pool can search for mining in nNonce and Extranonce2. If there is not enough search space, it can be easily solved by increasing the Extranonce2_size to a few more bytes.
5. Miners submit workload when miners find a shares that meets the difficulty, they submit it to the mining pool with very little information, all of which are essential fields:
Slush.miner1: miner's name. The pool is used to identify who submitted the workload bf: task number ID. Before the task is assigned, the pool constructs information such as Coinbase, which uniquely identifies 00000001:
Extranonce2 504e86ed:nTime field b2957c02:nNonce field
After getting the above five fields, the mining pool first finds out the information stored before the assigned task according to the task number ID (mainly the constructed coinbase transaction and the included transaction list, etc.), then reconstructs the block, and then verifies the shares difficulty. For the shares that meets the difficulty requirements, check whether it meets the difficulty of the whole network.
6. The difficulty of adjusting the mining pool for the miners
The pool records the difficulty of each miner and constantly adjusts it according to the shares rate to specify the appropriate difficulty. The mining pool can send a message to the miners at any time through the mining.set_difficulty method to change the difficulty.
As above, the core concept of the Stratum agreement is basically clear. With the cooperation of the getblocktemplate protocol and the Stratum protocol, the mining pool can finally say loudly to the miners, let the computing power come more violently.
6 、 Auxpow
In the development history of mining, there is also a wild thing, that is, mixed mining (Merge Mining). Domain name coin (Namecoin) first used mixed mining mode, linked to the bitcoin chain, miners can mine bitcoin at the same time, and later dog coin (Dogecoin) also supports mixed mining, linked to the Litecoin chain. Hybrid mining is implemented using the Auxiliary Proof-of-Work (AuxPOW) protocol. Although hybrid mining is not very popular, the design of the protocol is very ingenious. When I first saw the agreement, I could not help but sigh at the power of the community.
Take the mixed mining of domain coins as an example. Bitcoin is used as the parent chain (Parent Blockchain) and domain coin as the auxiliary chain (Auxiliary Blockchain). The implementation of the AuxPOW protocol does not need to change the parent chain (of course, Bitcoin will not make any changes for the domain coin), but the auxiliary chain needs to be designed specifically. For example, the dog coin is forked when it is changed to support mixed mining.
AuxPOW is implemented thanks to the input field of bitcoin Coinbase, where Satoshi Nakamoto, unwittingly or unwittingly, only imposed a length limit, leaving an undefined area. This area later had a far-reaching impact on the development of Bitcoin, and many upgrades and optimizations focused on this area, such as the Stratum agreement mentioned above. Satoshi Nakamoto has a lot of similar intentional or unintentional situations, such as the nSequence field of the transaction, because it is not clearly defined, and the "malleability" problem caused by hackers has become a scapegoat for the collapse of "Mentougou". For example, nNonce, if you initially defined a larger byte, say 32 bytes, the evolution of mining would not require as many protocols as discussed above.
The differences in the core concepts of the AuxPOW agreement are as follows:
For the classic POW block, it is stipulated that only if the difficulty meets the requirements can it be considered as a qualified block. AuxPOW protocol does not require the difficulty of the block, but two conditions are attached:
The hash value of the child chain block must be built into the Coinbase of the parent chain block.
The difficulty of the parent chain block must meet the difficulty requirements of the auxiliary chain.
By embedding the hash value of the child chain block into the Coinbase of the parent chain, the parent chain is actually used to prove the existence of the parent chain. In this way, we can indirectly rely on the calculation power of the parent chain to maintain the security of the auxiliary chain. Generally speaking, the computing power of the parent chain is larger than that of the auxiliary chain, so the blocks that meet the difficulty requirements of the parent chain must meet the difficulty requirements of the auxiliary chain at the same time, otherwise it is not true. In this way, many blocks that could not meet the difficulty requirements of the parent chain have reached the difficulty requirements of the auxiliary chain. Miners'g = broadcast to the auxiliary chain network to obtain benefits in the auxiliary chain, why not do it.
The AuxPOW protocol has some data structure provisions for both chains. For the parent chain, 44 bytes of data in the following format must be inserted in the scriptSig field of the coinbase of the block:
For the auxiliary chain, the structure of the original block is changed greatly, and five fields are inserted between the nNonce field and txn_count. This block is named AuxPOW block.
* * mixed mining requires that the algorithms of parent chain and auxiliary chain are the same. Whether or not to support mixed mining is the decision of the mining pool, and the miners do not know whether they are doing mixed mining or not. * * if the ore pool supports mixed mining, it is necessary to connect the nodes of all auxiliary chains.
The hash value of the child chain block is built into the Coinbase of the parent chain, which means that the miner must construct the AuxPOW block of the child chain and calculate the hash value before constructing the parent chain Coinbase. If only one auxiliary chain is dug, the situation is relatively simple. If multiple auxiliary chains are dug at the same time, Merkleroot is constructed for all auxiliary chains in the digging block first. The pool can embed specific 44 bytes of information into the Coinb1 mentioned in the Stratum protocol above and give it to the miner for mining. The parent chain block and all the auxiliary chain blocks are reconstructed from the shares returned by the miners, and the difficulty is detected. If the difficulty requirements of the auxiliary chain are met, the whole AuxPOW block is broadcast to the auxiliary chain.
The secondary chain node verifies the AuxPOW block logic as follows:
Rely on the parent chain block (parent_block) and the block hash value (block_hash, this field is not necessary because the node can calculate by itself) to verify whether the parent chain block meets the difficulty requirements of the child chain.
Rely on the Coinbase transaction (coinbase_txn), its branch (coinbase_branch), and the parent chain block (parent_block) to verify that the Coinbase transaction is really included in the parent chain block.
Verify that the child chain block Hash is built into the Coinbase transaction of the parent chain block by relying on the child chain branch (blockchain_branch) and where the hash value is placed in the Coinbase (aux_block_hash).
Through the verification of the above three points, it will be regarded as a qualified auxiliary chain block.
7 、 Conclusion
When Satoshi Nakamoto first designed Bitcoin, he wanted all nodes to use CPU mining, which is generally believed to be the only way to fully ensure the decentralized characteristics of the blockchain. Bitcoin safely passed through the embryonic stage in the era of CPU. Getwork and cgminer brought mining into the GPU era, the domestic graphics card was once out of stock, the computing power of the whole network rapidly improved a level, CPU mining was eliminated. As more and more people participate in mining, the computing power of the whole network continues to rise, giving birth to clustered mining (ore pool). However, the prosperous history of the GPU era did not last long before it was brought into the ASIC era by getblocktemplate,stratum and mining machines.
Getwork realizes the separation of data and mining, and getblocktemplate provides the maximum degree of freedom for the external mining program, which completely solves the problem of scalability (scalability problems) between the external mining program and nodes, which is mainly used for the docking of mining pools and network nodes. Stratum not only solves the problem of insufficient search space, but also solves the problem of large amount of interactive data between mining pool and mining machine. Getblocktemplate and stratum make it possible for large-scale mining pools, large-scale mines and large-scale mining machines, and the mining industry has entered a new stage. since then, the evolution of mining has mainly focused on several directions: the design optimization and stable operation of mining pools, the scientific deployment of mines, and the upgrading of mining machine technology, improving computing power, reducing power consumption and so on.
Thank you for your reading. The above is the content of "what are the two mining methods of block chain". After the study of this article, I believe you have a deeper understanding of what the two mining methods of block chain are. Specific use also needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.