Kian Paimani
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
1
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Substrate's NPoS overview ### Introduction to NPoS NPoS is a very difficult problem to solve in a blockchain context. The reason for that is that we want a sovereign algorithm, be it our currently used `phragmen` or not, to solve the problem of NPoS for us offchain, and resubmit the solution back to the chain. The problem of NPoS can be summarized as: given an input graph of nominations, find a distribution of stake for each nominator so that some objectives are optimized. As an example, say Alice nominates Bob, Charlie and Dave. Bob and Charlie are in the active validator set. How should Alice's stake be divided between them? What about Dave? To contrast the simplicity of DPoS, such a problem does not exist there, since each nominator backs only one account. Even if you can back multiple accounts, your stake is split between them equally, or based on some pre-defined order. This is basically the same as splitting your funds into multiple accounts. Current objectives of NPoS in substrate (and consequently polkadot and any other use of `sp-npos-elections` crate) is set to be: - the backing stake of the least-backed elected validator, which should be maximized. - the sum of backing stake of all elected validators, which should be maximized. - the sum squared of backing stake of all elected validators, which should be minimized. For a more extensive detail about all of this, see [this talk](https://www.youtube.com/watch?v=MjOvVhc1oXw). For any additional question, feel free to ask @kianenigma in github or [Polkadot's watercooler](https://app.element.io/#/room/!FdCojkeGzZLSEoiecf:web3.foundation?via=matrix.parity.io&via=matrix.org&via=web3.foundation) chat. --------- ### Current Solutions We have a set of algorithms that solve the NPoS problem, optimize it further, and reduce its size, all of which are packed nicely in `sp-npos-election`. In the runtime, we have a dedicated pallet that does our multi-phase, offchain-oriented, election process, named `pallet-election-provider(-multi-phase)`, as described in [#6242](https://github.com/paritytech/substrate/issues/6242). pallet-staking will only use the election pallet and does not deal with details of the election itself. An important part of the current system is that the pallet-staking and pallet-election-provider don't keep up with each other's changes, and this is intentional. At some point, pallet-staking will need to provide a snapshot of its nominators and validators (or a subset thereof) to pallet-election-provider. Form this point onwards, the two pallets can work independently. This design decision has multiple benefits for us. Most importantly, we can use the snapshot as a **source of index-lookup** for all nominators and validators. In all solutions computed and submitted offchain, we never use account ids, but rather the much more efficient index in snapshot (compare a 4 byte u32 with 32 byte account id.). ### Bottlenecks With this overview of the system in mind, let's look at the main bottlenecks: 1. **Snapshot creation**: This happens `on_initialize`, and can easily cause a heavy block. More importantly, there is a strict limit on how much memory each block can use, so we surely can never iterate a massive number of nominators in a single block. 2. **Solution Submission**: A solution that is being submitted must also not reach neither the block size limit, not the block memory limit. The latter is the real bottleneck with low congestion. 3. **Solution Verification**: The solution needs to be verified at some point. This needs to happen **against the snapshot**, and is thus again a memory intense operation. The solution to all of this, and our direction of movement is towards doing all of this over multple blocks. The snapshot will be taken over multiple blocks, and the outcome snapshot will be a map of `page-index -> snapshot-page`, instead of one big flat snapshot. The solution will need to take this into account. It needs to provide nominator indices in a way that is understandable, to the chain. Instead of identifying a nominator by a single index, each nominator is now identifiable by a `(page, index)` tuple. Similarly, the solution verification also needs to take this into account, and verify each page of the solution against its corresponding page in the snapshot. Finally, the partial solutions need to be amalgamated into a single one.

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully