Companion for #3629 (XCM v2) (#571)

* Update .gitignore and bring into line with XCM v2's SendError

* type

* Some work

* Weighed responses

* extra fields to xcm pallet

* Fixes

* Bump
This commit is contained in:
Gavin Wood
2021-08-28 15:51:49 +02:00
committed by GitHub
parent f2f4f642ec
commit 276e5bdd38
12 changed files with 320 additions and 323 deletions
+7 -7
View File
@@ -19,11 +19,11 @@
#![cfg_attr(not(feature = "std"), no_std)]
use sp_std::prelude::*;
use xcm::latest::prelude::*;
use sp_runtime::traits::Saturating;
use frame_system::Config as SystemConfig;
use cumulus_primitives_core::ParaId;
use cumulus_pallet_xcm::{Origin as CumulusOrigin, ensure_sibling_para};
use xcm::latest::{Xcm, Error as XcmError, SendXcm, OriginKind, Junction};
pub use pallet::*;
@@ -85,8 +85,8 @@ pub mod pallet {
Pinged(ParaId, u32, Vec<u8>),
PongSent(ParaId, u32, Vec<u8>),
Ponged(ParaId, u32, Vec<u8>, T::BlockNumber),
ErrorSendingPing(XcmError, ParaId, u32, Vec<u8>),
ErrorSendingPong(XcmError, ParaId, u32, Vec<u8>),
ErrorSendingPing(SendError, ParaId, u32, Vec<u8>),
ErrorSendingPong(SendError, ParaId, u32, Vec<u8>),
UnknownPong(ParaId, u32, Vec<u8>),
}
@@ -102,11 +102,11 @@ pub mod pallet {
let seq = PingCount::<T>::mutate(|seq| { *seq += 1; *seq });
match T::XcmSender::send_xcm(
(1, Junction::Parachain(para.into())).into(),
Xcm::Transact {
Xcm(vec![Transact {
origin_type: OriginKind::Native,
require_weight_at_most: 1_000,
call: <T as Config>::Call::from(Call::<T>::ping(seq, payload.clone())).encode().into(),
},
}]),
) {
Ok(()) => {
Pings::<T>::insert(seq, n);
@@ -164,11 +164,11 @@ pub mod pallet {
Self::deposit_event(Event::Pinged(para, seq, payload.clone()));
match T::XcmSender::send_xcm(
(1, Junction::Parachain(para.into())).into(),
Xcm::Transact {
Xcm(vec![Transact {
origin_type: OriginKind::Native,
require_weight_at_most: 1_000,
call: <T as Config>::Call::from(Call::<T>::pong(seq, payload.clone())).encode().into(),
},
}]),
) {
Ok(()) => Self::deposit_event(Event::PongSent(para, seq, payload)),
Err(e) => Self::deposit_event(Event::ErrorSendingPong(e, para, seq, payload)),
+5 -2
View File
@@ -318,6 +318,7 @@ parameter_types! {
pub UnitWeightCost: Weight = 1_000_000;
// One ROC buys 1 second of weight.
pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), ROC);
pub const MaxInstructions: u32 = 100;
}
match_type! {
@@ -345,7 +346,7 @@ impl Config for XcmConfig {
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of ROC
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type Trader = UsingComponents<IdentityFee<Balance>, RocLocation, AccountId, Balances, ()>;
type ResponseHandler = (); // Don't handle responses for now.
}
@@ -371,8 +372,10 @@ impl pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = frame_support::traits::Nothing;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
}
impl cumulus_pallet_xcm::Config for Runtime {
+2 -1
View File
@@ -197,6 +197,7 @@ match_type! {
parameter_types! {
// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.
pub UnitWeightCost: Weight = 1_000_000;
pub const MaxInstructions: u32 = 100;
}
pub struct XcmConfig;
@@ -209,7 +210,7 @@ impl Config for XcmConfig {
type IsTeleporter = (); // balances not supported
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = AllowUnpaidExecutionFrom<JustTheParent>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>; // balances not supported
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>; // balances not supported
type Trader = (); // balances not supported
type ResponseHandler = (); // Don't handle responses for now.
}
+5 -2
View File
@@ -512,6 +512,7 @@ pub type XcmOriginToTransactDispatchOrigin = (
parameter_types! {
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
pub UnitWeightCost: Weight = 1_000_000_000;
pub const MaxInstructions: u32 = 100;
}
match_type! {
@@ -539,7 +540,7 @@ impl Config for XcmConfig {
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of KSM
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type Trader = UsingComponents<IdentityFee<Balance>, KsmLocation, AccountId, Balances, ()>;
type ResponseHandler = (); // Don't handle responses for now.
}
@@ -569,8 +570,10 @@ impl pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
}
impl cumulus_pallet_xcm::Config for Runtime {
+5 -2
View File
@@ -477,6 +477,7 @@ pub type XcmOriginToTransactDispatchOrigin = (
parameter_types! {
// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.
pub UnitWeightCost: Weight = 1_000_000;
pub const MaxInstructions: u32 = 100;
}
match_type! {
@@ -504,7 +505,7 @@ impl Config for XcmConfig {
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of DOT
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type Trader = UsingComponents<IdentityFee<Balance>, DotLocation, AccountId, Balances, ()>;
type ResponseHandler = (); // Don't handle responses for now.
}
@@ -534,8 +535,10 @@ impl pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
}
impl cumulus_pallet_xcm::Config for Runtime {
+5 -2
View File
@@ -475,6 +475,7 @@ pub type XcmOriginToTransactDispatchOrigin = (
parameter_types! {
pub UnitWeightCost: Weight = 1_000;
pub const MaxInstructions: u32 = 100;
}
match_type! {
@@ -502,7 +503,7 @@ impl Config for XcmConfig {
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of WND
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type Trader = UsingComponents<IdentityFee<Balance>, WestendLocation, AccountId, Balances, ()>;
type ResponseHandler = (); // Don't handle responses for now.
}
@@ -532,8 +533,10 @@ impl pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
}
impl cumulus_pallet_xcm::Config for Runtime {