From f5926c2f50df73bf36171b138241437131d76fff Mon Sep 17 00:00:00 2001 From: Dan Shields <35669742+NukeManDan@users.noreply.github.com> Date: Sat, 23 Oct 2021 09:40:14 -0600 Subject: [PATCH] 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 --- parachain-template/runtime/src/lib.rs | 21 +++++++++------------ polkadot-parachains/rococo/src/lib.rs | 12 +++++++----- polkadot-parachains/statemine/src/lib.rs | 9 +++++---- polkadot-parachains/statemint/src/lib.rs | 10 ++++++---- polkadot-parachains/westmint/src/lib.rs | 5 +++-- primitives/utility/src/lib.rs | 2 +- 6 files changed, 31 insertions(+), 28 deletions(-) diff --git a/parachain-template/runtime/src/lib.rs b/parachain-template/runtime/src/lib.rs index 0520aba8fa4..14213f1f2d8 100644 --- a/parachain-template/runtime/src/lib.rs +++ b/parachain-template/runtime/src/lib.rs @@ -23,7 +23,7 @@ use sp_version::RuntimeVersion; use frame_support::{ construct_runtime, match_type, parameter_types, - traits::Everything, + traits::{Everything, Nothing}, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, WEIGHT_PER_SECOND}, DispatchClass, IdentityFee, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, @@ -50,10 +50,9 @@ use polkadot_runtime_common::{BlockHashCount, RocksDbWeight, SlowAdjustingFeeUpd use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, - EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, - ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative, - SiblingParachainConvertsVia, SignedAccountId32AsNative, - SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, ParentIsDefault, + RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, }; 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. SovereignSignedViaLocation, // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when - // recognised. + // recognized. RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when - // recognised. + // recognized. SiblingParachainAsNative, - // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a - // transaction from the Root origin. - ParentAsSuperuser, // Native signed account converter; this just converts an `AccountId32` origin into a normal // `Origin::Signed` origin of the same 32-byte value. SignedAccountId32AsNative, @@ -481,7 +477,7 @@ impl Config for XcmConfig { type AssetTransactor = LocalAssetTransactor; type OriginConverter = XcmOriginToTransactDispatchOrigin; type IsReserve = NativeAsset; - type IsTeleporter = NativeAsset; // Should be enough to allow teleportation of ROC + type IsTeleporter = (); // Teleporting is disabled. type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; @@ -516,13 +512,14 @@ impl pallet_xcm::Config for Runtime { type XcmExecuteFilter = Everything; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; - type XcmReserveTransferFilter = Everything; + type XcmReserveTransferFilter = Nothing; type Weigher = FixedWeightBounds; type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; + // Override for AdvertisedXcmVersion default type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; } diff --git a/polkadot-parachains/rococo/src/lib.rs b/polkadot-parachains/rococo/src/lib.rs index d835cd4aa3e..2a7e8c8449e 100644 --- a/polkadot-parachains/rococo/src/lib.rs +++ b/polkadot-parachains/rococo/src/lib.rs @@ -38,7 +38,7 @@ use sp_version::RuntimeVersion; // A few exports that help ease life for downstream crates. pub use frame_support::{ construct_runtime, match_type, parameter_types, - traits::{Everything, IsInVec, Randomness}, + traits::{Everything, Nothing}, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, DispatchClass, IdentityFee, Weight, @@ -186,7 +186,7 @@ impl frame_system::Config for Runtime { type OnNewAccount = (); type OnKilledAccount = (); type DbWeight = (); - type BaseCallFilter = frame_support::traits::Everything; + type BaseCallFilter = Everything; type SystemWeightInfo = (); type BlockWeights = RuntimeBlockWeights; 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. SovereignSignedViaLocation, // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when - // recognised. + // recognized. RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when - // recognised. + // recognized. SiblingParachainAsNative, // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a // transaction from the Root origin. @@ -423,12 +423,14 @@ impl pallet_xcm::Config for Runtime { type XcmExecuteFilter = Everything; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; - type XcmReserveTransferFilter = frame_support::traits::Nothing; + type XcmReserveTransferFilter = Nothing; type Weigher = FixedWeightBounds; type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; + const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; + // Override for AdvertisedXcmVersion default type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; } diff --git a/polkadot-parachains/statemine/src/lib.rs b/polkadot-parachains/statemine/src/lib.rs index b7b21815d66..99ca7c8c097 100644 --- a/polkadot-parachains/statemine/src/lib.rs +++ b/polkadot-parachains/statemine/src/lib.rs @@ -74,8 +74,8 @@ use xcm_builder::{ AsPrefixedGeneralIndex, ConvertedConcreteAssetId, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, IsConcrete, LocationInverter, NativeAsset, ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative, - SiblingParachainConvertsVia, SignedAccountId32AsNative, - SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + SiblingParachainConvertsVia, SignedAccountId32AsNative, SovereignSignedViaLocation, + TakeWeightCredit, UsingComponents, }; 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. SovereignSignedViaLocation, // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when - // recognised. + // recognized. RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when - // recognised. + // recognized. SiblingParachainAsNative, // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a // transaction from the Root origin. @@ -615,6 +615,7 @@ impl pallet_xcm::Config for Runtime { type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; + // Override for AdvertisedXcmVersion default type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; } diff --git a/polkadot-parachains/statemint/src/lib.rs b/polkadot-parachains/statemint/src/lib.rs index fdaa3c07bbb..7c26104dda1 100644 --- a/polkadot-parachains/statemint/src/lib.rs +++ b/polkadot-parachains/statemint/src/lib.rs @@ -74,8 +74,8 @@ use xcm_builder::{ AsPrefixedGeneralIndex, ConvertedConcreteAssetId, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, IsConcrete, LocationInverter, NativeAsset, ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative, - SiblingParachainConvertsVia, SignedAccountId32AsNative, - SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + SiblingParachainConvertsVia, SignedAccountId32AsNative, SovereignSignedViaLocation, + TakeWeightCredit, UsingComponents, }; 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. SovereignSignedViaLocation, // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when - // recognised. + // recognized. RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when - // recognised. + // recognized. SiblingParachainAsNative, // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a // transaction from the Root origin. @@ -577,7 +577,9 @@ impl pallet_xcm::Config for Runtime { type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; + const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; + // Override for AdvertisedXcmVersion default type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; } diff --git a/polkadot-parachains/westmint/src/lib.rs b/polkadot-parachains/westmint/src/lib.rs index ace9ce9afac..d3c8ff781ea 100644 --- a/polkadot-parachains/westmint/src/lib.rs +++ b/polkadot-parachains/westmint/src/lib.rs @@ -494,10 +494,10 @@ pub type XcmOriginToTransactDispatchOrigin = ( // foreign chains who want to have a local sovereign account on this chain which they control. SovereignSignedViaLocation, // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when - // recognised. + // recognized. RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when - // recognised. + // recognized. SiblingParachainAsNative, // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a // transaction from the Root origin. @@ -577,6 +577,7 @@ impl pallet_xcm::Config for Runtime { type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; + // Override for AdvertisedXcmVersion default type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; } diff --git a/primitives/utility/src/lib.rs b/primitives/utility/src/lib.rs index 69397247a39..0921af8f723 100644 --- a/primitives/utility/src/lib.rs +++ b/primitives/utility/src/lib.rs @@ -24,7 +24,7 @@ use cumulus_primitives_core::UpwardMessageSender; use sp_std::marker::PhantomData; 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 /// `UpwardMessageSender` trait impl into a `SendXcm` trait impl. ///