From a3197ec188e99136efb47c3df9a577cf42fbcdc7 Mon Sep 17 00:00:00 2001 From: muharem Date: Sat, 12 Nov 2022 11:24:20 +0100 Subject: [PATCH 01/13] Kusamsa origins as xcm multilocation --- runtime/kusama/constants/src/lib.rs | 29 +++++++++++ runtime/kusama/src/xcm_config.rs | 64 ++++++++++++++++++++---- xcm/pallet-xcm/src/lib.rs | 12 +++++ xcm/xcm-builder/src/lib.rs | 8 +-- xcm/xcm-builder/src/origin_conversion.rs | 21 ++++++++ 5 files changed, 121 insertions(+), 13 deletions(-) diff --git a/runtime/kusama/constants/src/lib.rs b/runtime/kusama/constants/src/lib.rs index a8d047241b24..2234bed1e9e9 100644 --- a/runtime/kusama/constants/src/lib.rs +++ b/runtime/kusama/constants/src/lib.rs @@ -97,6 +97,35 @@ pub mod fee { } } +/// XCM protocol related constants. +pub mod xcm { + /// Origin item index in the context of the runtime. Used as `Junction::GeneralIndex`. + /// + /// # Examples: + /// + /// ```rust + /// use xcm::latest::prelude::*; + /// // MultiLocation of the StakingAdmin origin within the current context. + /// let o = MultiLocation { + /// parent: 0, + /// interior: X2( + /// GeneralIndex(ORIGIN_INDEX), + /// GeneralIndex(STAKING_ADMIN_INDEX) + /// ) + /// }; + /// ``` + pub const ORIGIN_INDEX: u8 = 0; + + /// XCM origins. + pub mod origins { + /// Root origin index. Use `Junctions::Here` instead. + #[allow(dead_code)] + const ROOT_INDEX: u8 = 0; + /// StakingAdmin origin index in the context of the runtime. Used as `Junction::GeneralIndex`. + pub const STAKING_ADMIN_INDEX: u8 = 1; + } +} + #[cfg(test)] mod tests { use super::{ diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 17310dd5ead1..e75727162186 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -18,18 +18,20 @@ use super::{ parachains_origin, AccountId, Balances, CouncilCollective, ParaId, Runtime, RuntimeCall, - RuntimeEvent, RuntimeOrigin, WeightToFee, XcmPallet, + RuntimeEvent, RuntimeOrigin, StakingAdmin, WeightToFee, XcmPallet, }; use frame_support::{match_types, parameter_types, traits::Everything}; +use kusama_runtime_constants::xcm::{origins::STAKING_ADMIN_INDEX, ORIGIN_INDEX}; use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, - CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, - LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, - TakeWeightCredit, UsingComponents, WeightInfoBounds, + CurrencyAdapter as XcmCurrencyAdapter, EnsureOriginToLocation, FixedWeightBounds, + IsChildSystemParachain, IsConcrete, LocationInverter, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + WeightInfoBounds, }; parameter_types! { @@ -154,6 +156,10 @@ impl xcm_executor::Config for XcmConfig { parameter_types! { pub const CouncilBodyId: BodyId = BodyId::Executive; + // StakingAdmin origin XCM location within the current context. + pub const StakingAdminLocation: MultiLocation = X2( + GeneralIndex(ORIGIN_INDEX as u128), + GeneralIndex(STAKING_ADMIN_INDEX as u128)).into(); } /// Type to convert the council origin to a Plurality `MultiLocation` value. @@ -172,13 +178,28 @@ pub type LocalOriginToLocation = ( // And a usual Signed origin to be used in XCM as a corresponding AccountId32 SignedToAccountId32, ); + +/// Type to convert the StakingAdmin origin to a `MultiLocation` value. +pub type StakingAdminToLocation = + EnsureOriginToLocation; + +/// Type to convert a pallet `Origin` type value into a `MultiLocation` value which represents an interior location +/// of this chain for a destination chain. +pub type LocalPalletOriginToLocation = ( + // We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the + // `Unit` body. + CouncilToPlurality, + // StakingAdmin origin to be used in XCM as a corresponding `MultiLocation`. + StakingAdminToLocation, +); + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; - // We only allow the council to send messages. This is basically safe to enable for everyone - // (safe the possibility of someone spamming the parachain if they're willing to pay the KSM to - // send from the Relay-chain), but it's useless until we bring in XCM v3 which will make - // `DescendOrigin` a bit more useful. - type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; + // We only allow the root, the council and the staking admin to send messages. + // This is basically safe to enable for everyone (safe the possibility of someone spamming the parachain + // if they're willing to pay the KSM to send from the Relay-chain), but it's useless until we bring in XCM v3 + // which will make `DescendOrigin` a bit more useful. + type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmRouter = XcmRouter; // Anyone can execute XCM messages locally. type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; @@ -196,3 +217,28 @@ impl pallet_xcm::Config for Runtime { const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; } + +#[cfg(test)] +mod tests { + use super::*; + use crate::governance::pallet_custom_origins::Origin as GovOrigin; + use xcm_executor::traits::Convert; + + #[test] + fn staking_origin_to_location_works() { + let account_origin = RuntimeOrigin::signed(sp_runtime::AccountId32::new([7u8; 32])); + assert!(>::convert( + account_origin + ) + .is_err()); + + let staking_origin: RuntimeOrigin = GovOrigin::StakingAdmin.into(); + assert_eq!( + >::convert( + staking_origin + ) + .unwrap(), + StakingAdminLocation::get(), + ); + } +} diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 78dc5087d960..2b3b7c126e00 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -1517,6 +1517,18 @@ impl, Body: Get> Contains } } +/// Adapter to `Contains` trait to check the equality of an inner `MultiLocation` with an outer. +/// +/// May reasonably be used with `EnsureXcm`. +pub struct EqualMultiLocation(PhantomData); +impl> Contains + for EqualMultiLocation +{ + fn contains(t: &MultiLocation) -> bool { + InnerLocation::get().eq(t) + } +} + /// `EnsureOrigin` implementation succeeding with a `MultiLocation` value to recognize and filter the /// `Origin::Xcm` item. pub struct EnsureXcm(PhantomData); diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index e3473d55d5eb..62c1f6596427 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -36,10 +36,10 @@ pub use location_conversion::{ mod origin_conversion; pub use origin_conversion::{ - BackingToPlurality, ChildParachainAsNative, ChildSystemParachainAsSuperuser, EnsureXcmOrigin, - ParentAsSuperuser, RelayChainAsNative, SiblingParachainAsNative, - SiblingSystemParachainAsSuperuser, SignedAccountId32AsNative, SignedAccountKey20AsNative, - SignedToAccountId32, SovereignSignedViaLocation, + BackingToPlurality, ChildParachainAsNative, ChildSystemParachainAsSuperuser, + EnsureOriginToLocation, EnsureXcmOrigin, ParentAsSuperuser, RelayChainAsNative, + SiblingParachainAsNative, SiblingSystemParachainAsSuperuser, SignedAccountId32AsNative, + SignedAccountKey20AsNative, SignedToAccountId32, SovereignSignedViaLocation, }; mod barriers; diff --git a/xcm/xcm-builder/src/origin_conversion.rs b/xcm/xcm-builder/src/origin_conversion.rs index 9fe50eaf9c3f..ff8724e64428 100644 --- a/xcm/xcm-builder/src/origin_conversion.rs +++ b/xcm/xcm-builder/src/origin_conversion.rs @@ -321,3 +321,24 @@ where }) } } + +/// `Convert` implementation to convert from some an origin which passes the check of of an `EnsureOrigin` +/// into a given `MultiLocation`. +pub struct EnsureOriginToLocation( + PhantomData<(RuntimeOrigin, EnsureLocationOrigin, OriginLocation)>, +); + +impl< + RuntimeOrigin: Clone, + EnsureLocationOrigin: EnsureOrigin, + OriginLocation: Get, + > Convert + for EnsureOriginToLocation +{ + fn convert(o: RuntimeOrigin) -> Result { + match EnsureLocationOrigin::try_origin(o) { + Ok(_) => Ok(OriginLocation::get()), + Err(o) => Err(o), + } + } +} From 6919d89fe2c20d479f2633dd1b24f8d0dada374d Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 14 Nov 2022 12:01:49 +0100 Subject: [PATCH 02/13] Fellows origin index --- runtime/kusama/constants/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/kusama/constants/src/lib.rs b/runtime/kusama/constants/src/lib.rs index 2234bed1e9e9..87f93e4f8512 100644 --- a/runtime/kusama/constants/src/lib.rs +++ b/runtime/kusama/constants/src/lib.rs @@ -123,6 +123,7 @@ pub mod xcm { const ROOT_INDEX: u8 = 0; /// StakingAdmin origin index in the context of the runtime. Used as `Junction::GeneralIndex`. pub const STAKING_ADMIN_INDEX: u8 = 1; + pub const FELLOWS_INDEX: u8 = 2; } } From 3e0cf79e5256153299d35fdd1010241bf645d085 Mon Sep 17 00:00:00 2001 From: muharem Date: Fri, 18 Nov 2022 15:19:44 +0100 Subject: [PATCH 03/13] origins to xcm plurality body --- runtime/kusama/constants/src/lib.rs | 31 +++++---------------- runtime/kusama/src/xcm_config.rs | 34 +++++++++++++----------- xcm/pallet-xcm/src/lib.rs | 13 +++++++++ xcm/xcm-builder/src/lib.rs | 8 +++--- xcm/xcm-builder/src/origin_conversion.rs | 22 +++++++-------- 5 files changed, 52 insertions(+), 56 deletions(-) diff --git a/runtime/kusama/constants/src/lib.rs b/runtime/kusama/constants/src/lib.rs index 87f93e4f8512..bd1432126b95 100644 --- a/runtime/kusama/constants/src/lib.rs +++ b/runtime/kusama/constants/src/lib.rs @@ -99,31 +99,14 @@ pub mod fee { /// XCM protocol related constants. pub mod xcm { - /// Origin item index in the context of the runtime. Used as `Junction::GeneralIndex`. - /// - /// # Examples: - /// - /// ```rust - /// use xcm::latest::prelude::*; - /// // MultiLocation of the StakingAdmin origin within the current context. - /// let o = MultiLocation { - /// parent: 0, - /// interior: X2( - /// GeneralIndex(ORIGIN_INDEX), - /// GeneralIndex(STAKING_ADMIN_INDEX) - /// ) - /// }; - /// ``` - pub const ORIGIN_INDEX: u8 = 0; - - /// XCM origins. - pub mod origins { - /// Root origin index. Use `Junctions::Here` instead. + /// Pluralistic bodies existing within the consensus. + pub mod body { + // Preallocated for the Root body. #[allow(dead_code)] - const ROOT_INDEX: u8 = 0; - /// StakingAdmin origin index in the context of the runtime. Used as `Junction::GeneralIndex`. - pub const STAKING_ADMIN_INDEX: u8 = 1; - pub const FELLOWS_INDEX: u8 = 2; + const ROOT_INDEX: u32 = 0; + // The bodies corresponding to the runtime origins representing a plurality voice given via a referendum. + pub const STAKING_ADMIN_INDEX: u32 = 1; + pub const FELLOWS_INDEX: u32 = 2; } } diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index e75727162186..8388c2aaa854 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -21,17 +21,16 @@ use super::{ RuntimeEvent, RuntimeOrigin, StakingAdmin, WeightToFee, XcmPallet, }; use frame_support::{match_types, parameter_types, traits::Everything}; -use kusama_runtime_constants::xcm::{origins::STAKING_ADMIN_INDEX, ORIGIN_INDEX}; +use kusama_runtime_constants::xcm::body::{FELLOWS_INDEX, STAKING_ADMIN_INDEX}; use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, - CurrencyAdapter as XcmCurrencyAdapter, EnsureOriginToLocation, FixedWeightBounds, - IsChildSystemParachain, IsConcrete, LocationInverter, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, - WeightInfoBounds, + CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, + LocationInverter, OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, }; parameter_types! { @@ -156,10 +155,10 @@ impl xcm_executor::Config for XcmConfig { parameter_types! { pub const CouncilBodyId: BodyId = BodyId::Executive; - // StakingAdmin origin XCM location within the current context. - pub const StakingAdminLocation: MultiLocation = X2( - GeneralIndex(ORIGIN_INDEX as u128), - GeneralIndex(STAKING_ADMIN_INDEX as u128)).into(); + // StakingAdmin pluralistic body. + pub const StakingAdminBodyId: BodyId = BodyId::Index(STAKING_ADMIN_INDEX); + // Fellows pluralistic body. + pub const FellowsBodyId: BodyId = BodyId::Index(FELLOWS_INDEX); } /// Type to convert the council origin to a Plurality `MultiLocation` value. @@ -179,9 +178,12 @@ pub type LocalOriginToLocation = ( SignedToAccountId32, ); -/// Type to convert the StakingAdmin origin to a `MultiLocation` value. -pub type StakingAdminToLocation = - EnsureOriginToLocation; +/// Type to convert the StakingAdmin origin to a Plurality `MultiLocation` value. +pub type StakingAdminToPlurality = + OriginToPluralityVoice; + +/// Type to convert the Fellows origin to a Plurality `MultiLocation` value. +pub type FellowsToPlurality = OriginToPluralityVoice; /// Type to convert a pallet `Origin` type value into a `MultiLocation` value which represents an interior location /// of this chain for a destination chain. @@ -189,13 +191,15 @@ pub type LocalPalletOriginToLocation = ( // We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the // `Unit` body. CouncilToPlurality, - // StakingAdmin origin to be used in XCM as a corresponding `MultiLocation`. - StakingAdminToLocation, + // StakingAdmin origin to be used in XCM as a corresponding Plurality `MultiLocation` value. + StakingAdminToPlurality, + // Fellows origin to be used in XCM as a corresponding Plurality `MultiLocation` value. + FellowsToPlurality, ); impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; - // We only allow the root, the council and the staking admin to send messages. + // We only allow the root, the council, fellows and the staking admin to send messages. // This is basically safe to enable for everyone (safe the possibility of someone spamming the parachain // if they're willing to pay the KSM to send from the Relay-chain), but it's useless until we bring in XCM v3 // which will make `DescendOrigin` a bit more useful. diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 2b3b7c126e00..4cda309ea666 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -1517,6 +1517,19 @@ impl, Body: Get> Contains } } +/// Filter for `MultiLocation` to find those which represent a voice of an identified plurality. +/// +/// May reasonably be used with `EnsureXcm`. +pub struct IsVoiceOfBody(PhantomData<(Prefix, Body)>); +impl, Body: Get> Contains + for IsVoiceOfBody +{ + fn contains(l: &MultiLocation) -> bool { + let maybe_suffix = l.match_and_split(&Prefix::get()); + matches!(maybe_suffix, Some(Plurality { id, part }) if id == &Body::get() && part == &BodyPart::Voice) + } +} + /// Adapter to `Contains` trait to check the equality of an inner `MultiLocation` with an outer. /// /// May reasonably be used with `EnsureXcm`. diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index 62c1f6596427..aa55c56d2cd7 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -36,10 +36,10 @@ pub use location_conversion::{ mod origin_conversion; pub use origin_conversion::{ - BackingToPlurality, ChildParachainAsNative, ChildSystemParachainAsSuperuser, - EnsureOriginToLocation, EnsureXcmOrigin, ParentAsSuperuser, RelayChainAsNative, - SiblingParachainAsNative, SiblingSystemParachainAsSuperuser, SignedAccountId32AsNative, - SignedAccountKey20AsNative, SignedToAccountId32, SovereignSignedViaLocation, + BackingToPlurality, ChildParachainAsNative, ChildSystemParachainAsSuperuser, EnsureXcmOrigin, + OriginToPluralityVoice, ParentAsSuperuser, RelayChainAsNative, SiblingParachainAsNative, + SiblingSystemParachainAsSuperuser, SignedAccountId32AsNative, SignedAccountKey20AsNative, + SignedToAccountId32, SovereignSignedViaLocation, }; mod barriers; diff --git a/xcm/xcm-builder/src/origin_conversion.rs b/xcm/xcm-builder/src/origin_conversion.rs index ff8724e64428..4d024a9d12c2 100644 --- a/xcm/xcm-builder/src/origin_conversion.rs +++ b/xcm/xcm-builder/src/origin_conversion.rs @@ -322,22 +322,18 @@ where } } -/// `Convert` implementation to convert from some an origin which passes the check of of an `EnsureOrigin` -/// into a given `MultiLocation`. -pub struct EnsureOriginToLocation( - PhantomData<(RuntimeOrigin, EnsureLocationOrigin, OriginLocation)>, +/// `Convert` implementation to convert from an origin which passes the check of an `EnsureOrigin` +/// into a voice of a given pluralistic `Body`. +pub struct OriginToPluralityVoice( + PhantomData<(RuntimeOrigin, EnsureBodyOrigin, Body)>, ); - -impl< - RuntimeOrigin: Clone, - EnsureLocationOrigin: EnsureOrigin, - OriginLocation: Get, - > Convert - for EnsureOriginToLocation +impl, Body: Get> + Convert + for OriginToPluralityVoice { fn convert(o: RuntimeOrigin) -> Result { - match EnsureLocationOrigin::try_origin(o) { - Ok(_) => Ok(OriginLocation::get()), + match EnsureBodyOrigin::try_origin(o) { + Ok(_) => Ok(Junction::Plurality { id: Body::get(), part: BodyPart::Voice }.into()), Err(o) => Err(o), } } From 96a223b679545f58cf3c7c47c467c7725ac4d294 Mon Sep 17 00:00:00 2001 From: muharem Date: Fri, 18 Nov 2022 15:22:45 +0100 Subject: [PATCH 04/13] cleanup --- runtime/kusama/src/xcm_config.rs | 25 ------------------------- xcm/pallet-xcm/src/lib.rs | 12 ------------ 2 files changed, 37 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 8388c2aaa854..c79fae4e2145 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -221,28 +221,3 @@ impl pallet_xcm::Config for Runtime { const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; } - -#[cfg(test)] -mod tests { - use super::*; - use crate::governance::pallet_custom_origins::Origin as GovOrigin; - use xcm_executor::traits::Convert; - - #[test] - fn staking_origin_to_location_works() { - let account_origin = RuntimeOrigin::signed(sp_runtime::AccountId32::new([7u8; 32])); - assert!(>::convert( - account_origin - ) - .is_err()); - - let staking_origin: RuntimeOrigin = GovOrigin::StakingAdmin.into(); - assert_eq!( - >::convert( - staking_origin - ) - .unwrap(), - StakingAdminLocation::get(), - ); - } -} diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 4cda309ea666..a66da4dcd718 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -1530,18 +1530,6 @@ impl, Body: Get> Contains } } -/// Adapter to `Contains` trait to check the equality of an inner `MultiLocation` with an outer. -/// -/// May reasonably be used with `EnsureXcm`. -pub struct EqualMultiLocation(PhantomData); -impl> Contains - for EqualMultiLocation -{ - fn contains(t: &MultiLocation) -> bool { - InnerLocation::get().eq(t) - } -} - /// `EnsureOrigin` implementation succeeding with a `MultiLocation` value to recognize and filter the /// `Origin::Xcm` item. pub struct EnsureXcm(PhantomData); From 96ddd4b677bb01e5452ef49d754840db7806e7df Mon Sep 17 00:00:00 2001 From: muharem Date: Fri, 18 Nov 2022 15:43:32 +0100 Subject: [PATCH 05/13] fix cargo spellcheck --- runtime/kusama/src/xcm_config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index c79fae4e2145..fde26ed9ed4f 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -178,7 +178,7 @@ pub type LocalOriginToLocation = ( SignedToAccountId32, ); -/// Type to convert the StakingAdmin origin to a Plurality `MultiLocation` value. +/// Type to convert the `StakingAdmin` origin to a Plurality `MultiLocation` value. pub type StakingAdminToPlurality = OriginToPluralityVoice; From 5c26797ea881f9886c5e7d06d70cd239dd8f6c21 Mon Sep 17 00:00:00 2001 From: Muharem Ismailov Date: Thu, 24 Nov 2022 10:07:50 +0100 Subject: [PATCH 06/13] Apply suggestions from code review Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- runtime/kusama/src/xcm_config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index fde26ed9ed4f..3c79b36b7a49 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -183,7 +183,7 @@ pub type StakingAdminToPlurality = OriginToPluralityVoice; /// Type to convert the Fellows origin to a Plurality `MultiLocation` value. -pub type FellowsToPlurality = OriginToPluralityVoice; +pub type FellowsToPlurality = OriginToPluralityVoice; /// Type to convert a pallet `Origin` type value into a `MultiLocation` value which represents an interior location /// of this chain for a destination chain. From ffb5eb6f747df8c47927a317f637e78d7123bd36 Mon Sep 17 00:00:00 2001 From: muharem Date: Thu, 24 Nov 2022 10:12:17 +0100 Subject: [PATCH 07/13] include Fellows into scope --- runtime/kusama/src/xcm_config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 3c79b36b7a49..f7caa20e04fe 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -17,8 +17,8 @@ //! XCM configurations for the Kusama runtime. use super::{ - parachains_origin, AccountId, Balances, CouncilCollective, ParaId, Runtime, RuntimeCall, - RuntimeEvent, RuntimeOrigin, StakingAdmin, WeightToFee, XcmPallet, + parachains_origin, AccountId, Balances, CouncilCollective, Fellows, ParaId, Runtime, + RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, WeightToFee, XcmPallet, }; use frame_support::{match_types, parameter_types, traits::Everything}; use kusama_runtime_constants::xcm::body::{FELLOWS_INDEX, STAKING_ADMIN_INDEX}; From 78474c111756b259c787a69030b2e89827b72027 Mon Sep 17 00:00:00 2001 From: muharem Date: Thu, 24 Nov 2022 10:26:04 +0100 Subject: [PATCH 08/13] include Fellows into scope --- runtime/kusama/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 7ef451e52ea9..e51c6260864e 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -105,7 +105,7 @@ pub mod xcm_config; // Governance configurations. pub mod governance; use governance::{ - old::CouncilCollective, pallet_custom_origins, AuctionAdmin, GeneralAdmin, LeaseAdmin, + old::CouncilCollective, pallet_custom_origins, AuctionAdmin, Fellows, GeneralAdmin, LeaseAdmin, StakingAdmin, TreasurySpender, }; From 5a7a49ee96e0a1991746bfe381ae98b6e1784001 Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 12 Dec 2022 15:28:00 +0100 Subject: [PATCH 09/13] include common bodies into xcm --- runtime/kusama/constants/src/lib.rs | 13 ------------- runtime/kusama/src/xcm_config.rs | 5 ++--- xcm/src/v0/junction.rs | 6 ++++++ 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/runtime/kusama/constants/src/lib.rs b/runtime/kusama/constants/src/lib.rs index bd1432126b95..a8d047241b24 100644 --- a/runtime/kusama/constants/src/lib.rs +++ b/runtime/kusama/constants/src/lib.rs @@ -97,19 +97,6 @@ pub mod fee { } } -/// XCM protocol related constants. -pub mod xcm { - /// Pluralistic bodies existing within the consensus. - pub mod body { - // Preallocated for the Root body. - #[allow(dead_code)] - const ROOT_INDEX: u32 = 0; - // The bodies corresponding to the runtime origins representing a plurality voice given via a referendum. - pub const STAKING_ADMIN_INDEX: u32 = 1; - pub const FELLOWS_INDEX: u32 = 2; - } -} - #[cfg(test)] mod tests { use super::{ diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index f7caa20e04fe..70c16c6038c8 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -21,7 +21,6 @@ use super::{ RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, WeightToFee, XcmPallet, }; use frame_support::{match_types, parameter_types, traits::Everything}; -use kusama_runtime_constants::xcm::body::{FELLOWS_INDEX, STAKING_ADMIN_INDEX}; use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; use xcm_builder::{ @@ -156,9 +155,9 @@ impl xcm_executor::Config for XcmConfig { parameter_types! { pub const CouncilBodyId: BodyId = BodyId::Executive; // StakingAdmin pluralistic body. - pub const StakingAdminBodyId: BodyId = BodyId::Index(STAKING_ADMIN_INDEX); + pub const StakingAdminBodyId: BodyId = BodyId::Defence; // Fellows pluralistic body. - pub const FellowsBodyId: BodyId = BodyId::Index(FELLOWS_INDEX); + pub const FellowsBodyId: BodyId = BodyId::Technical; } /// Type to convert the council origin to a Plurality `MultiLocation` value. diff --git a/xcm/src/v0/junction.rs b/xcm/src/v0/junction.rs index 67f17f464a37..c20cefba2523 100644 --- a/xcm/src/v0/junction.rs +++ b/xcm/src/v0/junction.rs @@ -52,6 +52,12 @@ pub enum BodyId { /// The unambiguous judicial body (this doesn't exist on Polkadot, but if it were to get a "grand oracle", it /// may be considered as that). Judicial, + /// The unambiguous defence body (for Polkadot, an opinion on the topic given via a public referendum). + Defence, + /// The unambiguous administration body (for Polkadot, an opinion on the topic given via a public referendum). + Administration, + /// The unambiguous treasury body (for Polkadot, an opinion on the topic given via a public referendum). + Treasury, } /// A part of a pluralistic body. From 11fd946ba82d0b8a4b28ead5b5ebc2e190a68e98 Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 12 Dec 2022 15:37:55 +0100 Subject: [PATCH 10/13] whitelist "defence" for spellchecker --- scripts/ci/gitlab/lingua.dic | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ci/gitlab/lingua.dic b/scripts/ci/gitlab/lingua.dic index a2f64af1cbd6..85454f7f18ee 100644 --- a/scripts/ci/gitlab/lingua.dic +++ b/scripts/ci/gitlab/lingua.dic @@ -336,3 +336,4 @@ XCMP/M yeet yml zsh +defence From cbd0dd6b32f37500f14cf2cd47a4e6616437d15a Mon Sep 17 00:00:00 2001 From: muharem Date: Tue, 13 Dec 2022 11:23:30 +0100 Subject: [PATCH 11/13] rename to more frequent "defense" --- runtime/kusama/src/xcm_config.rs | 2 +- scripts/ci/gitlab/lingua.dic | 1 - xcm/src/v0/junction.rs | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 70c16c6038c8..55a474e239f6 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -155,7 +155,7 @@ impl xcm_executor::Config for XcmConfig { parameter_types! { pub const CouncilBodyId: BodyId = BodyId::Executive; // StakingAdmin pluralistic body. - pub const StakingAdminBodyId: BodyId = BodyId::Defence; + pub const StakingAdminBodyId: BodyId = BodyId::Defense; // Fellows pluralistic body. pub const FellowsBodyId: BodyId = BodyId::Technical; } diff --git a/scripts/ci/gitlab/lingua.dic b/scripts/ci/gitlab/lingua.dic index 85454f7f18ee..a2f64af1cbd6 100644 --- a/scripts/ci/gitlab/lingua.dic +++ b/scripts/ci/gitlab/lingua.dic @@ -336,4 +336,3 @@ XCMP/M yeet yml zsh -defence diff --git a/xcm/src/v0/junction.rs b/xcm/src/v0/junction.rs index c20cefba2523..7c22c35e94fa 100644 --- a/xcm/src/v0/junction.rs +++ b/xcm/src/v0/junction.rs @@ -52,8 +52,8 @@ pub enum BodyId { /// The unambiguous judicial body (this doesn't exist on Polkadot, but if it were to get a "grand oracle", it /// may be considered as that). Judicial, - /// The unambiguous defence body (for Polkadot, an opinion on the topic given via a public referendum). - Defence, + /// The unambiguous defense body (for Polkadot, an opinion on the topic given via a public referendum). + Defense, /// The unambiguous administration body (for Polkadot, an opinion on the topic given via a public referendum). Administration, /// The unambiguous treasury body (for Polkadot, an opinion on the topic given via a public referendum). From 4ff9d36f12097ad5b849e31c7abcc4d0c2d03da8 Mon Sep 17 00:00:00 2001 From: muharem Date: Thu, 15 Dec 2022 15:15:16 +0100 Subject: [PATCH 12/13] improve docs --- xcm/src/v0/junction.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xcm/src/v0/junction.rs b/xcm/src/v0/junction.rs index 7c22c35e94fa..ce4d76754bf6 100644 --- a/xcm/src/v0/junction.rs +++ b/xcm/src/v0/junction.rs @@ -52,11 +52,14 @@ pub enum BodyId { /// The unambiguous judicial body (this doesn't exist on Polkadot, but if it were to get a "grand oracle", it /// may be considered as that). Judicial, - /// The unambiguous defense body (for Polkadot, an opinion on the topic given via a public referendum). + /// The unambiguous defense body (for Polkadot, an opinion on the topic given via a public referendum + /// on the `staking_admin` track). Defense, - /// The unambiguous administration body (for Polkadot, an opinion on the topic given via a public referendum). + /// The unambiguous administration body (for Polkadot, an opinion on the topic given via a public referendum + /// on the `general_admin` track). Administration, - /// The unambiguous treasury body (for Polkadot, an opinion on the topic given via a public referendum). + /// The unambiguous treasury body (for Polkadot, an opinion on the topic given via a public referendum + /// on the `treasurer` track). Treasury, } From 1d78d62c71defa51acfa3346fa82ad5d5def2058 Mon Sep 17 00:00:00 2001 From: muharem Date: Thu, 15 Dec 2022 15:17:05 +0100 Subject: [PATCH 13/13] rustfmt --- xcm/src/v0/junction.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xcm/src/v0/junction.rs b/xcm/src/v0/junction.rs index ce4d76754bf6..450e882ac3e8 100644 --- a/xcm/src/v0/junction.rs +++ b/xcm/src/v0/junction.rs @@ -52,13 +52,13 @@ pub enum BodyId { /// The unambiguous judicial body (this doesn't exist on Polkadot, but if it were to get a "grand oracle", it /// may be considered as that). Judicial, - /// The unambiguous defense body (for Polkadot, an opinion on the topic given via a public referendum + /// The unambiguous defense body (for Polkadot, an opinion on the topic given via a public referendum /// on the `staking_admin` track). Defense, - /// The unambiguous administration body (for Polkadot, an opinion on the topic given via a public referendum + /// The unambiguous administration body (for Polkadot, an opinion on the topic given via a public referendum /// on the `general_admin` track). Administration, - /// The unambiguous treasury body (for Polkadot, an opinion on the topic given via a public referendum + /// The unambiguous treasury body (for Polkadot, an opinion on the topic given via a public referendum /// on the `treasurer` track). Treasury, }