Bitcoin mining or welcoming 3.0 era, Stratum V2 will return power to miners

In order to obtain a more stable and reliable income stream than solo mining, most bitcoin miners today choose to mine through the mine. This is achieved through the open source "Stratum" mining protocol, which is currently used in almost all mines, which was announced seven years ago by SlushPool.

Now, Braines, behind the Slush Pool, has announced the second-generation Stratum Protocol (Stratum V2) program. The Prague-based mining company started the research two years ago, and believes that the second-generation agreement has improved the first-generation Stratum protocol in several key areas:

“It solves historical technical and security issues, is generally more efficient, and allows for some advanced use cases such as job selection or easier mine management,” Brains co-CEO Pavel Moravec told Bitcoin Magazine. "This should be done a few years ago, really."

The principle of the first generation Stratum mining protocol

As a short supplement, we first mention the principle of using the Stratum V1 for mining.

First, pool users (sometimes referred to as miners) connect their mining computers (usually dedicated machines with ASIC chips) to the pool, or more specifically, they connect their computers to the pool. On the computer operated by the operator.

The mining computer then requests a partial "block template" from the mine operator. This partial block module version is qualitatively an incomplete bitcoin block.

Importantly, the transactions in this block are selected by the tank operator. In fact, the transaction itself was not sent to the miners, but instead the Merkel path (a series of hashes) for all transactions.

In addition, the mine operator can choose which "version bit" to include, which may be related to the activation of the soft fork protocol upgrade.

Then, the miner began to hash some of the block templates, hoping that one of the hashes would produce a valid block header to meet the network's workload proof requirements. If the miner hashes a valid block header, it will return it to the mine operator, who will add it to the rest of the block and broadcast it to the bitcoin network. Then, the mine pool operator will allocate the block rewards obtained according to the workload of the miners in the pool. (This is measured by having miners send almost effective block heads that can prove that the miners have performed their work)

Therefore, using the first-generation Stratum protocol will give the mine operator more power than the miner. They are not only responsible for assigning rewards, but also determining which transactions are included in the block and which versions are included. If they are willing, a mine operator can decide to review certain transactions or prevent certain agreements from escalating.

The second generation of the Stratum protocol was inspired by Betterhash

Last year, Chaincode lab engineer and Bitcoin Core developer Matt Corallo proposed an alternative mining protocol called BetterHash , and the second-generation Stratum protocol was inspired by Betterhash. Instead of having the tank operator send a (partial) block template to the miners in the pool, the miner can choose to send the block template to the tank operator through the second-generation Stratum protocol. This "work choice" allows miners to choose their own trading and block version.

In order to do this, Braiins, which was helped by Matt Corallo, had to solve some of the practical problems with BetterHash. The most important of these is that the miner is likely to mine on an invalid block template (for example, because it contains an invalid transaction). Even if the miners can find an effective hash, the block itself is still ineffective, and the same miner can still benefit from the effective blocks found by other miners.

One solution to this problem is that the tank operator first checks if the miner's block template is valid and then puts it into the pool. But in a large public pool, this step will also encounter technical difficulties.

“Imagine what happens when a new block of data is found on the Bitcoin network and every miner in the pool wants to start using a new block template?” Moravec explains, “every of them One, there can be a slightly different mempool (unconfirmed transaction) version, and there may be different transaction selection rules… they all want to start mining immediately. Let all of them send their block templates to the pool. Approval, basically the first second after the network discovers the block, launches a denial of service attack on the service. This mechanism needs to be extended to play a role in practice."

Braiins solves this problem by letting the mine operator asynchronously check the validity of the new block template. Once the miner submits the block template, he can begin the hash operation immediately. At the same time, the mine operator began to check all block templates.

Moravec added:

“If the block template is later found to be invalid, then the reward for the miner can be adjusted accordingly. Therefore, the miner has the incentive to work on the appropriate block and provide all the data in time. He can continue without delay. Working on his template."

Increased safety, efficiency and flexibility

In addition to changes in trading options, the second-generation Stratum protocol will include more improvements, some of which may be important for many miners.

For example, in the first-generation Stratum protocol, there was no encrypted data validation to ensure that the miner computer was truly connected to the mine operator computer, which opened the door for man-in-the-middle attacks: for example, an attacker could intercept miners and mine operators The communication between and deceives the miners to work on the block provided by the attacker. The attacker can pay the block reward for this block to one of his own addresses, effectively "hijacking" the miner's computing power.

The second-generation Stratum protocol defends against this attack by allowing the mine operator to cryptographically sign some of the block templates. If the miner knows the mine operator's public key, it can check whether some of the block templates have a valid signature, thereby determining whether these block templates are actually provided by the mine operator.

Point 2, the second-generation Stratum protocol will be more efficient than the first generation. The reason is that the first generation of Stratum protocol communication is performed by human readable text (JSON), while the second generation of Stratum protocol communication is performed by binary (computer readable code). Moravec said that, coupled with some data elimination from the protocol layer itself, this will reduce the amount of data shared between pool operators by 1/2-2/3, making communication faster and cheaper.

Third, the second-generation Stratum protocol has a built-in "multiplexing" mechanism. This means that miners can have separate communication channels on the same connection, allowing their machines to share data about temperature, chip voltage or how the power supply works. The pool can provide additional services based on this information, or miners can share it with other services or servers.

Fourth, the second-generation Stratum protocol also allows the mine to "guess" what the next block is. Whenever a new block is found, it takes a while for the pool to determine which transactions are included in the block and which transactions cannot be included in the next block. Today, many mines wait a few seconds while digging a block to ensure that no double-flower transactions are included in the block (otherwise the block will be invalid).

With the second-generation Stratum protocol, the mine operator (or the miner who chooses to trade) can make educated guesses about which transactions will be included based on all unconfirmed transactions. In the first few seconds, they can start digging into what they think might be valid for the next block. Especially when block subsidies become a small part of the block award and are eventually replaced by transaction costs, this efficiency increase may benefit miners.

Places to be improved

Finally, the Braiins team said that there are still some unreleased improvements to the second-generation Stratum protocol. Although the company has a running prototype, the protocol specification has not yet been finalized.

“We now want to collect feedback from everyone, first complete the proposal internally, and then release a Bitcoin Improvement Proposal (BIP). I think this will lead to another round of discussion… At the same time, we will deploy the second generation Stratum protocol to SlushPool. And released it as part of the beta version of Brains OS, we are implementing it as soon as possible so that everyone can participate," Moravec said.