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

Asset Conversion: Pool Account ID derivation with additional Pallet ID seed #3250

Merged
merged 52 commits into from
Apr 17, 2024

Conversation

muharem
Copy link
Contributor

@muharem muharem commented Feb 8, 2024

Introduce PalletId as an additional seed parameter for pool's account id derivation.

The PR also introduces the pallet_asset_conversion_ops pallet with a call to migrate a given pool to thew new account. Additionally fungibles::lifetime::ResetTeam and fungible::lifetime::Refund traits, to facilitate the migration of pools.

@muharem muharem added the T2-pallets This PR/Issue is related to a particular pallet. label Feb 8, 2024
@muharem muharem requested a review from a team as a code owner February 8, 2024 03:38
@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: cargo-clippy
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5930659

Copy link

Review required! Latest push from author must always be reviewed

@@ -2474,6 +2496,9 @@ mod runtime {

#[runtime::pallet_index(78)]
pub type PalletExampleMbms = pallet_example_mbm;

#[runtime::pallet_index(79)]
pub type AssetConversionMigration = pallet_asset_conversion_ops;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to add the migration to this runtime? It's not live, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This runtime serves as an example of pallets integration. I think it make sense to have here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not required, I'm guessing it was probably added for pallet benchmarks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true, we also need it for the benchmarks.


doc:
- audience: Runtime Dev
description: |
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't you mention the migration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I can improve this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

if let Some((depositor, deposit)) =
T::AssetsRefund::deposit_held(asset1.clone(), prior_account.clone())
{
T::DepositAsset::mint_into(&depositor, deposit + deposit_asset_ed)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you mint deposit + deposit_asset_ed? Doesn't the depositor already have the deposit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, depositor might now have it. There is a comment above.

}
);

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove many types given that you're deriving the defaults. Take a look at:

#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

type MaxConsumers = ConstU32<16>;
}

impl pallet_balances::Config for Test {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you use derive_impl here, it means less maintenance when we add new config items to these traits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

type RuntimeFreezeReason = ();
}

impl pallet_assets::Config<Instance1> for Test {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@@ -1013,4 +1018,28 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
})
.collect::<Vec<_>>()
}

/// Reset the team for the asset with the given `id`.
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the "team" of an asset?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is not it clear from arguments? this also how we name it in pallet's call

@paritytech-review-bot paritytech-review-bot bot requested a review from a team April 16, 2024 13:13
@muharem
Copy link
Contributor Author

muharem commented Apr 16, 2024

@franciscoaguirre all the comments addressed, can you have a look again please

@@ -2474,6 +2496,9 @@ mod runtime {

#[runtime::pallet_index(78)]
pub type PalletExampleMbms = pallet_example_mbm;

#[runtime::pallet_index(79)]
pub type AssetConversionMigration = pallet_asset_conversion_ops;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not required, I'm guessing it was probably added for pallet benchmarks.

substrate/frame/asset-conversion/ops/Cargo.toml Outdated Show resolved Hide resolved
substrate/frame/asset-conversion/ops/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines 37 to 54
/// Trait for resetting the team configuration of an existing fungible asset.
pub trait ResetTeam<AccountId>: Inspect<AccountId> {
/// Reset the team for the asset with the given `id`.
///
/// ### Parameters
/// - `id`: The identifier of the asset for which the team is being reset.
/// - `owner`: The new `owner` account for the asset.
/// - `admin`: The new `admin` account for the asset.
/// - `issuer`: The new `issuer` account for the asset.
/// - `freezer`: The new `freezer` account for the asset.
fn reset_team(
id: Self::AssetId,
owner: AccountId,
admin: AccountId,
issuer: AccountId,
freezer: AccountId,
) -> DispatchResult;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure this belongs in lifetime.rs.. Maybe roles.rs?

@paritytech-review-bot paritytech-review-bot bot requested a review from a team April 16, 2024 14:30
@muharem muharem added this pull request to the merge queue Apr 17, 2024
Merged via the queue into master with commit 4e10d3b Apr 17, 2024
131 of 136 checks passed
@muharem muharem deleted the muharem-asset-conversion-pool-account branch April 17, 2024 11:17
sandreim pushed a commit that referenced this pull request Apr 18, 2024
…D seed (#3250)

Introduce `PalletId` as an additional seed parameter for pool's account
id derivation.

The PR also introduces the `pallet_asset_conversion_ops` pallet with a
call to migrate a given pool to thew new account. Additionally
`fungibles::lifetime::ResetTeam` and `fungible::lifetime::Refund`
traits, to facilitate the migration of pools.

---------

Co-authored-by: command-bot <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T2-pallets This PR/Issue is related to a particular pallet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants