Koniverse / SubWallet-Extension

SubWallet is the comprehensive non-custodial wallet solution for Polkadot, Substrate & Ethereum ecosystems.
https://www.subwallet.app
Apache License 2.0
92 stars 62 forks source link

Update default validator selection for staking #2575

Open nampc1 opened 5 months ago

nampc1 commented 5 months ago

We should implement an algorithm to automatically select the best validators for user staking directly through nomination

bluezdot commented 5 months ago

Use activeEra instead of currentEra for fetching last-14-eras points. Because when currentEra jumps to a new era, activeEra is still in the previous era, and the era point is still distributed.

Sokol142196 commented 4 months ago

@bluezdot please describe the Validator selection algorithm

bluezdot commented 4 months ago

@Sokol142196 The algorithm to select the top 50% validator is in the following step:

  1. At the current era n, I fetch all validators's point information from era n-14 to era n-1 (14 eras in total).
  2. Calculate the total point of each validator that appears with this format: validator_address: total_point.
  3. Sort the list of validators by total_point in descending order.
  4. Filter the top 50% from the list in step 3.

Above is the algorithm from background logic. The remaining algorithm to select 16 validators is implemented by @lw-cdm. 

ThaoNguyen998 commented 4 months ago

Validation passed. Check with Polkadot: Top 50% validator

polkadot.txt

https://konistudio-my.sharepoint.com/:x:/g/personal/nhungphung_koni_studio/EXAYw6nH8MhFmunGwYWTpIcBn5B2_l_51nIwaalvxPAGLg?e=YtMmkz

Sokol142196 commented 3 months ago

Needs discussion and improvement in case there is already a stake