XcmPaymentApi: take into account AH sufficient assets#6033
XcmPaymentApi: take into account AH sufficient assets#6033mrshiposha wants to merge 1 commit intoparitytech:masterfrom
Conversation
acatangiu
left a comment
There was a problem hiding this comment.
Asset sufficiency does not mean asset can be directly used for paying fees.
For finding assets that can be (indirectly) used for paying fees, you need to check the list of pools. Specifying any asset in a pool paired with DOT/KSM/WND as the fee payment asset, will result in just-in-time auto swap for DOT just enough to pay for fees.
Maybe we actually need some other runtime API for exposing list of active pools if we don't have it already?
@franciscoaguirre has more info
| let assets = Assets::sufficient_assets() | ||
| .filter_map(|asset_id| TrustBackedAssetsPalletLocation::get().appended_with(GeneralIndex(asset_id.into())).ok().map(AssetId)); | ||
| let foreign_assets = ForeignAssets::sufficient_assets() | ||
| .map(AssetId); |
There was a problem hiding this comment.
Asset sufficiency doesn't mean it can be used to buy weight, i.e. directly pay for fees.
Asset sufficiency only means the asset is sufficient for the account to exist, i.e. you doesn't require DOT ED on that account to hold a sufficient asset.
This code is incorrect as it will return assets as suitable for directly paying fees which is not the case. I suggest you always add a simple emulator test to PoC any XCM config change.
There was a problem hiding this comment.
Asset sufficiency doesn't mean it can be used to buy weight, i.e. directly pay for fees.
Hmm, there are comments in the code stating the opposite...
Also, I ran Westend AssetHub locally. I haven't set up the pools, but sufficient assets (both from Assets and ForeignAssets) worked as XCM execution fees. The code under the linker above provides this functionality.
There was a problem hiding this comment.
There are even tests for that:
- ForeignAssets:
- Assets:
There was a problem hiding this comment.
ah yes, it is unfortunate that the TakeFirstAssetTrader is still there.. afaik the plan was to remove it once we have some pools set up and can rely on the one above it SwapFirstAssetTrader.
The reason to remote TakeFirstAssetTrader is that it doesn't (and can't) correctly account the economic value of weight. Depending on market movements buying weight with sufficient assets can be abused to potentially severely undercut fees.
AFAIK the plan still is to remove TakeFirstAssetTrader from system chains.
(opened polkadot-fellows/runtimes#475 to track this)
|
I think this is superseeded by #5599? |
|
Yes, sufficient assets should only mean valid for ED but not necessarily for fees |
|
@mrshiposha does #5599 cover your needs? |
|
Closing in favor of #5599 |
Description
This PR provides:
sufficient_assetsfunction to thepallet-assets.query_weight_to_asset_fee.