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

Relay Chain Accounts to Asset Hub Migration #515

Merged

Conversation

muharem
Copy link
Contributor

@muharem muharem commented Dec 22, 2024

This PR is not intended to be merged into the master branch but into a dedicated Asset Hub migration working branch. Please create such a branch if you have the necessary permissions and change the base for this PR.

The PR introduces two pallets designed for the Asset Hub migration, Relay Chain migrator (rc-migrator) and Asset Hub migrator (ah-migrator). Please refer to the code base for more docs.

Currently, these pallets handle only the migration of Relay Chain accounts. They are intended to support the migration of all migrating pallets and act as managers for the overall migration process.

It might be helpful to merge this PR into the dev branch to use this initial setup as a base for further development.

[x] Does not require a CHANGELOG entry

@muharem muharem marked this pull request as draft December 22, 2024 12:52
///
/// Since the `reserved` and `frozen` balances will be known on a receiving side (AH) they will
/// be calculated there.
pub fn get_consumer_count(_who: &T::AccountId, _info: &AccountInfoFor<T>) -> u8 {
Copy link
Member

@ggwpez ggwpez Jan 6, 2025

Choose a reason for hiding this comment

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

Suggested change
pub fn get_consumer_count(_who: &T::AccountId, _info: &AccountInfoFor<T>) -> u8 {
pub fn count_consumers(_who: &T::AccountId, _info: &AccountInfoFor<T>) -> u8 {

So you want to query every pallet on how many refs it expects?

This can probably be worked on in parallel.

Copy link
Member

@ggwpez ggwpez left a comment

Choose a reason for hiding this comment

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

LGTM going to prepare a dev branch for AHM.

// `Self::get_consumer_count` and `Self::get_provider_count` functions.
SystemAccount::<T>::mutate(&who, |a| {
a.consumers = 0;
a.providers = 1;
Copy link
Member

Choose a reason for hiding this comment

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

We could place a flag on the account that it was migrated. Not sure if its needed, but then we would know which accounts got moved, which stayed and which got created after the migration.

pallets/rc-migrator/src/accounts.rs Show resolved Hide resolved
pub fn migrate_accounts(
maybe_last_key: Option<T::AccountId>,
weight_counter: &mut WeightMeter,
) -> Result<Option<Option<T::AccountId>>, ()> {
Copy link
Member

Choose a reason for hiding this comment

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

Why a double option?

/// Migrating account balances.
MigratingAccounts {
// Last migrated account
last_key: Option<AccountId>,
Copy link
Member

Choose a reason for hiding this comment

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

Does None mean that it is done or that it is not yet started?

last_key: Option<AccountId>,
},
/// Some next stage
TODO,
Copy link
Member

Choose a reason for hiding this comment

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

I guess it would go through each pallet here?

with_transaction_opaque_err::<Option<Option<T::AccountId>>, (), _>(|| {
match Self::migrate_accounts(last_key, &mut weight_counter) {
Ok(ok) => TransactionOutcome::Commit(Ok(ok)),
Err(err) => TransactionOutcome::Commit(Err(err)),
Copy link
Member

Choose a reason for hiding this comment

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

Could also roll back and try with a smaller batch size next block.

pallets/rc-migrator/src/types.rs Show resolved Hide resolved
return weight_counter.consumed();
}

// TODO init
Copy link
Member

Choose a reason for hiding this comment

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

Note to self: This is probably where development should continue.

@ggwpez ggwpez changed the base branch from main to dev-asset-hub-migration January 6, 2025 13:39
@ggwpez
Copy link
Member

ggwpez commented Jan 6, 2025

It might be helpful to merge this PR into the dev branch to use this initial setup as a base for further development.

Yes going to do this. Comments can be address async.

ggwpez added 2 commits January 6, 2025 14:45
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
@ggwpez ggwpez marked this pull request as ready for review January 6, 2025 13:46
ggwpez added 4 commits January 6, 2025 14:54
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
@ggwpez ggwpez merged commit fd8d0c2 into polkadot-fellows:dev-asset-hub-migration Jan 6, 2025
44 of 45 checks passed
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.

2 participants