Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
XCM: Replace council XCM origin with general admin (#7633)
Browse files Browse the repository at this point in the history
* XCM: Replace council XCM origin with general admin

* Fixes

* Fixes

* Update runtime/polkadot/src/xcm_config.rs

Co-authored-by: ordian <[email protected]>

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

---------

Co-authored-by: ordian <[email protected]>
Co-authored-by: command-bot <>
  • Loading branch information
KiChjang and ordian authored Aug 18, 2023
1 parent 56d45fe commit 1ef2f8a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 46 deletions.
2 changes: 1 addition & 1 deletion runtime/kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
37 changes: 17 additions & 20 deletions runtime/polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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;

Expand Down Expand Up @@ -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.
Expand All @@ -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>,
);
Expand All @@ -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.
Expand All @@ -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;
Expand Down
28 changes: 5 additions & 23 deletions runtime/rococo/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 1ef2f8a

Please sign in to comment.