Send messages using xcm pallet#1518
Conversation
|
One important note Rialto -> Millau messages are still being sent using messages pallet. The reason is that the rational relayer is unable to deliver XCM messages if they're sent without conversion rate override (and when the on-chain rate is obsolete). Let it be here for some time - I have a feeling that we may still need rational relayer in the future. |
| /// Encode a send XCM call of the XCM pallet. | ||
| fn encode_send_xcm( | ||
| message: xcm::VersionedXcm<()>, | ||
| bridge_instance_index: u8, |
There was a problem hiding this comment.
Nit: Could we use the FullBridge enum here directly ?
| Ok(match bridge_instance_index { | ||
| bridge::MILLAU_TO_RIALTO_INDEX => { | ||
| let dest = | ||
| (Parent, X1(GlobalConsensus(millau_runtime::xcm_config::RialtoNetwork::get()))); | ||
| millau_runtime::Call::XcmPallet(millau_runtime::XcmCall::send { | ||
| dest: Box::new(dest.into()), | ||
| message: Box::new(message), | ||
| }) | ||
| .into() | ||
| }, | ||
| bridge::MILLAU_TO_RIALTO_PARACHAIN_INDEX => { | ||
| let dest = ( | ||
| Parent, | ||
| X2( | ||
| GlobalConsensus(millau_runtime::xcm_config::RialtoNetwork::get()), | ||
| Parachain(RIALTO_PARACHAIN_ID), | ||
| ), | ||
| ); | ||
| millau_runtime::Call::XcmPallet(millau_runtime::XcmCall::send { | ||
| dest: Box::new(dest.into()), | ||
| message: Box::new(message), | ||
| }) | ||
| .into() | ||
| }, | ||
| _ => anyhow::bail!( | ||
| "Unsupported target bridge pallet with instance index: {}", | ||
| bridge_instance_index | ||
| ), | ||
| }) |
There was a problem hiding this comment.
Since the message is the same for both cases we could de-duplicate this a bit by transforming it into:
let dest = match bridge_instance_index {
bridge::MILLAU_TO_RIALTO_INDEX =>
(Parent, X1(GlobalConsensus(millau_runtime::xcm_config::RialtoNetwork::get()))),
bridge::MILLAU_TO_RIALTO_PARACHAIN_INDEX => (
Parent,
X2(
GlobalConsensus(millau_runtime::xcm_config::RialtoNetwork::get()),
Parachain(RIALTO_PARACHAIN_ID),
),
),
_ => anyhow::bail!(
"Unsupported target bridge pallet with instance index: {}",
bridge_instance_index
),
};
Ok(millau_runtime::Call::XcmPallet(millau_runtime::XcmCall::send {
dest: Box::new(dest.into()),
message: Box::new(message),
})
.into())
| bridge::MILLAU_TO_RIALTO_INDEX => { | ||
| let dest = | ||
| (Parent, X1(GlobalConsensus(millau_runtime::xcm_config::RialtoNetwork::get()))); | ||
| millau_runtime::Call::XcmPallet(millau_runtime::XcmCall::send { | ||
| dest: Box::new(dest.into()), | ||
| message: Box::new(message), | ||
| }) | ||
| .into() | ||
| }, | ||
| bridge::MILLAU_TO_RIALTO_PARACHAIN_INDEX => { | ||
| let dest = ( | ||
| Parent, | ||
| X2( | ||
| GlobalConsensus(millau_runtime::xcm_config::RialtoNetwork::get()), | ||
| Parachain(RIALTO_PARACHAIN_ID), | ||
| ), | ||
| ); |
There was a problem hiding this comment.
This destinations seem very similar to what we check in XcmBridge::verify_destination() (ToRialtoBridge, ToRialtoParachainBridge) and I was wondering if we could have something that we could use in both places.
There was a problem hiding this comment.
Yeah, that's a good idea
| } | ||
|
|
||
| let route = T::build_destination(); | ||
| let msg = (route, msg.take().unwrap()).encode(); |
There was a problem hiding this comment.
Should we check the msg first and return MissingArgument if it is none ? Instead of panicking.
There was a problem hiding this comment.
Yeah - that's obviously my fault. Can you, please, fix it? Thank you
There was a problem hiding this comment.
Sure, thanks for the answers. I will implement them in a follow-up PR.
| fee.cast().into(), | ||
| data.bridge.bridge_instance_index(), | ||
| )?; | ||
| let send_message_call = if data.use_xcm_pallet { |
There was a problem hiding this comment.
Nits, not related to this PR:
- I think that we can modify
estimate_message_delivery_and_dispatch_feeto receive a reference to thepayloadin order to avoid cloning it. If we handle very large messages, this should help. - On the line above we might be able to use
payload.encoded_size(), which should be more efficient.
|
|
||
| # Polkadot Dependencies | ||
|
|
||
| #pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "gav-xcm-v3", default-features = false } |
There was a problem hiding this comment.
Nit: Is this line needed ?
There was a problem hiding this comment.
Nope, thanks for spotting!
| /// The Millau network ID, associated with Kusama. | ||
| pub const MillauNetwork: NetworkId = Kusama; | ||
| /// The RialtoParachain network ID, associated with Westend. | ||
| pub const ThisNetwork: NetworkId = Westend; |
There was a problem hiding this comment.
Sorry, it might be something simple, but I couldn't udnerstand it so far. Why is MillauNetwork == Kusama and ThisNetwork == Westend ?
There was a problem hiding this comment.
It's just an association - there's this existing NetworkId enum in XCM, but obviously Rialto and Millau are not there. We have also associated Rialto/Millau tokens with Polakdot/Kusama tokens, so this association is kept. For RialtoParachain it's just new association
* Adjustments for the xcm messages sending logic Signed-off-by: Serban Iorga <serban@parity.io> * Deduplicate XCM destination Signed-off-by: Serban Iorga <serban@parity.io> * [send_message] small changes Signed-off-by: Serban Iorga <serban@parity.io> * Define CustomNetworkId Right now we use some associations between Rialto, RialtoParachain and Millau chains and chains defined in the NetworkId enum. But if we are not carreful we might do mistakes like: In Millau: pub const ThisNetwork: NetworkId = Kusama; pub const RialtoNetwork: NetworkId = Polkadot; In Rialto: pub const ThisNetwork: NetworkId = Kusama; pub const MillauNetwork: NetworkId = Polkadot; We're introducing CustomNetworkId to have a centralized mapping between NetworkId chains and our custom chains. Signed-off-by: Serban Iorga <serban@parity.io> * Revert "Deduplicate XCM destination" This reverts commit 3a0a950. Signed-off-by: Serban Iorga <serban@parity.io>
|
The comments were addressed in #1546 Marking this PR as reviewed. |
* changes to read json spec in test binary
* add zombienet tests
* fmt
* use {{COL_IMAGE}} and clean config
* add comment and use relay image from env
* use test-parachain image from pr
* fix warns
* fix warns
* fmt
* typo
* fix ci to use zombienet image
* fix spawn nodes for test
* reorg test
* add within to test
* remove check for full node collators is up
* add tests for pov, mirate solo to para, sync blocks
* bump zombienet image
* add job dep with artifacts
* add sleep for test
* fix after merge
* fmt
* bump zombienet version
* changes from clap
* use base/shared params
* fmt
* debug ci
* add upgrade test
* update js test for debug
* less debug in test
* print assertion
* fix upgrade test
* Collator key only needed if we run as collator
* [Fix] Benchmark build artifact folder creation (#1518)
* Trivial networking changes for Substrate PR #11940 (#1486)
* Trivial networking changes for Substrate PR paritytech/substrate#11940
* Apply formatting rules
* update lockfile for {"polkadot", "substrate"}
Co-authored-by: parity-processbot <>
* bump zombienet version
* update network def for test
* typo
Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
Co-authored-by: Roman Useinov <roman.useinov@gmail.com>
Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com>
* send messages using xcm pallet * XcmBridge && XcmBridgeAdapter + (untested) config in RialtoParachain * impl encode_send_xcm for the rest * remove duplicate code * some fixes * cleanup * some more tests * cleanup * cleanup * send Rialto -> Millau messages using bridge-messages pallet * fmt * some clippy fixes * more clippy
* Adjustments for the xcm messages sending logic Signed-off-by: Serban Iorga <serban@parity.io> * Deduplicate XCM destination Signed-off-by: Serban Iorga <serban@parity.io> * [send_message] small changes Signed-off-by: Serban Iorga <serban@parity.io> * Define CustomNetworkId Right now we use some associations between Rialto, RialtoParachain and Millau chains and chains defined in the NetworkId enum. But if we are not carreful we might do mistakes like: In Millau: pub const ThisNetwork: NetworkId = Kusama; pub const RialtoNetwork: NetworkId = Polkadot; In Rialto: pub const ThisNetwork: NetworkId = Kusama; pub const MillauNetwork: NetworkId = Polkadot; We're introducing CustomNetworkId to have a centralized mapping between NetworkId chains and our custom chains. Signed-off-by: Serban Iorga <serban@parity.io> * Revert "Deduplicate XCM destination" This reverts commit 3a0a950. Signed-off-by: Serban Iorga <serban@parity.io>
* send messages using xcm pallet * XcmBridge && XcmBridgeAdapter + (untested) config in RialtoParachain * impl encode_send_xcm for the rest * remove duplicate code * some fixes * cleanup * some more tests * cleanup * cleanup * send Rialto -> Millau messages using bridge-messages pallet * fmt * some clippy fixes * more clippy
* Adjustments for the xcm messages sending logic Signed-off-by: Serban Iorga <serban@parity.io> * Deduplicate XCM destination Signed-off-by: Serban Iorga <serban@parity.io> * [send_message] small changes Signed-off-by: Serban Iorga <serban@parity.io> * Define CustomNetworkId Right now we use some associations between Rialto, RialtoParachain and Millau chains and chains defined in the NetworkId enum. But if we are not carreful we might do mistakes like: In Millau: pub const ThisNetwork: NetworkId = Kusama; pub const RialtoNetwork: NetworkId = Polkadot; In Rialto: pub const ThisNetwork: NetworkId = Kusama; pub const MillauNetwork: NetworkId = Polkadot; We're introducing CustomNetworkId to have a centralized mapping between NetworkId chains and our custom chains. Signed-off-by: Serban Iorga <serban@parity.io> * Revert "Deduplicate XCM destination" This reverts commit 3a0a950. Signed-off-by: Serban Iorga <serban@parity.io>
closes #1512
TODOs:
encode_send_xcmfor remaining chains;