1 thought on “STRATUM”

  1. Transfer from: zhuanlan.hu/p/23558268
    Agreement was born in mid -2012, and the mining pool has appeared at this time. The mining pool adopts an agreement to interact with the node client, and uses the Stratum protocol to interact with miners. This is the most typical mining pool building model.
    Compared with getwork, the biggest difference between the agreement is that the protocol allows miners to construct a block by itself. In this way, nodes and mining are completely separated. For getwork, the blockchain is dark. Getwork knows nothing about the blockchain. He only knows that the 4 bytes of the Data field are modified. For, the entire blockchain is transparent. Mastering all information related to mining on the blockchain, including the transaction pool to be confirmed, you can choose a transaction containing the block.
    The mining has two ways, one is called SOLO mining, and the other is to mine the mining pool. The CPU mining directly on the node client described earlier, and relying on the getwork cgminer driving graphics card to directly connect to the node client mining. Back to yourself. Mining to the mining pool is like buying lottery tickets. Everyone pays for the money and can buy a bunch of lottery tickets. In theory, mining machines can use the agreement to link node client SOLO mining, but in fact, there is no such thing as a mining union. When writing this article, Bitcoin's entire network computing power is 1600p , and the current most advanced mining machine computing power is 10T There are less than 160,000 in the probability of a single mining machine SOLO. The miner (person) invested in real gold and silver to buy mining machines and delivered electricity bills. Entering mining of mining ponds to reduce risks, and it is more suitable to obtain stable returns. Therefore, the emergence of the mining pool is inevitable and cannot be eliminated, whether or not the decentralization principle of the system is destroyed.
    The core work of the mining pool is to distribute tasks for miners, statistical workload and distribution income. The mining pool divides the block difficulty into many difficult tasks to the miners to calculate. After the miner completes a task, the workload is submitted to the mining pool, called submitting a Share. If the top 70 specials of the HASH computing result are 0, the task of allocating the results of the HASH computing result is 0, then the task of allocating the miners to the miners may only require the top 30 to 0 (according to the miner's computing power), and the miners have completed the designated difficult task. Saying Share, the mining pool is tested on the basis of satisfying the top 30 bits 0, to see if the first 70 digits are 0.
    The mining pool will allocate different difficulty tasks according to the computing power of each miner. How can the mining pool judge the computing power of the miner to allocate the appropriate task difficulty? The difficulty of regulating ideas is the same as Bitcoin block. The mining pool needs to use the SHARE rate of the miner. The mining pool hopes that the task of allocating each miner is enough to allow the miner to calculate for a certain period of time, such as 1 second. After several tasks, it shows that the difficulty of the mining pool is currently less difficult, and it needs to be raised, vice versa. In this way, after a period of adjustment, the mining pool can distribute reasonable difficulties to the miners and calculate the computing power of the miners.
    The interaction with network nodes through protocols to obtain the latest information of the blockchain and interact with miners through the Stratum protocol. In addition, in order to allow the software that previously used the Getwork protocol, the software can also be connected to the mining pool mining. The mining pool generally supports the Getwork protocol and implemented through the class mining agency mechanism (Stratum Mining Proxy). It should be noted that when the mining pool appears, the graphics card mining is still the main force. Getwork is very convenient to use. In addition, some of the early FPGA mining machines were implemented with getwork. The Stratum and the mining pool were communicated by TCP. rn 先来说一下遗留下来的几个问题:rn 矿工驱动:在协议里,依然是由矿工主动通过HTTP方式调用RPC接口向节点申请挖矿数据,这就意味着,网络The changes in the latest blocks cannot be notified in time, causing computing power loss.
    In data load: As mentioned above, a normal call node will be fed back to about 1.5m of data. The main data is the trading list. Miners and mining pools need to interact frequently. With so many information to the miners. Furthermore, huge memory demand will greatly affect the performance of mining machines and increase costs.
    Tratum protocols have completely solved the above problems.
    Tratum protocol adopts the method of actively allocating tasks, that is, the mining pool can assign new tasks to the miners at any time. For miners, if you receive a new task assigned by the mining pool, you should immediately turn to the new task unconditionally immediately to the new task. ; Miners can also actively apply for new tasks with the mining pool.
    The core question is how to make the miners get greater search space. If you refer to the Getwork protocol, only the miners can change the Nnonce and NTime fields. not enough. If you want to increase the search space, you can only work hard. If the miners are allowed to construct Coinbase themselves, the problem of searching space will be solved, but the cost is to give all the transactions contained in the block to the miners, and the miners can construct the trading list. This For miners, the pressure is greater, and the bandwidth of the mining pool is higher.
    Tratum protocols cleverly solve this problem. Successfully realizing can increase enough search space to miners, and only requires small amounts of data. This is also the most innovative place for the Stratum protocol.
    It again to review the 6 fields of the block head 80 bytes. This is very important. Nversion, nbits, these 3 fields are fixed, nnonce, ntime, the miners can now change. Increasing search space can only start from, this cannot be turned around. The Stratum protocol allows the miners to construct the coinbase transaction. Coinbase's Scriptsig field has many bytes that allow miners to fill in freely, and the change of Coinbase means changes. From the coinbase structure, no all transactions are required,
    as shown in the figure above, if the block will contain 13 transactions, the mining pool will process the 13 transactions first, and finally the 4 black spots in the figure (have HASH value) Delivery to the miners and delivering the information required to construct coinbase to the miners, and the miners can be constructed by themselves (the green dots in the figure are obtained by the miners themselves. Put it on the right)
    . According to this method, if the block contains N transactions, the mining pool can be concentrated to LOG2 (N) for a hash value and delivered to the miners, which greatly reduces the amount of data from the mine pool and miner interaction.
    Tratum protocol strictly strictly stipulates the interface data structure and interaction logic of the interface of miners and mining pools. The specifics are as follows:
    . Miner subscription tasks
    This to start mining machines and use the mining.subscrip method to link minerals. Pond
    The return data is very important. Miners need local records and use it throughout the mining process. Among them,:
    , and it is important for mining. There are at least 8 byte search spaces, namely Nnonce's 4 bytes, and 4 bytes.
    2. Mining pool authorization
    Im registering an account in the mining pool, adding miners, the mining pool allows each account to add the number of miners at will, and take different names to distinguish. Miners use the MINING.AUTHORIZE method to apply for authorization, and only miners authorized by the mining pool can receive mines assigned tasks.
    3. Mining pool allocation tasks
    The information above each field is essential, of which:
    has the above information, plus the previous and _size you got before, you can dig it to dig it to dig it. It's mine.
    4. Mining
    ) Constructing Coinbase transactions
    Mi n The information used includes coinb1, _size, and coinb2. The miners have done a lot of work. The mining pool has built Coinbase transactions. After series, it is divided into coinb1 and coinb2 at the specified location. Coinb1 and Coinb2 include specified information. For information, this information is not important for miners, and the place where miners mining are only 4 bytes. In addition, the designated information of the mine pool is written in the block. Generally speaking, each mining pool will write the information of its own mining pool, such as the name of the mining pool or domain name. We are based on this information statistics. The proportion of computing power.
    2) Construct
    The use of coinbase and Merkle_branch to construct fields according to the above figure.
    3) Build the block head
    Filling the remaining 5 fields. Now, the mining pool can be searched for mining in nnonce. The festival can be easily solved.
    5. The workload of the miner is submitted
    When the miner finds a difficult Shares, submitted to the mining pool, the amount of information submitted is very small, all of which are essential fields:
    mining pool pools After getting the above 5 fields, first find the information stored before the task number ID (mainly the coinbase transaction and the trading list contained in the construction of the task number ID, etc.), and then reconstruct the block, and then verify the difficulty of Shares. For compliance Shares that requires difficulty, then detect whether it meets the difficulty of the entire network.
    6. Mining pool adjustment difficulties for miners
    Mine pool records the difficulty of each miner, and continuously adjusts according to the Shares rate to specify the appropriate difficulty. The mining pool can send a message to the miners at any time to change the difficulty through the mining.set_ method.
    In as above, the core concept of the Stratum protocol is basically analyzed. With the cooperation of the agreement and the Stratum protocol, the mining pool can finally say loudly to the miners and make the computing power more violent.

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart
Scroll to Top
Scroll to Top