Use safer template defaults for polkadot-v0.9.12, move to recognize, comment on Override for AdvertisedXcmVersion default (#690)

* use safer defaults in template for sovereign paraobjects

* fmt

* Nothing trait, fix XcmTeleportFilter

* rm unused traits, update rococo and template runtimes

* https://writingexplained.org/recognise-or-recognize-difference

* Override for AdvertisedXcmVersion default ->  to match all runtimes

* cargo +nightly fmt
This commit is contained in:
Dan Shields
2021-10-23 09:40:14 -06:00
committed by GitHub
parent 92982729eb
commit f5926c2f50
6 changed files with 31 additions and 28 deletions
+9 -12
View File
@@ -23,7 +23,7 @@ use sp_version::RuntimeVersion;
use frame_support::{ use frame_support::{
construct_runtime, match_type, parameter_types, construct_runtime, match_type, parameter_types,
traits::Everything, traits::{Everything, Nothing},
weights::{ weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, WEIGHT_PER_SECOND}, constants::{BlockExecutionWeight, ExtrinsicBaseWeight, WEIGHT_PER_SECOND},
DispatchClass, IdentityFee, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, DispatchClass, IdentityFee, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients,
@@ -50,10 +50,9 @@ use polkadot_runtime_common::{BlockHashCount, RocksDbWeight, SlowAdjustingFeeUpd
use xcm::latest::prelude::*; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, ParentIsDefault,
ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedAccountId32AsNative, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
}; };
use xcm_executor::{Config, XcmExecutor}; use xcm_executor::{Config, XcmExecutor};
@@ -438,14 +437,11 @@ pub type XcmOriginToTransactDispatchOrigin = (
// foreign chains who want to have a local sovereign account on this chain which they control. // foreign chains who want to have a local sovereign account on this chain which they control.
SovereignSignedViaLocation<LocationToAccountId, Origin>, SovereignSignedViaLocation<LocationToAccountId, Origin>,
// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
// recognised. // recognized.
RelayChainAsNative<RelayChainOrigin, Origin>, RelayChainAsNative<RelayChainOrigin, Origin>,
// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
// recognised. // recognized.
SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>, SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,
// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
// transaction from the Root origin.
ParentAsSuperuser<Origin>,
// Native signed account converter; this just converts an `AccountId32` origin into a normal // Native signed account converter; this just converts an `AccountId32` origin into a normal
// `Origin::Signed` origin of the same 32-byte value. // `Origin::Signed` origin of the same 32-byte value.
SignedAccountId32AsNative<RelayNetwork, Origin>, SignedAccountId32AsNative<RelayNetwork, Origin>,
@@ -481,7 +477,7 @@ impl Config for XcmConfig {
type AssetTransactor = LocalAssetTransactor; type AssetTransactor = LocalAssetTransactor;
type OriginConverter = XcmOriginToTransactDispatchOrigin; type OriginConverter = XcmOriginToTransactDispatchOrigin;
type IsReserve = NativeAsset; type IsReserve = NativeAsset;
type IsTeleporter = NativeAsset; // Should be enough to allow teleportation of ROC type IsTeleporter = (); // Teleporting is disabled.
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier; type Barrier = Barrier;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>; type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
@@ -516,13 +512,14 @@ impl pallet_xcm::Config for Runtime {
type XcmExecuteFilter = Everything; type XcmExecuteFilter = Everything;
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything; type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything; type XcmReserveTransferFilter = Nothing;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>; type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin; type Origin = Origin;
type Call = Call; type Call = Call;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
// Override for AdvertisedXcmVersion default
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
} }
+7 -5
View File
@@ -38,7 +38,7 @@ use sp_version::RuntimeVersion;
// A few exports that help ease life for downstream crates. // A few exports that help ease life for downstream crates.
pub use frame_support::{ pub use frame_support::{
construct_runtime, match_type, parameter_types, construct_runtime, match_type, parameter_types,
traits::{Everything, IsInVec, Randomness}, traits::{Everything, Nothing},
weights::{ weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
DispatchClass, IdentityFee, Weight, DispatchClass, IdentityFee, Weight,
@@ -186,7 +186,7 @@ impl frame_system::Config for Runtime {
type OnNewAccount = (); type OnNewAccount = ();
type OnKilledAccount = (); type OnKilledAccount = ();
type DbWeight = (); type DbWeight = ();
type BaseCallFilter = frame_support::traits::Everything; type BaseCallFilter = Everything;
type SystemWeightInfo = (); type SystemWeightInfo = ();
type BlockWeights = RuntimeBlockWeights; type BlockWeights = RuntimeBlockWeights;
type BlockLength = RuntimeBlockLength; type BlockLength = RuntimeBlockLength;
@@ -335,10 +335,10 @@ pub type XcmOriginToTransactDispatchOrigin = (
// foreign chains who want to have a local sovereign account on this chain which they control. // foreign chains who want to have a local sovereign account on this chain which they control.
SovereignSignedViaLocation<LocationToAccountId, Origin>, SovereignSignedViaLocation<LocationToAccountId, Origin>,
// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
// recognised. // recognized.
RelayChainAsNative<RelayChainOrigin, Origin>, RelayChainAsNative<RelayChainOrigin, Origin>,
// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
// recognised. // recognized.
SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>, SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,
// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
// transaction from the Root origin. // transaction from the Root origin.
@@ -423,12 +423,14 @@ impl pallet_xcm::Config for Runtime {
type XcmExecuteFilter = Everything; type XcmExecuteFilter = Everything;
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything; type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = frame_support::traits::Nothing; type XcmReserveTransferFilter = Nothing;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>; type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin; type Origin = Origin;
type Call = Call; type Call = Call;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
// Override for AdvertisedXcmVersion default
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
} }
+5 -4
View File
@@ -74,8 +74,8 @@ use xcm_builder::{
AsPrefixedGeneralIndex, ConvertedConcreteAssetId, CurrencyAdapter, EnsureXcmOrigin, AsPrefixedGeneralIndex, ConvertedConcreteAssetId, CurrencyAdapter, EnsureXcmOrigin,
FixedWeightBounds, FungiblesAdapter, IsConcrete, LocationInverter, NativeAsset, FixedWeightBounds, FungiblesAdapter, IsConcrete, LocationInverter, NativeAsset,
ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative, ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SovereignSignedViaLocation,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, TakeWeightCredit, UsingComponents,
}; };
use xcm_executor::{traits::JustTry, Config, XcmExecutor}; use xcm_executor::{traits::JustTry, Config, XcmExecutor};
@@ -530,10 +530,10 @@ pub type XcmOriginToTransactDispatchOrigin = (
// foreign chains who want to have a local sovereign account on this chain which they control. // foreign chains who want to have a local sovereign account on this chain which they control.
SovereignSignedViaLocation<LocationToAccountId, Origin>, SovereignSignedViaLocation<LocationToAccountId, Origin>,
// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
// recognised. // recognized.
RelayChainAsNative<RelayChainOrigin, Origin>, RelayChainAsNative<RelayChainOrigin, Origin>,
// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
// recognised. // recognized.
SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>, SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,
// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
// transaction from the Root origin. // transaction from the Root origin.
@@ -615,6 +615,7 @@ impl pallet_xcm::Config for Runtime {
type Call = Call; type Call = Call;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
// Override for AdvertisedXcmVersion default
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
} }
+6 -4
View File
@@ -74,8 +74,8 @@ use xcm_builder::{
AsPrefixedGeneralIndex, ConvertedConcreteAssetId, CurrencyAdapter, EnsureXcmOrigin, AsPrefixedGeneralIndex, ConvertedConcreteAssetId, CurrencyAdapter, EnsureXcmOrigin,
FixedWeightBounds, FungiblesAdapter, IsConcrete, LocationInverter, NativeAsset, FixedWeightBounds, FungiblesAdapter, IsConcrete, LocationInverter, NativeAsset,
ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative, ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SovereignSignedViaLocation,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, TakeWeightCredit, UsingComponents,
}; };
use xcm_executor::{traits::JustTry, Config, XcmExecutor}; use xcm_executor::{traits::JustTry, Config, XcmExecutor};
@@ -495,10 +495,10 @@ pub type XcmOriginToTransactDispatchOrigin = (
// foreign chains who want to have a local sovereign account on this chain which they control. // foreign chains who want to have a local sovereign account on this chain which they control.
SovereignSignedViaLocation<LocationToAccountId, Origin>, SovereignSignedViaLocation<LocationToAccountId, Origin>,
// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
// recognised. // recognized.
RelayChainAsNative<RelayChainOrigin, Origin>, RelayChainAsNative<RelayChainOrigin, Origin>,
// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
// recognised. // recognized.
SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>, SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,
// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
// transaction from the Root origin. // transaction from the Root origin.
@@ -577,7 +577,9 @@ impl pallet_xcm::Config for Runtime {
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin; type Origin = Origin;
type Call = Call; type Call = Call;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
// Override for AdvertisedXcmVersion default
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
} }
+3 -2
View File
@@ -494,10 +494,10 @@ pub type XcmOriginToTransactDispatchOrigin = (
// foreign chains who want to have a local sovereign account on this chain which they control. // foreign chains who want to have a local sovereign account on this chain which they control.
SovereignSignedViaLocation<LocationToAccountId, Origin>, SovereignSignedViaLocation<LocationToAccountId, Origin>,
// Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when
// recognised. // recognized.
RelayChainAsNative<RelayChainOrigin, Origin>, RelayChainAsNative<RelayChainOrigin, Origin>,
// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
// recognised. // recognized.
SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>, SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,
// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
// transaction from the Root origin. // transaction from the Root origin.
@@ -577,6 +577,7 @@ impl pallet_xcm::Config for Runtime {
type Call = Call; type Call = Call;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
// Override for AdvertisedXcmVersion default
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
} }
+1 -1
View File
@@ -24,7 +24,7 @@ use cumulus_primitives_core::UpwardMessageSender;
use sp_std::marker::PhantomData; use sp_std::marker::PhantomData;
use xcm::{latest::prelude::*, WrapVersion}; use xcm::{latest::prelude::*, WrapVersion};
/// Xcm router which recognises the `Parent` destination and handles it by sending the message into /// Xcm router which recognizes the `Parent` destination and handles it by sending the message into
/// the given UMP `UpwardMessageSender` implementation. Thus this essentially adapts an /// the given UMP `UpwardMessageSender` implementation. Thus this essentially adapts an
/// `UpwardMessageSender` trait impl into a `SendXcm` trait impl. /// `UpwardMessageSender` trait impl into a `SendXcm` trait impl.
/// ///