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

Commit

Permalink
Allow Queries and Subscriptions (#4150)
Browse files Browse the repository at this point in the history
* Allow Queries and Subscriptions

* Formatting

* Formatting
  • Loading branch information
gavofyork authored and drahnr committed Oct 27, 2021
1 parent 21ce8fa commit 2d0029f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
23 changes: 17 additions & 6 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use runtime_parachains::{
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId;
use frame_support::{
construct_runtime, parameter_types,
construct_runtime, match_type, parameter_types,
traits::{Contains, Everything, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, Nothing},
weights::Weight,
PalletId, RuntimeDebug,
Expand Down Expand Up @@ -77,11 +77,12 @@ use sp_version::RuntimeVersion;
use static_assertions::const_assert;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom,
BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia,
ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds,
IsChildSystemParachain, IsConcrete, LocationInverter, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, BackingToPlurality,
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete,
LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
TakeWeightCredit, UsingComponents,
};
use xcm_executor::XcmExecutor;

Expand Down Expand Up @@ -1329,6 +1330,12 @@ parameter_types! {
}
pub type TrustedTeleporters = (xcm_builder::Case<KusamaForStatemine>,);

match_type! {
pub type OnlyParachains: impl Contains<MultiLocation> = {
MultiLocation { parents: 0, interior: X1(Parachain(_)) }
};
}

/// The barriers one of which must be passed for an XCM message to be executed.
pub type Barrier = (
// Weight that is paid for may be consumed.
Expand All @@ -1337,6 +1344,10 @@ pub type Barrier = (
AllowTopLevelPaidExecutionFrom<Everything>,
// Messages coming from system parachains need not pay for execution.
AllowUnpaidExecutionFrom<IsChildSystemParachain<ParaId>>,
// Expected responses are OK.
AllowKnownQueryResponses<XcmPallet>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<OnlyParachains>,
);

pub struct XcmConfig;
Expand Down
12 changes: 8 additions & 4 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ use constants::{currency::*, fee::*, time::*};
use frame_support::traits::InstanceFilter;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia,
ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds,
IsConcrete, LocationInverter, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, UsingComponents,
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, BackingToPlurality,
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, LocationInverter,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, UsingComponents,
};
use xcm_executor::XcmExecutor;

Expand Down Expand Up @@ -672,6 +672,10 @@ pub type Barrier = (
TakeWeightCredit,
AllowTopLevelPaidExecutionFrom<Everything>,
AllowUnpaidExecutionFrom<IsInVec<AllowUnpaidFrom>>, // <- Trusted parachains get free execution
// Expected responses are OK.
AllowKnownQueryResponses<XcmPallet>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
);

pub struct XcmConfig;
Expand Down
9 changes: 7 additions & 2 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ use runtime_parachains::{

use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom,
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ChildParachainAsNative,
ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, LocationInverter,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
UsingComponents, WeightInfoBounds,
Expand Down Expand Up @@ -976,6 +977,10 @@ pub type Barrier = (
AllowTopLevelPaidExecutionFrom<Everything>,
// Messages coming from system parachains need not pay for execution.
AllowUnpaidExecutionFrom<IsChildSystemParachain<ParaId>>,
// Expected responses are OK.
AllowKnownQueryResponses<XcmPallet>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
);

pub struct XcmConfig;
Expand Down

0 comments on commit 2d0029f

Please sign in to comment.