Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Use safer template defaults for polkadot-v0.9.12, move to `recogniz…
Browse files Browse the repository at this point in the history
…e`, 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
  • Loading branch information
nuke-web3 committed Oct 23, 2021
1 parent 9298272 commit f5926c2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
21 changes: 9 additions & 12 deletions parachain-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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};

Expand Down Expand Up @@ -438,14 +437,11 @@ pub type XcmOriginToTransactDispatchOrigin = (
// foreign chains who want to have a local sovereign account on this chain which they control.
SovereignSignedViaLocation<LocationToAccountId, Origin>,
// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
// recognised.
// recognized.
RelayChainAsNative<RelayChainOrigin, Origin>,
// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
// recognised.
// recognized.
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
// `Origin::Signed` origin of the same 32-byte value.
SignedAccountId32AsNative<RelayNetwork, Origin>,
Expand Down Expand Up @@ -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<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
Expand Down Expand Up @@ -516,13 +512,14 @@ impl pallet_xcm::Config for Runtime {
type XcmExecuteFilter = Everything;
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything;
type XcmReserveTransferFilter = Nothing;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;

const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
// Override for AdvertisedXcmVersion default
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
}

Expand Down
12 changes: 7 additions & 5 deletions polkadot-parachains/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -335,10 +335,10 @@ pub type XcmOriginToTransactDispatchOrigin = (
// foreign chains who want to have a local sovereign account on this chain which they control.
SovereignSignedViaLocation<LocationToAccountId, Origin>,
// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
// recognised.
// recognized.
RelayChainAsNative<RelayChainOrigin, Origin>,
// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
// recognised.
// recognized.
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.
Expand Down Expand Up @@ -423,12 +423,14 @@ impl pallet_xcm::Config for Runtime {
type XcmExecuteFilter = Everything;
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = frame_support::traits::Nothing;
type XcmReserveTransferFilter = Nothing;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;

const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
// Override for AdvertisedXcmVersion default
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
}

Expand Down
9 changes: 5 additions & 4 deletions polkadot-parachains/statemine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -530,10 +530,10 @@ pub type XcmOriginToTransactDispatchOrigin = (
// foreign chains who want to have a local sovereign account on this chain which they control.
SovereignSignedViaLocation<LocationToAccountId, Origin>,
// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
// recognised.
// recognized.
RelayChainAsNative<RelayChainOrigin, Origin>,
// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
// recognised.
// recognized.
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.
Expand Down Expand Up @@ -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;
}

Expand Down
10 changes: 6 additions & 4 deletions polkadot-parachains/statemint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -495,10 +495,10 @@ pub type XcmOriginToTransactDispatchOrigin = (
// foreign chains who want to have a local sovereign account on this chain which they control.
SovereignSignedViaLocation<LocationToAccountId, Origin>,
// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
// recognised.
// recognized.
RelayChainAsNative<RelayChainOrigin, Origin>,
// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
// recognised.
// recognized.
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.
Expand Down Expand Up @@ -577,7 +577,9 @@ impl pallet_xcm::Config for Runtime {
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;

const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
// Override for AdvertisedXcmVersion default
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
}

Expand Down
5 changes: 3 additions & 2 deletions polkadot-parachains/westmint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,10 @@ pub type XcmOriginToTransactDispatchOrigin = (
// foreign chains who want to have a local sovereign account on this chain which they control.
SovereignSignedViaLocation<LocationToAccountId, Origin>,
// Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when
// recognised.
// recognized.
RelayChainAsNative<RelayChainOrigin, Origin>,
// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
// recognised.
// recognized.
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.
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion primitives/utility/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down

0 comments on commit f5926c2

Please sign in to comment.