Reward: The staking system pays out rewards to all validators regardless of stake. Having more stake in a validator does not influence the number of block rewards it receives.
- There are 2 types of rewards:
- Block reward (Reward from transaction fee)
- Reward from share revenue
Reward fund is a place to hold rewards that are shared with validators and nominators. There are 2 sources of the rewards:
- Rewards from revenue sharing: Owners of the Dapps transfer GLCH to the fund so that their list of smart contract addresses will be prioritized.
- Rewards from transaction fee and tip: When transactions are made, fee and tip will be directly transferred to the fund. Note that it is optional for users to make a tip with the purpose of prioritizing their transactions.
- Validators and nominators claim rewards at different times, so it is necessary that there should be a list of rewards for each era. At this point, the income of the chain in one era can be calculated as follows:
income= total amount of fund - total unclaimed reward.At the end of each era, the total reward is stored in the list. The list includes the order of the era and the total amount of rewards in that era. Note that the
total of amount of rewards in one era = current total of shared revenue + transaction fee + tip (if any).The reward memory storage is limited, so this list stores the rewards of only 84 eras (equal to 302400 blocks). This period is set with the purpose of limiting the effort of calculating when the reward is claimed. It also limits the size of data stored in a chain state.
- Each one has the option to trigger manually the payout for all unclaimed eras. If no one makes transactions to claiming rewards in one era until the next 84 eras run out, the total rewards in this expired era are removed from the list and no longer available for the validators and nominators in this era to claim. Then this total amount is put into the latest era (a new era right after an 84-era period). So the validators and nominators in the latest era can claim this unclaimed reward of the expired era. For example, the reward list now stores the rewards of the 84 eras: from the 1st era to 84th era. Assume that the rewards of the 1st era are equal to 2 GLCH. When the 85th era comes, the 1st era will become an expired era. If no one has claimed the rewards in the 1st era yet, the rewards of 85th will increase by 2 GLCH. The validators and nominators in the 85th era can claim the unclaimed reward of the 1st era.
- To get the reward, anyone needs to make a signed transaction called
payoutStakerwith 2 parameters: the order of the era and
account_idof the validator that they nominate. When a transaction is made, the validator and its nominators in that era will get the rewards. Then reward is put into their Stash account.
For every era, validators are paid proportionally to the number of era points they have collected. Era points are reward points earned for their contribution in one era. So the payout of validators in one era may differ based on era points.
There is a range of point to calculate reward points to block authors:
- 20 points to the block producer for producing a (non-uncle) block in the relay chain
- 2 points to the block producer for each reference to a previously unreferenced uncle
- 1 point to the producer of each referenced uncle block. -> Reward points are calculated per block, then at the end of the era, the total reward points are calculated.
Reward point of each era is stored in the chain state and shown below:
We have a list of reward points for each validator in 1st era as below:
total points: 12,000
Total reward: 2000
Then we calculate the reward distribution of each validator based on the era point proportion as below:
era point proportion= 2980/12000= 0.2483 → Reward= 0.2483 * 2000 = 496.6 V2:
era point proportion= 3360/12000= 0.28→ Reward= 0.28 * 2000 = 560
era point proportion= 3300/12000= 0.275→ Reward= 0.275* 2000 = 550
era point proportion= 2360/12000= 0.1967→ Reward= 0.1967 * 2000 = 393.4
- Reward is distributed to validators and nominators as below:
- A (configurable) percentage of the reward goes to pay the validator's commission. The validators define the commission rate. So they can change this rate by themselves.
- The remainder is paid to the nominators and validators in proportion to the staked amount.
Validator Alice: Stake 10 GLCH , commission rate: 60%
Nominator Bob: Stake 10GLCH
=> Staking rate: Alice 50%, Bob 50%
Assume that 20 GLCH is sent to the reward fund. Payout records are changed at the end of every era.
- Call transaction payout for validator and nominator
- Calculate rewards distribution:
- Validator Alice is reward from commission= 20 * 60% =12 GLCH
- Reward for stakers= 20 - 12=8 GLCH
- Validator Alice is reward from stake= 8 * 50% = 4 GLCH
- Nominator Bob is rewarded from stake= 8 * 50% = 4 GLCH
- Alice total reward= 4 + 12= 16
- Alice’s bonded GLCH increase from 10 to 26
- Bob’s bonded GLCH increase from 10 to 14