Polkadot NPoS Overview
Tags: polkadot, consensus, blockchain, npos
Published: 2022-06-04 18:47:27

> Polkadot is the fully-sharded blockchain that is built to connect and secure the other blockchains as layer-0. 

> Polkadot has interesting feature that it gives any Dot holders a role to be part of network security entities, called _Nominated-Proof-of-Staking(NPoS)_. 

> So what is **NPoS**?

## Overview

> _What is NPoS?_

To continuously produce blocks and secure the network in blockchain, it is important to have good **validators**. In normal _proof-of-staking_, validators are the entities who have the great amount of stakes in the network, which can lead to be centralized network. However, in Polkadot, the system encourages any Dot holders to participate in securing the network in two ways, **Nominators** and **Validators**. In general, most of the crypto users would be a _nominator_ because being a _validator_ requires lots of works. Nominators can select up to 16 validators who they trust with minimum bonded asset. Then, a limit number of validators(_not all validators!_) would be elected by the system who have the most backing Dot. Both locked their assets as collateral and receive staking rewards. Most importantly, staking system pays out staking rewards equally to all elected Validators not proportional to their amount of stake. The network creates an incentive to lower-staked validators so when certain time passed, Polkadot system wants to achieve as much _**equally-staked validator**_ set as possible. 

_Let's say there are two validation pools, A with 1000 Dot and B with 500 Dot and rewards are 2000 Dot for each. Then, someone who backed 200 Dot in pool B will get more rewards than someone who backed 200 Dot in pool A_ 

Finally, rewards are distributed into nominators with proportional to their amount of stake.

## NPoS Scheme

> _What Polkadot wants to achieve through NPoS?_

Polkadot gives validator equal voting power in consensus protocol. To reach this, NPoS election mechanism tries to distribute nominators' stake to elected validators as evenly as possible. The objective of this mechanism is to maximize the _security_ of network as most of the validators have equal amount stake, and to achieve **two** important factors, **Fair Representation** and **Security**.

- Fair Representation

Polkadot NPoS election system is inspired by Swedish Mathematician Lars Edvard Phragmén's _proportional justified representation_. That is, when we want _n validators_ to be elected, nominators who stake about (n / total staking) are guaranteed to have at least one of their validators to be elected. Let's look at the illustration about _fair representation_ from Medium.

![Fair Representation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/00ar2uvy5vl5viq3tvye.png) 

This illustration is electing 4 validators. First seems unfair representation because it doesn't represent the validator which is backed by 10 Dot nominators. Since 10 Dot is 1/4 of total stake, there should be at least one validator to be elected. However, there is no validator for this nominator, so it is unfair. Rest is fair.

- Security 

_Remember_ nominators can select up to 16 validators who they trust? Polkadot NPoS mechanism tries to distribute the nominator stake among these validators equal as possible. However, there is a situation where malicious validator is selected with the most backed while other validators with small equal amount. To make this situation difficult, Polkadot reaches _Security_ with the **_minimum amounts_** backing of any elected validators. Let's look at the illustration.

![Security](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lsprzka7al2g36pthgxx.png)

Left is level 6 security and right is 9 security. As you can see, second seems more secure since almost all validators have equal amount of backed stake. This is what NPoS mechanism tries to optimize so far.

## Conclusion

**NPoS** is the same way we choose _congress man_ for our country. To make our country a great place, it is our responsibilities to have great interest in whom we pick.  Since validators are acting as representatives in Polkadot network, nominators should know who is going to be a good validator and choose carefully. If they choose bad validators, their asset could be slashed, so _Nominating_ is not _"set and forget"_ operation. 

There are lots of things happen behind NPoS such as _How NPoS handle the nominators and _How Phragmén method is used in NPoS_. Later, I am going to handle the details of this mechanism. 


## Reference
[Medium: How Nominated Proof-of-Stake will work in Polkadot](https://medium.com/web3foundation/how-nominated-proof-of-stake-will-work-in-polkadot-377d70c6bd43)
[Polkadot-Wiki: Staking](https://wiki.polkadot.network/docs/learn-staking)