Polkadot parachains get topic-based message IDs (#2642)

* Polkadot parachains get topics

* Formatting

---------

Co-authored-by: joepetrowski <joe@parity.io>
Co-authored-by: parity-processbot <>
This commit is contained in:
Gavin Wood
2023-08-10 02:08:56 -07:00
committed by GitHub
parent 195a2c38eb
commit 0765e2d152
4 changed files with 89 additions and 81 deletions
@@ -38,8 +38,8 @@ use xcm_builder::{
EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NativeAsset, EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NativeAsset,
NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WithComputedOrigin, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
}; };
use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
@@ -350,30 +350,34 @@ impl Contains<RuntimeCall> for SafeCallFilter {
} }
} }
pub type Barrier = DenyThenTry< pub type Barrier = TrailingSetTopicAsId<
DenyReserveTransferToRelayChain, DenyThenTry<
( DenyReserveTransferToRelayChain,
TakeWeightCredit, (
// Expected responses are OK. TakeWeightCredit,
AllowKnownQueryResponses<PolkadotXcm>, // Expected responses are OK.
// Allow XCMs with some computed origins to pass through. AllowKnownQueryResponses<PolkadotXcm>,
WithComputedOrigin< // Allow XCMs with some computed origins to pass through.
( WithComputedOrigin<
// If the message is one that immediately attemps to pay for execution, then allow it. (
AllowTopLevelPaidExecutionFrom<Everything>, // If the message is one that immediately attemps to pay for execution, then
// Parent, its pluralities (i.e. governance bodies), and the Fellows plurality get free execution. // allow it.
AllowExplicitUnpaidExecutionFrom<( AllowTopLevelPaidExecutionFrom<Everything>,
ParentOrParentsPlurality, // Parent, its pluralities (i.e. governance bodies), and the Fellows plurality
FellowsPlurality, // get free execution.
FellowshipSalaryPallet, AllowExplicitUnpaidExecutionFrom<(
)>, ParentOrParentsPlurality,
// Subscriptions for version tracking are OK. FellowsPlurality,
AllowSubscriptionsFrom<ParentOrSiblings>, FellowshipSalaryPallet,
), )>,
UniversalLocation, // Subscriptions for version tracking are OK.
ConstU32<8>, AllowSubscriptionsFrom<ParentOrSiblings>,
>, ),
), UniversalLocation,
ConstU32<8>,
>,
),
>,
>; >;
pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentialDepositMultiplier< pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentialDepositMultiplier<
@@ -443,12 +447,12 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
/// The means for routing XCM messages which are not for local execution into the right message /// The means for routing XCM messages which are not for local execution into the right message
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = WithUniqueTopic<(
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); )>;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
parameter_types! { parameter_types! {
@@ -33,7 +33,7 @@ use xcm_builder::{
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, IsConcrete, ParentAsSuperuser, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, IsConcrete, ParentAsSuperuser,
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
UsingComponents, WeightInfoBounds, WithComputedOrigin, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
}; };
use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
@@ -156,26 +156,28 @@ impl Contains<RuntimeCall> for SafeCallFilter {
} }
} }
pub type Barrier = DenyThenTry< pub type Barrier = TrailingSetTopicAsId<
DenyReserveTransferToRelayChain, DenyThenTry<
( DenyReserveTransferToRelayChain,
// Allow local users to buy weight credit. (
TakeWeightCredit, // Allow local users to buy weight credit.
// Expected responses are OK. TakeWeightCredit,
AllowKnownQueryResponses<PolkadotXcm>, // Expected responses are OK.
WithComputedOrigin< AllowKnownQueryResponses<PolkadotXcm>,
( WithComputedOrigin<
// If the message is one that immediately attemps to pay for execution, then allow it. (
AllowTopLevelPaidExecutionFrom<Everything>, // If the message is one that immediately attemps to pay for execution, then allow it.
// Parent, its pluralities (i.e. governance bodies), and the Fellows plurality get free execution. AllowTopLevelPaidExecutionFrom<Everything>,
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>, // Parent, its pluralities (i.e. governance bodies), and the Fellows plurality get free execution.
// Subscriptions for version tracking are OK. AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>,
AllowSubscriptionsFrom<ParentOrSiblings>, // Subscriptions for version tracking are OK.
), AllowSubscriptionsFrom<ParentOrSiblings>,
UniversalLocation, ),
ConstU32<8>, UniversalLocation,
>, ConstU32<8>,
), >,
),
>,
>; >;
pub struct XcmConfig; pub struct XcmConfig;
@@ -220,12 +222,12 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
/// The means for routing XCM messages which are not for local execution into the right message /// The means for routing XCM messages which are not for local execution into the right message
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = WithUniqueTopic<(
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); )>;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
parameter_types! { parameter_types! {
@@ -33,8 +33,8 @@ use xcm_builder::{
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, IsConcrete,
OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
WithComputedOrigin, UsingComponents, WithComputedOrigin, WithUniqueTopic,
}; };
use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
@@ -202,27 +202,29 @@ impl Contains<RuntimeCall> for SafeCallFilter {
} }
} }
pub type Barrier = DenyThenTry< pub type Barrier = TrailingSetTopicAsId<
DenyReserveTransferToRelayChain, DenyThenTry<
( DenyReserveTransferToRelayChain,
// Allow local users to buy weight credit. (
TakeWeightCredit, // Allow local users to buy weight credit.
// Expected responses are OK. TakeWeightCredit,
AllowKnownQueryResponses<PolkadotXcm>, // Expected responses are OK.
// Allow XCMs with some computed origins to pass through. AllowKnownQueryResponses<PolkadotXcm>,
WithComputedOrigin< // Allow XCMs with some computed origins to pass through.
( WithComputedOrigin<
// If the message is one that immediately attemps to pay for execution, then allow it. (
AllowTopLevelPaidExecutionFrom<Everything>, // If the message is one that immediately attemps to pay for execution, then allow it.
// Parent and its pluralities (i.e. governance bodies) get free execution. AllowTopLevelPaidExecutionFrom<Everything>,
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>, // Parent and its pluralities (i.e. governance bodies) get free execution.
// Subscriptions for version tracking are OK. AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
AllowSubscriptionsFrom<ParentOrSiblings>, // Subscriptions for version tracking are OK.
), AllowSubscriptionsFrom<ParentOrSiblings>,
UniversalLocation, ),
ConstU32<8>, UniversalLocation,
>, ConstU32<8>,
), >,
),
>,
>; >;
pub struct XcmConfig; pub struct XcmConfig;
@@ -263,12 +265,12 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
/// The means for routing XCM messages which are not for local execution into the right message /// The means for routing XCM messages which are not for local execution into the right message
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = WithUniqueTopic<(
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); )>;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
parameter_types! { parameter_types! {
@@ -70,7 +70,7 @@ use parachains_common::{
}; };
use xcm_builder::{ use xcm_builder::{
AllowKnownQueryResponses, AllowSubscriptionsFrom, AsPrefixedGeneralIndex, ConvertedConcreteId, AllowKnownQueryResponses, AllowSubscriptionsFrom, AsPrefixedGeneralIndex, ConvertedConcreteId,
FungiblesAdapter, LocalMint, FungiblesAdapter, LocalMint, TrailingSetTopicAsId, WithUniqueTopic,
}; };
use xcm_executor::traits::JustTry; use xcm_executor::traits::JustTry;
@@ -383,7 +383,7 @@ match_types! {
}; };
} }
pub type Barrier = ( pub type Barrier = TrailingSetTopicAsId<(
TakeWeightCredit, TakeWeightCredit,
AllowTopLevelPaidExecutionFrom<Everything>, AllowTopLevelPaidExecutionFrom<Everything>,
// Parent & its unit plurality gets free execution. // Parent & its unit plurality gets free execution.
@@ -394,7 +394,7 @@ pub type Barrier = (
AllowKnownQueryResponses<PolkadotXcm>, AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK. // Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>, AllowSubscriptionsFrom<Everything>,
); )>;
parameter_types! { parameter_types! {
pub MaxAssetsIntoHolding: u32 = 64; pub MaxAssetsIntoHolding: u32 = 64;
@@ -441,12 +441,12 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
/// The means for routing XCM messages which are not for local execution into the right message /// The means for routing XCM messages which are not for local execution into the right message
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = WithUniqueTopic<(
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, (), ()>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, (), ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); )>;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
parameter_types! { parameter_types! {