Expand description

Parachain Staking

Minimal staking pallet that implements collator selection by total backed stake. The main difference between this pallet and frame/pallet-staking is that this pallet uses direct delegation. Delegators choose exactly who they delegate and with what stake. This is different from frame/pallet-staking where delegators approval vote and run Phragmen.

Actors

There are multiple functions that can be distinguished:

  • Collator Candidate - depending on managed stake can or can not bo chosen as collator
  • Delegator - delegates to collator candidate, if that collator candidate will become collator delegator is eligible for proportional part of the rewards that collator receives for building blocks
  • Aggregator - A collator candiate may choose to aggregate under an aggregator. If this aggregator gets selected then he becomes an author/collator representing the collator candidates aggregating under him. If a collator candidate does not choose to aggregate under an aggregator and gets selected, then he himself becomes the author/collator. Any account that is not delegator or candidate can become aggregator

Rules

There is a new round every <Round<T>>::get().length blocks.

At the start of every round,

  • issuance is assigned to collators (and their delegators) for block authoring T::RewardPaymentDelay rounds ago, afterwards it can be claimed using dedicated extrinsics
  • queued collator and delegator exits are executed
  • a new set of collators is chosen from the candidates

To join the set of candidates, call join_candidates with bond >= MinCandidateStk. To leave the set of candidates, call schedule_leave_candidates. If the call succeeds, the collator is removed from the pool of candidates so they cannot be selected for future collator sets, but they are not unbonded until their exit request is executed. Any signed account may trigger the exit T::LeaveCandidatesDelay rounds after the round in which the original request was made.

To join the set of delegators, call delegate and pass in an account that is already a collator candidate and bond >= MinDelegatorStk. Each delegator can delegate up to T::MaxDelegationsPerDelegator collator candidates by calling delegate.

To revoke a delegation, call revoke_delegation with the collator candidate’s account. To leave the set of delegators and revoke all delegations, call leave_delegators.

Aggregation

Aggregation feature allows accumulating stake in different liquidity tokens under single aggregator account by assosiating several candidates stake with that (aggregator) account. Each candidate needs to bond different liquidity token

                           ###################
              -------------#  Aggregator A    #-------------
             |             #                  #             |
             |             ####################             |
             |                       |                      |
             |                       |                      |
             |                       |                      |
             |                       |                      |
             |                       |                      |
             |                       |                      |
     --------------------  --------------------  --------------------
     |  Candidate B     |  |  Candidate C     |  |  Candidate D     |
     | token: MGX:TUR   |  | token: MGX:IMBU  |  | token: MGX:MOVR  |
     --------------------  --------------------  --------------------

If candidate decides to aggregate under Aggregator it cannot be chosen to be collator(the candidate), instead aggregator account can be selected (even though its not present on candidates list).

Block authors selection algorithm details Pallet::select_top_candidates

                        candidate B MGX valuation
 Candidate B rewards = ------------------------------------ * Aggregator A total staking rewards
                        candidate ( B + C + D) valuation

Extrinsics:

Storage entries:

Candidate selection mechanism

Aggregation feature modifies how collators are selected. Rules are as follows:

  • Everything is valuated in MGX part of staked liquidity token. So if collator A has X MGX:KSM liquidity tokens. And X MGX:KSM liquidity token is convertible to Y MGX and Z KSM. Then X MGX:KSM tokens has valuation of Y.
  • If candidate allows for staking native tokens number of native tokens/2 == candidate valuation.
  • for aggregator(A) each aggregation account (such that aggregates under A) is valuated in MGX and sumed.
  • Candidates that aggregates under some other account cannot be selected as collators (but the account they aggregate under can)
  • Candidates with top MGX valuation are selected as collators

Manual payouts

Due to big cost of automatic rewards distribution (N transfers where N is total amount of all rewarded collators & delegators) it was decided to switch to manual payouts mechanism. Instead of automatically transferring all the rewards at the end session only rewards amount per account is stored. Then collators & delegators can claim their rewards manually (after T::RewardPaymentDelay).

Extrinsics:

Storage entries:

is not available.

Re-exports

Modules

  • The pallet module in each FRAME pallet hosts the most important items needed to construct this pallet.
  • Autogenerated weights for parachain_staking

Enums

Traits