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
+23
View File
@@ -20,6 +20,7 @@
use bp_runtime::FilterCall;
use sp_runtime::transaction_validity::TransactionValidity;
use xcm::v3::NetworkId;
pub mod messages;
pub mod messages_api;
@@ -119,6 +120,28 @@ macro_rules! generate_bridge_reject_obsolete_headers_and_messages {
};
}
/// A mapping over `NetworkId`.
/// Since `NetworkId` doesn't include `Millau`, `Rialto` and `RialtoParachain`, we create some
/// synthetic associations between these chains and `NetworkId` chains.
pub enum CustomNetworkId {
/// The Millau network ID, associated with Kusama.
Millau,
/// The Rialto network ID, associated with Polkadot.
Rialto,
/// The RialtoParachain network ID, associated with Westend.
RialtoParachain,
}
impl CustomNetworkId {
pub const fn as_network_id(&self) -> NetworkId {
match *self {
CustomNetworkId::Millau => NetworkId::Kusama,
CustomNetworkId::Rialto => NetworkId::Polkadot,
CustomNetworkId::RialtoParachain => NetworkId::Westend,
}
}
}
#[cfg(test)]
mod tests {
use crate::BridgeRuntimeFilterCall;
+1 -1
View File
@@ -569,7 +569,7 @@ pub mod source {
}
let route = T::build_destination();
let msg = (route, msg.take().unwrap()).encode();
let msg = (route, msg.take().ok_or(SendError::MissingArgument)?).encode();
let fee = estimate_message_dispatch_and_delivery_fee::<T::MessageBridge>(
&msg,