here() should be a self-reserve#697
Conversation
Codecov Report
@@ Coverage Diff @@
## master #697 +/- ##
==========================================
- Coverage 74.63% 74.62% -0.01%
==========================================
Files 83 83
Lines 7261 7264 +3
==========================================
+ Hits 5419 5421 +2
- Misses 1842 1843 +1
Continue to review full report at Codecov.
|
|
Can you add some tests here |
|
the then open-runtime-module-library/xtokens/src/lib.rs Lines 750 to 754 in 4a66b29 |
|
@zqhxuyuan I am not sure changing pub SelfLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into()))); to pub SelfLocation: MultiLocation = MultiLocation::here();is not a super good idea given how does the current tests are written. For example: pub struct CurrencyIdConvert;
impl Convert<CurrencyId, Option<MultiLocation>> for CurrencyIdConvert {
fn convert(id: CurrencyId) -> Option<MultiLocation> {
match id {
CurrencyId::R => Some(Parent.into()),
CurrencyId::A => Some((Parent, Parachain(1), GeneralKey("A".into())).into()),
CurrencyId::A1 => Some((Parent, Parachain(1), GeneralKey("A1".into())).into()),
CurrencyId::B => Some((Parent, Parachain(2), GeneralKey("B".into())).into()),
CurrencyId::B1 => Some((Parent, Parachain(2), GeneralKey("B1".into())).into()),
}
}
}The way how to convert |
|
@stechu yeah, you're right, there'll be failed testcases if change SelfLocation to Here. in this PR you add another gate to open-runtime-module-library/xtokens/src/lib.rs Lines 753 to 754 in 4a66b29 could you tried set SelfLocation to (1, Parachain(id)) in your testcase and validate if still failed? PS: I've add another testcase with parachain(3), seems it's ok without your PR here. https://github.com/open-web3-stack/open-runtime-module-library/pull/699/files |
| // children parachain | ||
| (0, Some(Parachain(id))) => Some(MultiLocation::new(0, X1(Parachain(*id)))), | ||
| // self reserve | ||
| // All asset that is not a children parachain is a self reserved asset |
There was a problem hiding this comment.
One of chain_part use case is to check user errors on dest param in xtokens calls.
Changes in this PR will make any random dest has valid chain part.
It will also make any multi assets has valid reserve.
There was a problem hiding this comment.
The core issue here is that the new reanchoring logic encourage a "relative path" point of view of MultiLocation. For example, if the current working parachain ID is 1. Then, the following two MultiLocations should be equivalent:
../Parachain(1)/xxxxxxThe previous ORML design and tests are leaning towards always using the first case. This is fine, but I think using the second case should be encouraged since it simpler.
I think at end of the day, it really matters what is the opinionated view of how a local asset's location should be represented. In my view (seems also by Parity), your own parachain balance should be:
here()instead of
../Parachain(your_own_id)The asset on your own should be
./asset_locationinstead of:
../Parachain(your_own_id)/asset_locationPS:
It will also make any multi assets has valid reserve.
Not really, see the updated new test.
There was a problem hiding this comment.
ORML uses "absolute" location path on purpose. One of the benefit is to be compatible with token location register module we planned. It's a design choice, instead of which point of view we preferred to see assets on our own parachain.
I think using the second case should be encouraged since it simpler.
I don't see how it makes implementation and integration simpler, but it needs to cover more edge cases.
I think at end of the day, it really matters what is the opinionated view of how a local asset's location should be represented. In my view (seems also by Parity), your own parachain balance should be:
XCM executor is designed to be flexible and in the end it's parachains choice to decide how to convert between multi location and their local currency. Not sure about what you mean by Parity's view.
If ORML impl changed to relative location path design, the way how params are used in xtokens would be very different. It's not just how local asset are represent but also foreign locations in dest and assets. It would be a breaking change.
There was a problem hiding this comment.
One way that we could fullfil both requests is to introduce a new pub trait ReserveCalculator like
pub trait ReserveCalculator {
/// Calculates a reserve location of a multiasset.
fn calculate_reserve(&MultiAsset) -> Option<MultiLocation>;
}
And add a new associated type in the config of orml_xtokens
/// Reserve Calculator
type ReserveCalculator: ReserveCalculator;
That way xtokens is not tied to a specific way of seeing self tokens (absolute vs relative) and each runtime can configure it indepentently
There was a problem hiding this comment.
we got Reserve trait already, if we want expose a trait, I think we could use Reserve and make some adjustment.
open-runtime-module-library/traits/src/location.rs
Lines 43 to 46 in 4a66b29
|
@zqhxuyuan @shaunxw @xlc Thanks for the code review. I think we should reach the consensus of the design decision here first. For example:
For example, it is perfectly fine to set However, it does requires change the test of |
Under the new re-anchoring logic, it is advised to use
here()to be the sender location, in this case, ORML should allowhere()to be a self-reserve.The related test code on Manta:
https://github.com/Manta-Network/Manta/blob/xcm-v4/runtime/dolphin/tests/xcm_tests.rs#L286