Implement assets forwarder pallet - #67
Conversation
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
|
|
||
| /// Location of the local `pallet-assets` instance the forwarded assets live in. Asset ids | ||
| /// are appended to it as `GeneralIndex` junctions and reanchored to the destination. | ||
| type AssetsPalletLocation: Get<Location>; |
There was a problem hiding this comment.
Maybe this can be deducted from the pallet assets. The index is available through the trait PalletInfo or PalletInfoAccess, then I believe it is standard to make the location of the asset 'Here, PalletIndex, GeneralIndex'.
On the other hand if we wanted to support the forward of foreign asset in this pallet then we would need to specify None as the location here I guess, so that forwarded asset like Eth would keep their same location on the destination (converted to the destination point of view).
It is just a nit, anyway the code will be fine.
| type DestinationAccountOf: ConvertLocation<Self::AccountId>; | ||
|
|
||
| /// Converts an asset id into the `GeneralIndex` value of its location. | ||
| type AssetIdToIndex: Convert<Self::AssetId, u128>; |
There was a problem hiding this comment.
Or you can change this to asset id to location and remove the associated type pallet assets location.
So it would support both local assets and foreign assets, foreign assets would convert to themselves.
(Also given Hollar is already created on PC, we would need to take it into account if we ever support foreign asset forwarding. We would need to do a migration to put the forwarded value in the state here on AH, or maybe let the force create fail on PC, anyway not an concern for now)
There was a problem hiding this comment.
It will just fail on PC, no harm done and state on AH will be updated.
There was a problem hiding this comment.
what would fail on PC? The Hollar forwarding? yes true, we don't even need migration. but this is not my main comment:
My proposition is to generalize this pallet by improving the Config trait:
- remove
AssetsPalletLocationandAssetIdToIndex - introduce
AssetIdToLocation.
So we could support AH foreign assets to be forwarded to PC as well in the future using the same pallet.
| let message = Self::build_remote_xcm(&create); | ||
| let message_id = Self::send_remote_xcm(origin, message)?; | ||
|
|
||
| ForwardedAssets::<T, I>::insert( |
There was a problem hiding this comment.
Here you assume all went well so I wonder if we don't need a mechanism to handle failures.
For example clearing the ForwardedAssets entry via an origin-gated call.
There was a problem hiding this comment.
using TechnicalMaintenance instead of root would help indeed.
There was a problem hiding this comment.
Added a call to remove the entry.
| let details = | ||
| pallet_assets::Asset::<T, I>::get(&asset_id).ok_or(Error::<T, I>::UnknownAsset)?; | ||
| ensure!( | ||
| details.status == pallet_assets::AssetStatus::Live, |
There was a problem hiding this comment.
Should we also check if details.min_balance is not zero?
There was a problem hiding this comment.
I think it should be fine. I don't see why we should limit what is on AH, if the asset is min balance 0, it is likely not sufficient, or maybe only distributed to some specific individuals.
There was a problem hiding this comment.
We should aim to mirror the state 1:1 with AH and this also lets us keep this pallet simple. I don't want to reinvent another pallet-assets.
| Error::<T, I>::AssetNotLive | ||
| ); | ||
| ensure!( | ||
| record.min_balance != details.min_balance || |
There was a problem hiding this comment.
If these assets can be created by anyone, then the owner could be changing these values and requesting the sync without limit.
There was a problem hiding this comment.
Yes but they pay for the call. They can manually send it even without this particular call wrapper in this pallet by going straight to pallet-xcm. Obviously it will just fail on arrival and it will burn funds, so it's not a valid attack.
There was a problem hiding this comment.
the execution fee on the destination chain is waived, but it isn't much, the delivery fee are still charged at the moment.
We can probably ignore or charge a little more with a configurable constant.
| freezer: MultiAddress::Id(owner), | ||
| min_balance: details.min_balance, | ||
| is_sufficient: details.is_sufficient, | ||
| is_frozen: false, |
There was a problem hiding this comment.
Can there be a scenario where the remote chain froze an asset on purpose?
In such a scenario this call would unfreeze it.
There was a problem hiding this comment.
No, the remote chain isn't a "sovereign" 3rd party parachain, it's a system chain answering to the same governance as PC, therefore it does not need to assert control over the assets mirrored from AH.
There was a problem hiding this comment.
if we introduce some test using the XCM emulator similarly to what exists on fellowship/runtimes we could have more accurate testing maybe. Anyway it is ok for now.
There was a problem hiding this comment.
I'd defer this for later.
gui1117
left a comment
There was a problem hiding this comment.
Some nits were opened: refactor of the config types and add an assertion to the benchmark. Otherwise all looks good.
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
| /// destination is untouched, so a later re-forward fails there while the replica exists. | ||
| #[pallet::call_index(2)] | ||
| #[pallet::weight(<T as Config<I>>::WeightInfo::remove_forwarded_asset())] | ||
| pub fn remove_forwarded_asset( |
There was a problem hiding this comment.
Note that this doesn't cover the failure of sync_asset_status.
If we remove the forwarded asset, then the next call to forward_asset will re-recreate the entry and the XCM will fail, and sync_asset_status can't be called because the entry exists and is up to date.
This PR adds permissionless forwarding of assets from one chain to another (built for AH to PC trust backed asset registration). As in the paseo example in our repo, the assets being forwarded are force created and can only be minted via XCM transfers and are usable in pools. Force creation means there will be no issuer, so nobody can alter the issuance outside of XCM transfers, which are checked on AH. The owner of these assets will be the forwarder pallet on AH. An existing asset (like HOLLAR on PC) is unaffected as it was force created before this change.
Still TODO:
In another PR, we would need to port this to Polkadot runtimes.