Skip to content

Commit

Permalink
Add BridgeHub to the trusted teleporters for relaychain.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed Nov 8, 2023
1 parent 4d669dc commit 96f6566
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
10 changes: 10 additions & 0 deletions relay/kusama/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ pub mod fee {
}
}

/// System Parachains.
pub mod system_parachain {
/// Asset Hub parachain ID.
pub const ASSET_HUB_ID: u32 = 1000;
/// Encointer parachain ID.
pub const ENCOINTER_ID: u32 = 1001;
/// BridgeHub parachain ID.
pub const BRIDGE_HUB_ID: u32 = 1002;
}

#[cfg(test)]
mod tests {
use super::{
Expand Down
19 changes: 13 additions & 6 deletions relay/kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use frame_support::{
weights::Weight,
};
use frame_system::EnsureRoot;
use kusama_runtime_constants::currency::CENTS;
use kusama_runtime_constants::{currency::CENTS, system_parachain::*};
use runtime_common::{
crowdloan, paras_registrar,
xcm_sender::{ChildParachainRouter, ExponentialPrice},
Expand Down Expand Up @@ -123,14 +123,21 @@ pub type XcmRouter = WithUniqueTopic<(

parameter_types! {
pub const Ksm: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) });
pub const Statemine: MultiLocation = Parachain(1000).into_location();
pub const Encointer: MultiLocation = Parachain(1001).into_location();
pub const Statemine: MultiLocation = Parachain(ASSET_HUB_ID).into_location();
pub const EncointerLocation: MultiLocation = Parachain(ENCOINTER_ID).into_location();
pub const BridgeHubLocation: MultiLocation = Parachain(BRIDGE_HUB_ID).into_location();
pub const KsmForStatemine: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Statemine::get());
pub const KsmForEncointer: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Encointer::get());
pub const KsmForEncointer: (MultiAssetFilter, MultiLocation) = (Ksm::get(), EncointerLocation::get());
pub const KsmForBridgeHub: (MultiAssetFilter, MultiLocation) = (Ksm::get(), BridgeHubLocation::get());
pub const MaxAssetsIntoHolding: u32 = 64;
}
pub type TrustedTeleporters =
(xcm_builder::Case<KsmForStatemine>, xcm_builder::Case<KsmForEncointer>);

/// Kusama Relay recognizes/respects AssetHub, Encointer, and BridgeHub chains as teleporters.
pub type TrustedTeleporters = (
xcm_builder::Case<KsmForStatemine>,
xcm_builder::Case<KsmForEncointer>,
xcm_builder::Case<KsmForBridgeHub>,
);

match_types! {
pub type OnlyParachains: impl Contains<MultiLocation> = {
Expand Down
2 changes: 2 additions & 0 deletions relay/polkadot/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ pub mod system_parachain {
pub const STATEMINT_ID: u32 = 1000;
/// Collectives parachain ID.
pub const COLLECTIVES_ID: u32 = 1001;
/// BridgeHub parachain ID.
pub const BRIDGE_HUB_ID: u32 = 1002;
}

#[cfg(test)]
Expand Down
11 changes: 8 additions & 3 deletions relay/polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,17 @@ parameter_types! {
pub const DotForStatemint: (MultiAssetFilter, MultiLocation) = (Dot::get(), StatemintLocation::get());
pub const CollectivesLocation: MultiLocation = Parachain(COLLECTIVES_ID).into_location();
pub const DotForCollectives: (MultiAssetFilter, MultiLocation) = (Dot::get(), CollectivesLocation::get());
pub const BridgeHubLocation: MultiLocation = Parachain(BRIDGE_HUB_ID).into_location();
pub const DotForBridgeHub: (MultiAssetFilter, MultiLocation) = (Dot::get(), BridgeHubLocation::get());
pub const MaxAssetsIntoHolding: u32 = 64;
}

/// Polkadot Relay recognizes/respects the Statemint chain as a teleporter.
pub type TrustedTeleporters =
(xcm_builder::Case<DotForStatemint>, xcm_builder::Case<DotForCollectives>);
/// Polkadot Relay recognizes/respects Statemint, Collectives, and BridgeHub chains as teleporters.
pub type TrustedTeleporters = (
xcm_builder::Case<DotForStatemint>,
xcm_builder::Case<DotForCollectives>,
xcm_builder::Case<DotForBridgeHub>,
);

match_types! {
pub type OnlyParachains: impl Contains<MultiLocation> = {
Expand Down

0 comments on commit 96f6566

Please sign in to comment.