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

refactor: Drop tranche multiLocation #1340

Merged
merged 24 commits into from
May 17, 2023

Conversation

NunoAlexandre
Copy link
Contributor

@NunoAlexandre NunoAlexandre commented May 10, 2023

Closes #1336

We make AssetMetadata.location of a Tranche simply None since having a MultiLocation for Tranche tokens implies they are XCM-transferrable when in fact we have specific Xcm configs in place to forbid tranche tokens transfers. Tranche tokens are only transferrable through Centrifuge Connectors, which guarantees that the permissioned-nature of tranche tokens are respected.

Changes

  • 1. We set the AssetMetadata.location of a Tranche token to None
  • 2. We add a migration for all the runtimes that ensure 1. for all the already registered Tranche tokens

To Do

  • Write a migration that, for every CurrencyId::Tranche in entry in the AssetRegistry, updates that asset by setting location to None.
    • Centrifuge
    • Altair
    • Development

Discussion

Can we dry the migration so that we define it once for all all runtimes? We need to reference directly on the (external dependency) orml_asset_registry which I don't think we can abstract over the runtime it's in 🤔

We make it just `None` since having a MultiLocation for Tranche tokens
implies they are XCM-transferrable when in fact we have specific Xcm
configs in place to forbid tranche tokens transfers. Tranche tokens are
only transferrable through Centrifuge Connectors, which guarantee the
permissioned-nature of tranche tokens are respected.
@NunoAlexandre NunoAlexandre changed the title Refactor/drop tranche multilocation refactor: Drop tranche multiLocation May 10, 2023
@NunoAlexandre NunoAlexandre self-assigned this May 11, 2023
@NunoAlexandre NunoAlexandre marked this pull request as ready for review May 11, 2023 10:03
Copy link
Collaborator

@mustermeiszer mustermeiszer left a comment

Choose a reason for hiding this comment

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

I would really like us to stick with the naming for upgrades, so use UpgradeAltair1028 instead of just the plain migration. Makes it so much easier in the future to remove what needs to be removed.

Otherwise, looks good!

For approval:

Need clarification whether the following will never fail:

  • let location: MultiLocation = old_location.clone().try_into().map_err(|()| Error::<T>::BadVersion)?;

runtime/altair/src/lib.rs Outdated Show resolved Hide resolved
runtime/development/src/lib.rs Outdated Show resolved Hide resolved
runtime/centrifuge/src/lib.rs Outdated Show resolved Hide resolved
runtime/altair/src/migrations.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@thea-leake thea-leake 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! Left some comments about crates we can likely remove from the pool-system deps.

pallets/pool-system/src/tests/mod.rs Show resolved Hide resolved
pallets/pool-system/src/lib.rs Show resolved Hide resolved
@NunoAlexandre
Copy link
Contributor Author

I would really like us to stick with the naming for upgrades, so use UpgradeAltair1028 instead of just the plain migration. Makes it so much easier in the future to remove what needs to be removed.

Otherwise, looks good!

For approval:

Need clarification whether the following will never fail:

  • let location: MultiLocation = old_location.clone().try_into().map_err(|()| Error::<T>::BadVersion)?;

@mustermeiszer what's the context for this code snippet? 🤔

@mustermeiszer
Copy link
Collaborator

Just the only error that could happen behind the expect call in the upgrade logic. Not really a blocker though. . Was just curious or wanted to be sure they expect never gets triggered

@NunoAlexandre
Copy link
Contributor Author

Just the only error that could happen behind the expect call in the upgrade logic. Not really a blocker though. . Was just curious or wanted to be sure they expect never gets triggered

Yeah, that's a valid concern. Maybe we can just log in case it fails?

@NunoAlexandre
Copy link
Contributor Author

@wischli @mustermeiszer I believe I have addressed everything, thanks for the feedback and I look forward for the next round :)

mustermeiszer
mustermeiszer previously approved these changes May 15, 2023
Copy link
Collaborator

@mustermeiszer mustermeiszer left a comment

Choose a reason for hiding this comment

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

LGTM!

@NunoAlexandre NunoAlexandre enabled auto-merge (squash) May 16, 2023 09:26
wischli
wischli previously approved these changes May 16, 2023
Copy link
Contributor

@wischli wischli left a comment

Choose a reason for hiding this comment

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

LGTM! I left two nitpicks which definitely don't need to be addressed.

UPDATE: Seeing the conflicts, I would recommend to move your runtime migration code into its own module inside runtime/$runtime/migrations.rs. In #1342, I ensured all imports tied to a specific migration where part of the module's scope such that deprecated migrations can be removed seamlessly without breaking clippy.

runtime/altair/src/migrations.rs Outdated Show resolved Hide resolved
runtime/altair/src/migrations.rs Outdated Show resolved Hide resolved
@NunoAlexandre NunoAlexandre dismissed stale reviews from wischli and mustermeiszer via ad08698 May 16, 2023 14:59
mustermeiszer
mustermeiszer previously approved these changes May 16, 2023
@NunoAlexandre
Copy link
Contributor Author

@wischli @mustermeiszer could you approve this again? :)

Copy link
Contributor

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

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

Re-approving based on previous approvals 😃

@NunoAlexandre NunoAlexandre merged commit 9239998 into main May 17, 2023
@lemunozm lemunozm deleted the refactor/drop-tranche-multilocation branch May 17, 2023 09:14
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.

Drop Tranche location
6 participants