Polkadot self-upgrade
Last time I learned the concept of parallel threads. Parallel threads are many parallel running threads divided by Polkadot's parachain. The project party can enjoy the same functions and shared security as a complete parachain with a small deposit and cost. .
Parallel threads mean that the project party can be chained according to demand, and the most cost-effective solution is provided for projects that are not frequently chained, so that the entire Polkadot ecology can not only have giant projects but also include countless small projects. In a true sense, Polkadot has become the most universal underlying basic protocol for blockchain.
Learn the important concepts of Polkadot today
1. What is a fork
Take Bitcoin as an example.
Bitcoin generates a new block about every 10 minutes. Nodes need to fight for the accounting right of this block by solving math problems. When a node wins the accounting right, the node will record the transaction within 10 minutes Pack it into the block and broadcast it to nearby nodes for synchronization. Due to the broadcast behavior, all nodes in the entire network maintain the same ledger.
If only one node wins the right to keep accounts, after the whole network broadcasts, everyone keeps the same ledger, this will not cause any problems.
However, there is a delay in broadcasting. If two nodes win the accounting right at almost the same moment, both nodes will pack the transaction data into the block and broadcast to nearby nodes. This is fun. Two blocks are generated at the same time, for example, block D and block E.
Blocks D and E will respectively broadcast to their neighboring nodes: "I am a newly generated block! Hurry up and record me in!" and will start to generate new blocks on this basis:
At this time, the blockchain ledgers of the entire network began to diverge, some were D’s ledgers, and some were E’s ledgers.
As if the tree trunk is forked, we call this situation where the same blockchain network produces two different ledgers as a fork.
Then, nearby nodes will receive broadcasts from D and E, so which chain should be maintained?
In Bitcoin's algorithm, nodes will automatically choose the longest chain, that is, nearby nodes will automatically maintain the blockchain where D is located.
Then as more and more nodes are maintained for D, and fewer and fewer nodes are maintained for E, the nodes that maintain E will find that this chain is no longer worthwhile, and continuing to dig will only do nothing.
So the node that first built block E will abandon this part of the block and resynchronize D's ledger. The fork chain where E is located is completely invalidated, and the blockchain network has reached a unified ledger.
In the above example, the surrounding nodes all recognize D and give up E, and the forked chain where E exists for a period of time then disappears. This kind of temporary fork that can be eliminated is called a "soft fork."
Therefore, it is generally believed that the transaction on Bitcoin is difficult to be subverted after 6 blocks are confirmed. Don't be too happy to dig a new block, and celebrate when there are 6 other blocks connected later.
Bitcoin generates a block in an average of 10 minutes, and "six confirmations" take about an hour.
2. Block generation and connection
Some people do not follow the rules. If they know that the chain of block D is the longest, but they want to call on other nodes to maintain the chain of block E, then a "hard fork" will be formed at this time. The hard fork is permanent.
In addition to this "natural fork" that is inevitable due to the system itself, there is also a type of fork called "upgrade fork".
To explain the concept of upgrade forks, we must learn how Bitcoin blocks are generated and connected. Bitcoin has an algorithm called hash value. After inputting any character, it will output a fixed-length result after algorithm operation. This result is called hash value.
So how is the block produced?
In fact, the node keeps performing hash operations, inputting the characters composed of the transaction data during this period and an unknown number. Once the output hash value meets a certain specification, then the unknown number is solved.
What does that mean? We learned to solve equations in junior high school.
There is an unknown, and when the result is known, to calculate the unknown is called solving the equation.
For example, x + 1 = 3, of course you can solve x = 2.
But in the hash algorithm, knowing the hash value, it is impossible to deduct this unknown number.
So for the node, let it solve x + 1 = 3, it must let x start from 0 to test one by one, and then the equation is established.
Therefore, the node will keep counting the numbers one by one to test, solve this unknown number, and win the first right to bookkeeping, and at the same time can get bitcoin rewards.
Then the node will pack the transaction data and this unknown number into a block, and each block records the hash value of the previous block, thus achieving the effect of connecting the blocks.
It can be found that the hash algorithm is easy to verify the unknown, but it is difficult to calculate the unknown.
3. upgrade the fork
If each node is the same mathematical problem, for example, the first 60 bits of the hash value must be all 0s, then all nodes will recognize the new block.
However, the blockchain also needs to modify the program to upgrade. For example, a program is updated to change the math problem. That is to say, the first 60 digits of the hash value were originally required to be all 0, but now the first 100 digits are all 0 (difficulty ratio It used to be bigger).
It's like changing from x + 1 = 3 to x + 1 = 5.
This is interesting, because the node upgrade procedure is not mandatory, some nodes have upgraded procedures, and some do not, which results in different math problems for different nodes!
As a result, the block generated by the node calculating x + 1 = 5 is not recognized by the node calculating x + 1 = 3. (Because one solution x = 4, one solution x = 2)
Therefore, the node that calculates x + 1 = 3 is still accumulating blocks, and the node that calculates x + 1 = 5 is also accumulating blocks but is not recognized by the node that calculates x + 1 = 3, so the hard fork forms two Blockchain.
We call this kind of fork caused by the inconsistent node upgrade procedures as an upgrade fork. For the Internet, there is only one node, and a server upgrade procedure is successful. For the blockchain, there are countless nodes, and it is very difficult for countless nodes to reach a consensus upgrade procedure.
Miners all have their own ideas. Whether to upgrade or not depends on whether they benefit from them. If the upgraded program becomes more difficult to calculate math problems and requires more difficulty to mine, then some miners will not respond to the developer’s call and will still dig mines that cannot be upgraded, so developers will often be led by miners. He walked with his nose, but was helpless.
The typical cases of hard forks that developers and miners fail to reach a consensus are BTC and BCH.
4. self-upgrade
How does Polkadot solve the problem of node upgrade?
Comrade Lin Jiawen once again saw the root of the problem, thinking about the problem from the essential factor of the problem, this is the greatness of Lin Jiawen.
The reason why it is difficult to upgrade the blockchain and the hard fork is because each node is not upgraded uniformly.
Therefore, it is only necessary to design a set of procedures so that every time the node upgrades the program, there is no choice and must be enforced, so that the upgrade of the nodes will be unified, and there will be no hard fork. This is Polkadot's self-upgrade.
Lin Jiawen took this self-upgrading program as the bottom layer and packaged it in the Substrate framework. Brother Duck said before that Substrate is like a chain-making factory. Even Polkadot is made by Substrate's one-click chain. Therefore, it is not only Polkadot, but all the ecological projects based on Polkadot developed by Substrate and Polkadot's parachain. They all have the characteristics of self-upgrading, and they will never hard fork!
With the feature of self-upgrading, Polkadot enables the project to maintain a high degree of flexibility and develop with the development of technology, greatly reducing the risk of controversial hard forks.


