8000 Allow sibling chains to create foreign assets by gonzamontiel · Pull Request #3104 · moonbeam-foundation/moonbeam · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow sibling chains to create foreign assets #3104

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

Merged
merged 113 commits into from
Feb 20, 2025

Conversation

gonzamontiel
Copy link
Contributor
@gonzamontiel gonzamontiel commented Dec 13, 2024

What does it do?

  • Introduces a new origin ForeignAssetOwnerOrigin. It validates that the origin is an XCM location, that contains another location. This is useful to validate that a parachain can create or modify an asset only if it contains the asset. It's based on an implementation of xcm_simulator.
  • The allowed XCM origins are defined by LocationToAccountId
  • The above origin affects all extrinsics inside the moonbeam foreign assets pallet
  • create_foreign_asset now reserves a deposit from the caller (i.e. parachain sovereign accounts)
  • The deposit amount is configurable (ForeignAssetCreationDeposit) and can be changed with pallet_parameters
  • A new storage maps the asset creator, and the amount reserved at creation, by asset id. The creator is an enum that allows to be Governance (for old or migrated assets), and any account for new assets.

Non-breaking Changes

  • The extrinsics create_foreign_asset, change_xcm_location, freeze_foreign_asset, unfreeze_foreign_asset can now be called by a Parachain Location origin (through XCM) or Governance.
  • When calling create_foreign_asset from a Sibling Parachain, it requires a deposit of funds that is configurable in the pallet.
  • When calling from Governance, the deposit is not required.
  • The deposit will be taken from the sovereign account of the caller of create_foreign_asset
  • The initial deposit values are:
    • Moonbase: 100 DEV
    • Moonriver: 1000 MOVR
    • Moonbeam: 10000 GLMR

TODO

  • Make deposit amount configurable (and changable with pallet parameters)
  • Modify foreign assets migration to add the old assets to the new storage
  • Add tests

What important points reviewers should know?

Some assumptions were made considering the current state of the pallet:

  • There are no foreign assets yet created in live chains
  • The AssetOwner was meant initially to be a descriptive enum of the possible sources of creation of an asset, but since there were no assets yet created, we only need to distinguish between migrated assets, and the ones created from now on (any account). Naming in this enum might be improved.
  • The Foreign assets migration was modified to mark the migrated assets in the storage and distinguish them from the newly created ones.

Is there something left for follow-up PRs?

What alternative implementations were considered?

Using Fungibles was investigated, but the implementation uses ReservableCurrency, following the same pattern as pallet assets.

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

We should run the migration added here #3020 after this PR is merged.

What value does it bring to the blockchain users?

It should be easier for Parachain teams to register their assets natively in Moonbeam

@gonzamontiel gonzamontiel changed the title Gonza/foreign assets via token lock Foreign assets creation via token reserve Dec 13, 2024
@gonzamontiel gonzamontiel added D9-needsaudit👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited breaking Needs to be mentioned in breaking changes B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D1-runtime-migration PR introduces code that might require downstream chains to run a runtime upgrade. and removed D1-runtime-migration PR introduces code that might require downstream chains to run a runtime upgrade. labels Dec 13, 2024
Copy link
Contributor
github-actions bot commented Dec 13, 2024

WASM runtime size check:

Compared to target branch

Moonbase runtime: 2420 KB (no changes) 🚨

Moonbeam runtime: 2408 KB (+8 KB) 🚨

Moonriver runtime: 2412 KB (+12 KB) 🚨

Compared to latest release (runtime-3501)

Moonbase runtime: 2420 KB (+468 KB compared to latest release) 🚨

Moonbeam runtime: 2408 KB (+468 KB compared to latest release) 🚨

Moonriver runtime: 2412 KB (+472 KB compared to latest release) 🚨

@gonzamontiel gonzamontiel marked this pull request as ready for review January 7, 2025 12:47
@gonzamontiel gonzamontiel marked this pull request as draft January 7, 2025 14:27
@TarekkMA TarekkMA requested a review from RomarQ February 17, 2025 21:11
Copy link
Contributor
@RomarQ RomarQ left a comment

Choose a reason for hiding this comment

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

Added a few remarks, the overall changes look good.

We have redundant tests, which may add technical debt to maintain them. (Correct me if I am wrong, but I think what is being tested in file test/suites/dev/moonbase/test-assets/test-foreign-assets-xcm-freeze.ts, was tested implicitly in other tests)

@TarekkMA TarekkMA requested a review from stiiifff February 19, 2025 10:12
@RomarQ RomarQ changed the title Foreign assets creation via token reserve Allow sibling chains to create foreign assets Feb 19, 2025
@RomarQ
Copy link
Contributor
RomarQ commented Feb 19, 2025

@pLabarta @TarekkMA we need to update the description. I think this PR no-longer adds breaking changes.

@RomarQ RomarQ removed the breaking Needs to be mentioned in breaking changes label Feb 19, 2025
@RomarQ RomarQ added the not-breaking Does not need to be mentioned in breaking changes label Feb 19, 2025
@RomarQ RomarQ merged commit d474a05 into master Feb 20, 2025
45 of 46 checks passed
@RomarQ RomarQ deleted the gonza/foreign-assets-via-token-lock branch February 20, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D9-needsaudit👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited not-breaking Does not need to be mentioned in breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0