Rename Origin (#6020)

* Rename Origin

* fmt

* fixes

* more fixes

* fix

* more fixing

* small fixes

* last touches

* update lockfile for {"substrate"}

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Sergej Sakac
2022-09-21 00:53:12 +02:00
committed by GitHub
parent 8d8bd99582
commit 937c4e76ae
46 changed files with 1176 additions and 910 deletions
+18 -7
View File
@@ -75,7 +75,10 @@ pub mod pallet {
/// Required origin for sending XCM messages. If successful, it resolves to `MultiLocation`
/// which exists as an interior location within this chain's XCM context.
type SendXcmOrigin: EnsureOrigin<<Self as SysConfig>::Origin, Success = MultiLocation>;
type SendXcmOrigin: EnsureOrigin<
<Self as SysConfig>::RuntimeOrigin,
Success = MultiLocation,
>;
/// The type used to actually dispatch an XCM to its destination.
type XcmRouter: SendXcm;
@@ -83,7 +86,10 @@ pub mod pallet {
/// Required origin for executing XCM messages, including the teleport functionality. If successful,
/// then it resolves to `MultiLocation` which exists as an interior location within this chain's XCM
/// context.
type ExecuteXcmOrigin: EnsureOrigin<<Self as SysConfig>::Origin, Success = MultiLocation>;
type ExecuteXcmOrigin: EnsureOrigin<
<Self as SysConfig>::RuntimeOrigin,
Success = MultiLocation,
>;
/// Our XCM filter which messages to be executed using `XcmExecutor` must pass.
type XcmExecuteFilter: Contains<(MultiLocation, Xcm<<Self as SysConfig>::RuntimeCall>)>;
@@ -104,13 +110,16 @@ pub mod pallet {
type LocationInverter: InvertLocation;
/// The outer `Origin` type.
type Origin: From<Origin> + From<<Self as SysConfig>::Origin>;
type RuntimeOrigin: From<Origin> + From<<Self as SysConfig>::RuntimeOrigin>;
/// The outer `Call` type.
type RuntimeCall: Parameter
+ GetDispatchInfo
+ IsType<<Self as frame_system::Config>::RuntimeCall>
+ Dispatchable<Origin = <Self as Config>::Origin, PostInfo = PostDispatchInfo>;
+ Dispatchable<
RuntimeOrigin = <Self as Config>::RuntimeOrigin,
PostInfo = PostDispatchInfo,
>;
const VERSION_DISCOVERY_QUEUE_SIZE: u32;
@@ -1555,12 +1564,14 @@ where
/// A simple passthrough where we reuse the `MultiLocation`-typed XCM origin as the inner value of
/// this crate's `Origin::Xcm` value.
pub struct XcmPassthrough<Origin>(PhantomData<Origin>);
impl<Origin: From<crate::Origin>> ConvertOrigin<Origin> for XcmPassthrough<Origin> {
pub struct XcmPassthrough<RuntimeOrigin>(PhantomData<RuntimeOrigin>);
impl<RuntimeOrigin: From<crate::Origin>> ConvertOrigin<RuntimeOrigin>
for XcmPassthrough<RuntimeOrigin>
{
fn convert_origin(
origin: impl Into<MultiLocation>,
kind: OriginKind,
) -> Result<Origin, MultiLocation> {
) -> Result<RuntimeOrigin, MultiLocation> {
let origin = origin.into();
match kind {
OriginKind::Xcm => Ok(crate::Origin::Xcm(origin).into()),
+13 -13
View File
@@ -52,8 +52,8 @@ pub mod pallet_test_notifier {
#[pallet::config]
pub trait Config: frame_system::Config + crate::Config {
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 RuntimeOrigin: IsType<<Self as frame_system::Config>::RuntimeOrigin>
+ Into<Result<crate::Origin, <Self as Config>::RuntimeOrigin>>;
type RuntimeCall: IsType<<Self as crate::Config>::RuntimeCall> + From<Call<Self>>;
}
@@ -110,7 +110,7 @@ pub mod pallet_test_notifier {
query_id: QueryId,
response: Response,
) -> DispatchResult {
let responder = ensure_response(<T as Config>::Origin::from(origin))?;
let responder = ensure_response(<T as Config>::RuntimeOrigin::from(origin))?;
Self::deposit_event(Event::<T>::ResponseReceived(responder, query_id, response));
Ok(())
}
@@ -171,7 +171,7 @@ parameter_types! {
}
impl frame_system::Config for Test {
type Origin = Origin;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
@@ -229,10 +229,10 @@ pub type LocalAssetTransactor =
XcmCurrencyAdapter<Balances, IsConcrete<RelayLocation>, SovereignAccountOf, AccountId, ()>;
type LocalOriginConverter = (
SovereignSignedViaLocation<SovereignAccountOf, Origin>,
ChildParachainAsNative<origin::Origin, Origin>,
SignedAccountId32AsNative<AnyNetwork, Origin>,
ChildSystemParachainAsSuperuser<ParaId, Origin>,
SovereignSignedViaLocation<SovereignAccountOf, RuntimeOrigin>,
ChildParachainAsNative<origin::Origin, RuntimeOrigin>,
SignedAccountId32AsNative<AnyNetwork, RuntimeOrigin>,
ChildSystemParachainAsSuperuser<ParaId, RuntimeOrigin>,
);
parameter_types! {
@@ -267,7 +267,7 @@ impl xcm_executor::Config for XcmConfig {
type SubscriptionService = XcmPallet;
}
pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, AnyNetwork>;
pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, AnyNetwork>;
parameter_types! {
pub static AdvertisedXcmVersion: pallet_xcm::XcmVersion = 2;
@@ -275,16 +275,16 @@ parameter_types! {
impl pallet_xcm::Config for Test {
type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmRouter = (TestSendXcmErrX8, TestSendXcm);
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmExecuteFilter = Everything;
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = AdvertisedXcmVersion;
@@ -294,7 +294,7 @@ impl origin::Config for Test {}
impl pallet_test_notifier::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
}
+26 -22
View File
@@ -171,7 +171,11 @@ fn send_works() {
]);
let versioned_dest = Box::new(RelayLocation::get().into());
let versioned_message = Box::new(VersionedXcm::from(message.clone()));
assert_ok!(XcmPallet::send(Origin::signed(ALICE), versioned_dest, versioned_message));
assert_ok!(XcmPallet::send(
RuntimeOrigin::signed(ALICE),
versioned_dest,
versioned_message
));
assert_eq!(
sent_xcm(),
vec![(
@@ -209,7 +213,7 @@ fn send_fails_when_xcm_router_blocks() {
]);
assert_noop!(
XcmPallet::send(
Origin::signed(ALICE),
RuntimeOrigin::signed(ALICE),
Box::new(MultiLocation::ancestor(8).into()),
Box::new(VersionedXcm::from(message.clone())),
),
@@ -233,7 +237,7 @@ fn teleport_assets_works() {
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
let dest: MultiLocation = AccountId32 { network: Any, id: BOB.into() }.into();
assert_ok!(XcmPallet::teleport_assets(
Origin::signed(ALICE),
RuntimeOrigin::signed(ALICE),
Box::new(RelayLocation::get().into()),
Box::new(dest.clone().into()),
Box::new((Here, SEND_AMOUNT).into()),
@@ -276,7 +280,7 @@ fn limmited_teleport_assets_works() {
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
let dest: MultiLocation = AccountId32 { network: Any, id: BOB.into() }.into();
assert_ok!(XcmPallet::limited_teleport_assets(
Origin::signed(ALICE),
RuntimeOrigin::signed(ALICE),
Box::new(RelayLocation::get().into()),
Box::new(dest.clone().into()),
Box::new((Here, SEND_AMOUNT).into()),
@@ -320,7 +324,7 @@ fn unlimmited_teleport_assets_works() {
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
let dest: MultiLocation = AccountId32 { network: Any, id: BOB.into() }.into();
assert_ok!(XcmPallet::limited_teleport_assets(
Origin::signed(ALICE),
RuntimeOrigin::signed(ALICE),
Box::new(RelayLocation::get().into()),
Box::new(dest.clone().into()),
Box::new((Here, SEND_AMOUNT).into()),
@@ -363,7 +367,7 @@ fn reserve_transfer_assets_works() {
Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }.into();
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
assert_ok!(XcmPallet::reserve_transfer_assets(
Origin::signed(ALICE),
RuntimeOrigin::signed(ALICE),
Box::new(Parachain(PARA_ID).into().into()),
Box::new(dest.clone().into()),
Box::new((Here, SEND_AMOUNT).into()),
@@ -411,7 +415,7 @@ fn limited_reserve_transfer_assets_works() {
Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }.into();
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
assert_ok!(XcmPallet::limited_reserve_transfer_assets(
Origin::signed(ALICE),
RuntimeOrigin::signed(ALICE),
Box::new(Parachain(PARA_ID).into().into()),
Box::new(dest.clone().into()),
Box::new((Here, SEND_AMOUNT).into()),
@@ -460,7 +464,7 @@ fn unlimited_reserve_transfer_assets_works() {
Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }.into();
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
assert_ok!(XcmPallet::limited_reserve_transfer_assets(
Origin::signed(ALICE),
RuntimeOrigin::signed(ALICE),
Box::new(Parachain(PARA_ID).into().into()),
Box::new(dest.clone().into()),
Box::new((Here, SEND_AMOUNT).into()),
@@ -507,7 +511,7 @@ fn execute_withdraw_to_deposit_works() {
Junction::AccountId32 { network: NetworkId::Any, id: BOB.into() }.into();
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
assert_ok!(XcmPallet::execute(
Origin::signed(ALICE),
RuntimeOrigin::signed(ALICE),
Box::new(VersionedXcm::from(Xcm(vec![
WithdrawAsset((Here, SEND_AMOUNT).into()),
buy_execution((Here, SEND_AMOUNT)),
@@ -534,7 +538,7 @@ fn trapped_assets_can_be_claimed() {
Junction::AccountId32 { network: NetworkId::Any, id: BOB.into() }.into();
assert_ok!(XcmPallet::execute(
Origin::signed(ALICE),
RuntimeOrigin::signed(ALICE),
Box::new(VersionedXcm::from(Xcm(vec![
WithdrawAsset((Here, SEND_AMOUNT).into()),
buy_execution((Here, SEND_AMOUNT)),
@@ -569,7 +573,7 @@ fn trapped_assets_can_be_claimed() {
let weight = 3 * BaseXcmWeight::get();
assert_ok!(XcmPallet::execute(
Origin::signed(ALICE),
RuntimeOrigin::signed(ALICE),
Box::new(VersionedXcm::from(Xcm(vec![
ClaimAsset { assets: (Here, SEND_AMOUNT).into(), ticket: Here.into() },
buy_execution((Here, SEND_AMOUNT)),
@@ -584,7 +588,7 @@ fn trapped_assets_can_be_claimed() {
let weight = 3 * BaseXcmWeight::get();
assert_ok!(XcmPallet::execute(
Origin::signed(ALICE),
RuntimeOrigin::signed(ALICE),
Box::new(VersionedXcm::from(Xcm(vec![
ClaimAsset { assets: (Here, SEND_AMOUNT).into(), ticket: Here.into() },
buy_execution((Here, SEND_AMOUNT)),
@@ -615,7 +619,7 @@ fn basic_subscription_works() {
new_test_ext_with_balances(vec![]).execute_with(|| {
let remote = Parachain(1000).into();
assert_ok!(XcmPallet::force_subscribe_version_notify(
Origin::root(),
RuntimeOrigin::root(),
Box::new(remote.clone().into()),
));
@@ -658,13 +662,13 @@ fn subscriptions_increment_id() {
new_test_ext_with_balances(vec![]).execute_with(|| {
let remote = Parachain(1000).into();
assert_ok!(XcmPallet::force_subscribe_version_notify(
Origin::root(),
RuntimeOrigin::root(),
Box::new(remote.clone().into()),
));
let remote2 = Parachain(1001).into();
assert_ok!(XcmPallet::force_subscribe_version_notify(
Origin::root(),
RuntimeOrigin::root(),
Box::new(remote2.clone().into()),
));
@@ -689,12 +693,12 @@ fn double_subscription_fails() {
new_test_ext_with_balances(vec![]).execute_with(|| {
let remote = Parachain(1000).into();
assert_ok!(XcmPallet::force_subscribe_version_notify(
Origin::root(),
RuntimeOrigin::root(),
Box::new(remote.clone().into()),
));
assert_noop!(
XcmPallet::force_subscribe_version_notify(
Origin::root(),
RuntimeOrigin::root(),
Box::new(remote.clone().into())
),
Error::<Test>::AlreadySubscribed,
@@ -707,16 +711,16 @@ fn unsubscribe_works() {
new_test_ext_with_balances(vec![]).execute_with(|| {
let remote = Parachain(1000).into();
assert_ok!(XcmPallet::force_subscribe_version_notify(
Origin::root(),
RuntimeOrigin::root(),
Box::new(remote.clone().into()),
));
assert_ok!(XcmPallet::force_unsubscribe_version_notify(
Origin::root(),
RuntimeOrigin::root(),
Box::new(remote.clone().into())
));
assert_noop!(
XcmPallet::force_unsubscribe_version_notify(
Origin::root(),
RuntimeOrigin::root(),
Box::new(remote.clone().into())
),
Error::<Test>::NoSubscription,
@@ -851,7 +855,7 @@ fn subscriber_side_subscription_works() {
new_test_ext_with_balances(vec![]).execute_with(|| {
let remote = Parachain(1000).into();
assert_ok!(XcmPallet::force_subscribe_version_notify(
Origin::root(),
RuntimeOrigin::root(),
Box::new(remote.clone().into()),
));
take_sent_xcm();
@@ -893,7 +897,7 @@ fn auto_subscription_works() {
let remote0 = Parachain(1000).into();
let remote1 = Parachain(1001).into();
assert_ok!(XcmPallet::force_default_xcm_version(Origin::root(), Some(1)));
assert_ok!(XcmPallet::force_default_xcm_version(RuntimeOrigin::root(), Some(1)));
// Wrapping a version for a destination we don't know elicits a subscription.
let v1_msg = xcm::v1::Xcm::<()>::QueryResponse {