About Epochs, Slot Leaders, Random Number Proposers and Statistics

ChainLayer.io
Wanchain
Published in
7 min readSep 10, 2019

(Editor’s note: the following is a guest post from Wanchain validator and longtime community member, Chainlayer)

This article is for those people who are getting confused seeing the payments of the recently launched Wanchain PoS network and want to know a little better how those numbers add up. We will walk you through the key aspects of Wanchain’s reward mechanism so you understand for yourself why the rewards seem to be different from day to day.

Luck or fairness

Luck has a lot to do with it. I think most questions that were asked in the past few days had “luck” as an answer. Now no one wants to hear luck too often especially if it’s the answer to why you would have less rewards. And yet luck is a very powerful word. Luck in this sense isn’t actually luck. It is randomness that truly explains whats going on here, and I’ll give you a small example first.

Let’s say you and me start flipping some coins. If it is heads I win, if it is tails you win. Now let’s flip a coin 10 times.

In the image you can see the probability of the number of heads coming up. As you can see the chance we both get 5 wins is the highest. This means that an algorithm using heads and tails to divide income over two people could be seen as fair.

Now we play a game with 6 people and a 6 sided dice. The number of wins expected here is 1/6th of all wins. If you do that 100 times the distribution of wins look similar to the heads and tails image above. So out of 60 throws you can expect to win 10 times on average, however a real distribution of 10,000 throws might look like the picture on the left.

Number of times a 6 is thrown in 60 throws

Even worse, during those 10,000 throws the amounts of sixes thrown doesn't always grow linearly (i.e., not 1 out of every 6 throws). On average it does, but sometimes you throw 2 sixes in a row and sometimes even 3 or more. Does that mean the person throwing is lucky? Most likely, but it is still considered fair.

Statistics on Wanchain

Epoch Leaders (EL) and Random Number Proposers (RNP) in Wanchain are chosen randomly in a way similar to throwing dice. Every epoch (or day) in the 2880th block there is a selection process for the next epoch. Based on the total stake weight (editor’s note: technically it is based on the parameter called votingPower, which is also equivalent to the Wanstake parameter referred to in the Galaxy Consensus paper, but for the purpose of this article stake weight is a close enough approximation) of the validator and delegators, each validator is assigned a slice of time on a clock. Then at random 49 times are chosen and the validators whose slice of time contains those random 49 specific times gets to be EL or RNP. This selects the 24 EL and 25 RNP. A validator can get selected multiple times here (we’ll show you why later).

You might wonder why it’s a lottery like this and not a hard number. The reason is that given a certain stake weight you could never do this fairly. If two validators both have 0.5 slot who would get it? You can’t reconcile any differences the next day because the stake weight might be different again. You also can’t divide the income on all validators even though they are not all selected because that would remove the incentive from people for working. We’ll not go into more details regarding this choice, but take it as a given from here on.

So in Epoch 2, block number 2880 we decide who’s going to work in Epoch 3, based on the stake weight at the end (last block) of Epoch 1.

Rewards sharing

Now besides the EL and RNP there are also Slot Leaders (SL) Slot leaders are always the Epoch leaders of the day before and they are responsible for actually proposing the new blocks. Because they are connected they also share the rewards. That means in an Epoch the rewards are divided evenly over the EL, SL and RNP in the ratio 25%, 25% and 50%.

So if the total rewards for an Epoch are 100, the ELs and SLs both get 25 and the RNPs gets 50. EL and RNP get that amount fixed per selection, but SL are responsible for mining blocks and get that 25 relative to the number of blocks they mined in that Epoch. The number is close to 25 but can differ a few percentage points.

These amounts are not relative to the stake of the EL/SL/RNP! This is the reason a bigger validator can be selected more than once, otherwise he would never be able to get rewards that average against his total staking size.

The total rewards distributed per Epoch are around 7500 Wan (Edit: this should be 2.5M / 365 = 6849.3). If we divide that according to actual stake weight we would get this division across the top 30:

The smallest reward possible however is of 1 EL which is around 75 Wan (Edit: As daily rewards are ~6850 this should be around 68 Wan). As you can see only the top 15 have “enough” stake to be rewarded one EL daily and only the top 8 have enough for 1 RNP(150 Wan). To put it in perspective on the clock again, number 16 has a 0.66% stake weight meaning a 9.5 minute timespan on the 24-hour clock!

The number 30 has a 15.7% chance to be selected in any given day. Thats roughly the chance of rolling a 6 on a six sided die. On average he should be selected once every six days.

Now if we take the first picture again something else becomes clear:

See how when flipping a coin we say getting the same number of coins has the highest chance? Thats actually not completely true. The chance is 24% and of all the outcomes it is indeed the highest. But it means that in 74% of all cases the number of heads and tails are not the same! This distribution is a so called Bell Curve.

With Wanchain’s distribution it’s precisely the same. Over any number of epochs the chance that the ideal distribution is met is the highest, but the chance that another distribution was used is bigger. That doesn’t make it unfair though because there is simply no fairer way to do it. The good thing is that the chance to get lucky is the same as the chance to get unlucky. Also the chance of an average selection does not change if the size of the validator grows. While you can expect more (smaller) payments from a bigger validator, the chance to get lucky is roughly the same.

As time passes though, the luck factor should even out over the validator set getting the rewards, as each validator’s rewards will move closer to the average they should have based on their stake weight.

Hope you made it till the end! Thanks so much for reading this :)

About ChainLayer

ChainLayer is a Staking as a Service (StaaS) provider working from The Netherlands. The founders have been active in crypto since 2012 and have been running a successful validator for Tezos and Cosmos (chainlayer.io) for some time now as well as being a node for Chainlink, Irisnet, and Terra. Co-founded by the creator (Tyrion70) of MyWanWallet and WanMask.

About Wanchain

Wanchain is the infrastructure connecting the decentralized financial world. Wanchain’s live cross-blockchain solution is EVM-based, includes optional private transactions, and provides a decentralized, permissionless, and secure approach for interoperability. Wanchain has employees globally with teams in Beijing (China), Austin (USA), Kuala Lumpur (Malaysia), and Madrid (Spain).

You can find more information about Wanchain on our website. Additionally, you can reach us through Telegram, Discord, Medium, Twitter, and Reddit. You can also sign up for our monthly email newsletter here.

--

--

ChainLayer.io
Wanchain

ChainLayer is a Blockchain Infrastructure and Staking provider based in The Netherlands. We offer staking services as well as Chainlink Nodes to our customers.