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

Commit

Permalink
Allow relay chain council to send XCMs (#5597)
Browse files Browse the repository at this point in the history
* Allow relay chain council to send XCMs

* Update runtime/kusama/src/xcm_config.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* spellcheck

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: joepetrowski <joe@parity.io>
  • Loading branch information
4 people committed Jun 16, 2022
1 parent f57d7f1 commit 56e9b67
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
23 changes: 13 additions & 10 deletions runtime/kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,26 +152,29 @@ parameter_types! {
pub const CouncilBodyId: BodyId = BodyId::Executive;
}

/// Type to convert the council origin to a Plurality `MultiLocation` value.
pub type CouncilToPlurality = BackingToPlurality<
Origin,
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.
BackingToPlurality<
Origin,
pallet_collective::Origin<Runtime, CouncilCollective>,
CouncilBodyId,
>,
CouncilToPlurality,
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
SignedToAccountId32<Origin, AccountId, KusamaNetwork>,
);
impl pallet_xcm::Config for Runtime {
type Event = Event;
// We don't allow any messages to be sent via the transaction yet. This is basically safe to
// enable, (safe the possibility of someone spamming the parachain if they're willing to pay
// the DOT 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<Origin, ()>;
// 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<Origin, CouncilToPlurality>;
type XcmRouter = XcmRouter;
// Anyone can execute XCM messages locally.
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
Expand Down
17 changes: 10 additions & 7 deletions runtime/polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,24 +157,27 @@ parameter_types! {
pub const AdvertisedXcmVersion: u32 = 2;
}

/// Type to convert a council origin to a Plurality `MultiLocation` value.
pub type CouncilToPlurality = BackingToPlurality<
Origin,
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.
BackingToPlurality<
Origin,
pallet_collective::Origin<Runtime, CouncilCollective>,
CouncilBodyId,
>,
CouncilToPlurality,
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
SignedToAccountId32<Origin, AccountId, PolkadotNetwork>,
);

impl pallet_xcm::Config for Runtime {
type Event = Event;
// Not much use in sending XCM at this point.
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, ()>; // == Deny All
// Only allow the council to send messages.
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, CouncilToPlurality>;
type XcmRouter = XcmRouter;
// Anyone can execute XCM messages locally...
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
Expand Down

0 comments on commit 56e9b67

Please sign in to comment.