Giuseppe Re
    • 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
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

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

      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.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      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
    • Note Insights New
    • Engagement control
    • Make a copy
    • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy 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
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

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

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Testing account balances migration to Asset Hub This document focuses on testing the migration of account balances on Polkadot, with Holds (Reserves) and Locks (Freezes). There is also an overview of the current migration process. **Reserved and frozen balances** Notice that, initially, reserves on Polkadot were unnamed and they were later replaced by named reserves. Finally, all named reserves have been migrated to holds. Currently, we only have unnamed reserves and holds: the former are just counted into the amount of reserved balance for an account, the latter are also stored in the map `Holds`. However, they both contribute to the total amount of reserved balance for an account. The balance amount which is not reserved is also known as the _free_ balance of the account. Besides reserved balance, Polkadot also used locks for locked balances, storing them in the map `Locks`. They have been now deprecated in favor of freezes, which are stored in the map `Freezes`, and locked balance is now referred to as _frozen_. However, locks and freezes both contribute to the amount of frozen balance for an account. The Asset Hub Migration needs to migrate reserved and frozen balances together with the corresponding storage maps. ## Migrating Accounts with Balances When possible, relay chain accounts should be fully migrated to Asset Hub with their whole balance, their holds, reserves, locks, and freezes. However, some accounts need to be kept on the relay chain, fully or in part. ### Accounts partially preserved on the relay chain There are several categories of accounts that cannot be fully migrated to Asset Hub because they have reserves that need to be kept on the relay chain. Those reserves are: - deposits for the sender and the receiver of existing HRMP channels - deposits for requests for opening an HRMP channel - deposits for registered parachains Accounts having some balance reserved for one of these reasons need to be preserved on the relay chain with the corresponding reserved balance and the Relay Chain existential deposit as free balance. The remaining balance with all the holds/reserves and freezes/locks associated with the account is migrated to Asset Hub. It may happen than the account free balance is not enough to cover for both the Relay Chain existential deposit (1 DOT) and the Asset Hub existential deposit (0,01 DOT). This may cause problems on Asset Hub, like failures when migrating holds for unsufficient reservable balance. For this reason, in such cases we unreserve some of the reserved balance kept on the Relay Chain so that we have at least 1,01 DOT free balance to cover both existential deposits: 1 DOT free balance will be kept on the relay chain, while the remaining free balance (always ≥ 0,01 DOT) will be migrated to Asset Hub. ### Fully preserved accounts on the Relay Chain The on-demand pallet account, which holds the funds from instantaneous coretime sale, must be fully preserved on the relay chain. Moreover, all accounts having total balance which is less than the Relay Chain existential deposit are also preserved on the Relay Chain. ### Checking Account The checking account, which tracks the total amount of DOT stored outside of the relay chain, is also migrated to Asset Hub. Its balance is adjusted to reflect the total balance stored outside of Asset Hub. For more details, see [this](https://github.com/polkadot-fellows/runtimes/blob/dev-asset-hub-migration/pallets/rc-migrator/src/accounts.md#xcm-checking-account-and-dotksm-total-issuance-tracking). ### What happens on Asset Hub After accounts have been migrated to Asset Hub, their holds may change and their reserved balance too. This is the case of multisig deposits, which are unreserved since multisigs are not migrated to Asset Hub. The same happens for deposits for legacy storage items for pallet preimage, while proxy announcements deposits may be unreserved if they cannot be converted to Asset Hub proxy announcements. Also notice that preimage deposits are re-computed and changed on Asset Hub during the migration, and so the corresponding holds are changed. For this reason, computing the total amount of reserved balance on Asset Hub after the migration for a single account is quite involved and has not been tested yet. Instead, freezes and locks should not change, so they are easily predictable and can be tested on Asset Hub. ### Edge cases After nomination pools have been changed to use holds from `pallet-delegated-staking`, many accounts ended up with holds that covered all their balance, leaving them with zero or close to zero free balance. This may cause issues when migrating those accounts to Asset Hub, like failures in applying unnamed reserves. Among those accounts, we noticed that account [5HBpFvUckfYEevbMnGXgGidcCRBygFww1FyksaJXYxjagPCK](https://polkadot.subscan.io/account/1687QFjgcSoi6TbsjuagQsTm43BdNZW55kiF2sHt73m6ronH) has ~ 0,0001 DOT free balance on the relay chain and a delegated staking hold of ~ 2,2084 DOT. When migrated to Asset Hub, at first its whole ~ 2,2085 DOT balance is minted correctly. However, when the delegated staking hold is applied, since the remaining free balance is less than the Asset Hub existential deposit, the free balance gets dusted and the account is left with 0 free balance. We need to take this into account for tests. ## Unit Tests There is a tradeoff between the coverage of tests and their complexity. In general, we must avoid re-using the migration code in tests: this prevented us from noticing a bug in hold id translation. Here are some details about the tests. ### Accounts For individual accounts, we check that all holds, locks, and freezes are correctly migrated to Asset Hub. Moreover, as for balances, we check that: - partly migrated accounts keep only the minimun necessary balance on the relay chain (1 DOT existential deposit), while fully migrated accounts do not have any balance on the relay chain after migration - partly and fully migrated accounts have their total relay chain balance correctly migrated to Asset Hub, allowing an error of at most the AH existential deposit (for dusted balances like the one mentioned in [Edge Cases](#edge-cases)) - the amount of reserved balance on Asset Hub for a single account is at most the amount of migrated reserved balance. Here we do not make more precise checks accounting for multisig deposits or other unreserved deposits, as mentioned in [this section](#what-happens-on-asset-hub). - Holds are correctly migrated to Asset Hub (with Preimage deposits being re-computed correctly), as well as locks and freezes. ### Total issuance and Checking balance We check the identities on total balances and checking accounts from [this doc](https://github.com/polkadot-fellows/runtimes/blob/dev-asset-hub-migration/pallets/rc-migrator/src/accounts.md#xcm-checking-account-and-dotksm-total-issuance-tracking). There is only a small error on total issuances, since we expect the total issuance on Asset Hub after migration to be equal to the total issuance on the Relay Chain before migration. However, they differ by ~ 0.010108 DOT, so we just assert the equality up to an error < 0,1 DOT. The difference may come from: - 0,000108 DOT dusted for account [5HBpFvUckfYEevbMnGXgGidcCRBygFww1FyksaJXYxjagPCK](https://polkadot.subscan.io/account/1687QFjgcSoi6TbsjuagQsTm43BdNZW55kiF2sHt73m6ronH) - 0,01 DOT probably from the DED airdrop to the checking account (this is just an hypothesis)

    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
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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