From df5555741e6fd5171fe5a8f579e1c9e08119486c Mon Sep 17 00:00:00 2001 From: Rodrigo Quelhas Date: Tue, 28 Jan 2025 11:22:55 +0000 Subject: [PATCH 1/4] feat(gov): normalize FastGeneralAdmin track origin for creating new foreign assets --- runtime/moonbase/src/xcm_config.rs | 23 ++++++++++++++++++----- runtime/moonbeam/src/xcm_config.rs | 18 +++++------------- runtime/moonriver/src/xcm_config.rs | 19 +++++-------------- 3 files changed, 28 insertions(+), 32 deletions(-) diff --git a/runtime/moonbase/src/xcm_config.rs b/runtime/moonbase/src/xcm_config.rs index a2f25db09c5..6f2a24062e2 100644 --- a/runtime/moonbase/src/xcm_config.rs +++ b/runtime/moonbase/src/xcm_config.rs @@ -726,18 +726,31 @@ impl frame_support::traits::Contains for AssetFeesFilter { } } +pub type AddAndEditSupportedAssetOrigin = EitherOfDiverse< + EnsureRoot, + EitherOfDiverse< + pallet_collective::EnsureProportionMoreThan, + governance::custom_origins::FastGeneralAdmin, + >, +>; + +pub type RemoveSupportedAssetOrigin = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionMoreThan, +>; + impl pallet_xcm_weight_trader::Config for Runtime { type AccountIdToLocation = AccountIdToLocation; - type AddSupportedAssetOrigin = EnsureRoot; + type AddSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; type AssetLocationFilter = AssetFeesFilter; type AssetTransactor = AssetTransactors; type Balance = Balance; - type EditSupportedAssetOrigin = EnsureRoot; + type EditSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; type NativeLocation = SelfReserve; - type PauseSupportedAssetOrigin = EnsureRoot; - type RemoveSupportedAssetOrigin = EnsureRoot; + type PauseSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; + type RemoveSupportedAssetOrigin = RemoveSupportedAssetOrigin; type RuntimeEvent = RuntimeEvent; - type ResumeSupportedAssetOrigin = EnsureRoot; + type ResumeSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; type WeightInfo = moonbase_weights::pallet_xcm_weight_trader::WeightInfo; type WeightToFee = ::WeightToFee; type XcmFeesAccount = XcmFeesAccount; diff --git a/runtime/moonbeam/src/xcm_config.rs b/runtime/moonbeam/src/xcm_config.rs index 506f91d5ff8..fe9d62b2c63 100644 --- a/runtime/moonbeam/src/xcm_config.rs +++ b/runtime/moonbeam/src/xcm_config.rs @@ -712,15 +712,7 @@ impl frame_support::traits::Contains for AssetFeesFilter { } } -pub type AddSupportedAssetOrigin = EitherOfDiverse< - EnsureRoot, - EitherOfDiverse< - pallet_collective::EnsureProportionMoreThan, - governance::custom_origins::GeneralAdmin, - >, ->; - -pub type EditSupportedAssetOrigin = EitherOfDiverse< +pub type AddAndEditSupportedAssetOrigin = EitherOfDiverse< EnsureRoot, EitherOfDiverse< pallet_collective::EnsureProportionMoreThan, @@ -735,16 +727,16 @@ pub type RemoveSupportedAssetOrigin = EitherOfDiverse< impl pallet_xcm_weight_trader::Config for Runtime { type AccountIdToLocation = AccountIdToLocation; - type AddSupportedAssetOrigin = AddSupportedAssetOrigin; + type AddSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; type AssetLocationFilter = AssetFeesFilter; type AssetTransactor = AssetTransactors; type Balance = Balance; - type EditSupportedAssetOrigin = EditSupportedAssetOrigin; + type EditSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; type NativeLocation = SelfReserve; - type PauseSupportedAssetOrigin = EditSupportedAssetOrigin; + type PauseSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; + type ResumeSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; type RemoveSupportedAssetOrigin = RemoveSupportedAssetOrigin; type RuntimeEvent = RuntimeEvent; - type ResumeSupportedAssetOrigin = RemoveSupportedAssetOrigin; type WeightInfo = moonbeam_weights::pallet_xcm_weight_trader::WeightInfo; type WeightToFee = ::WeightToFee; type XcmFeesAccount = XcmFeesAccount; diff --git a/runtime/moonriver/src/xcm_config.rs b/runtime/moonriver/src/xcm_config.rs index 1519d252032..fc3e0b6e67e 100644 --- a/runtime/moonriver/src/xcm_config.rs +++ b/runtime/moonriver/src/xcm_config.rs @@ -725,15 +725,7 @@ impl frame_support::traits::Contains for AssetFeesFilter { } } -pub type AddSupportedAssetOrigin = EitherOfDiverse< - EnsureRoot, - EitherOfDiverse< - pallet_collective::EnsureProportionMoreThan, - governance::custom_origins::GeneralAdmin, - >, ->; - -pub type EditSupportedAssetOrigin = EitherOfDiverse< +pub type AddAndEditSupportedAssetOrigin = EitherOfDiverse< EnsureRoot, EitherOfDiverse< pallet_collective::EnsureProportionMoreThan, @@ -748,17 +740,16 @@ pub type RemoveSupportedAssetOrigin = EitherOfDiverse< impl pallet_xcm_weight_trader::Config for Runtime { type AccountIdToLocation = AccountIdToLocation; - type AddSupportedAssetOrigin = AddSupportedAssetOrigin; + type AddSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; type AssetLocationFilter = AssetFeesFilter; type AssetTransactor = AssetTransactors; type Balance = Balance; - type EditSupportedAssetOrigin = EditSupportedAssetOrigin; + type EditSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; type NativeLocation = SelfReserve; - type PauseSupportedAssetOrigin = EditSupportedAssetOrigin; + type PauseSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; + type ResumeSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; type RemoveSupportedAssetOrigin = RemoveSupportedAssetOrigin; type RuntimeEvent = RuntimeEvent; - type ResumeSupportedAssetOrigin = RemoveSupportedAssetOrigin; - type WeightInfo = moonriver_weights::pallet_xcm_weight_trader::WeightInfo; type WeightToFee = ::WeightToFee; type XcmFeesAccount = XcmFeesAccount; From 14374c15cccbd3e625646e55be75063b59bb1901 Mon Sep 17 00:00:00 2001 From: Rodrigo Quelhas Date: Tue, 28 Jan 2025 11:29:20 +0000 Subject: [PATCH 2/4] improvement --- runtime/moonbase/src/xcm_config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/moonbase/src/xcm_config.rs b/runtime/moonbase/src/xcm_config.rs index 6f2a24062e2..935194b4bd6 100644 --- a/runtime/moonbase/src/xcm_config.rs +++ b/runtime/moonbase/src/xcm_config.rs @@ -748,9 +748,9 @@ impl pallet_xcm_weight_trader::Config for Runtime { type EditSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; type NativeLocation = SelfReserve; type PauseSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; + type ResumeSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; type RemoveSupportedAssetOrigin = RemoveSupportedAssetOrigin; type RuntimeEvent = RuntimeEvent; - type ResumeSupportedAssetOrigin = AddAndEditSupportedAssetOrigin; type WeightInfo = moonbase_weights::pallet_xcm_weight_trader::WeightInfo; type WeightToFee = ::WeightToFee; type XcmFeesAccount = XcmFeesAccount; From cf29013951f8f9bdc2e3903ba350cb020ebd22cc Mon Sep 17 00:00:00 2001 From: Rodrigo Quelhas Date: Thu, 30 Jan 2025 17:24:18 +0000 Subject: [PATCH 3/4] Allow GeneralAdmin track when FastGeneralAdmin track is allowed --- runtime/moonbase/src/governance/referenda.rs | 3 ++- runtime/moonbase/src/lib.rs | 11 +++++++---- runtime/moonbase/src/xcm_config.rs | 12 +++++++++--- runtime/moonbeam/src/governance/referenda.rs | 3 ++- runtime/moonbeam/src/lib.rs | 10 +++++++--- runtime/moonbeam/src/xcm_config.rs | 12 +++++++++--- runtime/moonriver/src/governance/referenda.rs | 3 ++- runtime/moonriver/src/lib.rs | 10 +++++++--- runtime/moonriver/src/xcm_config.rs | 12 +++++++++--- 9 files changed, 54 insertions(+), 22 deletions(-) diff --git a/runtime/moonbase/src/governance/referenda.rs b/runtime/moonbase/src/governance/referenda.rs index 21cd96253f5..03e078bc2d0 100644 --- a/runtime/moonbase/src/governance/referenda.rs +++ b/runtime/moonbase/src/governance/referenda.rs @@ -52,7 +52,8 @@ parameter_types! { pub type GeneralAdminOrRoot = EitherOf, origins::GeneralAdmin>; /// The policy allows for Root or FastGeneralAdmin. -pub type FastGeneralAdminOrRoot = EitherOf, origins::FastGeneralAdmin>; +pub type FastGeneralAdminOrRoot = + EitherOf, EitherOf>; impl custom_origins::Config for Runtime {} diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index 5cd1c82cc1c..c916b25c9de 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -65,9 +65,9 @@ use frame_support::{ traits::{ fungible::{Balanced, Credit, HoldConsideration, Inspect}, tokens::{PayFromAccount, UnityAssetBalanceConversion}, - ConstBool, ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, Contains, EitherOfDiverse, - EqualPrivilegeOnly, FindAuthor, InstanceFilter, LinearStoragePrice, OnFinalize, - OnUnbalanced, + ConstBool, ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, Contains, EitherOf, + EitherOfDiverse, EqualPrivilegeOnly, FindAuthor, InstanceFilter, LinearStoragePrice, + OnFinalize, OnUnbalanced, }, weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient, @@ -1122,7 +1122,10 @@ pub type ForeignAssetMigratorOrigin = EitherOfDiverse< EnsureRoot, EitherOfDiverse< pallet_collective::EnsureProportionMoreThan, - governance::custom_origins::FastGeneralAdmin, + EitherOf< + governance::custom_origins::GeneralAdmin, + governance::custom_origins::FastGeneralAdmin, + >, >, >; diff --git a/runtime/moonbase/src/xcm_config.rs b/runtime/moonbase/src/xcm_config.rs index 935194b4bd6..18a1b8a29a8 100644 --- a/runtime/moonbase/src/xcm_config.rs +++ b/runtime/moonbase/src/xcm_config.rs @@ -33,7 +33,7 @@ use sp_runtime::{ use frame_support::{ parameter_types, - traits::{EitherOfDiverse, Everything, Nothing, PalletInfoAccess, TransformOrigin}, + traits::{EitherOf, EitherOfDiverse, Everything, Nothing, PalletInfoAccess, TransformOrigin}, }; use frame_system::{EnsureRoot, RawOrigin}; @@ -699,7 +699,10 @@ pub type ForeignAssetManagerOrigin = EitherOfDiverse< EnsureRoot, EitherOfDiverse< pallet_collective::EnsureProportionMoreThan, - governance::custom_origins::FastGeneralAdmin, + EitherOf< + governance::custom_origins::GeneralAdmin, + governance::custom_origins::FastGeneralAdmin, + >, >, >; @@ -730,7 +733,10 @@ pub type AddAndEditSupportedAssetOrigin = EitherOfDiverse< EnsureRoot, EitherOfDiverse< pallet_collective::EnsureProportionMoreThan, - governance::custom_origins::FastGeneralAdmin, + EitherOf< + governance::custom_origins::GeneralAdmin, + governance::custom_origins::FastGeneralAdmin, + >, >, >; diff --git a/runtime/moonbeam/src/governance/referenda.rs b/runtime/moonbeam/src/governance/referenda.rs index 62720a0d601..ae7ca1c524d 100644 --- a/runtime/moonbeam/src/governance/referenda.rs +++ b/runtime/moonbeam/src/governance/referenda.rs @@ -51,7 +51,8 @@ parameter_types! { // Origin for general admin or root pub type GeneralAdminOrRoot = EitherOf, origins::GeneralAdmin>; // The policy allows for Root or FastGeneralAdmin. -pub type FastGeneralAdminOrRoot = EitherOf, origins::FastGeneralAdmin>; +pub type FastGeneralAdminOrRoot = + EitherOf, EitherOf>; impl custom_origins::Config for Runtime {} diff --git a/runtime/moonbeam/src/lib.rs b/runtime/moonbeam/src/lib.rs index 9190d2804ae..ea2f2c20908 100644 --- a/runtime/moonbeam/src/lib.rs +++ b/runtime/moonbeam/src/lib.rs @@ -47,8 +47,9 @@ use frame_support::{ traits::{ fungible::{Balanced, Credit, HoldConsideration, Inspect}, tokens::{PayFromAccount, UnityAssetBalanceConversion}, - ConstBool, ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, Contains, EitherOfDiverse, - EqualPrivilegeOnly, InstanceFilter, LinearStoragePrice, OnFinalize, OnUnbalanced, + ConstBool, ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, Contains, EitherOf, + EitherOfDiverse, EqualPrivilegeOnly, InstanceFilter, LinearStoragePrice, OnFinalize, + OnUnbalanced, }, weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient, @@ -1118,7 +1119,10 @@ pub type ForeignAssetMigratorOrigin = EitherOfDiverse< EnsureRoot, EitherOfDiverse< pallet_collective::EnsureProportionMoreThan, - governance::custom_origins::FastGeneralAdmin, + EitherOf< + governance::custom_origins::GeneralAdmin, + governance::custom_origins::FastGeneralAdmin, + >, >, >; diff --git a/runtime/moonbeam/src/xcm_config.rs b/runtime/moonbeam/src/xcm_config.rs index fe9d62b2c63..b0bc7c0d982 100644 --- a/runtime/moonbeam/src/xcm_config.rs +++ b/runtime/moonbeam/src/xcm_config.rs @@ -27,7 +27,7 @@ use super::{ use super::moonbeam_weights; use frame_support::{ parameter_types, - traits::{EitherOfDiverse, Everything, Nothing, PalletInfoAccess, TransformOrigin}, + traits::{EitherOf, EitherOfDiverse, Everything, Nothing, PalletInfoAccess, TransformOrigin}, }; use moonkit_xcm_primitives::AccountIdAssetIdConversion; use sp_runtime::{ @@ -685,7 +685,10 @@ pub type ForeignAssetManagerOrigin = EitherOfDiverse< EnsureRoot, EitherOfDiverse< pallet_collective::EnsureProportionMoreThan, - governance::custom_origins::FastGeneralAdmin, + EitherOf< + governance::custom_origins::GeneralAdmin, + governance::custom_origins::FastGeneralAdmin, + >, >, >; @@ -716,7 +719,10 @@ pub type AddAndEditSupportedAssetOrigin = EitherOfDiverse< EnsureRoot, EitherOfDiverse< pallet_collective::EnsureProportionMoreThan, - governance::custom_origins::FastGeneralAdmin, + EitherOf< + governance::custom_origins::GeneralAdmin, + governance::custom_origins::FastGeneralAdmin, + >, >, >; diff --git a/runtime/moonriver/src/governance/referenda.rs b/runtime/moonriver/src/governance/referenda.rs index d3c06af7934..be271ce5f98 100644 --- a/runtime/moonriver/src/governance/referenda.rs +++ b/runtime/moonriver/src/governance/referenda.rs @@ -51,7 +51,8 @@ parameter_types! { // Origin for general admin or root pub type GeneralAdminOrRoot = EitherOf, origins::GeneralAdmin>; // The policy allows for Root or FastGeneralAdmin. -pub type FastGeneralAdminOrRoot = EitherOf, origins::FastGeneralAdmin>; +pub type FastGeneralAdminOrRoot = + EitherOf, EitherOf>; impl custom_origins::Config for Runtime {} diff --git a/runtime/moonriver/src/lib.rs b/runtime/moonriver/src/lib.rs index e8c82f33770..b6b28c81ae2 100644 --- a/runtime/moonriver/src/lib.rs +++ b/runtime/moonriver/src/lib.rs @@ -48,8 +48,9 @@ use frame_support::{ traits::{ fungible::{Balanced, Credit, HoldConsideration, Inspect}, tokens::{PayFromAccount, UnityAssetBalanceConversion}, - ConstBool, ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, Contains, EitherOfDiverse, - EqualPrivilegeOnly, InstanceFilter, LinearStoragePrice, OnFinalize, OnUnbalanced, + ConstBool, ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, Contains, EitherOf, + EitherOfDiverse, EqualPrivilegeOnly, InstanceFilter, LinearStoragePrice, OnFinalize, + OnUnbalanced, }, weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient, @@ -1126,7 +1127,10 @@ pub type ForeignAssetMigratorOrigin = EitherOfDiverse< EnsureRoot, EitherOfDiverse< pallet_collective::EnsureProportionMoreThan, - governance::custom_origins::FastGeneralAdmin, + EitherOf< + governance::custom_origins::GeneralAdmin, + governance::custom_origins::FastGeneralAdmin, + >, >, >; diff --git a/runtime/moonriver/src/xcm_config.rs b/runtime/moonriver/src/xcm_config.rs index fc3e0b6e67e..dee3e35a1bf 100644 --- a/runtime/moonriver/src/xcm_config.rs +++ b/runtime/moonriver/src/xcm_config.rs @@ -27,7 +27,7 @@ use super::{ use super::moonriver_weights; use frame_support::{ parameter_types, - traits::{EitherOfDiverse, Everything, Nothing, PalletInfoAccess, TransformOrigin}, + traits::{EitherOf, EitherOfDiverse, Everything, Nothing, PalletInfoAccess, TransformOrigin}, }; use moonkit_xcm_primitives::AccountIdAssetIdConversion; use sp_runtime::{ @@ -698,7 +698,10 @@ pub type ForeignAssetManagerOrigin = EitherOfDiverse< EnsureRoot, EitherOfDiverse< pallet_collective::EnsureProportionMoreThan, - governance::custom_origins::FastGeneralAdmin, + EitherOf< + governance::custom_origins::GeneralAdmin, + governance::custom_origins::FastGeneralAdmin, + >, >, >; @@ -729,7 +732,10 @@ pub type AddAndEditSupportedAssetOrigin = EitherOfDiverse< EnsureRoot, EitherOfDiverse< pallet_collective::EnsureProportionMoreThan, - governance::custom_origins::FastGeneralAdmin, + EitherOf< + governance::custom_origins::GeneralAdmin, + governance::custom_origins::FastGeneralAdmin, + >, >, >; From fadba6df9929182b7d66640f422206e67afd3111 Mon Sep 17 00:00:00 2001 From: Rodrigo Quelhas Date: Fri, 31 Jan 2025 10:54:17 +0000 Subject: [PATCH 4/4] improve type description --- runtime/moonbase/src/governance/referenda.rs | 2 +- runtime/moonbeam/src/governance/referenda.rs | 2 +- runtime/moonriver/src/governance/referenda.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/moonbase/src/governance/referenda.rs b/runtime/moonbase/src/governance/referenda.rs index 03e078bc2d0..46033a6a53c 100644 --- a/runtime/moonbase/src/governance/referenda.rs +++ b/runtime/moonbase/src/governance/referenda.rs @@ -51,7 +51,7 @@ parameter_types! { pub type GeneralAdminOrRoot = EitherOf, origins::GeneralAdmin>; -/// The policy allows for Root or FastGeneralAdmin. +/// The policy allows for Root, GeneralAdmin or FastGeneralAdmin. pub type FastGeneralAdminOrRoot = EitherOf, EitherOf>; diff --git a/runtime/moonbeam/src/governance/referenda.rs b/runtime/moonbeam/src/governance/referenda.rs index ae7ca1c524d..f68e69cb237 100644 --- a/runtime/moonbeam/src/governance/referenda.rs +++ b/runtime/moonbeam/src/governance/referenda.rs @@ -50,7 +50,7 @@ parameter_types! { // Origin for general admin or root pub type GeneralAdminOrRoot = EitherOf, origins::GeneralAdmin>; -// The policy allows for Root or FastGeneralAdmin. +/// The policy allows for Root, GeneralAdmin or FastGeneralAdmin. pub type FastGeneralAdminOrRoot = EitherOf, EitherOf>; diff --git a/runtime/moonriver/src/governance/referenda.rs b/runtime/moonriver/src/governance/referenda.rs index be271ce5f98..58ec4bea3b7 100644 --- a/runtime/moonriver/src/governance/referenda.rs +++ b/runtime/moonriver/src/governance/referenda.rs @@ -50,7 +50,7 @@ parameter_types! { // Origin for general admin or root pub type GeneralAdminOrRoot = EitherOf, origins::GeneralAdmin>; -// The policy allows for Root or FastGeneralAdmin. +/// The policy allows for Root, GeneralAdmin or FastGeneralAdmin. pub type FastGeneralAdminOrRoot = EitherOf, EitherOf>;