Elections Example
The validator election process is an iterative process. This examples covers a full election where 5 validators compete for 3 slots in the active set while 5 nominators vote for them.
Consider the following initial setup:
Nominator
Stake
Nominations
One
100 CTC
Alice & Bob
Two
200 CTC
Alice & Bob
Three
300 CTC
Alice
Four
400 CTC
Bob, Charlie & Dave
Five
500 CTC
Alice & Dave
Validator
Nominations (count)
Alice
4
Bob
3
Charlie
1
Dave
2
Eve
0
First, we must calculate the approval stake of each validator; this is the total support for them by all nominators.
Validator
Total
Detail
Alice
1100 CTC
100 + 200 + 300 + 500
Bob
700 CTC
100 + 200 + 400
Charlie
400 CTC
400
Dave
900 CTC
400 + 500
Eve
0 CTC
0
We remove any validators which do not have any support from nominators. Eve will never be elected, so we remove it from the set.
After this, we can calculate the initial scores for each candidate. In each round, the validator with the lowest score gets assigned a slot. This is calculated by the formula
1 / stake
Validator
Stake
Score
Alice
1100 CTC
1 / 1100 = 0.00091
Bob
700 CTC
1 / 700 = 0.00143
Charlie
400 CTC
1 / 400 = 0.0025
Dave
900 CTC
1 / 900 = 0.0011
The candidate with the lowest score is Alice. It has its slot reserved. After the first round, the weights of each nominator votes get updated to Alice being already elected. This makes the votes of those who picked Alice stronger. The formula is the following:
After updating the weights, we recalculate the scores for each validator:
Validator
Score
Bob
0.00182
Charlie
0.0025
Dave
0.00162
Validator Dave gets the next available slot and we update the nominator weights and validator scores again.
Validator
Score
Bob
0.00143
Charlie
0.0025
We end up with Bob taking the last slot. All 3 slots are filled and we have the election result
Last updated