Polkadot innovates the Staking economy under the NPoS consensus
Wetez
2019-04-19 02:37
本文约3805字,阅读全文需要约15分钟
The NPoS brought by Polkadot this time is quite innovative and solves the existing problems of PoS to a certain extent.

After participating in the Polkadot gathering in Beijing at the end of last year, I have been looking forward to the official economic and governance plan for Staking. Although the final plan has not yet been finalized, the research documents of Web3 seem to be quite complete. The whole design surprised me. I feel that after reading many projects that use PoS as the consensus, the design of the staking economy is different. New projects will always learn from past projects. The NPoS brought by Polkadot this time is quite innovative and solves the current PoS problem to a certain extent has a problem.

There are many things that Polkadot can write. This article will mainly focus on the Staking part and the method of selecting validator nodes by the NPoS formula. These two aspects are very closely related to the income of token holders and festivals.

If you don’t know the background of Polkadot, you can see me firstpast articles, I will directly start the topic.

Briefly review the complete block production process of the PoS consensus project

1. The team runs the node

2. Register as a validator

(passed the basic threshold)

3. Staking process

(The token holder entrusts to the node, or the team free tokens for Staking entrustment)

4. Elect validators

(The system selects each round of block producers or verification nodes through a certain algorithm. This article details Polkadot’s NPoS election algorithm)

5. Package transaction, broadcast transaction, verifier confirms a series of processes

6. Get rewarded
secondary title

From the perspective of currency holders, it is easier to understand PoS

The token holder owns the token Moon with PoS as the consensus, and entrusts Moon to the favorite node for staking, and the node generates blocks on behalf of the token holder and gets rewards, and the rewards are distributed according to the staking ratio. (Staking ratio = the number of Moons that the holder participates in staking / the number of all Moons that participate in staking).


The above mentioned is the method of calculating rewards for general PoS projects (the amount of rewards is positively correlated with the amount of Staking by the holder)

Polkadot proposed NPoS. The original intention was to solve the problems encountered after the PoS operation in the past. Because the positive correlation between the reward and the amount of Staking made the rich nodes richer, and the distribution of tokens tended to be centralized.


In NPoS, the final reward result is not based on the amount of staking, but is calculated based on the workload of each selected node that actually produced a block (in vernacular, no matter how much staking a node has, the reward for producing a block or verifying a block is The same), NPoS will solve the problem that some large nodes get more rewards because of the large amount of staking, but it also damages the interests of some large nodes.

secondary title


How did Polkadot do it?

Since NPoS is different from traditional PoS projects, it is not that the higher the staking weight, the higher the probability of block generation, so we will explain in detail the algorithm of NPoS electing verifiers.

secondary title

NPoS Consensus Algorithm History

NPoS refers to the election method proposed by a Swedish mathematician Lars Edvard Phragmén at the end of the 19th century. At that time, the seats in the Swedish parliament were occupied by mainstream parties. Through his algorithm, the distribution of seats and the proportion of votes can be more fair. Small parties can obtain seats that they could not obtain in the past. The Polkadot team believes that the two have similarities in design concepts, and the improved NPoS is now seen.

secondary title

The Electoral Algorithm has three objective objectives

1. Balance Balance

Once the Electors Committee is determined, the staking amount of the Nominators will be distributed as evenly as possible to each selected Validators.
PS: Token holders can choose multiple electors, so there is room for system reallocation


2. The maximum support Support

A committee of electors is elected, and the staking amount received by the validators in the committee should be as close as possible to the staking amount of the total currency holder Nominators.

3. Fair Representation

Elect a Council of Electors in which the voting power of Tokenholder Nominators is neither over-represented nor under-represented.

PS: Token holders can choose multiple nodes. The simplest representation of fairness is that at least one node corresponding to each token holder will be selected, plus realistic conditions (coin holding status and how many nodes the system needs to select) ), some nodes will be eliminated, but try to ensure that holders with a certain Staking weight can correspond to at least one node.


There may be multiple verification groups (Electors Committee) screened out based on these three principles. In the end, the system will select a group of the most reasonable Committee (Electors Committee) to generate blocks. It seems very complicated and confusing. My favorite It took a long time to start, and then I will use the following example of token holders to elect validators. Everyone will have a clearer understanding. It is recommended to quickly read this example, and then match the objective goals of the above three elector algorithms during the reading process. , and finally take a closer look at the example.

This is an example from an official person on Medium (I will help you understand better)

Assume that there are 5 token holders (on the left) and 5 nodes (on the right), from which 4 nodes are to be selected for block generation. In order to simplify the model, first ignore the staking amount of the nodes themselves

The following is an example of the election results (I will explain them one by one)

First picture (far left)

It does not meet the goal of Fair Representation, because the first holder in the figure has a weight of 10Dot, compared to the fifth holder who only has a weight of 3Dot, but in the end it does not correspond to any nodes he supports. Token holders who meet the objective of fair representation and have a certain staking weight correspond to at least one node (in the current situation, the first token holder will not be rewarded).

second picture

In line with the goal of Fair Representation, some people may question why node E is selected, but node B is not selected. This is related to the redistribution algorithm that will be exemplified next. Here is a simple understanding, the second in the figure The holder supports 3 nodes at the same time, the system only needs to ensure that at least one of the nodes he supports is elected (here two of the nodes he supports are elected, all the staking amount of the second holder will be assigned to these two nodes), while maintaining node E, which is also supported by the fifth token holder, is one of the possibilities for an election result like Polkadot.

third picture

In line with the goal of Fair Representation, some people may question that this contradicts the second picture. The goal is to have at least one support node selected for each token holder, and the fifth token holder The supported nodes were not selected, because the entire system only needs to select 4 nodes, so it is one of the possible results that the node supported by the fifth holder with low Staking weight was not selected.

The following are the possible results of the above two electoral committees that meet the principle of fairness. After the establishment of the electoral committee, the system will go through the redistribution of Staking weights

 

The Polkadot system will select a fairer and more secure result each time. In this example, the right side is selected because it has a better average distribution, and the lowest average staking weight of the nodes on the right is 9.


The above is the introduction of Polkadot’s election algorithm. The above logic is very convoluted, and the mathematics behind it is even more complicated. The official example is in a simple case. If the real situation is enlarged to 100 nodes, each token holder Staking The weights are different, and entrusted to multiple nodes at the same time, it will be quite complicated. You can think about it a few times. According to the three goals mentioned above, each goal can be tested as a standard, and you can understand it better.


NPoS, an election algorithm, dynamically allocates the Staking weight of token holders, and selects the final selected node based on some rules, which has caused some differences in the existing PoS ecology.

1. Under the condition that coin holders can choose multiple nodes, large nodes do not work hard to win community support, and have the opportunity to be excluded under the algorithm (B node in the middle of Figure 2)

2. Under the goal of balancing the staking amount, small nodes with no capital are more beneficial, because as long as more people in the community choose it, under the mechanism of the system's allocation of staking amount, the probability of rewarding the selected block is higher (as shown in Figure 2 Right D node)

3. Under the goal of balanced staking volume, the profits of large nodes are relatively compressed, and large nodes need to think about whether to entrust their own coins to get more profits

secondary title

What problem does Polkadot want to solve the existing PoS?

1. Part of the inevitable centralization problem

2. Low handling fees will not attract staking indefinitely in the future, because the income depends on the workload of nodes
(Now there are 0-fee nodes on Cosmos that attract a large number of token holders to entrust. In Polkadot, nodes with such a high staking weight and normal staking weight nodes get the same benefits)

3. Token holders can maximize their own interests by selecting different nodes while promoting decentralization

(There are a variety of entrustment strategies for token holders. I can choose safe and reliable nodes, and I can also choose some small but reliable nodes to obtain higher yields.)

The entire mechanism of Polkadot is actually very complicated, and I may have missed something. How to attack such a mechanism, and whether there are loopholes in the package-linked election algorithm that can be exploited, all require professionals to invest a lot of energy in the area of ​​special research, so I won’t discuss it here. .

This is the first article to explain the Polkadot mechanism. In the future, more examples will be given after the official parameters and testnet are released.

Wetez
作者文库