mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-10 00:38:07 +00:00
AllowHrmpNotificationsFromRelayChain barrier for HRMP notifications from the relaychain (#4156)
This PR: - introduces `AllowHrmpNotificationsFromRelayChain` barrier for allowing HRMP notifications just from the relay chain (to fulfill safety assumptions - [see](https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/xcm/src/v4/mod.rs#L532)) - sets it up for all testnet SP parachains Continuation of: https://github.com/paritytech/polkadot-sdk/pull/3696
This commit is contained in:
@@ -49,17 +49,17 @@ use testnet_parachains_constants::rococo::snowbridge::{
|
||||
};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor,
|
||||
FungibleAdapter, FungiblesAdapter, GlobalConsensusParachainConvertsFor, HashedDescription,
|
||||
IsConcrete, LocalMint, NetworkExportTableItem, NoChecking, NonFungiblesAdapter,
|
||||
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignPaidRemoteExporter, SovereignSignedViaLocation, StartsWith,
|
||||
StartsWithExplicitGlobalConsensus, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
|
||||
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
||||
XcmFeeToAccount,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily,
|
||||
EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter,
|
||||
GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, LocalMint,
|
||||
NetworkExportTableItem, NoChecking, NonFungiblesAdapter, ParentAsSuperuser, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignPaidRemoteExporter,
|
||||
SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
@@ -285,6 +285,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
||||
)>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||
// HRMP notifications from the relay chain are OK.
|
||||
AllowHrmpNotificationsFromRelayChain,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
|
||||
@@ -45,10 +45,10 @@ use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
||||
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, DescribeFamily, DescribePalletTerminal, EnsureXcmOrigin,
|
||||
FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, DescribeFamily, DescribePalletTerminal,
|
||||
EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter,
|
||||
GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, LocalMint,
|
||||
NetworkExportTableItem, NoChecking, NonFungiblesAdapter, ParentAsSuperuser, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
@@ -299,6 +299,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
||||
)>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<Everything>,
|
||||
// HRMP notifications from the relay chain are OK.
|
||||
AllowHrmpNotificationsFromRelayChain,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
|
||||
@@ -46,12 +46,13 @@ use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
deposit_or_burn_fee, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom,
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor,
|
||||
FungibleAdapter, HandleFee, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
||||
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeToAccount,
|
||||
AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin,
|
||||
FrameTransactionalProcessor, FungibleAdapter, HandleFee, IsConcrete, ParentAsSuperuser,
|
||||
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::{
|
||||
traits::{FeeManager, FeeReason, FeeReason::Export, TransactAsset},
|
||||
@@ -150,6 +151,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
||||
)>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||
// HRMP notifications from the relay chain are OK.
|
||||
AllowHrmpNotificationsFromRelayChain,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
|
||||
@@ -38,14 +38,14 @@ use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
||||
use sp_runtime::traits::AccountIdConversion;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, IsConcrete,
|
||||
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
|
||||
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
||||
XcmFeeToAccount,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor,
|
||||
FungibleAdapter, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
||||
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
@@ -139,6 +139,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
||||
)>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||
// HRMP notifications from the relay chain are OK.
|
||||
AllowHrmpNotificationsFromRelayChain,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
|
||||
@@ -35,14 +35,15 @@ use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
||||
use westend_runtime_constants::xcm as xcm_constants;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter,
|
||||
IsConcrete, LocatableAssetId, OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds,
|
||||
FrameTransactionalProcessor, FungibleAdapter, IsConcrete, LocatableAssetId,
|
||||
OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
||||
UsingComponents, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
||||
XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
@@ -156,6 +157,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||
// HRMP notifications from the relay chain are OK.
|
||||
AllowHrmpNotificationsFromRelayChain,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
|
||||
@@ -38,14 +38,14 @@ use sp_runtime::traits::AccountIdConversion;
|
||||
use testnet_parachains_constants::rococo::currency::CENTS;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter,
|
||||
IsConcrete, NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
||||
UsingComponents, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
||||
XcmFeeToAccount,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds,
|
||||
FrameTransactionalProcessor, FungibleAdapter, IsConcrete, NativeAsset, ParentAsSuperuser,
|
||||
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
@@ -149,6 +149,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
||||
)>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||
// HRMP notifications from the relay chain are OK.
|
||||
AllowHrmpNotificationsFromRelayChain,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
|
||||
@@ -39,13 +39,13 @@ use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
||||
use sp_runtime::traits::AccountIdConversion;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, IsConcrete,
|
||||
NonFungibleAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
||||
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor,
|
||||
FungibleAdapter, IsConcrete, NonFungibleAdapter, ParentAsSuperuser, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
@@ -156,6 +156,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||
// HRMP notifications from the relay chain are OK.
|
||||
AllowHrmpNotificationsFromRelayChain,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
|
||||
@@ -39,13 +39,13 @@ use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
||||
use sp_runtime::traits::AccountIdConversion;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, IsConcrete,
|
||||
NonFungibleAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
||||
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor,
|
||||
FungibleAdapter, IsConcrete, NonFungibleAdapter, ParentAsSuperuser, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
@@ -164,6 +164,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
||||
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||
// HRMP notifications from the relay chain are OK.
|
||||
AllowHrmpNotificationsFromRelayChain,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
|
||||
@@ -36,13 +36,13 @@ use polkadot_parachain_primitives::primitives::Sibling;
|
||||
use sp_runtime::traits::AccountIdConversion;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, DescribeTerminus, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter,
|
||||
HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
||||
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, DescribeTerminus, EnsureXcmOrigin,
|
||||
FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete, ParentAsSuperuser,
|
||||
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
@@ -165,6 +165,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||
// HRMP notifications from the relay chain are OK.
|
||||
AllowHrmpNotificationsFromRelayChain,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
|
||||
@@ -36,13 +36,13 @@ use polkadot_parachain_primitives::primitives::Sibling;
|
||||
use sp_runtime::traits::AccountIdConversion;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, DescribeTerminus, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter,
|
||||
HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
||||
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||
DenyReserveTransferToRelayChain, DenyThenTry, DescribeTerminus, EnsureXcmOrigin,
|
||||
FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete, ParentAsSuperuser,
|
||||
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
@@ -173,6 +173,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
||||
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||
// HRMP notifications from the relay chain are OK.
|
||||
AllowHrmpNotificationsFromRelayChain,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
|
||||
@@ -43,14 +43,15 @@ use polkadot_runtime_common::{impls::ToAuthor, xcm_sender::ExponentialPrice};
|
||||
use sp_runtime::traits::{AccountIdConversion, ConvertInto, Identity, TryConvertInto};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex, ConvertedConcreteId, EnsureXcmOrigin,
|
||||
FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, IsConcrete,
|
||||
LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, StartsWith, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
|
||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||
AccountId32Aliases, AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex,
|
||||
ConvertedConcreteId, EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor,
|
||||
FungibleAdapter, FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, NoChecking,
|
||||
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, StartsWith, TakeWeightCredit, TrailingSetTopicAsId,
|
||||
UsingComponents, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
||||
XcmFeeToAccount,
|
||||
};
|
||||
use xcm_executor::{traits::JustTry, XcmExecutor};
|
||||
|
||||
@@ -217,6 +218,8 @@ pub type Barrier = TrailingSetTopicAsId<(
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<Everything>,
|
||||
// HRMP notifications from the relay chain are OK.
|
||||
AllowHrmpNotificationsFromRelayChain,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
|
||||
@@ -74,9 +74,9 @@ use parachains_common::{
|
||||
AccountId, AssetIdForTrustBackedAssets, Signature,
|
||||
};
|
||||
use xcm_builder::{
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AsPrefixedGeneralIndex, ConvertedConcreteId,
|
||||
FrameTransactionalProcessor, FungiblesAdapter, LocalMint, TrailingSetTopicAsId,
|
||||
WithUniqueTopic,
|
||||
AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AsPrefixedGeneralIndex, ConvertedConcreteId, FrameTransactionalProcessor, FungiblesAdapter,
|
||||
LocalMint, TrailingSetTopicAsId, WithUniqueTopic,
|
||||
};
|
||||
use xcm_executor::traits::JustTry;
|
||||
|
||||
@@ -444,6 +444,8 @@ pub type Barrier = TrailingSetTopicAsId<(
|
||||
AllowKnownQueryResponses<PolkadotXcm>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<Everything>,
|
||||
// HRMP notifications from the relay chain are OK.
|
||||
AllowHrmpNotificationsFromRelayChain,
|
||||
)>;
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Common runtime code for Polkadot and Kusama.
|
||||
//! Common runtime code for the Relay Chain, e.g. Rococo, Westend, Polkadot, Kusama ...
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
|
||||
@@ -399,6 +399,41 @@ impl<T: Contains<Location>> ShouldExecute for AllowSubscriptionsFrom<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Allows execution for the Relay Chain origin (represented as `Location::parent()`) if it is just
|
||||
/// a straight `HrmpNewChannelOpenRequest`, `HrmpChannelAccepted`, or `HrmpChannelClosing`
|
||||
/// instruction.
|
||||
///
|
||||
/// Note: This barrier fulfills safety recommendations for the mentioned instructions - see their
|
||||
/// documentation.
|
||||
pub struct AllowHrmpNotificationsFromRelayChain;
|
||||
impl ShouldExecute for AllowHrmpNotificationsFromRelayChain {
|
||||
fn should_execute<RuntimeCall>(
|
||||
origin: &Location,
|
||||
instructions: &mut [Instruction<RuntimeCall>],
|
||||
_max_weight: Weight,
|
||||
_properties: &mut Properties,
|
||||
) -> Result<(), ProcessMessageError> {
|
||||
log::trace!(
|
||||
target: "xcm::barriers",
|
||||
"AllowHrmpNotificationsFromRelayChain origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}",
|
||||
origin, instructions, _max_weight, _properties,
|
||||
);
|
||||
// accept only the Relay Chain
|
||||
ensure!(matches!(origin.unpack(), (1, [])), ProcessMessageError::Unsupported);
|
||||
// accept only HRMP notifications and nothing else
|
||||
instructions
|
||||
.matcher()
|
||||
.assert_remaining_insts(1)?
|
||||
.match_next_inst(|inst| match inst {
|
||||
HrmpNewChannelOpenRequest { .. } |
|
||||
HrmpChannelAccepted { .. } |
|
||||
HrmpChannelClosing { .. } => Ok(()),
|
||||
_ => Err(ProcessMessageError::BadFormat),
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Deny executing the XCM if it matches any of the Deny filter regardless of anything else.
|
||||
/// If it passes the Deny, and matches one of the Allow cases then it is let through.
|
||||
pub struct DenyThenTry<Deny, Allow>(PhantomData<Deny>, PhantomData<Allow>)
|
||||
|
||||
@@ -35,10 +35,11 @@ pub use asset_conversion::{
|
||||
|
||||
mod barriers;
|
||||
pub use barriers::{
|
||||
AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, DenyReserveTransferToRelayChain,
|
||||
DenyThenTry, IsChildSystemParachain, IsParentsOnly, IsSiblingSystemParachain,
|
||||
RespectSuspension, TakeWeightCredit, TrailingSetTopicAsId, WithComputedOrigin,
|
||||
AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||
AllowUnpaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, IsChildSystemParachain,
|
||||
IsParentsOnly, IsSiblingSystemParachain, RespectSuspension, TakeWeightCredit,
|
||||
TrailingSetTopicAsId, WithComputedOrigin,
|
||||
};
|
||||
|
||||
mod controller;
|
||||
|
||||
@@ -315,56 +315,150 @@ fn allow_subscriptions_from_should_work() {
|
||||
// allow only parent
|
||||
AllowSubsFrom::set(vec![Location::parent()]);
|
||||
|
||||
let valid_xcm_1 = Xcm::<TestCall>(vec![SubscribeVersion {
|
||||
query_id: 42,
|
||||
max_response_weight: Weight::from_parts(5000, 5000),
|
||||
}]);
|
||||
let valid_xcm_2 = Xcm::<TestCall>(vec![UnsubscribeVersion]);
|
||||
let invalid_xcm_1 = Xcm::<TestCall>(vec![
|
||||
SetAppendix(Xcm(vec![])),
|
||||
SubscribeVersion { query_id: 42, max_response_weight: Weight::from_parts(5000, 5000) },
|
||||
]);
|
||||
let invalid_xcm_2 = Xcm::<TestCall>(vec![
|
||||
SubscribeVersion { query_id: 42, max_response_weight: Weight::from_parts(5000, 5000) },
|
||||
SetTopic([0; 32]),
|
||||
]);
|
||||
|
||||
let test_data = vec![
|
||||
(
|
||||
valid_xcm_1.clone(),
|
||||
Parachain(1).into_location(),
|
||||
// not allowed origin
|
||||
Err(ProcessMessageError::Unsupported),
|
||||
),
|
||||
(valid_xcm_1, Location::parent(), Ok(())),
|
||||
(
|
||||
valid_xcm_2.clone(),
|
||||
Parachain(1).into_location(),
|
||||
// not allowed origin
|
||||
Err(ProcessMessageError::Unsupported),
|
||||
),
|
||||
(valid_xcm_2, Location::parent(), Ok(())),
|
||||
(
|
||||
invalid_xcm_1,
|
||||
Location::parent(),
|
||||
// invalid XCM
|
||||
Err(ProcessMessageError::BadFormat),
|
||||
),
|
||||
(
|
||||
invalid_xcm_2,
|
||||
Location::parent(),
|
||||
// invalid XCM
|
||||
Err(ProcessMessageError::BadFormat),
|
||||
),
|
||||
];
|
||||
|
||||
for (mut message, origin, expected_result) in test_data {
|
||||
let r = AllowSubscriptionsFrom::<IsInVec<AllowSubsFrom>>::should_execute(
|
||||
&origin,
|
||||
message.inner_mut(),
|
||||
Weight::from_parts(10, 10),
|
||||
&mut props(Weight::zero()),
|
||||
// closure for (xcm, origin) testing with `AllowSubscriptionsFrom`
|
||||
let assert_should_execute = |mut xcm: Vec<Instruction<()>>, origin, expected_result| {
|
||||
assert_eq!(
|
||||
AllowSubscriptionsFrom::<IsInVec<AllowSubsFrom>>::should_execute(
|
||||
&origin,
|
||||
&mut xcm,
|
||||
Weight::from_parts(10, 10),
|
||||
&mut props(Weight::zero()),
|
||||
),
|
||||
expected_result
|
||||
);
|
||||
assert_eq!(r, expected_result, "Failed for origin: {origin:?} and message: {message:?}");
|
||||
}
|
||||
};
|
||||
|
||||
// invalid origin
|
||||
assert_should_execute(
|
||||
vec![SubscribeVersion {
|
||||
query_id: Default::default(),
|
||||
max_response_weight: Default::default(),
|
||||
}],
|
||||
Parachain(1).into_location(),
|
||||
Err(ProcessMessageError::Unsupported),
|
||||
);
|
||||
assert_should_execute(
|
||||
vec![UnsubscribeVersion],
|
||||
Parachain(1).into_location(),
|
||||
Err(ProcessMessageError::Unsupported),
|
||||
);
|
||||
|
||||
// invalid XCM (unexpected instruction before)
|
||||
assert_should_execute(
|
||||
vec![
|
||||
SetAppendix(Xcm(vec![])),
|
||||
SubscribeVersion {
|
||||
query_id: Default::default(),
|
||||
max_response_weight: Default::default(),
|
||||
},
|
||||
],
|
||||
Location::parent(),
|
||||
Err(ProcessMessageError::BadFormat),
|
||||
);
|
||||
assert_should_execute(
|
||||
vec![SetAppendix(Xcm(vec![])), UnsubscribeVersion],
|
||||
Location::parent(),
|
||||
Err(ProcessMessageError::BadFormat),
|
||||
);
|
||||
// invalid XCM (unexpected instruction after)
|
||||
assert_should_execute(
|
||||
vec![
|
||||
SubscribeVersion {
|
||||
query_id: Default::default(),
|
||||
max_response_weight: Default::default(),
|
||||
},
|
||||
SetTopic([0; 32]),
|
||||
],
|
||||
Location::parent(),
|
||||
Err(ProcessMessageError::BadFormat),
|
||||
);
|
||||
assert_should_execute(
|
||||
vec![UnsubscribeVersion, SetTopic([0; 32])],
|
||||
Location::parent(),
|
||||
Err(ProcessMessageError::BadFormat),
|
||||
);
|
||||
// invalid XCM (unexpected instruction)
|
||||
assert_should_execute(
|
||||
vec![SetAppendix(Xcm(vec![]))],
|
||||
Location::parent(),
|
||||
Err(ProcessMessageError::BadFormat),
|
||||
);
|
||||
|
||||
// ok
|
||||
assert_should_execute(
|
||||
vec![SubscribeVersion {
|
||||
query_id: Default::default(),
|
||||
max_response_weight: Default::default(),
|
||||
}],
|
||||
Location::parent(),
|
||||
Ok(()),
|
||||
);
|
||||
assert_should_execute(vec![UnsubscribeVersion], Location::parent(), Ok(()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_hrmp_notifications_from_relay_chain_should_work() {
|
||||
// closure for (xcm, origin) testing with `AllowHrmpNotificationsFromRelayChain`
|
||||
let assert_should_execute = |mut xcm: Vec<Instruction<()>>, origin, expected_result| {
|
||||
assert_eq!(
|
||||
AllowHrmpNotificationsFromRelayChain::should_execute(
|
||||
&origin,
|
||||
&mut xcm,
|
||||
Weight::from_parts(10, 10),
|
||||
&mut props(Weight::zero()),
|
||||
),
|
||||
expected_result
|
||||
);
|
||||
};
|
||||
|
||||
// invalid origin
|
||||
assert_should_execute(
|
||||
vec![HrmpChannelAccepted { recipient: Default::default() }],
|
||||
Location::new(1, [Parachain(1)]),
|
||||
Err(ProcessMessageError::Unsupported),
|
||||
);
|
||||
|
||||
// invalid XCM (unexpected instruction before)
|
||||
assert_should_execute(
|
||||
vec![SetAppendix(Xcm(vec![])), HrmpChannelAccepted { recipient: Default::default() }],
|
||||
Location::parent(),
|
||||
Err(ProcessMessageError::BadFormat),
|
||||
);
|
||||
// invalid XCM (unexpected instruction after)
|
||||
assert_should_execute(
|
||||
vec![HrmpChannelAccepted { recipient: Default::default() }, SetTopic([0; 32])],
|
||||
Location::parent(),
|
||||
Err(ProcessMessageError::BadFormat),
|
||||
);
|
||||
// invalid XCM (unexpected instruction)
|
||||
assert_should_execute(
|
||||
vec![SetAppendix(Xcm(vec![]))],
|
||||
Location::parent(),
|
||||
Err(ProcessMessageError::BadFormat),
|
||||
);
|
||||
|
||||
// ok
|
||||
assert_should_execute(
|
||||
vec![HrmpChannelAccepted { recipient: Default::default() }],
|
||||
Location::parent(),
|
||||
Ok(()),
|
||||
);
|
||||
assert_should_execute(
|
||||
vec![HrmpNewChannelOpenRequest {
|
||||
max_capacity: Default::default(),
|
||||
sender: Default::default(),
|
||||
max_message_size: Default::default(),
|
||||
}],
|
||||
Location::parent(),
|
||||
Ok(()),
|
||||
);
|
||||
assert_should_execute(
|
||||
vec![HrmpChannelClosing {
|
||||
recipient: Default::default(),
|
||||
sender: Default::default(),
|
||||
initiator: Default::default(),
|
||||
}],
|
||||
Location::parent(),
|
||||
Ok(()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
title: "`AllowHrmpNotificationsFromRelayChain` barrier for HRMP notifications from the relaychain"
|
||||
|
||||
doc:
|
||||
- audience: Runtime Dev
|
||||
description: |
|
||||
A new barrier, `AllowHrmpNotificationsFromRelayChain`, has been added.
|
||||
This barrier can be utilized to ensure that HRMP notifications originate solely from the Relay Chain.
|
||||
If your runtime relies on these notifications,
|
||||
you can include it in the runtime's barrier type for `xcm_executor::Config`.
|
||||
|
||||
crates:
|
||||
- name: staging-xcm-builder
|
||||
bump: minor
|
||||
Reference in New Issue
Block a user