mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 15:11:02 +00:00
* 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:
@@ -5,3 +5,5 @@
|
||||
/.cargo/config
|
||||
polkadot_argument_parsing
|
||||
**/node_modules
|
||||
**/chains/
|
||||
*.iml
|
||||
|
||||
Generated
+274
-293
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,7 @@ use cumulus_primitives_core::relay_chain::BlockNumber as RelayBlockNumber;
|
||||
use cumulus_primitives_core::DmpMessageHandler;
|
||||
use codec::{Encode, Decode};
|
||||
use sp_runtime::RuntimeDebug;
|
||||
use xcm::{VersionedXcm, latest::{Xcm, Outcome, Parent, ExecuteXcm, Error as XcmError}};
|
||||
use xcm::{VersionedXcm, latest::prelude::*};
|
||||
use frame_support::{traits::EnsureOrigin, dispatch::Weight, weights::constants::WEIGHT_PER_MILLIS};
|
||||
pub use pallet::*;
|
||||
|
||||
@@ -422,8 +422,8 @@ mod tests {
|
||||
weight_limit: Weight,
|
||||
_credit: Weight,
|
||||
) -> Outcome {
|
||||
let o = match &message {
|
||||
Xcm::Transact { require_weight_at_most, .. } => {
|
||||
let o = match (message.0.len(), &message.0.first()) {
|
||||
(1, Some(Transact { require_weight_at_most, .. })) => {
|
||||
if *require_weight_at_most <= weight_limit {
|
||||
Outcome::Complete(*require_weight_at_most)
|
||||
} else {
|
||||
@@ -466,11 +466,11 @@ mod tests {
|
||||
}
|
||||
|
||||
fn msg(weight: Weight) -> Xcm {
|
||||
Xcm::Transact {
|
||||
Xcm(vec![Transact {
|
||||
origin_type: OriginKind::Native,
|
||||
require_weight_at_most: weight,
|
||||
call: vec![].into(),
|
||||
}
|
||||
}])
|
||||
}
|
||||
|
||||
fn msg_complete(weight: Weight) -> (Xcm, Outcome) {
|
||||
|
||||
@@ -774,24 +774,24 @@ impl<T: Config> XcmpMessageSource for Pallet<T> {
|
||||
|
||||
/// Xcm sender for sending to a sibling parachain.
|
||||
impl<T: Config> SendXcm for Pallet<T> {
|
||||
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), XcmError> {
|
||||
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), SendError> {
|
||||
match &dest {
|
||||
// An HRMP message for a sibling parachain.
|
||||
MultiLocation { parents: 1, interior: X1(Parachain(id)) } => {
|
||||
let versioned_xcm = T::VersionWrapper::wrap_version(&dest, msg)
|
||||
.map_err(|()| XcmError::DestinationUnsupported)?;
|
||||
.map_err(|()| SendError::DestinationUnsupported)?;
|
||||
let hash = T::Hashing::hash_of(&versioned_xcm);
|
||||
Self::send_fragment(
|
||||
(*id).into(),
|
||||
XcmpMessageFormat::ConcatenatedVersionedXcm,
|
||||
versioned_xcm,
|
||||
)
|
||||
.map_err(|e| XcmError::SendFailed(<&'static str>::from(e)))?;
|
||||
.map_err(|e| SendError::Transport(<&'static str>::from(e)))?;
|
||||
Self::deposit_event(Event::XcmpMessageSent(Some(hash)));
|
||||
Ok(())
|
||||
}
|
||||
// Anything else is unhandled. This includes a message this is meant for us.
|
||||
_ => Err(XcmError::CannotReachDestination(dest, msg)),
|
||||
_ => Err(SendError::CannotReachDestination(dest, msg)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ parameter_types! {
|
||||
pub const RelayChain: MultiLocation = MultiLocation::parent();
|
||||
pub Ancestry: MultiLocation = X1(Parachain(1u32.into())).into();
|
||||
pub UnitWeightCost: Weight = 1_000_000;
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
}
|
||||
|
||||
/// Means for transacting assets on this chain.
|
||||
@@ -138,7 +139,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type IsTeleporter = NativeAsset;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Barrier = ();
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
|
||||
type Trader = ();
|
||||
type ResponseHandler = ();
|
||||
}
|
||||
|
||||
@@ -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)),
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -33,20 +33,20 @@ use xcm::{WrapVersion, latest::prelude::*};
|
||||
/// for the `SendXcm` implementation.
|
||||
pub struct ParentAsUmp<T, W>(PhantomData<(T, W)>);
|
||||
impl<T: UpwardMessageSender, W: WrapVersion> SendXcm for ParentAsUmp<T, W> {
|
||||
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), XcmError> {
|
||||
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), SendError> {
|
||||
if dest.contains_parents_only(1) {
|
||||
// An upward message for the relay chain.
|
||||
let versioned_xcm = W::wrap_version(&dest, msg)
|
||||
.map_err(|()| XcmError::DestinationUnsupported)?;
|
||||
.map_err(|()| SendError::DestinationUnsupported)?;
|
||||
let data = versioned_xcm.encode();
|
||||
|
||||
T::send_upward_message(data)
|
||||
.map_err(|e| XcmError::SendFailed(e.into()))?;
|
||||
.map_err(|e| SendError::Transport(e.into()))?;
|
||||
|
||||
Ok(())
|
||||
} else {
|
||||
// Anything else is unhandled. This includes a message this is meant for us.
|
||||
Err(XcmError::CannotReachDestination(dest, msg))
|
||||
Err(SendError::CannotReachDestination(dest, msg))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user