Polkadot staking — The theory

--

Welcome to the two-part series of articles dedicated to the staking in the Polkadot network. First, we will explain the concepts and important features and then show you how to secure your stake in practice. So let’s let look at the mechanics of staking in Polkadot a little closer.

NPoS

As you might know, Polkadot uses the Nominated Proof of Stake as a means of selecting the validator set which is validating in the network. There will always be a limited number of active validators, now we are about 200 and the number will grow up to 1000.

There are two roles defined in the network — validators and nominators. Validators are responsible for maintaining the network by authoring blocks and running consensus, nominators back validators by their DOT tokens.

The election process

Any validator can become a candidate and participate in the election process — there is no minimum amount of DOT for validator or any other requirements (except hardware ones) since Polkadot is a permissionless blockchain.

Validators are being elected once in the era (every 24 hours). The network will always elect validators with the largest amount of stake behind them — which makes sense because more stake means more reputation and trust which people put into such a validator. Unlike other PoS systems where validators voting power is derived from its stake size, Polkadot gives all active validators equal vote.

A nominator can nominate up to 16 validators, however, he cannot choose how his stake is going to be distributed among them. This is done by the Phragmén algorithm which we will discuss next.

Phragmén algorithm & stake distribution

Because all the validators have equal voting power, the entire stake should be distributed among them as evenly as possible. So here comes into play Phragmén’s multi-winner election algorithm which was originally developed by Lars Edvard Phragmén in Sweden to create more fair election outcomes with seats in parliament distributed proportionally to the votes.

Polkadot uses this algorithm to optimize the following network properties

  1. Maximize the total amount of stake in the validator set (which increases network security)
  2. Maximize the stake behind the minimally staked validator which has been elected
  3. Minimize differences in the stake between elected validators

The one thing to note here is that given a (possibly) large set of validators and an even larger set of nominators, this stake distribution algorithm becomes a really difficult computational task. That’s why Polkadot computes the result off-chain and then proposes a transaction with a set of validators that should be elected.

Also, one practical impact of this mechanism is that some user actions are not taken into account anymore at the end of the era (during the last epoch = 6 hours). These actions could change the outcome of the Phragmén (because it’s already running off the chain at that time) so users cannot nominate, unbond, or change the amount of their stake in the last epoch.

Reward mechanism

Since there is an equal voting power for each elected validator, the reward is also the same for each of them. There are actually two parts of the reward

  • Commission — is configurable on the validator side and it’s a fee collected to pay for its operation costs
  • Reward — is distributed between the validator and nominators proportionally to their stake (remember, validators can have their own stake as well)

There is an important concept to keep in mind and that since the reward which validator gets from the network remains the same regardless of the size of their stake, the validators with a lower stake will pay more rewards to their nominators. This is on purpose because the Polkadot wants the stake to be as evenly distributed among validators as possible so there is an incentive for nominators to shift their stake to validators with a lower stake to avoid concentration of power to a handful of validators. So, in the long term, all validators in a pool should have a similar amount of stake due to this economic incentive.

Another thing to consider is that there is a limit to how many nominators can validator pay in each era. Currently, only the top 64 nominators (by their stake) are getting paid while others won’t receive any rewards (we call this validator oversubscribed). So this is another important fact to bear in mind when choosing a validator to bond your tokens to (we will discuss choosing the best validator in the next article).

As of now, there is an ongoing referendum in Kusama network which is supposed to increase this limit up to 256 nominators. We can expect this change to be promoted to Polkadot pretty soon if there are no issues discovered regarding this change in Kusama.

Also, as we mentioned earlier, each validator can apply its own commission as a fee to pay for the operational costs. The consequence of this fact is that validators with lower fees will pay more rewards to the nominators who back them — the lower the fee, the more reward remains after the deduction. It is expected that there will be a high degree of competition in a long term between validators therefore fees will remain low for most of them.

You can use this tool to calculate the expected inflation rate for you as a nominator (you can adjust the parameters as you wish).

Era points

Rewards which will all validators receive once per era (remember, all active validators will get the same reward) is calculated from the era points.

These points are earned by different actions — for example producing a block (even if it doesn’t make it to the canonical chain), issuing validity statements, and others. Therefore there might be slight changes in reward size since the number of accumulated points can differ in each era so don’t expect your reward to be always the same.

Claiming rewards

Rewards are recorded once in epoch/session (6 hours) and calculated once in the era.

In order for rewards to get actually paid, someone has to claim them. This can be done by either validator itself or by any of the nominators via their wallet (or Polkadot JS API). Once any of these entities claim their reward, it gets distributed among all participants who bonded their tokens to the validator.

The reason for this behavior is not to send all the rewards to all participants in one block which could seriously affect the stability of the network. It rather forces participants to issue a transaction so payouts can be more spread across the blocks — automated payment of rewards for all validators and nominators in one time could temporarily flood the whole network.

One important thing to note is that rewards are stored only for 84 eras so they will disappear if no-one claims them within this period. So, be careful and check your payouts section from time to time for any pending rewards.

Staking, source: Pixabay

Slashing

Slashing is a way how to punish a validator if it misbehaves or even tries to attack the network. The validator’s entire stash will be slashed by some percentage and both the validator and its nominators will lose some of their funds. Let’s have a look at how the network can punish the validators if they misconduct

  • Level 1 — isolated unresponsiveness (maybe due to some occasional network problems on the validator’s side). No slashing occurs, only chilling (removing validator from the active validator set and preventing him from joining the next elections)
  • Level 2 — frequent unresponsiveness or rare equivocation (double voting). Only small slashing occurs and chills
  • Level 3 — misbehavior unlikely to be accidental but doesn’t harm network security (for example frequent equivocation or unjustified voting in GRANDPA). Slashes a moderately small amount and chills
  • Level 4 — malicious behavior that poses a security or monetary risk inside the network. Slashes most of the stake and chills

These slashed tokens are then added to the Polkadot’s treasury and can be sent back to validators and nominators if the council decides via governance that slashing was unjustified. The purpose of this is to revert slashing if the reason was faulty runtime or any kind of event in the network which they cannot be responsible for.

There is one notable point to the slashing and that is validators with larger stake get slashed more — this again encourages nominators to bond their funds to the less popular validators to prevent losses. Also, interestingly, the more validators misbehave at the same time, the harsher is the slash — Polkadot does this in order to prevent coordinated attacks against the network.

Number of tokens

Polkadot is set to be an inflationary network which means that there is no maximum of DOTs like in Bitcoin. This inflation is set to be 10% in the first year, the overall goal is to have 50% of all DOTs staked. If 50% of all DOTs are staked, all the inflation will go to the validators. If the number of tokens staked becomes bigger or lower, the network with lower the rewards for validators and send the rest to the treasury.

You can see current rewards being paid in the network in the Polkadot JS wallet.

Conclusion

Ok, it has been really a lot of the theory and ideas behind staking in Polkadot so feel free to take some time to digest it :) In the next writing, we will have a look at how to practically set up secure staking with stash and controller accounts and how to nominate the best validators based on what we have covered in this article.

Stay tuned for further information about the Polkadot ecosystem projects here on Medium, in our Twitter channel Polkadotters as well as in our Facebook Group Polkadot unofficial!

--

--

Polkadotters | Kusama & Polkadot validators
Polkadotters | Kusama & Polkadot validators

Written by Polkadotters | Kusama & Polkadot validators

Czech bloggers & community builders. We are validators of Polkadot, Kusama, Darwinia, Crab, Bifrost, HydraDX, StaFi, Centrifuge under the name: POLKADOTTERS

No responses yet