How to calculate Polkadot's Staking income?
PolkaWorld
2020-06-23 09:52
本文约7309字,阅读全文需要约29分钟
Polkadot Staking Advanced Tutorial.

Editor's Note: This article comes fromPolkaWorld(ID:gh_6c4c2038ddba), reproduced by Odaily with authorization.

Editor's Note: This article comes from), reproduced by Odaily with authorization.If you want to know how much your DOT will be rewarded for nomination, you can directly go to

Enter your DOTs and see the rewards for nominating each validator.

Staking

If you want to know more interesting staking designs of Polkadot, you can start the following reading.

mdnice editor

Polkadot uses NPoS (Nominated Proof of Stake) as the mechanism for selecting validator node pools. It designs two roles of verifier and nominator to maximize the security of the chain. Participants interested in maintaining the network can run validator nodes. At Genesis, Polkadot will have a limited number of slots for these validators, but this number will increase to over 1,000 over time.

Validators assume the role of generating new blocks in BABE, verifying parachain blocks and ensuring finality. Nominators can choose to back elect validators with their stake.

mdnice editor

How to do staking in Polkadot?

mdnice editor

1. Identify your roleIn staking, you can be a nominator or a validator.

As a nominator, you can nominate one or more (up to 16) validator candidates that you trust to help you earn DOT rewards. You can check out the nominator guide here for what to expect at mainnet launch.Validator nodes need to be online 7*24, perform their duties in a timely manner, and avoid any behavior punished by slash. If you want to run validators on Kusama, you can check out

Kusama's Validator Guide

mdnice editor

2. Nomination stageOnce the nomination phase is over, the NPoS election mechanism takes nominators and their associated votes as input, and outputs a limited set of validators that maximize the support of any validator and distribute the support of supporting validators as evenly as possible. The goal of this election mechanism is to maximize the security of the network and achieve a fair representation of nominees. If you want to know more about how NPoS works (e.g. elections, runtime complexity, etc.), please

read here

mdnice editor

3. Distribution of staking rewards

To explain how rewards are distributed between validators and nominators, we need to consider a validator pool, which consists of selected validators and the nominators who support it. (Note: If a nominator n uses s votes to stake and supports k validators, the NPoS election mechanism will divide its stake into s_1, s_2, …, s_k, that is, it supports validator i with s_i stake. Here In this case, nominator n gets the same reward as it would get if each nominator backed a validator i with s_i in another validator pool of k nominators). For each validator pool, we keep a list of nominators with associated stakes.ExcelIf you want to estimate the inflation rate and how many DOTs you can get per month as a nominator or validator, you can use this

table as a reference and to get a better estimate of inflation by changing some parameters such as validator pool, total supply, commissions, etc. While this may not be entirely accurate since staking participation is dynamic, it can serve as a ballpark estimate.

mdnice editor

4. Reward Mechanism

  • We emphasize two features of this payment scheme. First, since validator pool rewards are the same, nominators are rewarded more per DOT in pools with fewer stakes than in pools with more stakes. Therefore, we gain sufficient reputation by giving nominators financial incentives to gradually shift their preference to lower stake validators. The reason for this is that we want the stake in the validator pool to be distributed as evenly as possible to avoid large validators. In the long run, we want all validator pools to have a similar amount of stake, with higher stakes for validators with higher reputation, but at the same time, willing to take more risk by supporting validators with lower reputation nominees will receive higher rewards.

  • The following example is to explain the above problem. For simplicity, we have the following assumptions:

  • These validators are not self-staked

  • they don't charge any commission

The reward amount is 100 DOT tokens

The minimum number of DOTs required to become a validator is 350

Both validator pools A and B have 4 nominators with a total stake of 600 DOT and 400 DOT respectively.

The second point to note is that each validator candidate is free to set a desired commission (in the form of a percentage) to cover operating costs. Since validating pools earn the same rewards, pools with lower commissions pay more to nominators than pools with higher commissions. Therefore, each validator can choose to increase their commission to earn more DOTs, or decrease their commission to attract more nominators and increase their chances of being elected. We need to let the market self-regulate in this regard. In the long run, we want all validators to be cost-effective to remain competitive, and validators with higher reputations will also be able to charge slightly higher commissions (which is fair).

account

mdnice editor

  • account

  • There are two different accounts to manage your funds: Stash and Controller.


Stash: This account stores the funds bound for staking, but delegates some functions to the Controller control account. Therefore, you can participate using stash keys kept in a cold wallet, which means it is always offline. You can also designate a Proxy account to vote on governance proposals.

We designed this hierarchy of independent key types so that validator operators and nominators can protect themselves better than a system with only one key. In general, when you use one key for multiple roles, or even if you use keys related to derivations, you lose security. In particular, never use any account key for a "hot" session key.https://wiki.polkadot.network/docs/en/learn-keys

Controller and Stash account keys can be sr25519 or ed25519. More information on how keys are used in Polkadot and the cryptography behind them can be found here.

Validators and Nominators

Since validator slots are limited, it will be the nominators who most want to stake their DOTs and contribute economic security to the network. Validators do most of the heavy lifting: they generate new candidate blocks in BABE, vote and reach consensus in GRANDPA, verify state transition functions of parachains, and possibly some other responsibilities regarding data availability and XCMP. Nominators, on the other hand, do not need to do anything once they have staked their DOT. Nominators experience a “set it and forget it” experience, while validators provide proactive service to the network by performing key operations. As a result, validators have certain privileges over the payout of the staking mechanism and will be able to set their own reward ratios before the stake is distributed to nominators.

secondary title

"Latest Polkadot Nominee Tutorial (Soft Launch Stage)"

"Latest Tutorial: How to Set Up a Polkadot Validator Node"

mdnice editor

Slashing punishment

A slash penalty occurs if a validator misbehaves in the network, such as going offline, attacking the network, or running modified software. They and their nominees lose a portion of their DOTs due to slash penalties.

  • Validation pools with larger total stakes will be slashed more severely than less popular validation pools, so we encourage nominators to transfer their nominations to less popular validation pools to reduce possible losses.

  • Polkadot defines the following levels of bad behavior:

  • Level 1: Single-shot unresponsive, i.e. offline for a long time. There is no slash penalty, only freeze[2].

  • Level 2: Concurrent non-response or single-issue duplicate signatures. Slash stakes a small portion of DOT and freezes it.

Level 4: Misconduct that poses a serious security or monetary risk to the system, or large-scale collusion. Slash all or most of the stake behind that validator and freeze it.

Let's look at these violations in more detail.

mdnice editor

No response

Let x = offenders, n = total no. validators
min((3 * (x - (n / 10 + 1))) / n, 1) * 0.07

For each session, validators send an "I'm online" message indicating that they are online. If a validator fails to produce a block during an epoch and fails to send a heartbeat, it will be reported as unresponsive. Slash penalties will occur based on repeated violations and how many other validators are unresponsive or offline.

Note that if less than 10% of validators are offline, no penalty will be enforced.

Validators should have a well-architected network infrastructure to ensure nodes are up and running to reduce the risk of being slashed. A high-availability setup is advisable, preferably setting up backup nodes and only starting when the original node is verifiably offline (to avoid double signing and being slashed for duplicate signing - see below), and proxy nodes [4], to Avoid being attacked by DDoS when the IP address of the verification node is exposed. There is a comprehensive guide on setting up a security validator here. [5]

GRANDPA duplicate signature

Validators sign two or more votes on different chains in the same round.

mdnice editor

BABE duplicate signature

Let x = offenders, n = total no. validators
Min( (3 * x / n )^2, 1)

Validators produce two or more blocks on the relay chain within the same time period.

Penalties for GRANDPA and BABE duplicate signature slashes are calculated as follows:

Validators can run their nodes on multiple machines to ensure that if one of the nodes fails, they can still perform the validation work. It should be noted that duplicate signing is possible if they are not well coordinated to manage the signing machines.If you want to know more details about slash, please see our

research page

mdnice editor

Chilling

Freezing is the act of removing validators from the pool of active validator nodes, simultaneously disqualifying them from the selectable candidate list for the next NPoS cycle.

When used as part of a punishment, being frozen means not being nominated. It also incapacitates validators for the remainder of the current era and removes offending validators in the next election.

Polkadot allows some validators to be disabled, but if the number of disabled validators is too large, Polkadot will trigger a new validator election for the full pool of validator nodes. Disabled validators will need to resubmit their validator intent and regain nominator support.

mdnice editor

  • Slash penalty across Era

  • There are three major difficulties in calculating the slash penalty in NPoS:

  • A nominator can nominate multiple validators and get slashed by any one of them.

Punishable violations can also be discovered after the fact and not in sequence.

In order to balance the above points, we only punish the maximum punishment that the participant can receive in a certain period of time, not the sum of all punishments. This prevents excessive slash. Likewise, the time span over which the maximum slash is calculated is finite, and validators are frozen and withdraw nominations after a slash event, as described in the previous section. This prevents rage-quit attacks, in which participants intentionally misbehave once they are found to be misbehaving because they have already maxed out their slash amounts anyway.

mdnice editor

reward distribution

Note that Kusama runs about 4 times faster than Polkadot, except for block times. Polkadot also produces blocks at roughly 6-second intervals.

NOTE: If no one has claimed your staking rewards at this time, you will not be able to claim them and part of your staking rewards will be lost.

Receive award

Receive award

If you go to the staking payment page of Polkadot JS (https://polkadot.js.org/apps/#/staking/payout), you will see a list of validators you nominated in the last 84 eras. Everyone can choose to trigger payout payments for all unclaimed eras. Note that this will be paid out to every validator nominated in that era, and anyone can call it.

   PER_ERA * BLOCK_TIME = **Reward Distribution Time**
   3600 * 6 seconds = 21,600 s = 6 hours
   ***These parameters can be changed by proposing a referendum***

mdnice editor

Example of Reward Distribution

Validators can create a portion of the reward that is not shared with nominators. This portion is calculated as a percentage of the block reward, not an absolute value. After deducting this value, the remainder is split between the validator and all nominators who voted for that validator based on the value of their stake.

See this guide for details on validator payouts. [7]

inflation

mdnice editor

Source: Research - Web3 Foundation[8]

  • inflation

  • The inflation rate is designed to be 10% in the first year, the validator reward is a function of the amount of stake, and the rest of the reward will be deposited into the treasury.

  • X-axis: the proportion of DOT that has been staked

  • Y-axis: Inflation rate, annualized percentage

Blue line: inflation rewards for stakers

For those who want to learn more about the design of network inflation models, please seehere

here

  • first level title

  • Why stake?

  • 50% of the target staking amount

About 20% annualized return

  • first level title

  • Why not pledge?

  • Validators will be penalized if they are found to be misbehaving

You want to use tokens for parachain slots

How many verifiers will Polkadot have?

The plan is to start with around 50 to 100 open validator slots and gradually open up. The upper limit on the number of validators has not been determined, but is only limited by the strain on network bandwidth caused by frequent and large peer-to-peer messaging. Polkadot will have around 1000 validators when the network matures. Polkadot's canary network Kusama currently has more than 400 validator slots.

original:https://wiki.polkadot.network/docs/en/learn-staking

Translation: PolkaWorld Community

reference link

[1] session keys: https://wiki.polkadot.network/

mdnice editorhttps://wiki.polkadot.network/

[3] GRANDPA: https://wiki.polkadot.network/

[4] https://wiki.polkadot.network/

[5] https://wiki.polkadot.network/

[6] simple payouts: https://wiki.polkadot.network/

[7] https://wiki.polkadot.network/

[8] Research - Web3 Foundation: https://research.web3.foundation/

[9] Secure validator setup: https://wiki.polkadot.network/

PolkaWorld
作者文库