mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 12:35:42 +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::latest::prelude::*;
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||||
DenyThenTry, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor,
|
DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily,
|
||||||
FungibleAdapter, FungiblesAdapter, GlobalConsensusParachainConvertsFor, HashedDescription,
|
EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter,
|
||||||
IsConcrete, LocalMint, NetworkExportTableItem, NoChecking, NonFungiblesAdapter,
|
GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, LocalMint,
|
||||||
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
NetworkExportTableItem, NoChecking, NonFungiblesAdapter, ParentAsSuperuser, ParentIsPreset,
|
||||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||||
SovereignPaidRemoteExporter, SovereignSignedViaLocation, StartsWith,
|
SignedAccountId32AsNative, SignedToAccountId32, SovereignPaidRemoteExporter,
|
||||||
StartsWithExplicitGlobalConsensus, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
|
SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus, TakeWeightCredit,
|
||||||
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||||
XcmFeeToAccount,
|
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||||
};
|
};
|
||||||
use xcm_executor::XcmExecutor;
|
use xcm_executor::XcmExecutor;
|
||||||
|
|
||||||
@@ -285,6 +285,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
|||||||
)>,
|
)>,
|
||||||
// Subscriptions for version tracking are OK.
|
// Subscriptions for version tracking are OK.
|
||||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||||
|
// HRMP notifications from the relay chain are OK.
|
||||||
|
AllowHrmpNotificationsFromRelayChain,
|
||||||
),
|
),
|
||||||
UniversalLocation,
|
UniversalLocation,
|
||||||
ConstU32<8>,
|
ConstU32<8>,
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
|||||||
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
|
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
|
||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||||
DenyThenTry, DescribeFamily, DescribePalletTerminal, EnsureXcmOrigin,
|
DenyReserveTransferToRelayChain, DenyThenTry, DescribeFamily, DescribePalletTerminal,
|
||||||
FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter,
|
EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter,
|
||||||
GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, LocalMint,
|
GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, LocalMint,
|
||||||
NetworkExportTableItem, NoChecking, NonFungiblesAdapter, ParentAsSuperuser, ParentIsPreset,
|
NetworkExportTableItem, NoChecking, NonFungiblesAdapter, ParentAsSuperuser, ParentIsPreset,
|
||||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||||
@@ -299,6 +299,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
|||||||
)>,
|
)>,
|
||||||
// Subscriptions for version tracking are OK.
|
// Subscriptions for version tracking are OK.
|
||||||
AllowSubscriptionsFrom<Everything>,
|
AllowSubscriptionsFrom<Everything>,
|
||||||
|
// HRMP notifications from the relay chain are OK.
|
||||||
|
AllowHrmpNotificationsFromRelayChain,
|
||||||
),
|
),
|
||||||
UniversalLocation,
|
UniversalLocation,
|
||||||
ConstU32<8>,
|
ConstU32<8>,
|
||||||
|
|||||||
@@ -46,12 +46,13 @@ use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork;
|
|||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
deposit_or_burn_fee, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom,
|
deposit_or_burn_fee, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom,
|
||||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||||
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor,
|
AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin,
|
||||||
FungibleAdapter, HandleFee, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
FrameTransactionalProcessor, FungibleAdapter, HandleFee, IsConcrete, ParentAsSuperuser,
|
||||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||||
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeToAccount,
|
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||||
|
XcmFeeToAccount,
|
||||||
};
|
};
|
||||||
use xcm_executor::{
|
use xcm_executor::{
|
||||||
traits::{FeeManager, FeeReason, FeeReason::Export, TransactAsset},
|
traits::{FeeManager, FeeReason, FeeReason::Export, TransactAsset},
|
||||||
@@ -150,6 +151,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
|||||||
)>,
|
)>,
|
||||||
// Subscriptions for version tracking are OK.
|
// Subscriptions for version tracking are OK.
|
||||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||||
|
// HRMP notifications from the relay chain are OK.
|
||||||
|
AllowHrmpNotificationsFromRelayChain,
|
||||||
),
|
),
|
||||||
UniversalLocation,
|
UniversalLocation,
|
||||||
ConstU32<8>,
|
ConstU32<8>,
|
||||||
|
|||||||
@@ -38,14 +38,14 @@ use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
|||||||
use sp_runtime::traits::AccountIdConversion;
|
use sp_runtime::traits::AccountIdConversion;
|
||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||||
DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, IsConcrete,
|
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor,
|
||||||
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
FungibleAdapter, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||||
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
|
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
||||||
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||||
XcmFeeToAccount,
|
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||||
};
|
};
|
||||||
use xcm_executor::XcmExecutor;
|
use xcm_executor::XcmExecutor;
|
||||||
|
|
||||||
@@ -139,6 +139,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
|||||||
)>,
|
)>,
|
||||||
// Subscriptions for version tracking are OK.
|
// Subscriptions for version tracking are OK.
|
||||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||||
|
// HRMP notifications from the relay chain are OK.
|
||||||
|
AllowHrmpNotificationsFromRelayChain,
|
||||||
),
|
),
|
||||||
UniversalLocation,
|
UniversalLocation,
|
||||||
ConstU32<8>,
|
ConstU32<8>,
|
||||||
|
|||||||
@@ -35,14 +35,15 @@ use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
|||||||
use westend_runtime_constants::xcm as xcm_constants;
|
use westend_runtime_constants::xcm as xcm_constants;
|
||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||||
DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter,
|
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds,
|
||||||
IsConcrete, LocatableAssetId, OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset,
|
FrameTransactionalProcessor, FungibleAdapter, IsConcrete, LocatableAssetId,
|
||||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||||
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
|
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
||||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
UsingComponents, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
||||||
|
XcmFeeToAccount,
|
||||||
};
|
};
|
||||||
use xcm_executor::XcmExecutor;
|
use xcm_executor::XcmExecutor;
|
||||||
|
|
||||||
@@ -156,6 +157,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
|||||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
||||||
// Subscriptions for version tracking are OK.
|
// Subscriptions for version tracking are OK.
|
||||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||||
|
// HRMP notifications from the relay chain are OK.
|
||||||
|
AllowHrmpNotificationsFromRelayChain,
|
||||||
),
|
),
|
||||||
UniversalLocation,
|
UniversalLocation,
|
||||||
ConstU32<8>,
|
ConstU32<8>,
|
||||||
|
|||||||
@@ -38,14 +38,14 @@ use sp_runtime::traits::AccountIdConversion;
|
|||||||
use testnet_parachains_constants::rococo::currency::CENTS;
|
use testnet_parachains_constants::rococo::currency::CENTS;
|
||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||||
DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter,
|
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds,
|
||||||
IsConcrete, NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
FrameTransactionalProcessor, FungibleAdapter, IsConcrete, NativeAsset, ParentAsSuperuser,
|
||||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||||
UsingComponents, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
|
||||||
XcmFeeToAccount,
|
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||||
};
|
};
|
||||||
use xcm_executor::XcmExecutor;
|
use xcm_executor::XcmExecutor;
|
||||||
|
|
||||||
@@ -149,6 +149,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
|||||||
)>,
|
)>,
|
||||||
// Subscriptions for version tracking are OK.
|
// Subscriptions for version tracking are OK.
|
||||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||||
|
// HRMP notifications from the relay chain are OK.
|
||||||
|
AllowHrmpNotificationsFromRelayChain,
|
||||||
),
|
),
|
||||||
UniversalLocation,
|
UniversalLocation,
|
||||||
ConstU32<8>,
|
ConstU32<8>,
|
||||||
|
|||||||
@@ -39,13 +39,13 @@ use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
|||||||
use sp_runtime::traits::AccountIdConversion;
|
use sp_runtime::traits::AccountIdConversion;
|
||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||||
DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, IsConcrete,
|
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor,
|
||||||
NonFungibleAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
FungibleAdapter, IsConcrete, NonFungibleAdapter, ParentAsSuperuser, ParentIsPreset,
|
||||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||||
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||||
};
|
};
|
||||||
use xcm_executor::XcmExecutor;
|
use xcm_executor::XcmExecutor;
|
||||||
@@ -156,6 +156,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
|||||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
||||||
// Subscriptions for version tracking are OK.
|
// Subscriptions for version tracking are OK.
|
||||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||||
|
// HRMP notifications from the relay chain are OK.
|
||||||
|
AllowHrmpNotificationsFromRelayChain,
|
||||||
),
|
),
|
||||||
UniversalLocation,
|
UniversalLocation,
|
||||||
ConstU32<8>,
|
ConstU32<8>,
|
||||||
|
|||||||
@@ -39,13 +39,13 @@ use polkadot_runtime_common::xcm_sender::ExponentialPrice;
|
|||||||
use sp_runtime::traits::AccountIdConversion;
|
use sp_runtime::traits::AccountIdConversion;
|
||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||||
DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, IsConcrete,
|
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor,
|
||||||
NonFungibleAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
FungibleAdapter, IsConcrete, NonFungibleAdapter, ParentAsSuperuser, ParentIsPreset,
|
||||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||||
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||||
};
|
};
|
||||||
use xcm_executor::XcmExecutor;
|
use xcm_executor::XcmExecutor;
|
||||||
@@ -164,6 +164,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
|||||||
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>,
|
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>,
|
||||||
// Subscriptions for version tracking are OK.
|
// Subscriptions for version tracking are OK.
|
||||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||||
|
// HRMP notifications from the relay chain are OK.
|
||||||
|
AllowHrmpNotificationsFromRelayChain,
|
||||||
),
|
),
|
||||||
UniversalLocation,
|
UniversalLocation,
|
||||||
ConstU32<8>,
|
ConstU32<8>,
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ use polkadot_parachain_primitives::primitives::Sibling;
|
|||||||
use sp_runtime::traits::AccountIdConversion;
|
use sp_runtime::traits::AccountIdConversion;
|
||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||||
DenyThenTry, DescribeTerminus, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter,
|
DenyReserveTransferToRelayChain, DenyThenTry, DescribeTerminus, EnsureXcmOrigin,
|
||||||
HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete, ParentAsSuperuser,
|
||||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||||
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||||
};
|
};
|
||||||
use xcm_executor::XcmExecutor;
|
use xcm_executor::XcmExecutor;
|
||||||
@@ -165,6 +165,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
|||||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
||||||
// Subscriptions for version tracking are OK.
|
// Subscriptions for version tracking are OK.
|
||||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||||
|
// HRMP notifications from the relay chain are OK.
|
||||||
|
AllowHrmpNotificationsFromRelayChain,
|
||||||
),
|
),
|
||||||
UniversalLocation,
|
UniversalLocation,
|
||||||
ConstU32<8>,
|
ConstU32<8>,
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ use polkadot_parachain_primitives::primitives::Sibling;
|
|||||||
use sp_runtime::traits::AccountIdConversion;
|
use sp_runtime::traits::AccountIdConversion;
|
||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
|
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||||
DenyThenTry, DescribeTerminus, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter,
|
DenyReserveTransferToRelayChain, DenyThenTry, DescribeTerminus, EnsureXcmOrigin,
|
||||||
HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete, ParentAsSuperuser,
|
||||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||||
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
|
||||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
||||||
};
|
};
|
||||||
use xcm_executor::XcmExecutor;
|
use xcm_executor::XcmExecutor;
|
||||||
@@ -173,6 +173,8 @@ pub type Barrier = TrailingSetTopicAsId<
|
|||||||
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>,
|
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>,
|
||||||
// Subscriptions for version tracking are OK.
|
// Subscriptions for version tracking are OK.
|
||||||
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
|
||||||
|
// HRMP notifications from the relay chain are OK.
|
||||||
|
AllowHrmpNotificationsFromRelayChain,
|
||||||
),
|
),
|
||||||
UniversalLocation,
|
UniversalLocation,
|
||||||
ConstU32<8>,
|
ConstU32<8>,
|
||||||
|
|||||||
@@ -43,14 +43,15 @@ use polkadot_runtime_common::{impls::ToAuthor, xcm_sender::ExponentialPrice};
|
|||||||
use sp_runtime::traits::{AccountIdConversion, ConvertInto, Identity, TryConvertInto};
|
use sp_runtime::traits::{AccountIdConversion, ConvertInto, Identity, TryConvertInto};
|
||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
AccountId32Aliases, AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses,
|
||||||
AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex, ConvertedConcreteId, EnsureXcmOrigin,
|
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex,
|
||||||
FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, IsConcrete,
|
ConvertedConcreteId, EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor,
|
||||||
LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
FungibleAdapter, FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, NoChecking,
|
||||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||||
SignedToAccountId32, SovereignSignedViaLocation, StartsWith, TakeWeightCredit,
|
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||||
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
|
SovereignSignedViaLocation, StartsWith, TakeWeightCredit, TrailingSetTopicAsId,
|
||||||
XcmFeeManagerFromComponents, XcmFeeToAccount,
|
UsingComponents, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
||||||
|
XcmFeeToAccount,
|
||||||
};
|
};
|
||||||
use xcm_executor::{traits::JustTry, XcmExecutor};
|
use xcm_executor::{traits::JustTry, XcmExecutor};
|
||||||
|
|
||||||
@@ -217,6 +218,8 @@ pub type Barrier = TrailingSetTopicAsId<(
|
|||||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||||
// Subscriptions for version tracking are OK.
|
// Subscriptions for version tracking are OK.
|
||||||
AllowSubscriptionsFrom<Everything>,
|
AllowSubscriptionsFrom<Everything>,
|
||||||
|
// HRMP notifications from the relay chain are OK.
|
||||||
|
AllowHrmpNotificationsFromRelayChain,
|
||||||
),
|
),
|
||||||
UniversalLocation,
|
UniversalLocation,
|
||||||
ConstU32<8>,
|
ConstU32<8>,
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ use parachains_common::{
|
|||||||
AccountId, AssetIdForTrustBackedAssets, Signature,
|
AccountId, AssetIdForTrustBackedAssets, Signature,
|
||||||
};
|
};
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AsPrefixedGeneralIndex, ConvertedConcreteId,
|
AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||||
FrameTransactionalProcessor, FungiblesAdapter, LocalMint, TrailingSetTopicAsId,
|
AsPrefixedGeneralIndex, ConvertedConcreteId, FrameTransactionalProcessor, FungiblesAdapter,
|
||||||
WithUniqueTopic,
|
LocalMint, TrailingSetTopicAsId, WithUniqueTopic,
|
||||||
};
|
};
|
||||||
use xcm_executor::traits::JustTry;
|
use xcm_executor::traits::JustTry;
|
||||||
|
|
||||||
@@ -444,6 +444,8 @@ pub type Barrier = TrailingSetTopicAsId<(
|
|||||||
AllowKnownQueryResponses<PolkadotXcm>,
|
AllowKnownQueryResponses<PolkadotXcm>,
|
||||||
// Subscriptions for version tracking are OK.
|
// Subscriptions for version tracking are OK.
|
||||||
AllowSubscriptionsFrom<Everything>,
|
AllowSubscriptionsFrom<Everything>,
|
||||||
|
// HRMP notifications from the relay chain are OK.
|
||||||
|
AllowHrmpNotificationsFromRelayChain,
|
||||||
)>;
|
)>;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
// 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)]
|
#![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.
|
/// 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.
|
/// 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>)
|
pub struct DenyThenTry<Deny, Allow>(PhantomData<Deny>, PhantomData<Allow>)
|
||||||
|
|||||||
@@ -35,10 +35,11 @@ pub use asset_conversion::{
|
|||||||
|
|
||||||
mod barriers;
|
mod barriers;
|
||||||
pub use barriers::{
|
pub use barriers::{
|
||||||
AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
|
||||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, DenyReserveTransferToRelayChain,
|
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
|
||||||
DenyThenTry, IsChildSystemParachain, IsParentsOnly, IsSiblingSystemParachain,
|
AllowUnpaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, IsChildSystemParachain,
|
||||||
RespectSuspension, TakeWeightCredit, TrailingSetTopicAsId, WithComputedOrigin,
|
IsParentsOnly, IsSiblingSystemParachain, RespectSuspension, TakeWeightCredit,
|
||||||
|
TrailingSetTopicAsId, WithComputedOrigin,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod controller;
|
mod controller;
|
||||||
|
|||||||
@@ -315,56 +315,150 @@ fn allow_subscriptions_from_should_work() {
|
|||||||
// allow only parent
|
// allow only parent
|
||||||
AllowSubsFrom::set(vec![Location::parent()]);
|
AllowSubsFrom::set(vec![Location::parent()]);
|
||||||
|
|
||||||
let valid_xcm_1 = Xcm::<TestCall>(vec![SubscribeVersion {
|
// closure for (xcm, origin) testing with `AllowSubscriptionsFrom`
|
||||||
query_id: 42,
|
let assert_should_execute = |mut xcm: Vec<Instruction<()>>, origin, expected_result| {
|
||||||
max_response_weight: Weight::from_parts(5000, 5000),
|
assert_eq!(
|
||||||
}]);
|
AllowSubscriptionsFrom::<IsInVec<AllowSubsFrom>>::should_execute(
|
||||||
let valid_xcm_2 = Xcm::<TestCall>(vec![UnsubscribeVersion]);
|
&origin,
|
||||||
let invalid_xcm_1 = Xcm::<TestCall>(vec![
|
&mut xcm,
|
||||||
SetAppendix(Xcm(vec![])),
|
Weight::from_parts(10, 10),
|
||||||
SubscribeVersion { query_id: 42, max_response_weight: Weight::from_parts(5000, 5000) },
|
&mut props(Weight::zero()),
|
||||||
]);
|
),
|
||||||
let invalid_xcm_2 = Xcm::<TestCall>(vec![
|
expected_result
|
||||||
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()),
|
|
||||||
);
|
);
|
||||||
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