Skip to content

Send messages using xcm pallet#1518

Merged
svyatonik merged 13 commits into
masterfrom
send-messages-using-xcm-pallet
Jul 27, 2022
Merged

Send messages using xcm pallet#1518
svyatonik merged 13 commits into
masterfrom
send-messages-using-xcm-pallet

Conversation

@svyatonik
Copy link
Copy Markdown
Contributor

@svyatonik svyatonik commented Jul 20, 2022

closes #1512

TODOs:

  • do we still need an ability to send messages using messages pallet directly?;
  • add RialtoParachain to Millau XCM configuration (and vice versa);
  • impl encode_send_xcm for remaining chains;
  • tests;
  • use in deployments/

@svyatonik svyatonik marked this pull request as ready for review July 27, 2022 11:57
@svyatonik
Copy link
Copy Markdown
Contributor Author

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.

@svyatonik svyatonik enabled auto-merge (squash) July 27, 2022 12:14
@svyatonik svyatonik merged commit 9ad43b6 into master Jul 27, 2022
@svyatonik svyatonik deleted the send-messages-using-xcm-pallet branch July 27, 2022 12:15
/// Encode a send XCM call of the XCM pallet.
fn encode_send_xcm(
message: xcm::VersionedXcm<()>,
bridge_instance_index: u8,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Could we use the FullBridge enum here directly ?

Comment on lines +37 to +65
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
),
})
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())

Comment on lines +38 to +54
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),
),
);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a good idea

Comment thread bin/runtime-common/src/messages.rs
}

let route = T::build_destination();
let msg = (route, msg.take().unwrap()).encode();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check the msg first and return MissingArgument if it is none ? Instead of panicking.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - that's obviously my fault. Can you, please, fix it? Thank you

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks for the answers. I will implement them in a follow-up PR.

Comment thread bin/millau/runtime/src/xcm_config.rs
fee.cast().into(),
data.bridge.bridge_instance_index(),
)?;
let send_message_call = if data.use_xcm_pallet {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits, not related to this PR:

  1. I think that we can modify estimate_message_delivery_and_dispatch_fee to receive a reference to the payload in order to avoid cloning it. If we handle very large messages, this should help.
  2. 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 }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Is this line needed ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, thanks for spotting!

Comment on lines +309 to +312
/// The Millau network ID, associated with Kusama.
pub const MillauNetwork: NetworkId = Kusama;
/// The RialtoParachain network ID, associated with Westend.
pub const ThisNetwork: NetworkId = Westend;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it might be something simple, but I couldn't udnerstand it so far. Why is MillauNetwork == Kusama and ThisNetwork == Westend ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@serban300 serban300 mentioned this pull request Aug 11, 2022
svyatonik pushed a commit that referenced this pull request Aug 12, 2022
* 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>
@serban300
Copy link
Copy Markdown
Collaborator

The comments were addressed in #1546

Marking this PR as reviewed.

jiguantong added a commit to darwinia-network/darwinia-messages-substrate that referenced this pull request Oct 27, 2022
jiguantong added a commit to darwinia-network/darwinia-parachain that referenced this pull request Oct 31, 2022
jiguantong pushed a commit to darwinia-network/darwinia-messages-substrate that referenced this pull request Apr 13, 2023
svyatonik pushed a commit that referenced this pull request Jul 17, 2023
* 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>
serban300 pushed a commit to serban300/parity-bridges-common that referenced this pull request Mar 27, 2024
* 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
serban300 added a commit to serban300/parity-bridges-common that referenced this pull request Mar 27, 2024
* 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>
serban300 pushed a commit to serban300/parity-bridges-common that referenced this pull request Apr 8, 2024
* 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
serban300 added a commit to serban300/parity-bridges-common that referenced this pull request Apr 8, 2024
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Send messages using XCM pallet in the RialtoParachain <> Millau bridge

2 participants