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

Foreign assets creation via token reserve #3104

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

gonzamontiel
Copy link
Contributor

@gonzamontiel gonzamontiel commented Dec 13, 2024

What does it do?

  • Changes extrinsic create_foreign_asset so that reserves a deposit from the user to be able to create a new foreign asset
  • The deposit amount is configurable by the pallet's configuration: ForeignAssetCreationDeposit
  • A new storage map stores the asset creator, and the amount reserved at creation, by asset id. The creator is an enumn that allows to be Governance (for old or migrated assets), and any account for new assets.
  • The origin check for any other operation with the created asset (freeze, unfreeze, change location) remains the same as before.

⚠️ Breaking Changes ⚠️

  • The extrinsic create_foreign_asset can be executed by any account, by making a deposit in the native token.
  • The deposits are:
    • Moonbase: 100 DEV
    • Moonriver: 1000 MOVR
    • Moonbeam: 10000 GLMR

Disclaimer: the pallet is not in use and the functionality wasn't exposed publicly AFAIK. The changes are still breaking, but most likely harmless.

TODO

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

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: 2280 KB (no changes) ✅

Moonbeam runtime: 2260 KB (no changes) ✅

Moonriver runtime: 2264 KB (no changes) ✅

Compared to latest release (runtime-3400)

Moonbase runtime: 2280 KB (+252 KB compared to latest release) ⚠️

Moonbeam runtime: 2260 KB (+248 KB compared to latest release) ⚠️

Moonriver runtime: 2264 KB (+252 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
Copy link
Contributor

github-actions bot commented Jan 7, 2025

Coverage Report

@@                          Coverage Diff                           @@
##           master   gonza/foreign-assets-via-token-lock     +/-   ##
======================================================================
  Coverage   74.49%                                74.49%   0.00%     
  Files         375                                   375             
+ Lines       95313                                 95407     +94     
======================================================================
+ Hits        70998                                 71066     +68     
+ Misses      24315                                 24341     +26     
Files Changed Coverage
/pallets/moonbeam-foreign-assets/src/lib.rs 76.13% (+1.31%) 🔼
/pallets/moonbeam-foreign-assets/src/mock.rs 87.69% (+0.80%) 🔼
/runtime/moonbase/src/runtime_params.rs 40.00% (-2.86%) 🔽
/runtime/moonbeam/src/runtime_params.rs 40.00% (-2.86%) 🔽
/runtime/moonriver/src/runtime_params.rs 40.00% (-2.86%) 🔽

Coverage generated Wed Jan 8 04:37:47 UTC 2025

@gonzamontiel gonzamontiel marked this pull request as ready for review January 8, 2025 04:06
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.

I still need to get more context about this feature, will probably ping you later.

Added a few remarks for now.

@@ -121,7 +122,7 @@ pub mod pallet {
pub const PALLET_ID: frame_support::PalletId = frame_support::PalletId(*b"forgasst");

#[pallet::config]
pub trait Config: frame_system::Config + pallet_evm::Config {
pub trait Config: frame_system::Config + pallet_evm::Config + scale_info::TypeInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub trait Config: frame_system::Config + pallet_evm::Config + scale_info::TypeInfo {
pub trait Config: frame_system::Config + pallet_evm::Config {

@@ -75,6 +76,11 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}

fn create_foreign_asset_reserve() -> Weight {
Weight::default()
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use proper weights, generating it with release profile is file.

Comment on lines +406 to 410
.tx.sudo.sudoAs(
alith.address,
context
.polkadotJs()
.tx.evmForeignAssets.createForeignAsset(assetId, xcmLoc, decimals, symbol, name)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can do a normal call as Alith

Suggested change
.tx.sudo.sudoAs(
alith.address,
context
.polkadotJs()
.tx.evmForeignAssets.createForeignAsset(assetId, xcmLoc, decimals, symbol, name)
.tx.evmForeignAssets.createForeignAsset(assetId, xcmLoc, decimals, symbol, name)

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 breaking Needs to be mentioned in breaking changes D9-needsaudit👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants