Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AHM] Sovereign Account Translation #594

Merged
merged 8 commits into from
Feb 21, 2025

Conversation

ggwpez
Copy link
Member

@ggwpez ggwpez commented Feb 18, 2025

To be merged into the AHM working branch. Quote from accounts.md:

Account Migration

Accounts are migrated with all their balance, locks and reserves at the beginning of the Asset Hub
migration.

User Impact

Users need to be aware that all of their funds will be moved from the Relay chain to the Asset Hub.
The Account ID will stay the same. This ensures that normal user accounts will be to control their
funds on Asset Hub.

Sovereign Account Translation

For parachain sovereign accounts, it is not possible to just use the same account ID. The sovereign
account address of a parachain is calculated differently, depending on whether it is the account on
the Relay or a parachain (like Asset Hub).

There are different kinds of sovereign accounts. In this context, we only focus on these parachain
sovereign accounts:

  • On the Relay: derived from "para" ++ para_id ++ 00..
  • On the Asset Hub and all other sibling parachains: derived from "sibl" ++ para_id ++ 00..

Our translation logic inverts the derivation and changes the prefix from "para" to "sibl" for
all accounts that match the pattern "para" ++ para_id ++ 00... The full list of translated
accounts is in this CSV file.

It is advised that parachains check that they can control their account on Asset Hub. They can also
forego this check if they do not need control thereof - for example when they are not holding any
funds on their relay sovereign account. However, please note that someone could still send funds to
that address before or after the migration.

Example for Bifrost: this is the relay sovereign account and it gets translated to this sibling sovereign account.

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
/// - `Ok(None)` if the account is not a Parachain sovereign account
/// - `Ok(Some((ah_account, para_id)))` with the translated account and the para id
/// - `Err(())` otherwise
pub fn try_translate_rc_sovereign_to_ah(acc: T::AccountId) -> Result<Option<(T::AccountId, u16)>, ()> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the important function

@ggwpez ggwpez marked this pull request as ready for review February 18, 2025 11:39
Copy link
Contributor

@acatangiu acatangiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good so far! afaict still needs:

  • equivalent function for translating derived SA (given a derivation path param)
  • hooking this to the migration - do you plan to test every address if it is derived or use some static list of accounts that should go through this translation? I am guessing the latter.

@ggwpez
Copy link
Member Author

ggwpez commented Feb 20, 2025

do you plan to test every address if it is derived or use some static list of accounts that should go through this translation? I am guessing the latter.

We wanted to generate this list as first step of the migration - automatically on-chain.
I think this still makes sense, since there could be new parachains registered between the time when we generate the list and when the migration actually happens.

equivalent function for translating derived SA (given a derivation path param)

Yes, I did not look into accounts that are derived from SAs. Going to do that in the next MR.

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
@ggwpez ggwpez merged commit 5bab2c2 into dev-asset-hub-migration Feb 21, 2025
7 of 11 checks passed
@ggwpez ggwpez deleted the oty-ahm-account-translation branch February 21, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants