Follow-up on #1518 (#1546)

* 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 3a0a950e1d7484e3ecac45f5c00b152f0485cd11.

Signed-off-by: Serban Iorga <serban@parity.io>
This commit is contained in:
Serban Iorga
2022-08-12 12:05:46 +03:00
committed by Bastian Köcher
parent 050b12f3aa
commit e0b42dfae7
11 changed files with 89 additions and 72 deletions
@@ -100,7 +100,7 @@ where
data.conversion_rate_override,
Self::ESTIMATE_MESSAGE_FEE_METHOD,
lane,
payload,
&payload,
)
.await?;
@@ -141,7 +141,7 @@ pub(crate) async fn estimate_message_delivery_and_dispatch_fee<
conversion_rate_override: Option<ConversionRateOverride>,
estimate_fee_method: &str,
lane: bp_messages::LaneId,
payload: P,
payload: &P,
) -> anyhow::Result<BalanceOf<Source>> {
// actual conversion rate CAN be lesser than the rate stored in the runtime. So we may try to
// pay lesser fee for the message delivery. But in this case, message may be rejected by the
@@ -196,7 +196,7 @@ pub(crate) async fn estimate_message_delivery_and_dispatch_fee<
client,
estimate_fee_method,
lane,
payload.clone(),
payload,
None,
)
.await?;
@@ -204,7 +204,7 @@ pub(crate) async fn estimate_message_delivery_and_dispatch_fee<
client,
estimate_fee_method,
lane,
payload.clone(),
payload,
conversion_rate_override,
)
.await?;
@@ -227,7 +227,7 @@ async fn do_estimate_message_delivery_and_dispatch_fee<Source: Chain, P: Encode>
client: &relay_substrate_client::Client<Source>,
estimate_fee_method: &str,
lane: bp_messages::LaneId,
payload: P,
payload: &P,
conversion_rate_override: Option<FixedU128>,
) -> anyhow::Result<BalanceOf<Source>> {
let encoded_response = client
@@ -121,13 +121,13 @@ where
conversion_rate_override,
Self::ESTIMATE_MESSAGE_FEE_METHOD,
lane,
payload.clone(),
&payload,
)
.await?
.into(),
),
};
let payload_len = payload.encode().len();
let payload_len = payload.encoded_size();
let send_message_call = if data.use_xcm_pallet {
Self::Source::encode_send_xcm(
decode_xcm(payload)?,