-
Notifications
You must be signed in to change notification settings - Fork 41
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
Configure and test whitelisted XCM reserve transfers #661
Merged
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
sea212
changed the title
Reorganize XCM configuration
Whitelist, test and configure aUSD XCM reserve transfers
Jun 4, 2022
sea212
changed the title
Whitelist, test and configure aUSD XCM reserve transfers
Configure and test whitelisted XCM reserve transfers
Jun 6, 2022
- Add TokenInfo macro and implementation for Asset type - Add fee per second functions for all supported currencies - Use uppercase names for currencies in Asset enum
sea212
added
s:on-hold
Work on the pull request has been paused
and removed
s:in-progress
The pull requests is currently being worked on
labels
Jul 26, 2022
sea212
added
s:in-progress
The pull requests is currently being worked on
and removed
s:on-hold
Work on the pull request has been paused
labels
Aug 17, 2022
Co-authored-by: Chralt <[email protected]>
Chralt98
reviewed
Nov 23, 2022
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.
Just a couple more comments.
Co-authored-by: Chralt <[email protected]>
Co-authored-by: Chralt <[email protected]>
Chralt98
reviewed
Nov 23, 2022
runtime/battery-station/src/integration_tests/xcm/tests/currency_id_convert.rs
Outdated
Show resolved
Hide resolved
runtime/battery-station/src/integration_tests/xcm/tests/currency_id_convert.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Chralt <[email protected]>
Just waiting for #850.. |
sea212
added
s:review-needed
The pull request requires reviews
and removed
s:in-progress
The pull requests is currently being worked on
labels
Nov 24, 2022
Chralt98
approved these changes
Nov 24, 2022
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.
Ok, let's try that! Happy inter-chain talk.
vivekvpandya
approved these changes
Nov 25, 2022
vivekvpandya
added
s:accepted
This pull request is ready for merge
and removed
s:review-needed
The pull request requires reviews
labels
Nov 25, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
This PR adjusts the XCM configuration to only allow the necessary XCM instruction necessary to execute a reserve transfer. Asset teleports are disabled (needs trust).
By default no foreign assets are registered. The
AssetRegistry
pallet is used to register foreign asset, which are identified byCurrencyId::ForeignAsset(id)
. TheAssetRegistry
holds all necessary information about an asset, such as the location, existential deposit, name and the number of decimal fractional places. It also contains some custom metadata, which specifies if the asset can be used in a pool and how fees should be determined. Assets can only be added through governance.Whenever a foreign asset is received, the XCM implementation checks if it convert it to a local
CurrencyId
representation. It either maps the Zeitgeist parachain multilocation toCurrencyId::Ztg
, or queries the asset registry for that multilocation. In case the conversion succeeds, balance updates will happen accordingly. If the multilocation cannot be resolved, theUnknownTokens
pallet will be used to store those transferred tokens. XCM currently uses unidirectional channels and there is no response that lets the sender know if the operation succeeded. When another chain has an open channel to Zeitgeist and sends the XCM to reserve transfer some asset, the sending chain already locally updated the token balances to match the transfer. However, at that point in time it does not know if it will succeed in the destination chain. To avoid Zeitgeist receiving reserve asset transfers and just dropping them because the instructions cannot be handled (token conversion failed), theUnknownTokens
pallet keeps track of those unknown tokens.The fee for XCM transfers is calculated based on a formula that is used across all projects. The fees are always taken from the token that is received, such as KSM. Using the
AssetRegistry
custom metadata, one can specify a multiplier that is used to adjust fees. For example, if 1 KSM is 10x the worth of 1 ZTG, a 10x multiplier must be specified. Those multiplier can be updated through governance. All the fees are put into the treasury for now.A
Barrier
does specify whether XCM instructions should be executed. Such a barrier could include the constraint that execution time must be paid using theBuyExecution
XCM instruction. The barriers in place in this PR are restrictive default barriers used by most projects.Reserve Asset Transfers can be executed by calling the dispatchable
transfer
from the newly addedxTokens
pallet. It will ensure the XCM message is crafted properly and send it to the destination chain.The PR adds integration tests that simulate a relay chain and multiple parachains to verify that only the XCM instructions of interest can be executed and that only the whitelisted chains and assets can be transferred. It tests that transfers to and from another parachain and transfer to and from the parent chains works. It checks that fees are correctly calculated and deducted, that all account balances are updated accordingly, that the sovereign account balances are updated accordingly and that the fees are properly put into the treasury. It also tests that custom fees from the
AssetRegistry
calculated properly.