From the BSV off the wind wave, reveal the test scheme of the structural block chain fork

At the end of 2018, the computing power of BSV and BCH touched the eyes of the entire digital currency market. Eventually, BSV gave up the competition with Bitcoin ABC for BCH, and started to start another stove, and named bitcoin SV (Bitcoin cash in the game).

Recently, "Australia" Dr Craig S Wright and its BSV are once again on the cusp of the turmoil. The reason is that Oban has once again declared that he is "Zhong Bencong" because of the "evidence" that it provides. Bitcoin lightning network supporters, lightning torch promoter Hodlonaut's dissatisfaction and boycott .

Subsequent conflicts have led to scale escalation. Bitcoin community, V God, Zhao Changpeng, etc. have directly or indirectly denounced Oban, and many exchanges, including the currency security, have begun to release the announcement of the BSV, a series of operations for BSV. Fall into the crowd.

BSV is the product of BCH hard bifurcation

To understand what the BSV is, let's talk about what is a hard fork.

Hard forks means that the blockchain system has its own consensus rules. Once the blockchain consensus rules change and the old rules do not agree with the new rules, the new rules are not forward compatible, and the old blocks do not recognize new ones. The block causes the old and new nodes to run in different blockchains . This situation is called hard fork.

However, blockchain forks also have two sides, because hard forks have always been a very dangerous and controversial blockchain upgrade technique.

In the long run, when the entire blockchain network faces inevitable huge risks, the entire blockchain network will reach a consensus to upgrade the system to avoid risk violations.

However, without the consensus of most blockchain ecological participants , forcing a hard fork will undoubtedly pull the entire blockchain ecology into a splitting position. When ecological participants disagree on future development, hard points The fork is very likely to happen .

Because in a decentralized system, reaching consensus is not an easy task.

How to avoid block data inconsistency as much as possible ?

The blockchain acts as a state machine, and each transaction attempts to change the state once, and each time the consensus generated block is the participant confirms the result of the state change caused by all the transaction contents in the block.

A basic blockchain system, the first guarantee is the consistency of the entire network block, because the blockchain is the decentralized system, the network performance in the actual environment, the uncertainty of each node, etc., so in the block Each node needs to maintain synchronization to maximize its own benefits while ensuring the overall security of the blockchain.

In the development of blockchain, we must first ensure that the chain of all nodes always works in the main chain, or find that in the case of non-main chain, it can quickly roll back to the main chain (switching the main chain speed) to avoid unnecessary losses.

This paper introduces a test scheme that quickly simulates the construction of blockchain forks in real-world environments and then verifies that the blockchain can eliminate forks in time.

The main feature of the solution is that the test can be completed on one machine, and the automated script deployment can quickly set up the test environment, construct the forks required in the test, and verify whether the blockchain system can eliminate the points after the fork occurs. cross.

Please see the diagram:

Blockchain test plan

Take the above schematic diagram as an example:

  • In the figure, A1, B1, C1, A2, B2, and C2 are docker containers deployed on the test machine;
  • The six containers are divided into two groups, one group is A1, B1, C1, and the other group is A2, B2, C2;
  • P2P communication can be performed between blockchain nodes running in each container in the two groups;
  • Among them, the nodes A1 and A2 are mining nodes, and the other nodes are ordinary nodes;
  • The bifurcation can be constructed by controlling the start and stop of the two sets of containers.
  • By obtaining the block hash value of the same block of all test nodes, it can be verified whether there is a fork and whether the fork disappears.

The overall node control flow chart of the scheme is as shown in the following figure. The above A1, B1, C1, A2, B2, and C2 are divided into two groups A and B. Group A includes A1, B1, and C1, and group B includes A2 and B2. C2.

In some of the steps, the number of nodes in the current P2P network needs to be verified for verification. The timeout period can be set according to the actual situation.

Overall node control flow chart

Conclusion

The bifurcation problem is a problem that the blockchain network has to face. A blockchain network that can maintain a consistent block and accurate transaction status is the most basic requirement for a safe and stable blockchain in the future.

It is hoped that through the analysis of the above case process, it can help or inspire developers to achieve better optimization and solution for the fork problem, so that the fork can be effectively controlled and the abnormal transaction state can be quickly eliminated.

Author | Complex beauty blockchain

Editor | Aholiab Produce | Blockchain Base Camp (blockchain_camp)