Skip to content
Zikun Fan edited this page Aug 3, 2020 · 3 revisions

NOTE: This doc was ARCHIVED, please follow the docs shows in TOC to continue exploring Crust Network

GPoS(Guaranteed Proof of Stake)

Following description is based on the GPoS implementation of AlphaNet and is not final. GPoS's TODO includes Reward Distribution and Valid Stakes Calculation. Those features will be described in future updates.

Crust uses GPoS(Guaranteed Proof of Stake) as its mechanism for selecting the validator set. to maximize chain security. Actors who are interested in maintaining the network can run a validator node. At genesis, Crust will have a limited amount of slots available for these validators(6 in Alphanet), but this number will grow over time.

The system encourages CRU holders to participate as guarantors. Validators assume the role of producing new blocks in BABE and guaranteeing finality. Guarantors can choose to back select validators with their stake.

Valid Stakes

GPoS limited validators' stakes according to the formula below:

v_stake_limit = v_workload * (total_CRUs * R') / total_workload
R' = R * (1 + Y*Z*M)

v_stake_limit means the stake limit of validator, v_workload means the storage amount of validator, total_CRUs means the total issuance, total_workload means the total storage amount, R means the coefficient of exchange, Y means the coefficient of meaningful file, Z means the coefficient of account index, M means the meaningful file rate

The stake limitation will convert into valid stakes in both Validator and Guarantor. This will be used for the reward calculation.

Based on the stake limitation, GPoS contains 2 types of checking mechanism

Active Checking

Active Checking will decided the valid stakes in your ledger and happens on several actions, these actions are like the actions in Polkadot's NPoS mechanism, which contains 4 actions:

  • Bonded

    Both (wanna be) validator and (wanna be) guarantor can bond stakes from their stash account, this action won't do any active checking.

  • Bond Extra

    Bond Extra will do active checking on validator, it will judge if the extra stake exceeds the stake limit.
    For example, if the validator's stake limit is 5000 CRUs, he already bonded 2000 CRUs, then he can MAX add 3000 CRUs.

  • Validate

    If a bonded controller want to be a Validator, Active Checking will check if his stake limit >= 0.

  • Guarantee

    Guarantee's checking is a little bit complex, it contains 3 types of checking, and:

    g_vote_stakes is guarantor's voting stakes, v_stake_limit is validator's stake limit, v_own_stakes is validator's own bonded stake, v_remain_stakes = v_stake_limit - v_own_stakes, means validator's remain stakes, g_old_vote_stakes is the former g_vote_stakes.

    • Add new guarantee: if g_vote_stakes <= v_remain_stakes, add directly; else, g_vote_stakes = v_remain_stakes. Specially, if v_remain_stakes = 0, the adding will failed.

    • Update guarantee: if g_vote_stakes < g_old_vote_stakes update directly; if g_vote_stakes > g_old_vote_stakes: first of all, it will judge the v_remain_stakes like add new guarantee does; if v_remain_stakes > 0, it will change the sequence of this validator's guarantor, push it into last(sequence will influent Passive Checking).

    • Delete guarantee: Just delete it(including validator's guarantor, guarantor and guarantee relationship).

      There is an example shows the guarantee action:

      If there is a guarantee map shows below:

      Name Role Bonded Stakes Valid Stakes Stake Limit Vote Targets
      V1 Validator 20,000 20,000 40,000 /
      V2 Validator 40,000 40,000 60,000 /
      G1 Guarantor 900,000 / [(V1, 15,000), (V2, 20,000)]
      G2 Guarantor 40,000 / [(V1, 2,000), (V2, 20,000)]

      The result will be like this:

      Name Role Bonded Stakes Valid Stakes Stake Limit Vote Targets Real Targets
      V1 Validator 20,000 20,000 40,000 / /
      V2 Validator 40,000 40,000 60,000 / /
      G1 Guarantor 900,000 35,000 / [(V1, 15,000), (V2, 25,000)] [(V1, 15,000), (V2, 20,000)]
      G2 Guarantor 40,000 2,000 / [(V1, 2,000), (V2, 20,000)] [(V1, 2,000)]

      Then, if G1 want to add more stakes on V1, it will change the sequence of V1 from [V1, V2] to [V2, V1]:

      Name Role Bonded Stakes Valid Stakes Stake Limit Vote Targets Real Targets Validator's Guarantors
      V1 Validator 20,000 20,000 40,000 / / [V2, V1]
      V2 Validator 40,000 40,000 60,000 / / [V1]
      G1 Guarantor 900,000 38,000 / [(V1, 18,000), (V2, 25,000)] [(V1, 18,000), (V2, 20,000)] /
      G2 Guarantor 40,000 2,000 / [(V1, 2,000), (V2, 20,000)] [(V1, 2,000)] /

Passive Checking

Passive Checking will check the stake limitation and re-arrage guarantor's voting stakes, it happens in the end of era, and contains 2 rules:

  • Validator's own stake has the highest priority, which means if validator reach his stake limit, he will remove all his guarantors;
  • Guarantor will satisfaction by priority(this priority is Validator's Guarantors sequence);

For example, if there is a guarantee map shows below:

Name Role Bonded Stakes Valid Stakes Stake Limit Vote Targets Real Targets Validator's Guarantors
V1 Validator 20,000 20,000 40,000 / / [V1, V2]
G1 Guarantor 900,000 18,000 / [(V1, 18,000)] [(V1, 18,000)] /
G2 Guarantor 40,000 2,000 / [(V1, 2,000)] [(V1, 2,000)] /

And V1 bond extra stakes up to 21,000 CRUs, then the guaratee map will look like this:

Name Role Bonded Stakes Valid Stakes Stake Limit Vote Targets Real Targets Validator's Guarantors
V1 Validator 21,000 21,000 40,000 / / [V1, V2]
G1 Guarantor 900,000 18,000 / [(V1, 18,000)] [(V1, 18,000)] /
G2 Guarantor 40,000 1,000 / [(V1, 2,000)] [(V1, 1,000)] /

Then if V1 bond extra stakes up to 30,000 CRUs, then the guarantee map will look like this:

Name Role Bonded Stakes Valid Stakes Stake Limit Vote Targets Real Targets Validator's Guarantors
V1 Validator 30,000 30,000 40,000 / / [V1]
G1 Guarantor 900,000 10,000 / [(V1, 18,000)] [(V1, 10,000)] /
G2 Guarantor 40,000 0 / [(V1, 2,000)] None /

TopDown Election

After the Passive Checking in the end of era, GPoS will select next era's validator set based on validator's total_staker_stakes = Valid Stakes + Validator's Guarantors voted total stakes. Then the TopDown will sort the candidates by total_staker_stakes, and choose from high to low.

Staking rewards distribution

TODO