-
Notifications
You must be signed in to change notification settings - Fork 335
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
EVM foreign assets #2869
Merged
Merged
EVM foreign assets #2869
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
librelois
added
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
breaking
Needs to be mentioned in breaking changes
labels
Jul 16, 2024
This reverts commit 67fc5be.
Agusrodri
reviewed
Jul 22, 2024
Agusrodri
reviewed
Jul 22, 2024
Agusrodri
reviewed
Jul 22, 2024
…o elois-native-foreign-assets
Agusrodri
approved these changes
Jul 24, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Great work @librelois!
noandrea
approved these changes
Jul 25, 2024
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New way to create foreign asset
You need to call
evmForeignAssets.createForeignAsset(assetId, xcmLocation, decimals, symbol, name)
.Allowed origins: FastGeneralAdmin, 5/9 of OpenTechCommittee, Root
Parameters
assetId: u128
arbitrary unique integerxcmLocation: xcm::v4::Location
scale encoded xcm v4 location of asset reserve relative to moonbeamdecimals: u8
metadata that will be returned byERC20.decimals()
symbol: Boundedvec<u8, ConstU32<256>>
metadata that will be returned byERC20.symbol()
(max 256 characters)name: Boundedvec<u8, ConstU32<256>>
metadata that will be returned byERC20.name()
(max 256 characters)Substrate event
evmForeignAssets.ForeignAssetCreated(contractAddress, assetId, xcmLocation)
New way to update foreign asset XCM Location
You need to call
evmForeignAssets.changeXcmLocation(assetId, newXcmLocation)
.Allowed origins: FastGeneralAdmin, 5/9 of OpenTechCommittee, Root
Parameters
assetId: u128
unique identifier of the assetnewXcmLocation: xcm::v4::Location
scale encoded xcm v4 location of asset reserve relative to moonbeamSubstrate event
evmForeignAssets.ForeignAssetXcmLocationChanged(assetId, newXcmLocation)
New way to freeze a foreign asset (freeze all accounts)
You need to call
evmForeignAssets.freezeForeignAsset(assetId, allowXcmDeposit)
.Parameters
assetId: u128
unique identifier of the assetallowXcmDeposit: bool
if set to true XCM deposit will still work and mint tokens, if set to false XCM deposit will fail (no mint).Substrate event
evmForeignAssets.ForeignAssetFrozen(assetId, xcmLocation)
What does it do?
Add a new pallet "pallet-moonbeam-foreign-assets".
The purpose of this new pallet is to manage XCM derivative assets on moonbeam through EVM smart contracts.
Prior to this PR, XCM derivatives assets (aka. "foreign assets") were managed by the pallet asset-manager and the pallet substrate pallet "pallet-asset". The long-term goal is to remove these two pallets from moon$ runtimes (asset-manager and pallet-asset), but before doing so we will first have to migrate all existing foreign assets in production.
This PR only implements the first stage of the plan: creating future foreign assets according to the new design. Subsequent PRs will manage the migration of existing foreign assets and the removal of the two depreciated pallets.
Replacing pallet-asset with evm smart contracts offers several advantages:
What important points reviewers should know?
The new design take care of the compatiblity with existing foreign assets, in particular it identify each foreign assets the same way (with an integer named "AssetId").
Each foreign asset is implemented by an evm smart contract that is deployed by the new pallet.
The evm smart contract for each asset is trusted by the runtime, and must be deployed only by the runtime itself.
The runtime made several assumptions on theses evm smarts contracts:
Is there something left for follow-up PRs?
Subsequent PRs will manage the migration of existing foreign assets and the removal of the two depreciated pallets.
What alternative implementations were considered?
Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?
moonbeam-foundation/frontier#221
TODO