XCM: Replace council XCM origin with general admin (#7633)

* XCM: Replace council XCM origin with general admin

* Fixes

* Fixes

* Update runtime/polkadot/src/xcm_config.rs

Co-authored-by: ordian <write@reusable.software>

* ".git/.scripts/commands/fmt/fmt.sh"

---------

Co-authored-by: ordian <write@reusable.software>
Co-authored-by: command-bot <>
This commit is contained in:
Keith Yeung
2023-08-17 22:15:35 -07:00
committed by GitHub
parent eaf057c5ed
commit 688a4e4126
4 changed files with 25 additions and 46 deletions
+1 -1
View File
@@ -385,7 +385,7 @@ pub type LocalPalletOriginToLocation = (
impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
// We only allow the root, the council, fellows and the staking admin to send messages.
// We only allow the root, 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.
+2 -2
View File
@@ -110,8 +110,8 @@ mod bag_thresholds;
// Governance configurations.
pub mod governance;
use governance::{
old::CouncilCollective, pallet_custom_origins, AuctionAdmin, FellowshipAdmin, GeneralAdmin,
LeaseAdmin, StakingAdmin, Treasurer, TreasurySpender,
pallet_custom_origins, AuctionAdmin, FellowshipAdmin, GeneralAdmin, LeaseAdmin, StakingAdmin,
Treasurer, TreasurySpender,
};
pub mod xcm_config;
+17 -20
View File
@@ -17,8 +17,8 @@
//! XCM configuration for Polkadot.
use super::{
parachains_origin, AccountId, AllPalletsWithSystem, Balances, CouncilCollective, Dmp,
FellowshipAdmin, ParaId, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin,
parachains_origin, AccountId, AllPalletsWithSystem, Balances, Dmp, FellowshipAdmin,
GeneralAdmin, ParaId, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin,
TransactionByteFee, WeightToFee, XcmPallet,
};
use frame_support::{
@@ -40,11 +40,11 @@ use sp_core::ConstU32;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, BackingToPlurality,
ChildParachainAsNative, ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter,
IsConcrete, MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, ChildParachainAsNative,
ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, IsConcrete, MintLocation,
OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
};
use xcm_executor::traits::WithOriginFilter;
@@ -350,7 +350,8 @@ impl xcm_executor::Config for XcmConfig {
}
parameter_types! {
pub const CouncilBodyId: BodyId = BodyId::Executive;
// `GeneralAdmin` pluralistic body.
pub const GeneralAdminBodyId: BodyId = BodyId::Administration;
// StakingAdmin pluralistic body.
pub const StakingAdminBodyId: BodyId = BodyId::Defense;
// FellowshipAdmin pluralistic body.
@@ -362,17 +363,14 @@ parameter_types! {
pub ReachableDest: Option<MultiLocation> = Some(Parachain(1000).into());
}
/// Type to convert a council origin to a Plurality `MultiLocation` value.
pub type CouncilToPlurality = BackingToPlurality<
RuntimeOrigin,
pallet_collective::Origin<Runtime, CouncilCollective>,
CouncilBodyId,
>;
/// Type to convert the `GeneralAdmin` origin to a Plurality `MultiLocation` value.
pub type GeneralAdminToPlurality =
OriginToPluralityVoice<RuntimeOrigin, GeneralAdmin, GeneralAdminBodyId>;
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior
/// location of this chain.
pub type LocalOriginToLocation = (
CouncilToPlurality,
GeneralAdminToPlurality,
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
SignedToAccountId32<RuntimeOrigin, AccountId, ThisNetwork>,
);
@@ -381,16 +379,15 @@ pub type LocalOriginToLocation = (
pub type StakingAdminToPlurality =
OriginToPluralityVoice<RuntimeOrigin, StakingAdmin, StakingAdminBodyId>;
/// Type to convert the FellowshipAdmin origin to a Plurality `MultiLocation` value.
/// Type to convert the `FellowshipAdmin` origin to a Plurality `MultiLocation` value.
pub type FellowshipAdminToPlurality =
OriginToPluralityVoice<RuntimeOrigin, FellowshipAdmin, FellowshipAdminBodyId>;
/// 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,
// GeneralAdmin origin to be used in XCM as a corresponding Plurality `MultiLocation` value.
GeneralAdminToPlurality,
// StakingAdmin origin to be used in XCM as a corresponding Plurality `MultiLocation` value.
StakingAdminToPlurality,
// FellowshipAdmin origin to be used in XCM as a corresponding Plurality `MultiLocation` value.
@@ -399,7 +396,7 @@ pub type LocalPalletOriginToLocation = (
impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
// We only allow the root, the council, the fellowship admin and the staking admin to send
// We only allow the root, the general admin, the fellowship admin and the staking admin to send
// messages.
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalPalletOriginToLocation>;
type XcmRouter = XcmRouter;
+5 -23
View File
@@ -17,8 +17,8 @@
//! XCM configuration for Rococo.
use super::{
parachains_origin, AccountId, AllPalletsWithSystem, Balances, CouncilCollective, Dmp, ParaId,
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, TransactionByteFee, WeightToFee, XcmPallet,
parachains_origin, AccountId, AllPalletsWithSystem, Balances, Dmp, ParaId, Runtime,
RuntimeCall, RuntimeEvent, RuntimeOrigin, TransactionByteFee, WeightToFee, XcmPallet,
};
use frame_support::{
match_types, parameter_types,
@@ -36,8 +36,8 @@ use sp_core::ConstU32;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, BackingToPlurality,
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, ChildParachainAsNative,
ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete,
MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin,
@@ -322,33 +322,15 @@ impl xcm_executor::Config for XcmConfig {
type Aliasers = Nothing;
}
parameter_types! {
pub const CollectiveBodyId: BodyId = BodyId::Unit;
}
parameter_types! {
pub const CouncilBodyId: BodyId = BodyId::Executive;
}
#[cfg(feature = "runtime-benchmarks")]
parameter_types! {
pub ReachableDest: Option<MultiLocation> = Some(Parachain(1000).into());
}
/// Type to convert the council origin to a Plurality `MultiLocation` value.
pub type CouncilToPlurality = BackingToPlurality<
RuntimeOrigin,
pallet_collective::Origin<Runtime, CouncilCollective>,
CouncilBodyId,
>;
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior
/// location of this chain.
pub type LocalOriginToLocation = (
// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality
// of the `Unit` body.
CouncilToPlurality,
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
// A usual Signed origin to be used in XCM as a corresponding AccountId32
SignedToAccountId32<RuntimeOrigin, AccountId, ThisNetwork>,
);
impl pallet_xcm::Config for Runtime {