On Day 27 you wrote weighted_choice() to simulate validator selection. Today you see how Polkadot's real NPoS election works — and why it's designed the way it is.
# Day 27 — your weighted validator selection
validators = {
"Alice": 5000, # DOT staked
"Bob": 3000,
"Carol": 8000,
"Dave": 2000,
}
def weighted_choice(validators):
total = sum(validators.values())
r = random.uniform(0, total)
cumulative = 0
for name, stake in validators.items():
cumulative += stake
if r <= cumulative:
return nameA naive system would just pick the validators with the most DOT staked. Problem: 10 validators with 90% of all stake means huge centralisation. One cartel controls Polkadot.
At the end of each 24-hour era, the protocol calculates rewards for each validator based on the number of blocks they produced and the fees they collected. The validator takes their commission (e.g. 5%), and the rest is split proportionally among all nominators backing that validator.
| Offence | Slash Amount | Who Loses |
|---|---|---|
| Being offline / unresponsive | Small % (0.1%) | Validator only |
| Equivocation (double-signing) | Up to 100% | Validator + all nominators |
| Coordinated attack | Up to 100% | Validator + all nominators |
Go to polkadot.js.org/apps/#/staking. Pick one active validator. Record:
Write findings as Python comments.
Find one high-stake validator, one medium-stake, and one new/small validator.
Compare their commission, nominator count, and uptime. Which would you nominate and why? Write a short comment explaining your reasoning.