Companion for #11981 (#5915)

* Companion for #11981

* more renaming

* fmt

* fixes

* add generic type

* Companion for #11831

* fix

* revert changes

* Delete rename-outer-enum.diff

* revert

* Update run_benches_for_runtime.sh

* rename type Call & type Event

* passing tests

* fmt

* small fixes

* commit

* fix

* fmt

* commit

* error fixes

* fix

* small fix in test

* Update lib.rs

* Update lib.rs

* Update lib.rs

* Update lib.rs

* Update lib.rs

* Update lib.rs

* Update lib.rs

* remove RuntimeCall from pallet_grandpa

* last fix

* commit

* rename

* merge fix

* update lockfile for {"substrate"}

* cargo +nightly fmt

* fix

Co-authored-by: parity-processbot <>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Sergej Sakac
2022-09-13 01:03:47 +02:00
committed by GitHub
parent db0fc60344
commit 8ea6076fe5
73 changed files with 1241 additions and 1151 deletions
@@ -58,12 +58,12 @@ impl frame_system::Config for Test {
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = PalletInfo;
@@ -86,7 +86,7 @@ impl pallet_balances::Config for Test {
type ReserveIdentifier = [u8; 8];
type Balance = u64;
type DustRemoval = ();
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
@@ -128,7 +128,7 @@ parameter_types! {
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type Call = Call;
type RuntimeCall = RuntimeCall;
type XcmSender = DevNull;
type AssetTransactor = AssetTransactor;
type OriginConverter = ();
@@ -136,7 +136,7 @@ impl xcm_executor::Config for XcmConfig {
type IsTeleporter = TrustedTeleporters;
type LocationInverter = xcm_builder::LocationInverter<Ancestry>;
type Barrier = AllowUnpaidExecutionFrom<Everything>;
type Weigher = xcm_builder::FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type Weigher = xcm_builder::FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type Trader = xcm_builder::FixedRateOfFungible<WeightPrice, ()>;
type ResponseHandler = DevNull;
type AssetTrap = ();
@@ -85,7 +85,7 @@ benchmarks! {
transact {
let origin = T::transact_origin()?;
let mut executor = new_executor::<T>(origin);
let noop_call: <T as Config>::Call = frame_system::Call::remark_with_event {
let noop_call: <T as Config>::RuntimeCall = frame_system::Call::remark_with_event {
remark: Default::default()
}.into();
let double_encoded_noop_call: DoubleEncoded<_> = noop_call.encode().into();
@@ -64,12 +64,12 @@ impl frame_system::Config for Test {
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = PalletInfo;
@@ -100,7 +100,7 @@ parameter_types! {
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type Call = Call;
type RuntimeCall = RuntimeCall;
type XcmSender = DevNull;
type AssetTransactor = NoAssetTransactor;
type OriginConverter = AlwaysSignedByDefault<Origin>;
@@ -108,7 +108,7 @@ impl xcm_executor::Config for XcmConfig {
type IsTeleporter = ();
type LocationInverter = xcm_builder::LocationInverter<Ancestry>;
type Barrier = AllowUnpaidExecutionFrom<Everything>;
type Weigher = xcm_builder::FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type Weigher = xcm_builder::FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type Trader = xcm_builder::FixedRateOfFungible<WeightPrice, ()>;
type ResponseHandler = DevNull;
type AssetTrap = TestAssetTrap;
@@ -131,7 +131,7 @@ impl crate::Config for Test {
}
impl generic::Config for Test {
type Call = Call;
type RuntimeCall = RuntimeCall;
fn worst_case_response() -> (u64, Response) {
let assets: MultiAssets = (Concrete(Here.into()), 100).into();
@@ -12,7 +12,7 @@ pub mod pallet {
#[pallet::config]
pub trait Config<I: 'static = ()>: frame_system::Config + crate::Config {
type Call: Dispatchable<Origin = Self::Origin>
type RuntimeCall: Dispatchable<Origin = Self::Origin>
+ GetDispatchInfo
+ From<frame_system::Call<Self>>
+ Encode;
@@ -54,11 +54,11 @@ const SEED: u32 = 0;
/// The XCM executor to use for doing stuff.
pub type ExecutorOf<T> = xcm_executor::XcmExecutor<<T as Config>::XcmConfig>;
/// The overarching call type.
pub type OverArchingCallOf<T> = <T as frame_system::Config>::Call;
pub type OverArchingCallOf<T> = <T as frame_system::Config>::RuntimeCall;
/// The asset transactor of our executor
pub type AssetTransactorOf<T> = <<T as Config>::XcmConfig as xcm_executor::Config>::AssetTransactor;
/// The call type of executor's config. Should eventually resolve to the same overarching call type.
pub type XcmCallOf<T> = <<T as Config>::XcmConfig as xcm_executor::Config>::Call;
pub type XcmCallOf<T> = <<T as Config>::XcmConfig as xcm_executor::Config>::RuntimeCall;
pub fn mock_worst_case_holding() -> MultiAssets {
const HOLDING_FUNGIBLES: u32 = 99;
+16 -16
View File
@@ -71,7 +71,7 @@ pub mod pallet {
/// The module configuration trait.
pub trait Config: frame_system::Config {
/// The overarching event type.
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// Required origin for sending XCM messages. If successful, it resolves to `MultiLocation`
/// which exists as an interior location within this chain's XCM context.
@@ -86,10 +86,10 @@ pub mod pallet {
type ExecuteXcmOrigin: EnsureOrigin<<Self as SysConfig>::Origin, Success = MultiLocation>;
/// Our XCM filter which messages to be executed using `XcmExecutor` must pass.
type XcmExecuteFilter: Contains<(MultiLocation, Xcm<<Self as SysConfig>::Call>)>;
type XcmExecuteFilter: Contains<(MultiLocation, Xcm<<Self as SysConfig>::RuntimeCall>)>;
/// Something to execute an XCM message.
type XcmExecutor: ExecuteXcm<<Self as SysConfig>::Call>;
type XcmExecutor: ExecuteXcm<<Self as SysConfig>::RuntimeCall>;
/// Our XCM filter which messages to be teleported using the dedicated extrinsic must pass.
type XcmTeleportFilter: Contains<(MultiLocation, Vec<MultiAsset>)>;
@@ -98,7 +98,7 @@ pub mod pallet {
type XcmReserveTransferFilter: Contains<(MultiLocation, Vec<MultiAsset>)>;
/// Means of measuring the weight consumed by an XCM message locally.
type Weigher: WeightBounds<<Self as SysConfig>::Call>;
type Weigher: WeightBounds<<Self as SysConfig>::RuntimeCall>;
/// Means of inverting a location.
type LocationInverter: InvertLocation;
@@ -107,9 +107,9 @@ pub mod pallet {
type Origin: From<Origin> + From<<Self as SysConfig>::Origin>;
/// The outer `Call` type.
type Call: Parameter
type RuntimeCall: Parameter
+ GetDispatchInfo
+ IsType<<Self as frame_system::Config>::Call>
+ IsType<<Self as frame_system::Config>::RuntimeCall>
+ Dispatchable<Origin = <Self as Config>::Origin, PostInfo = PostDispatchInfo>;
const VERSION_DISCOVERY_QUEUE_SIZE: u32;
@@ -564,7 +564,7 @@ pub mod pallet {
#[pallet::weight(max_weight.saturating_add(Weight::from_ref_time(100_000_000u64)))]
pub fn execute(
origin: OriginFor<T>,
message: Box<VersionedXcm<<T as SysConfig>::Call>>,
message: Box<VersionedXcm<<T as SysConfig>::RuntimeCall>>,
max_weight: Weight,
) -> DispatchResultWithPostInfo {
let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?;
@@ -1142,13 +1142,13 @@ pub mod pallet {
pub fn report_outcome_notify(
message: &mut Xcm<()>,
responder: impl Into<MultiLocation>,
notify: impl Into<<T as Config>::Call>,
notify: impl Into<<T as Config>::RuntimeCall>,
timeout: T::BlockNumber,
) -> Result<(), XcmError> {
let responder = responder.into();
let dest = T::LocationInverter::invert_location(&responder)
.map_err(|()| XcmError::MultiLocationNotInvertible)?;
let notify: <T as Config>::Call = notify.into();
let notify: <T as Config>::RuntimeCall = notify.into();
let max_response_weight = notify.get_dispatch_info().weight;
let query_id = Self::new_notify_query(responder, notify, timeout);
let report_error = Xcm(vec![ReportError {
@@ -1169,7 +1169,7 @@ pub mod pallet {
/// which will call a dispatchable when a response happens.
pub fn new_notify_query(
responder: impl Into<MultiLocation>,
notify: impl Into<<T as Config>::Call>,
notify: impl Into<<T as Config>::RuntimeCall>,
timeout: T::BlockNumber,
) -> u64 {
let notify =
@@ -1214,10 +1214,10 @@ pub mod pallet {
}
impl<T: Config> WrapVersion for Pallet<T> {
fn wrap_version<Call>(
fn wrap_version<RuntimeCall>(
dest: &MultiLocation,
xcm: impl Into<VersionedXcm<Call>>,
) -> Result<VersionedXcm<Call>, ()> {
xcm: impl Into<VersionedXcm<RuntimeCall>>,
) -> Result<VersionedXcm<RuntimeCall>, ()> {
SupportedVersion::<T>::get(XCM_VERSION, LatestVersionedMultiLocation(dest))
.or_else(|| {
Self::note_unknown_version(dest);
@@ -1399,9 +1399,9 @@ pub mod pallet {
// be built by `(pallet_index: u8, call_index: u8, QueryId, Response)`.
// So we just encode that and then re-encode to a real Call.
let bare = (pallet_index, call_index, query_id, response);
if let Ok(call) = bare
.using_encoded(|mut bytes| <T as Config>::Call::decode(&mut bytes))
{
if let Ok(call) = bare.using_encoded(|mut bytes| {
<T as Config>::RuntimeCall::decode(&mut bytes)
}) {
Queries::<T>::remove(query_id);
let weight = call.get_dispatch_info().weight;
let max_weight = Weight::from_ref_time(max_weight);
+16 -16
View File
@@ -51,10 +51,10 @@ pub mod pallet_test_notifier {
#[pallet::config]
pub trait Config: frame_system::Config + crate::Config {
type Event: IsType<<Self as frame_system::Config>::Event> + From<Event<Self>>;
type RuntimeEvent: IsType<<Self as frame_system::Config>::RuntimeEvent> + From<Event<Self>>;
type Origin: IsType<<Self as frame_system::Config>::Origin>
+ Into<Result<crate::Origin, <Self as Config>::Origin>>;
type Call: IsType<<Self as crate::Config>::Call> + From<Call<Self>>;
type RuntimeCall: IsType<<Self as crate::Config>::RuntimeCall> + From<Call<Self>>;
}
#[pallet::event]
@@ -97,7 +97,7 @@ pub mod pallet_test_notifier {
Call::<T>::notification_received { query_id: 0, response: Default::default() };
let qid = crate::Pallet::<T>::new_notify_query(
Junction::AccountId32 { network: Any, id }.into(),
<T as Config>::Call::from(call),
<T as Config>::RuntimeCall::from(call),
100u32.into(),
);
Self::deposit_event(Event::<T>::NotifyQueryPrepared(qid));
@@ -172,7 +172,7 @@ parameter_types! {
impl frame_system::Config for Test {
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
@@ -180,7 +180,7 @@ impl frame_system::Config for Test {
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type BlockWeights = ();
type BlockLength = ();
@@ -206,7 +206,7 @@ parameter_types! {
impl pallet_balances::Config for Test {
type MaxLocks = MaxLocks;
type Balance = Balance;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
@@ -251,7 +251,7 @@ pub type Barrier = (
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type Call = Call;
type RuntimeCall = RuntimeCall;
type XcmSender = TestSendXcm;
type AssetTransactor = LocalAssetTransactor;
type OriginConverter = LocalOriginConverter;
@@ -259,7 +259,7 @@ impl xcm_executor::Config for XcmConfig {
type IsTeleporter = Case<TrustedAssets>;
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type Trader = FixedRateOfFungible<CurrencyPerSecond, ()>;
type ResponseHandler = XcmPallet;
type AssetTrap = XcmPallet;
@@ -274,7 +274,7 @@ parameter_types! {
}
impl pallet_xcm::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type XcmRouter = (TestSendXcmErrX8, TestSendXcm);
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
@@ -282,10 +282,10 @@ impl pallet_xcm::Config for Test {
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = AdvertisedXcmVersion;
}
@@ -293,16 +293,16 @@ impl pallet_xcm::Config for Test {
impl origin::Config for Test {}
impl pallet_test_notifier::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
}
pub(crate) fn last_event() -> Event {
System::events().pop().expect("Event expected").event
pub(crate) fn last_event() -> RuntimeEvent {
System::events().pop().expect("RuntimeEvent expected").event
}
pub(crate) fn last_events(n: usize) -> Vec<Event> {
pub(crate) fn last_events(n: usize) -> Vec<RuntimeEvent> {
System::events().into_iter().map(|e| e.event).rev().take(n).rev().collect()
}
+18 -15
View File
@@ -50,7 +50,7 @@ fn report_outcome_notify_works() {
query_id: 0,
response: Default::default(),
};
let notify = Call::TestNotifier(call);
let notify = RuntimeCall::TestNotifier(call);
new_test_ext_with_balances(balances).execute_with(|| {
XcmPallet::report_outcome_notify(&mut message, Parachain(PARA_ID).into(), notify, 100)
.unwrap();
@@ -85,12 +85,12 @@ fn report_outcome_notify_works() {
assert_eq!(
last_events(2),
vec![
Event::TestNotifier(pallet_test_notifier::Event::ResponseReceived(
RuntimeEvent::TestNotifier(pallet_test_notifier::Event::ResponseReceived(
Parachain(PARA_ID).into(),
0,
Response::ExecutionResult(None),
)),
Event::XcmPallet(crate::Event::Notified(0, 4, 2)),
RuntimeEvent::XcmPallet(crate::Event::Notified(0, 4, 2)),
]
);
assert_eq!(crate::Queries::<Test>::iter().collect::<Vec<_>>(), vec![]);
@@ -140,7 +140,10 @@ fn report_outcome_works() {
assert_eq!(r, Outcome::Complete(1_000));
assert_eq!(
last_event(),
Event::XcmPallet(crate::Event::ResponseReady(0, Response::ExecutionResult(None),))
RuntimeEvent::XcmPallet(crate::Event::ResponseReady(
0,
Response::ExecutionResult(None),
))
);
let response = Some((Response::ExecutionResult(None), 1));
@@ -181,7 +184,7 @@ fn send_works() {
);
assert_eq!(
last_event(),
Event::XcmPallet(crate::Event::Sent(sender, RelayLocation::get(), message))
RuntimeEvent::XcmPallet(crate::Event::Sent(sender, RelayLocation::get(), message))
);
});
}
@@ -253,7 +256,7 @@ fn teleport_assets_works() {
let _check_v0_ok: xcm::v0::Xcm<()> = versioned_sent.try_into().unwrap();
assert_eq!(
last_event(),
Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight)))
RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight)))
);
});
}
@@ -297,7 +300,7 @@ fn limmited_teleport_assets_works() {
let _check_v0_ok: xcm::v0::Xcm<()> = versioned_sent.try_into().unwrap();
assert_eq!(
last_event(),
Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight)))
RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight)))
);
});
}
@@ -339,7 +342,7 @@ fn unlimmited_teleport_assets_works() {
);
assert_eq!(
last_event(),
Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight)))
RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight)))
);
});
}
@@ -387,7 +390,7 @@ fn reserve_transfer_assets_works() {
let _check_v0_ok: xcm::v0::Xcm<()> = versioned_sent.try_into().unwrap();
assert_eq!(
last_event(),
Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight)))
RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight)))
);
});
}
@@ -436,7 +439,7 @@ fn limited_reserve_transfer_assets_works() {
let _check_v0_ok: xcm::v0::Xcm<()> = versioned_sent.try_into().unwrap();
assert_eq!(
last_event(),
Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight)))
RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight)))
);
});
}
@@ -483,7 +486,7 @@ fn unlimited_reserve_transfer_assets_works() {
);
assert_eq!(
last_event(),
Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight)))
RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight)))
);
});
}
@@ -516,7 +519,7 @@ fn execute_withdraw_to_deposit_works() {
assert_eq!(Balances::total_balance(&BOB), SEND_AMOUNT);
assert_eq!(
last_event(),
Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight)))
RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight)))
);
});
}
@@ -552,8 +555,8 @@ fn trapped_assets_can_be_claimed() {
assert_eq!(
last_events(2),
vec![
Event::XcmPallet(crate::Event::AssetsTrapped(hash.clone(), source, vma)),
Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(
RuntimeEvent::XcmPallet(crate::Event::AssetsTrapped(hash.clone(), source, vma)),
RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(
5 * BaseXcmWeight::get()
)))
]
@@ -591,7 +594,7 @@ fn trapped_assets_can_be_claimed() {
));
assert_eq!(
last_event(),
Event::XcmPallet(crate::Event::Attempted(Outcome::Incomplete(
RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Incomplete(
BaseXcmWeight::get(),
XcmError::UnknownClaim
)))
+35 -35
View File
@@ -308,11 +308,11 @@ impl TryFrom<VersionedMultiAssets> for v1::MultiAssets {
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub enum VersionedXcm<Call> {
V0(v0::Xcm<Call>),
V1(v1::Xcm<Call>),
V2(v2::Xcm<Call>),
#[scale_info(bounds(), skip_type_params(RuntimeCall))]
pub enum VersionedXcm<RuntimeCall> {
V0(v0::Xcm<RuntimeCall>),
V1(v1::Xcm<RuntimeCall>),
V2(v2::Xcm<RuntimeCall>),
}
impl<C> IntoVersion for VersionedXcm<C> {
@@ -326,27 +326,27 @@ impl<C> IntoVersion for VersionedXcm<C> {
}
}
impl<Call> From<v0::Xcm<Call>> for VersionedXcm<Call> {
fn from(x: v0::Xcm<Call>) -> Self {
impl<RuntimeCall> From<v0::Xcm<RuntimeCall>> for VersionedXcm<RuntimeCall> {
fn from(x: v0::Xcm<RuntimeCall>) -> Self {
VersionedXcm::V0(x)
}
}
impl<Call> From<v1::Xcm<Call>> for VersionedXcm<Call> {
fn from(x: v1::Xcm<Call>) -> Self {
impl<RuntimeCall> From<v1::Xcm<RuntimeCall>> for VersionedXcm<RuntimeCall> {
fn from(x: v1::Xcm<RuntimeCall>) -> Self {
VersionedXcm::V1(x)
}
}
impl<Call> From<v2::Xcm<Call>> for VersionedXcm<Call> {
fn from(x: v2::Xcm<Call>) -> Self {
impl<RuntimeCall> From<v2::Xcm<RuntimeCall>> for VersionedXcm<RuntimeCall> {
fn from(x: v2::Xcm<RuntimeCall>) -> Self {
VersionedXcm::V2(x)
}
}
impl<Call> TryFrom<VersionedXcm<Call>> for v0::Xcm<Call> {
impl<RuntimeCall> TryFrom<VersionedXcm<RuntimeCall>> for v0::Xcm<RuntimeCall> {
type Error = ();
fn try_from(x: VersionedXcm<Call>) -> Result<Self, ()> {
fn try_from(x: VersionedXcm<RuntimeCall>) -> Result<Self, ()> {
use VersionedXcm::*;
match x {
V0(x) => Ok(x),
@@ -356,9 +356,9 @@ impl<Call> TryFrom<VersionedXcm<Call>> for v0::Xcm<Call> {
}
}
impl<Call> TryFrom<VersionedXcm<Call>> for v1::Xcm<Call> {
impl<RuntimeCall> TryFrom<VersionedXcm<RuntimeCall>> for v1::Xcm<RuntimeCall> {
type Error = ();
fn try_from(x: VersionedXcm<Call>) -> Result<Self, ()> {
fn try_from(x: VersionedXcm<RuntimeCall>) -> Result<Self, ()> {
use VersionedXcm::*;
match x {
V0(x) => x.try_into(),
@@ -368,9 +368,9 @@ impl<Call> TryFrom<VersionedXcm<Call>> for v1::Xcm<Call> {
}
}
impl<Call> TryFrom<VersionedXcm<Call>> for v2::Xcm<Call> {
impl<RuntimeCall> TryFrom<VersionedXcm<RuntimeCall>> for v2::Xcm<RuntimeCall> {
type Error = ();
fn try_from(x: VersionedXcm<Call>) -> Result<Self, ()> {
fn try_from(x: VersionedXcm<RuntimeCall>) -> Result<Self, ()> {
use VersionedXcm::*;
match x {
V0(x) => V1(x.try_into()?).try_into(),
@@ -382,18 +382,18 @@ impl<Call> TryFrom<VersionedXcm<Call>> for v2::Xcm<Call> {
/// Convert an `Xcm` datum into a `VersionedXcm`, based on a destination `MultiLocation` which will interpret it.
pub trait WrapVersion {
fn wrap_version<Call>(
fn wrap_version<RuntimeCall>(
dest: &latest::MultiLocation,
xcm: impl Into<VersionedXcm<Call>>,
) -> Result<VersionedXcm<Call>, ()>;
xcm: impl Into<VersionedXcm<RuntimeCall>>,
) -> Result<VersionedXcm<RuntimeCall>, ()>;
}
/// `()` implementation does nothing with the XCM, just sending with whatever version it was authored as.
impl WrapVersion for () {
fn wrap_version<Call>(
fn wrap_version<RuntimeCall>(
_: &latest::MultiLocation,
xcm: impl Into<VersionedXcm<Call>>,
) -> Result<VersionedXcm<Call>, ()> {
xcm: impl Into<VersionedXcm<RuntimeCall>>,
) -> Result<VersionedXcm<RuntimeCall>, ()> {
Ok(xcm.into())
}
}
@@ -401,33 +401,33 @@ impl WrapVersion for () {
/// `WrapVersion` implementation which attempts to always convert the XCM to version 0 before wrapping it.
pub struct AlwaysV0;
impl WrapVersion for AlwaysV0 {
fn wrap_version<Call>(
fn wrap_version<RuntimeCall>(
_: &latest::MultiLocation,
xcm: impl Into<VersionedXcm<Call>>,
) -> Result<VersionedXcm<Call>, ()> {
Ok(VersionedXcm::<Call>::V0(xcm.into().try_into()?))
xcm: impl Into<VersionedXcm<RuntimeCall>>,
) -> Result<VersionedXcm<RuntimeCall>, ()> {
Ok(VersionedXcm::<RuntimeCall>::V0(xcm.into().try_into()?))
}
}
/// `WrapVersion` implementation which attempts to always convert the XCM to version 1 before wrapping it.
pub struct AlwaysV1;
impl WrapVersion for AlwaysV1 {
fn wrap_version<Call>(
fn wrap_version<RuntimeCall>(
_: &latest::MultiLocation,
xcm: impl Into<VersionedXcm<Call>>,
) -> Result<VersionedXcm<Call>, ()> {
Ok(VersionedXcm::<Call>::V1(xcm.into().try_into()?))
xcm: impl Into<VersionedXcm<RuntimeCall>>,
) -> Result<VersionedXcm<RuntimeCall>, ()> {
Ok(VersionedXcm::<RuntimeCall>::V1(xcm.into().try_into()?))
}
}
/// `WrapVersion` implementation which attempts to always convert the XCM to version 2 before wrapping it.
pub struct AlwaysV2;
impl WrapVersion for AlwaysV2 {
fn wrap_version<Call>(
fn wrap_version<RuntimeCall>(
_: &latest::MultiLocation,
xcm: impl Into<VersionedXcm<Call>>,
) -> Result<VersionedXcm<Call>, ()> {
Ok(VersionedXcm::<Call>::V2(xcm.into().try_into()?))
xcm: impl Into<VersionedXcm<RuntimeCall>>,
) -> Result<VersionedXcm<RuntimeCall>, ()> {
Ok(VersionedXcm::<RuntimeCall>::V2(xcm.into().try_into()?))
}
}
+14 -10
View File
@@ -97,8 +97,8 @@ pub enum Response {
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub enum Xcm<Call> {
#[scale_info(bounds(), skip_type_params(RuntimeCall))]
pub enum Xcm<RuntimeCall> {
/// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into `holding`. Execute the
/// orders (`effects`).
///
@@ -109,7 +109,7 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 0)]
WithdrawAsset { assets: Vec<MultiAsset>, effects: Vec<Order<Call>> },
WithdrawAsset { assets: Vec<MultiAsset>, effects: Vec<Order<RuntimeCall>> },
/// Asset(s) (`assets`) have been received into the ownership of this system on the `origin` system.
///
@@ -126,7 +126,7 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 1)]
ReserveAssetDeposit { assets: Vec<MultiAsset>, effects: Vec<Order<Call>> },
ReserveAssetDeposit { assets: Vec<MultiAsset>, effects: Vec<Order<RuntimeCall>> },
/// Asset(s) (`assets`) have been destroyed on the `origin` system and equivalent assets should be
/// created on this system.
@@ -144,7 +144,7 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 2)]
TeleportAsset { assets: Vec<MultiAsset>, effects: Vec<Order<Call>> },
TeleportAsset { assets: Vec<MultiAsset>, effects: Vec<Order<RuntimeCall>> },
/// Indication of the contents of the holding account corresponding to the `QueryHolding` order of `query_id`.
///
@@ -209,7 +209,11 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 6)]
Transact { origin_type: OriginKind, require_weight_at_most: u64, call: DoubleEncoded<Call> },
Transact {
origin_type: OriginKind,
require_weight_at_most: u64,
call: DoubleEncoded<RuntimeCall>,
},
/// A message to notify about a new incoming HRMP channel. This message is meant to be sent by the
/// relay-chain to a para.
@@ -276,10 +280,10 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 10)]
RelayedFrom { who: MultiLocation, message: alloc::boxed::Box<Xcm<Call>> },
RelayedFrom { who: MultiLocation, message: alloc::boxed::Box<Xcm<RuntimeCall>> },
}
impl<Call> Xcm<Call> {
impl<RuntimeCall> Xcm<RuntimeCall> {
pub fn into<C>(self) -> Xcm<C> {
Xcm::from(self)
}
@@ -330,9 +334,9 @@ impl TryFrom<Response1> for Response {
}
}
impl<Call> TryFrom<Xcm1<Call>> for Xcm<Call> {
impl<RuntimeCall> TryFrom<Xcm1<RuntimeCall>> for Xcm<RuntimeCall> {
type Error = ();
fn try_from(x: Xcm1<Call>) -> result::Result<Xcm<Call>, ()> {
fn try_from(x: Xcm1<RuntimeCall>) -> result::Result<Xcm<RuntimeCall>, ()> {
use Xcm::*;
Ok(match x {
Xcm1::WithdrawAsset { assets, effects } => WithdrawAsset {
+7 -7
View File
@@ -27,8 +27,8 @@ use parity_scale_codec::{self, Decode, Encode};
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub enum Order<Call> {
#[scale_info(bounds(), skip_type_params(RuntimeCall))]
pub enum Order<RuntimeCall> {
/// Do nothing. Not generally used.
#[codec(index = 0)]
Null,
@@ -122,7 +122,7 @@ pub enum Order<Call> {
weight: u64,
debt: u64,
halt_on_error: bool,
xcm: Vec<Xcm<Call>>,
xcm: Vec<Xcm<RuntimeCall>>,
},
}
@@ -130,7 +130,7 @@ pub mod opaque {
pub type Order = super::Order<()>;
}
impl<Call> Order<Call> {
impl<RuntimeCall> Order<RuntimeCall> {
pub fn into<C>(self) -> Order<C> {
Order::from(self)
}
@@ -155,9 +155,9 @@ impl<Call> Order<Call> {
}
}
impl<Call> TryFrom<Order1<Call>> for Order<Call> {
impl<RuntimeCall> TryFrom<Order1<RuntimeCall>> for Order<RuntimeCall> {
type Error = ();
fn try_from(old: Order1<Call>) -> result::Result<Order<Call>, ()> {
fn try_from(old: Order1<RuntimeCall>) -> result::Result<Order<RuntimeCall>, ()> {
use Order::*;
Ok(match old {
Order1::Noop => Null,
@@ -195,7 +195,7 @@ impl<Call> TryFrom<Order1<Call>> for Order<Call> {
Order1::BuyExecution { fees, weight, debt, halt_on_error, instructions } => {
let xcm = instructions
.into_iter()
.map(Xcm::<Call>::try_from)
.map(Xcm::<RuntimeCall>::try_from)
.collect::<result::Result<_, _>>()?;
BuyExecution { fees: fees.try_into()?, weight, debt, halt_on_error, xcm }
},
+7 -3
View File
@@ -139,11 +139,15 @@ impl Outcome {
}
/// Type of XCM message executor.
pub trait ExecuteXcm<Call> {
pub trait ExecuteXcm<RuntimeCall> {
/// Execute some XCM `message` from `origin` using no more than `weight_limit` weight. The weight limit is
/// a basic hard-limit and the implementation may place further restrictions or requirements on weight and
/// other aspects.
fn execute_xcm(origin: MultiLocation, message: Xcm<Call>, weight_limit: Weight) -> Outcome {
fn execute_xcm(
origin: MultiLocation,
message: Xcm<RuntimeCall>,
weight_limit: Weight,
) -> Outcome {
log::debug!(
target: "xcm::execute_xcm",
"origin: {:?}, message: {:?}, weight_limit: {:?}",
@@ -160,7 +164,7 @@ pub trait ExecuteXcm<Call> {
/// execution without associated payment.
fn execute_xcm_in_credit(
origin: MultiLocation,
message: Xcm<Call>,
message: Xcm<RuntimeCall>,
weight_limit: Weight,
weight_credit: Weight,
) -> Outcome;
+16 -12
View File
@@ -136,8 +136,8 @@ pub enum Response {
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub enum Xcm<Call> {
#[scale_info(bounds(), skip_type_params(RuntimeCall))]
pub enum Xcm<RuntimeCall> {
/// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into `holding`. Execute the
/// orders (`effects`).
///
@@ -148,7 +148,7 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 0)]
WithdrawAsset { assets: MultiAssets, effects: Vec<Order<Call>> },
WithdrawAsset { assets: MultiAssets, effects: Vec<Order<RuntimeCall>> },
/// Asset(s) (`assets`) have been received into the ownership of this system on the `origin` system.
///
@@ -165,7 +165,7 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 1)]
ReserveAssetDeposited { assets: MultiAssets, effects: Vec<Order<Call>> },
ReserveAssetDeposited { assets: MultiAssets, effects: Vec<Order<RuntimeCall>> },
/// Asset(s) (`assets`) have been destroyed on the `origin` system and equivalent assets should be
/// created on this system.
@@ -183,7 +183,7 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 2)]
ReceiveTeleportedAsset { assets: MultiAssets, effects: Vec<Order<Call>> },
ReceiveTeleportedAsset { assets: MultiAssets, effects: Vec<Order<RuntimeCall>> },
/// Indication of the contents of the holding register corresponding to the `QueryHolding` order of `query_id`.
///
@@ -249,7 +249,11 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 6)]
Transact { origin_type: OriginKind, require_weight_at_most: u64, call: DoubleEncoded<Call> },
Transact {
origin_type: OriginKind,
require_weight_at_most: u64,
call: DoubleEncoded<RuntimeCall>,
},
/// A message to notify about a new incoming HRMP channel. This message is meant to be sent by the
/// relay-chain to a para.
@@ -313,7 +317,7 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 10)]
RelayedFrom { who: InteriorMultiLocation, message: alloc::boxed::Box<Xcm<Call>> },
RelayedFrom { who: InteriorMultiLocation, message: alloc::boxed::Box<Xcm<RuntimeCall>> },
/// Ask the destination system to respond with the most recent version of XCM that they
/// support in a `QueryResponse` instruction. Any changes to this should also elicit similar
@@ -335,7 +339,7 @@ pub enum Xcm<Call> {
UnsubscribeVersion,
}
impl<Call> Xcm<Call> {
impl<RuntimeCall> Xcm<RuntimeCall> {
pub fn into<C>(self) -> Xcm<C> {
Xcm::from(self)
}
@@ -390,9 +394,9 @@ impl TryFrom<OldResponse> for Response {
}
}
impl<Call> TryFrom<OldXcm<Call>> for Xcm<Call> {
impl<RuntimeCall> TryFrom<OldXcm<RuntimeCall>> for Xcm<RuntimeCall> {
type Error = ();
fn try_from(old: OldXcm<Call>) -> result::Result<Xcm<Call>, ()> {
fn try_from(old: OldXcm<RuntimeCall>) -> result::Result<Xcm<RuntimeCall>, ()> {
use Xcm::*;
Ok(match old {
OldXcm::WithdrawAsset { assets, effects } => WithdrawAsset {
@@ -443,9 +447,9 @@ impl<Call> TryFrom<OldXcm<Call>> for Xcm<Call> {
}
}
impl<Call> TryFrom<NewXcm<Call>> for Xcm<Call> {
impl<RuntimeCall> TryFrom<NewXcm<RuntimeCall>> for Xcm<RuntimeCall> {
type Error = ();
fn try_from(old: NewXcm<Call>) -> result::Result<Xcm<Call>, ()> {
fn try_from(old: NewXcm<RuntimeCall>) -> result::Result<Xcm<RuntimeCall>, ()> {
use Xcm::*;
let mut iter = old.0.into_iter();
let instruction = iter.next().ok_or(())?;
+12 -10
View File
@@ -29,8 +29,8 @@ use scale_info::TypeInfo;
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub enum Order<Call> {
#[scale_info(bounds(), skip_type_params(RuntimeCall))]
pub enum Order<RuntimeCall> {
/// Do nothing. Not generally used.
#[codec(index = 0)]
Noop,
@@ -148,7 +148,7 @@ pub enum Order<Call> {
weight: u64,
debt: u64,
halt_on_error: bool,
instructions: Vec<Xcm<Call>>,
instructions: Vec<Xcm<RuntimeCall>>,
},
}
@@ -156,7 +156,7 @@ pub mod opaque {
pub type Order = super::Order<()>;
}
impl<Call> Order<Call> {
impl<RuntimeCall> Order<RuntimeCall> {
pub fn into<C>(self) -> Order<C> {
Order::from(self)
}
@@ -182,9 +182,9 @@ impl<Call> Order<Call> {
}
}
impl<Call> TryFrom<OldOrder<Call>> for Order<Call> {
impl<RuntimeCall> TryFrom<OldOrder<RuntimeCall>> for Order<RuntimeCall> {
type Error = ();
fn try_from(old: OldOrder<Call>) -> result::Result<Order<Call>, ()> {
fn try_from(old: OldOrder<RuntimeCall>) -> result::Result<Order<RuntimeCall>, ()> {
use Order::*;
Ok(match old {
OldOrder::Null => Noop,
@@ -224,17 +224,19 @@ impl<Call> TryFrom<OldOrder<Call>> for Order<Call> {
OldOrder::QueryHolding { query_id, dest, assets } =>
QueryHolding { query_id, dest: dest.try_into()?, assets: assets.try_into()? },
OldOrder::BuyExecution { fees, weight, debt, halt_on_error, xcm } => {
let instructions =
xcm.into_iter().map(Xcm::<Call>::try_from).collect::<result::Result<_, _>>()?;
let instructions = xcm
.into_iter()
.map(Xcm::<RuntimeCall>::try_from)
.collect::<result::Result<_, _>>()?;
BuyExecution { fees: fees.try_into()?, weight, debt, halt_on_error, instructions }
},
})
}
}
impl<Call> TryFrom<Instruction<Call>> for Order<Call> {
impl<RuntimeCall> TryFrom<Instruction<RuntimeCall>> for Order<RuntimeCall> {
type Error = ();
fn try_from(old: Instruction<Call>) -> result::Result<Order<Call>, ()> {
fn try_from(old: Instruction<RuntimeCall>) -> result::Result<Order<RuntimeCall>, ()> {
use Order::*;
Ok(match old {
Instruction::DepositAsset { assets, max_assets, beneficiary } =>
+3 -3
View File
@@ -142,13 +142,13 @@ impl Outcome {
}
/// Type of XCM message executor.
pub trait ExecuteXcm<Call> {
pub trait ExecuteXcm<RuntimeCall> {
/// Execute some XCM `message` from `origin` using no more than `weight_limit` weight. The weight limit is
/// a basic hard-limit and the implementation may place further restrictions or requirements on weight and
/// other aspects.
fn execute_xcm(
origin: impl Into<MultiLocation>,
message: Xcm<Call>,
message: Xcm<RuntimeCall>,
weight_limit: Weight,
) -> Outcome {
let origin = origin.into();
@@ -168,7 +168,7 @@ pub trait ExecuteXcm<Call> {
/// execution without associated payment.
fn execute_xcm_in_credit(
origin: impl Into<MultiLocation>,
message: Xcm<Call>,
message: Xcm<RuntimeCall>,
weight_limit: Weight,
weight_credit: Weight,
) -> Outcome;
+20 -20
View File
@@ -78,10 +78,10 @@ pub type QueryId = u64;
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub struct Xcm<Call>(pub Vec<Instruction<Call>>);
#[scale_info(bounds(), skip_type_params(RuntimeCall))]
pub struct Xcm<RuntimeCall>(pub Vec<Instruction<RuntimeCall>>);
impl<Call> Xcm<Call> {
impl<RuntimeCall> Xcm<RuntimeCall> {
/// Create an empty instance.
pub fn new() -> Self {
Self(vec![])
@@ -108,17 +108,17 @@ impl<Call> Xcm<Call> {
}
/// Return the first instruction, if any.
pub fn first(&self) -> Option<&Instruction<Call>> {
pub fn first(&self) -> Option<&Instruction<RuntimeCall>> {
self.0.first()
}
/// Return the last instruction, if any.
pub fn last(&self) -> Option<&Instruction<Call>> {
pub fn last(&self) -> Option<&Instruction<RuntimeCall>> {
self.0.last()
}
/// Return the only instruction, contained in `Self`, iff only one exists (`None` otherwise).
pub fn only(&self) -> Option<&Instruction<Call>> {
pub fn only(&self) -> Option<&Instruction<RuntimeCall>> {
if self.0.len() == 1 {
self.0.first()
} else {
@@ -128,7 +128,7 @@ impl<Call> Xcm<Call> {
/// Return the only instruction, contained in `Self`, iff only one exists (returns `self`
/// otherwise).
pub fn into_only(mut self) -> core::result::Result<Instruction<Call>, Self> {
pub fn into_only(mut self) -> core::result::Result<Instruction<RuntimeCall>, Self> {
if self.0.len() == 1 {
self.0.pop().ok_or(self)
} else {
@@ -233,8 +233,8 @@ pub type Weight = u64;
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub enum Instruction<Call> {
#[scale_info(bounds(), skip_type_params(RuntimeCall))]
pub enum Instruction<RuntimeCall> {
/// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into the Holding
/// Register.
///
@@ -340,7 +340,7 @@ pub enum Instruction<Call> {
origin_type: OriginKind,
#[codec(compact)]
require_weight_at_most: u64,
call: DoubleEncoded<Call>,
call: DoubleEncoded<RuntimeCall>,
},
/// A message to notify about a new incoming HRMP channel. This message is meant to be sent by the
@@ -584,7 +584,7 @@ pub enum Instruction<Call> {
/// Kind: *Instruction*
///
/// Errors: None.
SetErrorHandler(Xcm<Call>),
SetErrorHandler(Xcm<RuntimeCall>),
/// Set the Appendix Register. This is code that should be called after code execution
/// (including the error handler if any) is finished. This will be called regardless of whether
@@ -600,7 +600,7 @@ pub enum Instruction<Call> {
/// Kind: *Instruction*
///
/// Errors: None.
SetAppendix(Xcm<Call>),
SetAppendix(Xcm<RuntimeCall>),
/// Clear the Error Register.
///
@@ -647,16 +647,16 @@ pub enum Instruction<Call> {
UnsubscribeVersion,
}
impl<Call> Xcm<Call> {
impl<RuntimeCall> Xcm<RuntimeCall> {
pub fn into<C>(self) -> Xcm<C> {
Xcm::from(self)
}
pub fn from<C>(xcm: Xcm<C>) -> Self {
Self(xcm.0.into_iter().map(Instruction::<Call>::from).collect())
Self(xcm.0.into_iter().map(Instruction::<RuntimeCall>::from).collect())
}
}
impl<Call> Instruction<Call> {
impl<RuntimeCall> Instruction<RuntimeCall> {
pub fn into<C>(self) -> Instruction<C> {
Instruction::from(self)
}
@@ -707,7 +707,7 @@ impl<Call> Instruction<Call> {
}
// TODO: Automate Generation
impl<Call, W: XcmWeightInfo<Call>> GetWeight<W> for Instruction<Call> {
impl<RuntimeCall, W: XcmWeightInfo<RuntimeCall>> GetWeight<W> for Instruction<RuntimeCall> {
fn weight(&self) -> Weight {
use Instruction::*;
match self {
@@ -775,9 +775,9 @@ impl TryFrom<OldResponse> for Response {
}
}
impl<Call> TryFrom<OldXcm<Call>> for Xcm<Call> {
impl<RuntimeCall> TryFrom<OldXcm<RuntimeCall>> for Xcm<RuntimeCall> {
type Error = ();
fn try_from(old: OldXcm<Call>) -> result::Result<Xcm<Call>, ()> {
fn try_from(old: OldXcm<RuntimeCall>) -> result::Result<Xcm<RuntimeCall>, ()> {
use Instruction::*;
Ok(Xcm(match old {
OldXcm::WithdrawAsset { assets, effects } => Some(Ok(WithdrawAsset(assets)))
@@ -827,9 +827,9 @@ impl<Call> TryFrom<OldXcm<Call>> for Xcm<Call> {
}
}
impl<Call> TryFrom<OldOrder<Call>> for Instruction<Call> {
impl<RuntimeCall> TryFrom<OldOrder<RuntimeCall>> for Instruction<RuntimeCall> {
type Error = ();
fn try_from(old: OldOrder<Call>) -> result::Result<Instruction<Call>, ()> {
fn try_from(old: OldOrder<RuntimeCall>) -> result::Result<Instruction<RuntimeCall>, ()> {
use Instruction::*;
Ok(match old {
OldOrder::Noop => return Err(()),
+3 -3
View File
@@ -160,13 +160,13 @@ impl Outcome {
}
/// Type of XCM message executor.
pub trait ExecuteXcm<Call> {
pub trait ExecuteXcm<RuntimeCall> {
/// Execute some XCM `message` from `origin` using no more than `weight_limit` weight. The weight limit is
/// a basic hard-limit and the implementation may place further restrictions or requirements on weight and
/// other aspects.
fn execute_xcm(
origin: impl Into<MultiLocation>,
message: Xcm<Call>,
message: Xcm<RuntimeCall>,
weight_limit: Weight,
) -> Outcome {
let origin = origin.into();
@@ -186,7 +186,7 @@ pub trait ExecuteXcm<Call> {
/// execution without associated payment.
fn execute_xcm_in_credit(
origin: impl Into<MultiLocation>,
message: Xcm<Call>,
message: Xcm<RuntimeCall>,
weight_limit: Weight,
weight_credit: Weight,
) -> Outcome;
+10 -10
View File
@@ -31,9 +31,9 @@ use xcm_executor::traits::{OnResponse, ShouldExecute};
/// out of the local chain to another one.
pub struct TakeWeightCredit;
impl ShouldExecute for TakeWeightCredit {
fn should_execute<Call>(
fn should_execute<RuntimeCall>(
_origin: &MultiLocation,
_message: &mut Xcm<Call>,
_message: &mut Xcm<RuntimeCall>,
max_weight: Weight,
weight_credit: &mut Weight,
) -> Result<(), ()> {
@@ -54,9 +54,9 @@ impl ShouldExecute for TakeWeightCredit {
/// because they are the only ones that place assets in the Holding Register to pay for execution.
pub struct AllowTopLevelPaidExecutionFrom<T>(PhantomData<T>);
impl<T: Contains<MultiLocation>> ShouldExecute for AllowTopLevelPaidExecutionFrom<T> {
fn should_execute<Call>(
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut Xcm<Call>,
message: &mut Xcm<RuntimeCall>,
max_weight: Weight,
_weight_credit: &mut Weight,
) -> Result<(), ()> {
@@ -97,9 +97,9 @@ impl<T: Contains<MultiLocation>> ShouldExecute for AllowTopLevelPaidExecutionFro
/// Use only for executions from trusted origin groups.
pub struct AllowUnpaidExecutionFrom<T>(PhantomData<T>);
impl<T: Contains<MultiLocation>> ShouldExecute for AllowUnpaidExecutionFrom<T> {
fn should_execute<Call>(
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
_message: &mut Xcm<Call>,
_message: &mut Xcm<RuntimeCall>,
_max_weight: Weight,
_weight_credit: &mut Weight,
) -> Result<(), ()> {
@@ -128,9 +128,9 @@ impl<ParaId: IsSystem + From<u32>> Contains<MultiLocation> for IsChildSystemPara
/// Allows only messages if the generic `ResponseHandler` expects them via `expecting_response`.
pub struct AllowKnownQueryResponses<ResponseHandler>(PhantomData<ResponseHandler>);
impl<ResponseHandler: OnResponse> ShouldExecute for AllowKnownQueryResponses<ResponseHandler> {
fn should_execute<Call>(
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut Xcm<Call>,
message: &mut Xcm<RuntimeCall>,
_max_weight: Weight,
_weight_credit: &mut Weight,
) -> Result<(), ()> {
@@ -152,9 +152,9 @@ impl<ResponseHandler: OnResponse> ShouldExecute for AllowKnownQueryResponses<Res
/// `UnsubscribeVersion` instruction.
pub struct AllowSubscriptionsFrom<T>(PhantomData<T>);
impl<T: Contains<MultiLocation>> ShouldExecute for AllowSubscriptionsFrom<T> {
fn should_execute<Call>(
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut Xcm<Call>,
message: &mut Xcm<RuntimeCall>,
_max_weight: Weight,
_weight_credit: &mut Weight,
) -> Result<(), ()> {
+1 -1
View File
@@ -277,7 +277,7 @@ pub type TestBarrier = (
pub struct TestConfig;
impl Config for TestConfig {
type Call = TestCall;
type RuntimeCall = TestCall;
type XcmSender = TestSendXcm;
type AssetTransactor = TestAssetTransactor;
type OriginConverter = TestOriginConverter;
+8 -8
View File
@@ -62,7 +62,7 @@ parameter_types! {
impl frame_system::Config for Runtime {
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
@@ -70,7 +70,7 @@ impl frame_system::Config for Runtime {
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type BlockWeights = ();
type BlockLength = ();
@@ -96,7 +96,7 @@ parameter_types! {
impl pallet_balances::Config for Runtime {
type MaxLocks = MaxLocks;
type Balance = Balance;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
@@ -160,7 +160,7 @@ pub type TrustedTeleporters = (xcm_builder::Case<KusamaForStatemine>,);
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type Call = Call;
type RuntimeCall = RuntimeCall;
type XcmSender = TestSendXcm;
type AssetTransactor = LocalAssetTransactor;
type OriginConverter = LocalOriginConverter;
@@ -168,7 +168,7 @@ impl xcm_executor::Config for XcmConfig {
type IsTeleporter = TrustedTeleporters;
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type Trader = FixedRateOfFungible<KsmPerSecond, ()>;
type ResponseHandler = XcmPallet;
type AssetTrap = XcmPallet;
@@ -179,7 +179,7 @@ impl xcm_executor::Config for XcmConfig {
pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, KusamaNetwork>;
impl pallet_xcm::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type LocationInverter = LocationInverter<Ancestry>;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type XcmRouter = TestSendXcm;
@@ -189,8 +189,8 @@ impl pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
type Call = Call;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type RuntimeCall = RuntimeCall;
type Origin = Origin;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
@@ -45,7 +45,7 @@ fn basic_buy_fees_message_executes() {
let execute = construct_extrinsic(
&client,
polkadot_test_runtime::Call::Xcm(pallet_xcm::Call::execute {
polkadot_test_runtime::RuntimeCall::Xcm(pallet_xcm::Call::execute {
message: Box::new(VersionedXcm::from(msg)),
max_weight: Weight::from_ref_time(1_000_000_000),
}),
@@ -67,9 +67,9 @@ fn basic_buy_fees_message_executes() {
.inspect_state(|| {
assert!(polkadot_test_runtime::System::events().iter().any(|r| matches!(
r.event,
polkadot_test_runtime::Event::Xcm(pallet_xcm::Event::Attempted(Outcome::Complete(
_
))),
polkadot_test_runtime::RuntimeEvent::Xcm(pallet_xcm::Event::Attempted(
Outcome::Complete(_)
)),
)));
});
}
@@ -78,7 +78,7 @@ fn basic_buy_fees_message_executes() {
fn query_response_fires() {
use pallet_test_notifier::Event::*;
use pallet_xcm::QueryStatus;
use polkadot_test_runtime::Event::TestNotifier;
use polkadot_test_runtime::RuntimeEvent::TestNotifier;
sp_tracing::try_init_simple();
let mut client = TestClientBuilder::new()
@@ -89,7 +89,9 @@ fn query_response_fires() {
let execute = construct_extrinsic(
&client,
polkadot_test_runtime::Call::TestNotifier(pallet_test_notifier::Call::prepare_new_query {}),
polkadot_test_runtime::RuntimeCall::TestNotifier(
pallet_test_notifier::Call::prepare_new_query {},
),
sp_keyring::Sr25519Keyring::Alice,
0,
);
@@ -125,7 +127,7 @@ fn query_response_fires() {
let execute = construct_extrinsic(
&client,
polkadot_test_runtime::Call::Xcm(pallet_xcm::Call::execute {
polkadot_test_runtime::RuntimeCall::Xcm(pallet_xcm::Call::execute {
message: msg,
max_weight: Weight::from_ref_time(1_000_000_000),
}),
@@ -147,7 +149,7 @@ fn query_response_fires() {
.inspect_state(|| {
assert!(polkadot_test_runtime::System::events().iter().any(|r| matches!(
r.event,
polkadot_test_runtime::Event::Xcm(pallet_xcm::Event::ResponseReady(
polkadot_test_runtime::RuntimeEvent::Xcm(pallet_xcm::Event::ResponseReady(
q,
Response::ExecutionResult(None),
)) if q == query_id,
@@ -165,7 +167,7 @@ fn query_response_fires() {
#[test]
fn query_response_elicits_handler() {
use pallet_test_notifier::Event::*;
use polkadot_test_runtime::Event::TestNotifier;
use polkadot_test_runtime::RuntimeEvent::TestNotifier;
sp_tracing::try_init_simple();
let mut client = TestClientBuilder::new()
@@ -176,7 +178,7 @@ fn query_response_elicits_handler() {
let execute = construct_extrinsic(
&client,
polkadot_test_runtime::Call::TestNotifier(
polkadot_test_runtime::RuntimeCall::TestNotifier(
pallet_test_notifier::Call::prepare_new_notify_query {},
),
sp_keyring::Sr25519Keyring::Alice,
@@ -213,7 +215,7 @@ fn query_response_elicits_handler() {
let execute = construct_extrinsic(
&client,
polkadot_test_runtime::Call::Xcm(pallet_xcm::Call::execute {
polkadot_test_runtime::RuntimeCall::Xcm(pallet_xcm::Call::execute {
message: Box::new(VersionedXcm::from(msg)),
max_weight: Weight::from_ref_time(1_000_000_000),
}),
+3 -3
View File
@@ -27,7 +27,7 @@ use xcm::latest::SendXcm;
/// The trait to parameterize the `XcmExecutor`.
pub trait Config {
/// The outer call dispatch type.
type Call: Parameter + Dispatchable<PostInfo = PostDispatchInfo> + GetDispatchInfo;
type RuntimeCall: Parameter + Dispatchable<PostInfo = PostDispatchInfo> + GetDispatchInfo;
/// How to send an onward XCM message.
type XcmSender: SendXcm;
@@ -36,7 +36,7 @@ pub trait Config {
type AssetTransactor: TransactAsset;
/// How to get a call origin from a `OriginKind` value.
type OriginConverter: ConvertOrigin<<Self::Call as Dispatchable>::Origin>;
type OriginConverter: ConvertOrigin<<Self::RuntimeCall as Dispatchable>::Origin>;
/// Combinations of (Location, Asset) pairs which we trust as reserves.
type IsReserve: FilterAssetLocation;
@@ -51,7 +51,7 @@ pub trait Config {
type Barrier: ShouldExecute;
/// The means of determining an XCM message's weight.
type Weigher: WeightBounds<Self::Call>;
type Weigher: WeightBounds<Self::RuntimeCall>;
/// The means of purchasing weight credit for XCM execution.
type Trader: WeightTrader;
+14 -11
View File
@@ -51,9 +51,9 @@ pub struct XcmExecutor<Config: config::Config> {
/// the weight of dynamically determined instructions such as `Transact`).
pub total_surplus: u64,
pub total_refunded: u64,
pub error_handler: Xcm<Config::Call>,
pub error_handler: Xcm<Config::RuntimeCall>,
pub error_handler_weight: u64,
pub appendix: Xcm<Config::Call>,
pub appendix: Xcm<Config::RuntimeCall>,
pub appendix_weight: u64,
_config: PhantomData<Config>,
}
@@ -61,10 +61,10 @@ pub struct XcmExecutor<Config: config::Config> {
/// The maximum recursion limit for `execute_xcm` and `execute_effects`.
pub const MAX_RECURSION_LIMIT: u32 = 8;
impl<Config: config::Config> ExecuteXcm<Config::Call> for XcmExecutor<Config> {
impl<Config: config::Config> ExecuteXcm<Config::RuntimeCall> for XcmExecutor<Config> {
fn execute_xcm_in_credit(
origin: impl Into<MultiLocation>,
mut message: Xcm<Config::Call>,
mut message: Xcm<Config::RuntimeCall>,
weight_limit: Weight,
mut weight_credit: Weight,
) -> Outcome {
@@ -180,7 +180,7 @@ impl<Config: config::Config> XcmExecutor<Config> {
/// Execute the XCM program fragment and report back the error and which instruction caused it,
/// or `Ok` if there was no error.
pub fn execute(&mut self, xcm: Xcm<Config::Call>) -> Result<(), ExecutorError> {
pub fn execute(&mut self, xcm: Xcm<Config::RuntimeCall>) -> Result<(), ExecutorError> {
log::trace!(
target: "xcm::execute",
"origin: {:?}, total_surplus/refunded: {:?}/{:?}, error_handler_weight: {:?}",
@@ -231,8 +231,8 @@ impl<Config: config::Config> XcmExecutor<Config> {
}
/// Remove the registered error handler and return it. Do not refund its weight.
fn take_error_handler(&mut self) -> Xcm<Config::Call> {
let mut r = Xcm::<Config::Call>(vec![]);
fn take_error_handler(&mut self) -> Xcm<Config::RuntimeCall> {
let mut r = Xcm::<Config::RuntimeCall>(vec![]);
sp_std::mem::swap(&mut self.error_handler, &mut r);
self.error_handler_weight = 0;
r
@@ -240,14 +240,14 @@ impl<Config: config::Config> XcmExecutor<Config> {
/// Drop the registered error handler and refund its weight.
fn drop_error_handler(&mut self) {
self.error_handler = Xcm::<Config::Call>(vec![]);
self.error_handler = Xcm::<Config::RuntimeCall>(vec![]);
self.total_surplus.saturating_accrue(self.error_handler_weight);
self.error_handler_weight = 0;
}
/// Remove the registered appendix and return it.
fn take_appendix(&mut self) -> Xcm<Config::Call> {
let mut r = Xcm::<Config::Call>(vec![]);
fn take_appendix(&mut self) -> Xcm<Config::RuntimeCall> {
let mut r = Xcm::<Config::RuntimeCall>(vec![]);
sp_std::mem::swap(&mut self.appendix, &mut r);
self.appendix_weight = 0;
r
@@ -265,7 +265,10 @@ impl<Config: config::Config> XcmExecutor<Config> {
}
/// Process a single XCM instruction, mutating the state of the XCM virtual machine.
fn process_instruction(&mut self, instr: Instruction<Config::Call>) -> Result<(), XcmError> {
fn process_instruction(
&mut self,
instr: Instruction<Config::RuntimeCall>,
) -> Result<(), XcmError> {
match instr {
WithdrawAsset(assets) => {
// Take `assets` from the origin account (on-chain) and place in holding.
@@ -30,9 +30,9 @@ pub trait ShouldExecute {
/// - `weight_credit`: The pre-established amount of weight that the system has determined this
/// message may utilize in its execution. Typically non-zero only because of prior fee
/// payment, but could in principle be due to other factors.
fn should_execute<Call>(
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut Xcm<Call>,
message: &mut Xcm<RuntimeCall>,
max_weight: Weight,
weight_credit: &mut Weight,
) -> Result<(), ()>;
@@ -40,9 +40,9 @@ pub trait ShouldExecute {
#[impl_trait_for_tuples::impl_for_tuples(30)]
impl ShouldExecute for Tuple {
fn should_execute<Call>(
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut Xcm<Call>,
message: &mut Xcm<RuntimeCall>,
max_weight: Weight,
weight_credit: &mut Weight,
) -> Result<(), ()> {
@@ -19,14 +19,14 @@ use sp_std::result::Result;
use xcm::latest::{prelude::*, Weight};
/// Determine the weight of an XCM message.
pub trait WeightBounds<Call> {
pub trait WeightBounds<RuntimeCall> {
/// Return the maximum amount of weight that an attempted execution of this message could
/// consume.
fn weight(message: &mut Xcm<Call>) -> Result<Weight, ()>;
fn weight(message: &mut Xcm<RuntimeCall>) -> Result<Weight, ()>;
/// Return the maximum amount of weight that an attempted execution of this instruction could
/// consume.
fn instr_weight(instruction: &Instruction<Call>) -> Result<Weight, ()>;
fn instr_weight(instruction: &Instruction<RuntimeCall>) -> Result<Weight, ()>;
}
/// A means of getting approximate weight consumption for a given destination message executor and a
+22 -21
View File
@@ -118,10 +118,9 @@ mod tests {
fn dmp() {
MockNet::reset();
let remark =
parachain::Call::System(frame_system::Call::<parachain::Runtime>::remark_with_event {
remark: vec![1, 2, 3],
});
let remark = parachain::RuntimeCall::System(
frame_system::Call::<parachain::Runtime>::remark_with_event { remark: vec![1, 2, 3] },
);
Relay::execute_with(|| {
assert_ok!(RelayChainPalletXcm::send_xcm(
Here,
@@ -135,10 +134,11 @@ mod tests {
});
ParaA::execute_with(|| {
use parachain::{Event, System};
assert!(System::events()
.iter()
.any(|r| matches!(r.event, Event::System(frame_system::Event::Remarked { .. }))));
use parachain::{RuntimeEvent, System};
assert!(System::events().iter().any(|r| matches!(
r.event,
RuntimeEvent::System(frame_system::Event::Remarked { .. })
)));
});
}
@@ -146,7 +146,7 @@ mod tests {
fn ump() {
MockNet::reset();
let remark = relay_chain::Call::System(
let remark = relay_chain::RuntimeCall::System(
frame_system::Call::<relay_chain::Runtime>::remark_with_event { remark: vec![1, 2, 3] },
);
ParaA::execute_with(|| {
@@ -162,10 +162,11 @@ mod tests {
});
Relay::execute_with(|| {
use relay_chain::{Event, System};
assert!(System::events()
.iter()
.any(|r| matches!(r.event, Event::System(frame_system::Event::Remarked { .. }))));
use relay_chain::{RuntimeEvent, System};
assert!(System::events().iter().any(|r| matches!(
r.event,
RuntimeEvent::System(frame_system::Event::Remarked { .. })
)));
});
}
@@ -173,10 +174,9 @@ mod tests {
fn xcmp() {
MockNet::reset();
let remark =
parachain::Call::System(frame_system::Call::<parachain::Runtime>::remark_with_event {
remark: vec![1, 2, 3],
});
let remark = parachain::RuntimeCall::System(
frame_system::Call::<parachain::Runtime>::remark_with_event { remark: vec![1, 2, 3] },
);
ParaA::execute_with(|| {
assert_ok!(ParachainPalletXcm::send_xcm(
Here,
@@ -190,10 +190,11 @@ mod tests {
});
ParaB::execute_with(|| {
use parachain::{Event, System};
assert!(System::events()
.iter()
.any(|r| matches!(r.event, Event::System(frame_system::Event::Remarked { .. }))));
use parachain::{RuntimeEvent, System};
assert!(System::events().iter().any(|r| matches!(
r.event,
RuntimeEvent::System(frame_system::Event::Remarked { .. })
)));
});
}
@@ -53,7 +53,7 @@ parameter_types! {
impl frame_system::Config for Runtime {
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
@@ -61,7 +61,7 @@ impl frame_system::Config for Runtime {
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type BlockWeights = ();
type BlockLength = ();
@@ -87,7 +87,7 @@ parameter_types! {
impl pallet_balances::Config for Runtime {
type MaxLocks = MaxLocks;
type Balance = Balance;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
@@ -133,7 +133,7 @@ pub type Barrier = AllowUnpaidExecutionFrom<Everything>;
pub struct XcmConfig;
impl Config for XcmConfig {
type Call = Call;
type RuntimeCall = RuntimeCall;
type XcmSender = XcmRouter;
type AssetTransactor = LocalAssetTransactor;
type OriginConverter = XcmOriginToCallOrigin;
@@ -141,7 +141,7 @@ impl Config for XcmConfig {
type IsTeleporter = ();
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type Trader = FixedRateOfFungible<KsmPerSecond, ()>;
type ResponseHandler = ();
type AssetTrap = ();
@@ -156,8 +156,8 @@ pub mod mock_msg_queue {
#[pallet::config]
pub trait Config: frame_system::Config {
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
type XcmExecutor: ExecuteXcm<Self::Call>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type XcmExecutor: ExecuteXcm<Self::RuntimeCall>;
}
#[pallet::call]
@@ -175,7 +175,7 @@ pub mod mock_msg_queue {
#[pallet::storage]
#[pallet::getter(fn received_dmp)]
/// A queue of received DMP messages
pub(super) type ReceivedDmp<T: Config> = StorageValue<_, Vec<Xcm<T::Call>>, ValueQuery>;
pub(super) type ReceivedDmp<T: Config> = StorageValue<_, Vec<Xcm<T::RuntimeCall>>, ValueQuery>;
impl<T: Config> Get<ParaId> for Pallet<T> {
fn get() -> ParaId {
@@ -215,11 +215,11 @@ pub mod mock_msg_queue {
fn handle_xcmp_message(
sender: ParaId,
_sent_at: RelayBlockNumber,
xcm: VersionedXcm<T::Call>,
xcm: VersionedXcm<T::RuntimeCall>,
max_weight: Weight,
) -> Result<Weight, XcmError> {
let hash = Encode::using_encoded(&xcm, T::Hashing::hash);
let (result, event) = match Xcm::<T::Call>::try_from(xcm) {
let (result, event) = match Xcm::<T::RuntimeCall>::try_from(xcm) {
Ok(xcm) => {
let location = (1, Parachain(sender.into()));
match T::XcmExecutor::execute_xcm(location, xcm, max_weight.ref_time()) {
@@ -251,7 +251,9 @@ pub mod mock_msg_queue {
let mut remaining_fragments = &data_ref[..];
while !remaining_fragments.is_empty() {
if let Ok(xcm) = VersionedXcm::<T::Call>::decode(&mut remaining_fragments) {
if let Ok(xcm) =
VersionedXcm::<T::RuntimeCall>::decode(&mut remaining_fragments)
{
let _ = Self::handle_xcmp_message(sender, sent_at, xcm, max_weight);
} else {
debug_assert!(false, "Invalid incoming XCMP message data");
@@ -269,8 +271,8 @@ pub mod mock_msg_queue {
) -> Weight {
for (_i, (_sent_at, data)) in iter.enumerate() {
let id = sp_io::hashing::blake2_256(&data[..]);
let maybe_msg =
VersionedXcm::<T::Call>::decode(&mut &data[..]).map(Xcm::<T::Call>::try_from);
let maybe_msg = VersionedXcm::<T::RuntimeCall>::decode(&mut &data[..])
.map(Xcm::<T::RuntimeCall>::try_from);
match maybe_msg {
Err(_) => {
Self::deposit_event(Event::InvalidFormat(id));
@@ -292,14 +294,14 @@ pub mod mock_msg_queue {
}
impl mock_msg_queue::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
}
pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, RelayNetwork>;
impl pallet_xcm::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type XcmRouter = XcmRouter;
type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
@@ -307,10 +309,10 @@ impl pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Nothing;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
}
@@ -43,7 +43,7 @@ parameter_types! {
impl frame_system::Config for Runtime {
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
@@ -51,7 +51,7 @@ impl frame_system::Config for Runtime {
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type BlockWeights = ();
type BlockLength = ();
@@ -77,7 +77,7 @@ parameter_types! {
impl pallet_balances::Config for Runtime {
type MaxLocks = MaxLocks;
type Balance = Balance;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
@@ -124,7 +124,7 @@ pub type Barrier = AllowUnpaidExecutionFrom<Everything>;
pub struct XcmConfig;
impl Config for XcmConfig {
type Call = Call;
type RuntimeCall = RuntimeCall;
type XcmSender = XcmRouter;
type AssetTransactor = LocalAssetTransactor;
type OriginConverter = LocalOriginConverter;
@@ -132,7 +132,7 @@ impl Config for XcmConfig {
type IsTeleporter = ();
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type Trader = FixedRateOfFungible<KsmPerSecond, ()>;
type ResponseHandler = ();
type AssetTrap = ();
@@ -143,7 +143,7 @@ impl Config for XcmConfig {
pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, KusamaNetwork>;
impl pallet_xcm::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type XcmRouter = XcmRouter;
// Anyone can execute XCM messages locally...
@@ -152,10 +152,10 @@ impl pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
}
@@ -165,7 +165,7 @@ parameter_types! {
}
impl ump::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type UmpSink = ump::XcmSink<XcmExecutor<XcmConfig>, Runtime>;
type FirstMessageFactorPercent = FirstMessageFactorPercent;
type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;
@@ -53,7 +53,7 @@ parameter_types! {
impl frame_system::Config for Runtime {
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
@@ -61,7 +61,7 @@ impl frame_system::Config for Runtime {
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type BlockWeights = ();
type BlockLength = ();
@@ -87,7 +87,7 @@ parameter_types! {
impl pallet_balances::Config for Runtime {
type MaxLocks = MaxLocks;
type Balance = Balance;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
@@ -133,7 +133,7 @@ pub type Barrier = AllowUnpaidExecutionFrom<Everything>;
pub struct XcmConfig;
impl Config for XcmConfig {
type Call = Call;
type RuntimeCall = RuntimeCall;
type XcmSender = XcmRouter;
type AssetTransactor = LocalAssetTransactor;
type OriginConverter = XcmOriginToCallOrigin;
@@ -141,7 +141,7 @@ impl Config for XcmConfig {
type IsTeleporter = ();
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type Trader = FixedRateOfFungible<KsmPerSecond, ()>;
type ResponseHandler = ();
type AssetTrap = ();
@@ -156,8 +156,8 @@ pub mod mock_msg_queue {
#[pallet::config]
pub trait Config: frame_system::Config {
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
type XcmExecutor: ExecuteXcm<Self::Call>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type XcmExecutor: ExecuteXcm<Self::RuntimeCall>;
}
#[pallet::call]
@@ -175,7 +175,7 @@ pub mod mock_msg_queue {
#[pallet::storage]
#[pallet::getter(fn received_dmp)]
/// A queue of received DMP messages
pub(super) type ReceivedDmp<T: Config> = StorageValue<_, Vec<Xcm<T::Call>>, ValueQuery>;
pub(super) type ReceivedDmp<T: Config> = StorageValue<_, Vec<Xcm<T::RuntimeCall>>, ValueQuery>;
impl<T: Config> Get<ParaId> for Pallet<T> {
fn get() -> ParaId {
@@ -215,11 +215,11 @@ pub mod mock_msg_queue {
fn handle_xcmp_message(
sender: ParaId,
_sent_at: RelayBlockNumber,
xcm: VersionedXcm<T::Call>,
xcm: VersionedXcm<T::RuntimeCall>,
max_weight: Weight,
) -> Result<Weight, XcmError> {
let hash = Encode::using_encoded(&xcm, T::Hashing::hash);
let (result, event) = match Xcm::<T::Call>::try_from(xcm) {
let (result, event) = match Xcm::<T::RuntimeCall>::try_from(xcm) {
Ok(xcm) => {
let location = MultiLocation::new(1, X1(Parachain(sender.into())));
match T::XcmExecutor::execute_xcm(location, xcm, max_weight.ref_time()) {
@@ -251,7 +251,9 @@ pub mod mock_msg_queue {
let mut remaining_fragments = &data_ref[..];
while !remaining_fragments.is_empty() {
if let Ok(xcm) = VersionedXcm::<T::Call>::decode(&mut remaining_fragments) {
if let Ok(xcm) =
VersionedXcm::<T::RuntimeCall>::decode(&mut remaining_fragments)
{
let _ = Self::handle_xcmp_message(sender, sent_at, xcm, max_weight);
} else {
debug_assert!(false, "Invalid incoming XCMP message data");
@@ -269,8 +271,8 @@ pub mod mock_msg_queue {
) -> Weight {
for (_i, (_sent_at, data)) in iter.enumerate() {
let id = sp_io::hashing::blake2_256(&data[..]);
let maybe_msg =
VersionedXcm::<T::Call>::decode(&mut &data[..]).map(Xcm::<T::Call>::try_from);
let maybe_msg = VersionedXcm::<T::RuntimeCall>::decode(&mut &data[..])
.map(Xcm::<T::RuntimeCall>::try_from);
match maybe_msg {
Err(_) => {
Self::deposit_event(Event::InvalidFormat(id));
@@ -292,14 +294,14 @@ pub mod mock_msg_queue {
}
impl mock_msg_queue::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
}
pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, RelayNetwork>;
impl pallet_xcm::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type XcmRouter = XcmRouter;
type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
@@ -307,10 +309,10 @@ impl pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Nothing;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
}
@@ -43,7 +43,7 @@ parameter_types! {
impl frame_system::Config for Runtime {
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
@@ -51,7 +51,7 @@ impl frame_system::Config for Runtime {
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type BlockWeights = ();
type BlockLength = ();
@@ -77,7 +77,7 @@ parameter_types! {
impl pallet_balances::Config for Runtime {
type MaxLocks = MaxLocks;
type Balance = Balance;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
@@ -124,7 +124,7 @@ pub type Barrier = AllowUnpaidExecutionFrom<Everything>;
pub struct XcmConfig;
impl Config for XcmConfig {
type Call = Call;
type RuntimeCall = RuntimeCall;
type XcmSender = XcmRouter;
type AssetTransactor = LocalAssetTransactor;
type OriginConverter = LocalOriginConverter;
@@ -132,7 +132,7 @@ impl Config for XcmConfig {
type IsTeleporter = ();
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type Trader = FixedRateOfFungible<KsmPerSecond, ()>;
type ResponseHandler = ();
type AssetTrap = ();
@@ -143,7 +143,7 @@ impl Config for XcmConfig {
pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, KusamaNetwork>;
impl pallet_xcm::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type XcmRouter = XcmRouter;
// Anyone can execute XCM messages locally...
@@ -152,10 +152,10 @@ impl pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
}
@@ -165,7 +165,7 @@ parameter_types! {
}
impl ump::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type UmpSink = ump::XcmSink<XcmExecutor<XcmConfig>, Runtime>;
type FirstMessageFactorPercent = FirstMessageFactorPercent;
type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;