From 3ec82c2cf0b07ad80ad0fd9cb544adba579c95a8 Mon Sep 17 00:00:00 2001 From: muharem Date: Sat, 12 Nov 2022 12:24:54 +0100 Subject: [PATCH 1/7] Companion: Accept Kusamsa StakinAdmin origin --- .../runtimes/assets/statemine/src/lib.rs | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/parachains/runtimes/assets/statemine/src/lib.rs b/parachains/runtimes/assets/statemine/src/lib.rs index 02e51852193..40743183dc4 100644 --- a/parachains/runtimes/assets/statemine/src/lib.rs +++ b/parachains/runtimes/assets/statemine/src/lib.rs @@ -69,11 +69,13 @@ use xcm_config::{KsmLocation, XcmConfig}; pub use sp_runtime::BuildStorage; // Polkadot imports -use pallet_xcm::{EnsureXcm, IsMajorityOfBody}; +use pallet_xcm::{EnsureXcm, EqualMultiLocation, IsMajorityOfBody}; use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; -use xcm::latest::BodyId; +use xcm::latest::prelude::*; use xcm_executor::XcmExecutor; +use kusama_runtime_constants::xcm::{origins::STAKING_ADMIN_INDEX, ORIGIN_INDEX}; + use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; impl_opaque_keys! { @@ -506,11 +508,24 @@ parameter_types! { pub const MinCandidates: u32 = 5; pub const SessionLength: BlockNumber = 6 * HOURS; pub const MaxInvulnerables: u32 = 100; + // Relay chain StakingAdmin origin location. + pub const StakingAdminLocation: MultiLocation = MultiLocation { + parents: 1, + interior: X2( + GeneralIndex(ORIGIN_INDEX as u128), + GeneralIndex(STAKING_ADMIN_INDEX as u128), + ), + }; } -/// We allow root and the Relay Chain council to execute privileged collator selection operations. -pub type CollatorSelectionUpdateOrigin = - EitherOfDiverse, EnsureXcm>>; +/// We allow root, the Relay Chain council and the StakingAdmin to execute privileged collator selection operations. +pub type CollatorSelectionUpdateOrigin = EitherOfDiverse< + EnsureRoot, + EnsureXcm<( + IsMajorityOfBody, + EqualMultiLocation, + )>, +>; impl pallet_collator_selection::Config for Runtime { type RuntimeEvent = RuntimeEvent; From 6d063247f73fb3c527880468aec490a2809d22d4 Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 14 Nov 2022 11:59:03 +0100 Subject: [PATCH 2/7] Fellows origin for xcmp queue controller --- .../runtimes/assets/statemine/src/lib.rs | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/parachains/runtimes/assets/statemine/src/lib.rs b/parachains/runtimes/assets/statemine/src/lib.rs index 40743183dc4..026986a3a96 100644 --- a/parachains/runtimes/assets/statemine/src/lib.rs +++ b/parachains/runtimes/assets/statemine/src/lib.rs @@ -74,7 +74,10 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; use xcm::latest::prelude::*; use xcm_executor::XcmExecutor; -use kusama_runtime_constants::xcm::{origins::STAKING_ADMIN_INDEX, ORIGIN_INDEX}; +use kusama_runtime_constants::xcm::{ + origins::{FELLOWS_INDEX, STAKING_ADMIN_INDEX}, + ORIGIN_INDEX, +}; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; @@ -456,16 +459,27 @@ impl parachain_info::Config for Runtime {} impl cumulus_pallet_aura_ext::Config for Runtime {} +parameter_types! { + // Relay chain Fellows origin location. + pub const FellowsLocation: MultiLocation = MultiLocation { + parents: 1, + interior: X2( + GeneralIndex(ORIGIN_INDEX as u128), + GeneralIndex(FELLOWS_INDEX as u128), + ), + }; +} + impl cumulus_pallet_xcmp_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; type XcmExecutor = XcmExecutor; type ChannelInfo = ParachainSystem; type VersionWrapper = PolkadotXcm; type ExecuteOverweightOrigin = EnsureRoot; - type ControllerOrigin = EitherOfDiverse< - EnsureRoot, - EnsureXcm>, - >; + type ControllerOrigin = EnsureXcm<( + IsMajorityOfBody, + EqualMultiLocation, + )>; type ControllerOriginConverter = xcm_config::XcmOriginToTransactDispatchOrigin; type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; } From 1c8a40f0f6e3b31de788940072dc68dd5859db5e Mon Sep 17 00:00:00 2001 From: muharem Date: Fri, 18 Nov 2022 15:30:53 +0100 Subject: [PATCH 3/7] plurality bodies to ensure origin --- .../runtimes/assets/statemine/src/lib.rs | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/parachains/runtimes/assets/statemine/src/lib.rs b/parachains/runtimes/assets/statemine/src/lib.rs index 026986a3a96..cee30810a6a 100644 --- a/parachains/runtimes/assets/statemine/src/lib.rs +++ b/parachains/runtimes/assets/statemine/src/lib.rs @@ -69,15 +69,12 @@ use xcm_config::{KsmLocation, XcmConfig}; pub use sp_runtime::BuildStorage; // Polkadot imports -use pallet_xcm::{EnsureXcm, EqualMultiLocation, IsMajorityOfBody}; +use pallet_xcm::{EnsureXcm, IsMajorityOfBody, IsVoiceOfBody}; use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; -use xcm::latest::prelude::*; +use xcm::latest::BodyId; use xcm_executor::XcmExecutor; -use kusama_runtime_constants::xcm::{ - origins::{FELLOWS_INDEX, STAKING_ADMIN_INDEX}, - ORIGIN_INDEX, -}; +use kusama_runtime_constants::xcm::body::{FELLOWS_INDEX, STAKING_ADMIN_INDEX}; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; @@ -460,14 +457,8 @@ impl parachain_info::Config for Runtime {} impl cumulus_pallet_aura_ext::Config for Runtime {} parameter_types! { - // Relay chain Fellows origin location. - pub const FellowsLocation: MultiLocation = MultiLocation { - parents: 1, - interior: X2( - GeneralIndex(ORIGIN_INDEX as u128), - GeneralIndex(FELLOWS_INDEX as u128), - ), - }; + // Fellows pluralistic body. + pub const FellowsBodyId: BodyId = BodyId::Index(FELLOWS_INDEX); } impl cumulus_pallet_xcmp_queue::Config for Runtime { @@ -478,7 +469,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ExecuteOverweightOrigin = EnsureRoot; type ControllerOrigin = EnsureXcm<( IsMajorityOfBody, - EqualMultiLocation, + IsVoiceOfBody, )>; type ControllerOriginConverter = xcm_config::XcmOriginToTransactDispatchOrigin; type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; @@ -522,14 +513,8 @@ parameter_types! { pub const MinCandidates: u32 = 5; pub const SessionLength: BlockNumber = 6 * HOURS; pub const MaxInvulnerables: u32 = 100; - // Relay chain StakingAdmin origin location. - pub const StakingAdminLocation: MultiLocation = MultiLocation { - parents: 1, - interior: X2( - GeneralIndex(ORIGIN_INDEX as u128), - GeneralIndex(STAKING_ADMIN_INDEX as u128), - ), - }; + // StakingAdmin pluralistic body. + pub const StakingAdminBodyId: BodyId = BodyId::Index(STAKING_ADMIN_INDEX); } /// We allow root, the Relay Chain council and the StakingAdmin to execute privileged collator selection operations. @@ -537,7 +522,7 @@ pub type CollatorSelectionUpdateOrigin = EitherOfDiverse< EnsureRoot, EnsureXcm<( IsMajorityOfBody, - EqualMultiLocation, + IsVoiceOfBody, )>, >; From bd61c464315a8545396762c3c83ac6506eb1fe8a Mon Sep 17 00:00:00 2001 From: muharem Date: Thu, 24 Nov 2022 10:21:50 +0100 Subject: [PATCH 4/7] include root into controller ensure origin --- parachains/runtimes/assets/statemine/src/lib.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/parachains/runtimes/assets/statemine/src/lib.rs b/parachains/runtimes/assets/statemine/src/lib.rs index efe8e95cd6d..40ef7de46b9 100644 --- a/parachains/runtimes/assets/statemine/src/lib.rs +++ b/parachains/runtimes/assets/statemine/src/lib.rs @@ -471,10 +471,14 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ChannelInfo = ParachainSystem; type VersionWrapper = PolkadotXcm; type ExecuteOverweightOrigin = EnsureRoot; - type ControllerOrigin = EnsureXcm<( - IsMajorityOfBody, - IsVoiceOfBody, - )>; + type ControllerOrigin = EitherOfDiverse< + EnsureRoot, + EnsureXcm<( + IsMajorityOfBody, + IsVoiceOfBody, + )>, + >; + type ControllerOrigin = EnsureXcm; type ControllerOriginConverter = xcm_config::XcmOriginToTransactDispatchOrigin; type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; } From 876b196bf2f42ddc0c847c05d2bc370a5fb98be2 Mon Sep 17 00:00:00 2001 From: muharem Date: Thu, 24 Nov 2022 10:50:36 +0100 Subject: [PATCH 5/7] fix --- parachains/runtimes/assets/statemine/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/parachains/runtimes/assets/statemine/src/lib.rs b/parachains/runtimes/assets/statemine/src/lib.rs index 40ef7de46b9..dcd233803dd 100644 --- a/parachains/runtimes/assets/statemine/src/lib.rs +++ b/parachains/runtimes/assets/statemine/src/lib.rs @@ -478,7 +478,6 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { IsVoiceOfBody, )>, >; - type ControllerOrigin = EnsureXcm; type ControllerOriginConverter = xcm_config::XcmOriginToTransactDispatchOrigin; type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; } From 0a0c7b4213f5ee359605f1035b6df608c04957e0 Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 12 Dec 2022 15:26:19 +0100 Subject: [PATCH 6/7] use xcm bodies --- parachains/runtimes/assets/statemine/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/parachains/runtimes/assets/statemine/src/lib.rs b/parachains/runtimes/assets/statemine/src/lib.rs index dcd233803dd..76ca8ca8fb6 100644 --- a/parachains/runtimes/assets/statemine/src/lib.rs +++ b/parachains/runtimes/assets/statemine/src/lib.rs @@ -74,8 +74,6 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; use xcm::latest::BodyId; use xcm_executor::XcmExecutor; -use kusama_runtime_constants::xcm::body::{FELLOWS_INDEX, STAKING_ADMIN_INDEX}; - use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; impl_opaque_keys! { @@ -462,7 +460,7 @@ impl cumulus_pallet_aura_ext::Config for Runtime {} parameter_types! { // Fellows pluralistic body. - pub const FellowsBodyId: BodyId = BodyId::Index(FELLOWS_INDEX); + pub const FellowsBodyId: BodyId = BodyId::Technical; } impl cumulus_pallet_xcmp_queue::Config for Runtime { @@ -521,7 +519,7 @@ parameter_types! { pub const SessionLength: BlockNumber = 6 * HOURS; pub const MaxInvulnerables: u32 = 100; // StakingAdmin pluralistic body. - pub const StakingAdminBodyId: BodyId = BodyId::Index(STAKING_ADMIN_INDEX); + pub const StakingAdminBodyId: BodyId = BodyId::Defence; } /// We allow root, the Relay Chain council and the StakingAdmin to execute privileged collator selection operations. From 9d980b78e3091ed2f8f296bbbcc875c0837bf8b1 Mon Sep 17 00:00:00 2001 From: muharem Date: Tue, 13 Dec 2022 11:24:49 +0100 Subject: [PATCH 7/7] rename to more frequent "defense" --- parachains/runtimes/assets/statemine/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parachains/runtimes/assets/statemine/src/lib.rs b/parachains/runtimes/assets/statemine/src/lib.rs index f044407bd94..9bfd420e2a9 100644 --- a/parachains/runtimes/assets/statemine/src/lib.rs +++ b/parachains/runtimes/assets/statemine/src/lib.rs @@ -510,7 +510,7 @@ parameter_types! { pub const SessionLength: BlockNumber = 6 * HOURS; pub const MaxInvulnerables: u32 = 100; // StakingAdmin pluralistic body. - pub const StakingAdminBodyId: BodyId = BodyId::Defence; + pub const StakingAdminBodyId: BodyId = BodyId::Defense; } /// We allow root, the Relay Chain council and the StakingAdmin to execute privileged collator selection operations.