diff --git a/pallets/vane-xcm-transfer-system/src/helper.rs b/pallets/vane-xcm-transfer-system/src/helper.rs index 62569a07e..77bc5e9b3 100644 --- a/pallets/vane-xcm-transfer-system/src/helper.rs +++ b/pallets/vane-xcm-transfer-system/src/helper.rs @@ -536,7 +536,7 @@ use sp_std::ops::{Mul, Sub}; pallet_balances::Call::::transfer_keep_alive { dest: T::Lookup::unlookup(receiver.clone()), value: fees_amount - }.dispatch_bypass_filter(para_account_origin).unwrap(); + }.dispatch_bypass_filter(para_account_origin).unwrap(); // Error handling let _ = >::deposit(currency_id.into(), receiver, amount, Precision::Exact)?; Ok(()) diff --git a/runtime/vane-parachain-runtime/src/lib.rs b/runtime/vane-parachain-runtime/src/lib.rs index 2122b4727..9a4d69149 100644 --- a/runtime/vane-parachain-runtime/src/lib.rs +++ b/runtime/vane-parachain-runtime/src/lib.rs @@ -5,6 +5,9 @@ // Make the WASM binary available. #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +#[cfg(test)] +mod xcm_eml_testing; + mod weights; pub mod xcm_config; diff --git a/runtime/vane-parachain-runtime/src/xcm_eml_testing/mod.rs b/runtime/vane-parachain-runtime/src/xcm_eml_testing/mod.rs index 3d8e5971b..adf097c62 100644 --- a/runtime/vane-parachain-runtime/src/xcm_eml_testing/mod.rs +++ b/runtime/vane-parachain-runtime/src/xcm_eml_testing/mod.rs @@ -1,18 +1,22 @@ use std::sync::Once; +use integration_tests_common::constants::{polkadot,rococo,asset_hub_polkadot,asset_hub_kusama}; use xcm_emulator::*; -use integration_tests_common::{polkadot,asset_hub_polkadot,rococo}; use polkadot_core_primitives::AccountPublic; use sp_core::{sr25519, sr25519::Pair as PairType, Pair, Public}; use sp_core::crypto::Ss58AddressFormatRegistry; use sp_runtime::MultiSigner; use sp_runtime::traits::IdentifyAccount; -use crate::{AuraId,Balance}; +use crate::{AuraId,Balance,Runtime,AuraExt,XcmpQueue,DmpQueue,ParachainInfo,VaneAssets,PolkadotXcm,Balances,VaneXcmTransferSystem}; use sp_core::crypto::Ss58Codec; use sp_runtime::BuildStorage; -use xcm_executor::traits::ConvertLocation; +use staging_xcm_executor::traits::ConvertLocation; use frame_support::traits::UnfilteredDispatchable; +use frame_support::pallet_prelude::*; +use staging_xcm::prelude::*; +use cumulus_primitives_core::AccountId32; -const SAFE_XCM_VERSION: u32 = XCM_VERSION; + +const SAFE_XCM_VERSION: u32 = crate::XCM_VERSION; fn get_from_seed(seed: &str) -> ::Public { TPublic::Pair::from_string(&format!("//{}", seed), None) @@ -34,7 +38,7 @@ pub fn template_session_keys(keys: AuraId) -> crate::SessionKeys { crate::SessionKeys { aura: keys } } -#[derive(Encode,Decode)] +#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] pub struct RococoId(u32); fn calculate_sovereign_account( @@ -107,14 +111,50 @@ pub mod accounts { } } + +// Relay Network Implementation + +decl_test_relay_chains! { + #[api_version(5)] + pub struct Polkadot { + genesis = polkadot::genesis(), + on_init = (), + runtime = polkadot_runtime, + core = { + MessageProcessor: DefaultMessageProcessor, + SovereignAccountOf: polkadot_runtime::xcm_config::SovereignAccountOf, + }, + pallets = { + XcmPallet: polkadot_runtime::XcmPallet, + Balances: polkadot_runtime::Balances, + Hrmp: polkadot_runtime::Hrmp, + } + }, + #[api_version(5)] + pub struct Rococo { + genesis = rococo::genesis(), + on_init = (), + runtime = rococo_runtime, + core = { + MessageProcessor: DefaultMessageProcessor, + SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf, + }, + pallets = { + XcmPallet: rococo_runtime::XcmPallet, + Sudo: rococo_runtime::Sudo, + Balances: rococo_runtime::Balances, + } + } +} + + + pub use vane_parachain::*; pub mod vane_parachain { use super::*; - use integration_tests_common::Storage; - use sp_core::crypto::Ss58Codec; - use vane_primitive::CurrencyId; - use vane_primitive::CurrencyId::DOT; + use crate::xcm_eml_testing::Storage; use sp_core::crypto::Ss58Codec; + use vane_xcm_transfer_system::CurrencyId::*; use crate::{EXISTENTIAL_DEPOSIT,Balance}; use crate::xcm_eml_testing::accounts::{ALICE, invulnerables, sudo_key}; @@ -144,11 +184,10 @@ pub mod vane_parachain { }, balances: crate::BalancesConfig { - balances: accounts::init_balances() - .iter() - .cloned() - .map(|k| (k, ED * 4096)) - .collect(), + balances: vec![ + (para_account.clone(),10000000000), + (alice.clone(),10000000000) + ] }, vane_assets: crate::VaneAssetsConfig { @@ -161,7 +200,7 @@ pub mod vane_parachain { }, - vane_xcm: crate::VaneXcmConfig { + vane_xcm_transfer_system: crate::VaneXcmTransferSystemConfig { para_account: Some(para_account) }, @@ -204,148 +243,97 @@ pub mod vane_parachain { } -decl_test_relay_chains! { - #[api_version(5)] - pub struct PolkadotMain { - genesis = polkadot::genesis(), - on_init = (), - runtime = { - Runtime: polkadot_runtime::Runtime, - RuntimeOrigin: polkadot_runtime::RuntimeOrigin, - RuntimeCall: polkadot_runtime::RuntimeCall, - RuntimeEvent: polkadot_runtime::RuntimeEvent, - MessageQueue: polkadot_runtime::MessageQueue, - XcmConfig: polkadot_runtime::xcm_config::XcmConfig, - SovereignAccountOf: polkadot_runtime::xcm_config::SovereignAccountOf, - System: polkadot_runtime::System, - Balances: polkadot_runtime::Balances, - }, - pallets_extra = { - XcmPallet: polkadot_runtime::XcmPallet, - } - }, - #[api_version(5)] - pub struct Rococo { - genesis = rococo::genesis(), - on_init = (), - runtime = { - Runtime: rococo_runtime::Runtime, - RuntimeOrigin: rococo_runtime::RuntimeOrigin, - RuntimeCall: rococo_runtime::RuntimeCall, - RuntimeEvent: rococo_runtime::RuntimeEvent, - MessageQueue: rococo_runtime::MessageQueue, - XcmConfig: rococo_runtime::xcm_config::XcmConfig, - SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf, - System: rococo_runtime::System, - Balances: rococo_runtime::Balances, - }, - pallets_extra = { - XcmPallet: rococo_runtime::XcmPallet, - Sudo: rococo_runtime::Sudo, - } - } -} - decl_test_parachains!( - pub struct VaneParachain { + + pub struct VanePolkadot { genesis = vane_parachain::genesis(), - on_init = (), - runtime = { - Runtime: crate::Runtime, - RuntimeOrigin: crate::RuntimeOrigin, - RuntimeCall: crate::RuntimeCall, - RuntimeEvent: crate::RuntimeEvent, - XcmpMessageHandler: crate::XcmpQueue, - DmpMessageHandler: crate::DmpQueue, + on_init = { + AuraExt::on_initialize(1); + }, + runtime = crate, + core = { + XcmpMessageHandler: XcmpQueue, + DmpMessageHandler: DmpQueue, LocationToAccountId: crate::xcm_config::LocationToAccountId, - System: crate::System, - Balances: crate::Balances, - ParachainSystem: crate::ParachainSystem, - ParachainInfo: crate::ParachainInfo, + ParachainInfo: ParachainInfo, }, - pallets_extra = { - PolkadotXcm: crate::PolkadotXcm, - VaneAssets: crate::VaneAssets, - VaneXcm: crate::VaneXcm, - VanePayment: crate::VanePayment, - + pallets = { + PolkadotXcm: PolkadotXcm, + VaneAssets: VaneAssets, + Balances: Balances, + VaneXcmTransferSystem: VaneXcmTransferSystem, } + }, - pub struct VaneRococo { + pub struct VaneRococo { genesis = vane_parachain::genesis(), - on_init = (), - runtime = { - Runtime: crate::Runtime, - RuntimeOrigin: crate::RuntimeOrigin, - RuntimeCall: crate::RuntimeCall, - RuntimeEvent: crate::RuntimeEvent, - XcmpMessageHandler: crate::XcmpQueue, - DmpMessageHandler: crate::DmpQueue, + on_init = { + AuraExt::on_initialize(1); + }, + runtime = crate, + core = { + XcmpMessageHandler: XcmpQueue, + DmpMessageHandler: DmpQueue, LocationToAccountId: crate::xcm_config::LocationToAccountId, - System: crate::System, - Balances: crate::Balances, - ParachainSystem: crate::ParachainSystem, - ParachainInfo: crate::ParachainInfo, + ParachainInfo: ParachainInfo, }, - pallets_extra = { - PolkadotXcm: crate::PolkadotXcm, - VaneAssets: crate::VaneAssets, - VaneXcm: crate::VaneXcm, - VanePayment: crate::VanePayment, - + pallets = { + PolkadotXcm: PolkadotXcm, + VaneAssets: VaneAssets, + Balances: Balances, + VaneXcmTransferSystem: VaneXcmTransferSystem, } }, + + // AssetHubs pub struct AssetHubPolkadot { genesis = asset_hub_polkadot::genesis(), - on_init = (), - runtime = { - Runtime: asset_hub_polkadot_runtime::Runtime, - RuntimeOrigin: asset_hub_polkadot_runtime::RuntimeOrigin, - RuntimeCall: asset_hub_polkadot_runtime::RuntimeCall, - RuntimeEvent: asset_hub_polkadot_runtime::RuntimeEvent, + on_init = { + asset_hub_polkadot_runtime::AuraExt::on_initialize(1); + }, + runtime = asset_hub_polkadot_runtime, + core = { XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue, DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue, LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId, - System: asset_hub_polkadot_runtime::System, - Balances: asset_hub_polkadot_runtime::Balances, - ParachainSystem: asset_hub_polkadot_runtime::ParachainSystem, ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo, }, - pallets_extra = { + pallets = { PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm, Assets: asset_hub_polkadot_runtime::Assets, + Balances: asset_hub_polkadot_runtime::Balances, } }, + pub struct AssetHubRococo { - genesis = asset_hub_polkadot::genesis(), - on_init = (), - runtime = { - Runtime: asset_hub_polkadot_runtime::Runtime, - RuntimeOrigin: asset_hub_polkadot_runtime::RuntimeOrigin, - RuntimeCall: asset_hub_polkadot_runtime::RuntimeCall, - RuntimeEvent: asset_hub_polkadot_runtime::RuntimeEvent, - XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue, - DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue, - LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId, - System: asset_hub_polkadot_runtime::System, - Balances: asset_hub_polkadot_runtime::Balances, - ParachainSystem: asset_hub_polkadot_runtime::ParachainSystem, - ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo, + genesis = asset_hub_kusama::genesis(), + on_init = { + asset_hub_polkadot_runtime::AuraExt::on_initialize(1); }, - pallets_extra = { - PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm, - Assets: asset_hub_polkadot_runtime::Assets, + runtime = asset_hub_kusama_runtime, + core = { + XcmpMessageHandler: asset_hub_kusama_runtime::XcmpQueue, + DmpMessageHandler: asset_hub_kusama_runtime::DmpQueue, + LocationToAccountId: asset_hub_kusama_runtime::xcm_config::LocationToAccountId, + ParachainInfo: asset_hub_kusama_runtime::ParachainInfo, + }, + pallets = { + PolkadotXcm: asset_hub_kusama_runtime::PolkadotXcm, + Assets: asset_hub_kusama_runtime::Assets, } - } + }, + ); + + decl_test_networks!( // Polkadot pub struct PolkadotNet { - relay_chain = PolkadotMain, + relay_chain = Polkadot, parachains = vec![ AssetHubPolkadot, - VaneParachain, + VanePolkadot, ], bridge = () }, @@ -360,289 +348,156 @@ decl_test_networks!( bridge = () } ); - +// +// +// static INIT: Once = Once::new(); +// pub fn init_tracing() { +// INIT.call_once(|| { +// // Add test tracing (from sp_tracing::init_for_tests()) but filtering for xcm logs only +// let _ = tracing_subscriber::fmt() +// //.with_max_level(tracing::Level::TRACE) +// //.with_env_filter("xcm=trace,system::events=trace") // Comment out this line to see all traces +// .with_test_writer() +// .init(); +// }); +// } +// +// +// // Tests +// +// mod tests { +// use super::*; +// use frame_support::assert_ok; +// use frame_support::dispatch::RawOrigin; +// use hex_literal::hex; +// use staging_xcm::latest::OriginKind::SovereignAccount; +// use xcm_emulator::{Parachain, TestExt}; +// use crate::xcm_eml_testing::{VaneParachain,PolkadotMain}; +// use crate::xcm_eml_testing::accounts::{ALICE,BOB,CHARLIE}; +// use staging_xcm::VersionedXcm; +// use sp_tracing; +// use vane_primitive::CurrencyId::DOT; +// +// #[test] +// fn relay_chain_n_vane_remote_execution_works() { +// +// +// // Alice --> RC RC +// // - (Reserve transfer) ^ +// // ˯ - +// // Reserve Chain Reserve Chain +// // - (Deposit Equivalent) ^ +// // ˯ - +// // Vane --------> MultiSig(Alice,Bob) --------> VaneXcm +// // - ^ +// // - ----------> Confirmation - +// // - - +// // --->Ms(A,B)--->Bob ------------- +// } +// #[test] +// fn native_reserve_transfer_reserve_works() { +// +// } +// } static INIT: Once = Once::new(); -pub fn init_tracing() { +fn init_tracing() { INIT.call_once(|| { // Add test tracing (from sp_tracing::init_for_tests()) but filtering for xcm logs only let _ = tracing_subscriber::fmt() - //.with_max_level(tracing::Level::TRACE) - //.with_env_filter("xcm=trace,system::events=trace") // Comment out this line to see all traces + .with_max_level(tracing::Level::TRACE) + .with_env_filter("xcm=trace,system::events=trace") // Comment out this line to see all traces .with_test_writer() .init(); }); } +#[cfg(test)] +mod tests { + use cumulus_primitives_core::Junctions::Here; +use integration_tests_common::constants::accounts::ALICE; +use vane_xcm_transfer_system::CurrencyId; -// Tests +use super::*; -mod tests { - use super::*; - use frame_support::assert_ok; - use frame_support::dispatch::RawOrigin; - use hex_literal::hex; - use xcm::latest::OriginKind::SovereignAccount; - use xcm_emulator::{Parachain, TestExt}; - use vane_payment::helper::Token; - use crate::xcm_eml_testing::{VaneParachain,PolkadotMain}; - use crate::xcm_eml_testing::accounts::{ALICE,BOB,CHARLIE}; - use xcm::VersionedXcm; - use sp_tracing; - use vane_payment::Confirm; - use vane_primitive::CurrencyId::DOT; + + // This test check that the Xcm Reserve Transfered Dot token from Relay Chain being deposited to the multi_id form between Alice & Bob + // And all the necessary storage entities are taking place. + // This functionality of directly depositing into multi id can be found in the implemented AssetTransactor::transfer. + // AssetTransactor is responsible for handling token behaviour inside destination chain ( Note: check in staging_xcm_executor) #[test] - fn relay_chain_n_vane_remote_execution_works(){ + fn transfer_dot_from_relay_to_vane_deposits_into_multi_id_works(){ + } - // Alice --> RC RC - // - (Reserve transfer) ^ - // ˯ - - // Reserve Chain Reserve Chain - // - (Deposit Equivalent) ^ - // ˯ - - // Vane --------> MultiSig(Alice,Bob) --------> VaneXcm - // - ^ - // - ----------> Confirmation - - // - - - // --->Ms(A,B)--->Bob ------------- + // Acting like bridging the tokens from Alice's relay account into Alice's vane account + #[test] + fn reserve_transfer_from_relay_into_sender_account(){ - // Test RelayChain - PolkadotMain::execute_with(||{ + sp_tracing::init_for_tests(); - sp_tracing::init_for_tests(); - let sovererign_acount = calculate_sovereign_account::(PARA_ID.into()).unwrap(); - let para_account = sp_runtime::AccountId32::from_ss58check(&sovererign_acount).unwrap(); - type PolkadotOrigin = ::RuntimeOrigin; - type PolkadotEvents = ::RuntimeEvent; - type PolkadotCall = ::RuntimeCall; - type PolkadotSystem = ::System; - type VaneOrigin = ::RuntimeOrigin; - type VaneCall = ::RuntimeCall; + Rococo::execute_with(||{ + type RococoPalletSystem = ::System; + let alice_account = get_account_id_from_seed::(ALICE); - let alice = get_account_id_from_seed::(ALICE); - let bob = get_account_id_from_seed::(BOB); + let alice_relay_origin = ::RuntimeOrigin::signed(alice_account.clone()); + + let vane_destination = Rococo::child_location_of(VaneRococo::para_id()); + let amount = 100_000_000_000_000_000u128; + let asset_amount = 1000u128; - let amount = 100_000_000_000u128; - // Research on using XCM and send a message to AssetHub and dispatch a uniques pallet mint fn to mint a custom nft to parachain_account assert_ok!( - ::Balances::transfer_keep_alive( - PolkadotOrigin::signed(alice.clone()), - para_account.clone().into(), - amount.into() + ::XcmPallet::reserve_transfer_assets( + alice_relay_origin, + bx!(vane_destination.into()), + bx!(AccountId32 { network: None, id: alice_account.into() }.into()), + bx!((Here, amount).into()), + 0, ) ); - assert_eq!( - ::Balances::free_balance(para_account), - amount - ); - - let v_dot = MultiLocation{ - parents: 0, - interior: X2(PalletInstance(10),GeneralIndex(1)).into() - }; - - let vane_xcm_transfer_call = VaneCall::VaneXcm(vane_xcm::Call::vane_transfer { - payee: bob.into(), - amount, - currency: Token::DOT, - asset_id: DOT, - }); - - let encoded_call = vane_xcm_transfer_call.encode().to_vec(); - - println!(" Encoded Transfer Call : {:?}",encoded_call); - - let message = Xcm::<()>(vec![ - DescendOrigin(AccountId32 {network: None, id: alice.clone().into() }.into()), // look into remote derived accounts - Transact { - origin_kind: SovereignAccount, - require_weight_at_most: Weight::from_parts(1_000_000_000,1024*1024), - call: vane_xcm_transfer_call.encode().into(), - } - ]); - - // test dispatching xcm - assert_ok!( - ::XcmPallet::send( - PolkadotOrigin::signed(alice), - bx!(X1(Parachain(PARA_ID)).into()), - bx!(VersionedXcm::V3(message.clone())) - ) - ); - PolkadotSystem::events().iter().for_each(|e| println!("{:#?}",e)); + RococoPalletSystem::events().iter().for_each(|e| println!("{:#?} \n",e)); }); - VaneParachain::execute_with(||{ - - type VaneOrigin = ::RuntimeOrigin; - type VaneEvents = ::RuntimeEvent; - type VaneCall = ::RuntimeCall; - type VaneSystem = ::System; + VaneRococo::execute_with(||{ - let alice = get_account_id_from_seed::(ALICE); - let bob = get_account_id_from_seed::(BOB); + let alice_account = get_account_id_from_seed::(ALICE); - let amount = 100_000_000_000u128; + let alice_relay_origin = ::RuntimeOrigin::signed(alice_account.clone()); + let amount = 100_000_000_000_000_000u128; - // - // let vane_xcm_transfer_call = VaneCall::VaneXcm(vane_xcm::Call::vane_transfer { - // payee: bob.into(), - // amount, - // currency: Token::Dot, - // asset_id: v_dot, - // }); - // - // // test dispatching - // assert_ok!( - // vane_xcm_transfer_call.dispatch_bypass_filter(VaneOrigin::signed(alice.clone())) - // ); - - // assert_ok!( - // ::VaneXcm::test_storing( - // VaneOrigin::signed(alice.clone()), - // alice, - // 30 - // ) - // ); + // print the events + type VanePalletSystem = ::System; + assert_eq!( + ::VaneAssets::balance(CurrencyId::DOT,alice_account), + 99999999968000000 + ); - VaneSystem::events().iter().for_each(|e| println!("{:#?}",e)); + VanePalletSystem::events().iter().for_each(|e| println!("{:#?} \n",e)); }) } + // This test checks transaction lifecycle from Relay Chain to Vane and back to Relay Chain with confirmations in place and fees token being deposited #[test] - fn native_reserve_transfer_reserve_works(){ - - PolkadotMain::execute_with(|| { - - sp_tracing::init_for_tests(); - - let alice = get_account_id_from_seed::(ALICE); - let bob = get_account_id_from_seed::(BOB); - - let amount = 1_000_000_000_000u128; - - type PolkadotOrigin = ::RuntimeOrigin; - type PolkadotEvents = ::RuntimeEvent; - type PolkadotCall = ::RuntimeCall; - type PolkadotSystem = ::System; - - assert_ok!( - ::XcmPallet::reserve_transfer_assets( - PolkadotOrigin::signed(alice.clone()), - bx!(X1(Parachain(PARA_ID)).into()), - bx!(AccountId32 { network: None, id: alice.into() }.into()), - bx!((Here, amount).into()), - 0 - ) - ); - - PolkadotSystem::events().iter().for_each(|e| println!("{:#?}",e)); - - }); + fn full_transaction_execution_and_confirmation_works(){ - println!("Vane Area \n"); - - VaneParachain::execute_with(||{ - //let amount = 1_000_000u128; - - let alice = get_account_id_from_seed::(ALICE); - let bob = get_account_id_from_seed::(BOB); - - - type VaneOrigin = ::RuntimeOrigin; - type VaneEvents = ::RuntimeEvent; - type VaneCall = ::RuntimeCall; - type VaneSystem = ::System; - - VaneSystem::events().iter().for_each(|e| println!("{:#?} \n",e)); - - assert_eq!( - ::VaneAssets::balance(DOT,alice.clone()), - 999959040000 - ); - - // Vane transfer internally - println!("Vane Transfer Internaly \n"); - - assert_ok!( - ::VaneXcm::vane_transfer( - VaneOrigin::signed(alice.clone()), - bob.clone().into(), - 999959040000, - Token::DOT, - DOT - ) - ); - - VaneSystem::events().iter().for_each(|e| println!("{:#?} \n",e)); - - // Confirmation zone - // Bob -> Alice - println!(" Confirmation zone \n"); - - //Fetch the reference Id - let receipt = ::VaneXcm::read_payer_receipt( - VaneOrigin::signed(alice.clone()), - bob.clone() - ); - - println!(" Receipt: {:?} \n",receipt); - - // Bob Vane account - println!("Vane Bob: {:?}", bob.clone()); - - assert_ok!( - ::VaneXcm::vane_confirm( - VaneOrigin::signed(bob.clone()), - Confirm::Payee, - receipt.clone().unwrap().reference_no.to_vec(), - receipt.clone().unwrap().amount, - DOT - ) - ); - - assert_ok!( - ::VaneXcm::vane_confirm( - VaneOrigin::signed(alice.clone()), - Confirm::Payer, - receipt.clone().unwrap().reference_no.to_vec(), - receipt.unwrap().amount, - DOT - ) - ); - - println!("Vane last events \n "); - - VaneSystem::events().iter().for_each(|e| println!("{:#?} \n",e)); - - }); - - PolkadotMain::execute_with(||{ - type PolkadotSystem = ::System; - - let alice = get_account_id_from_seed::(ALICE); - let bob = get_account_id_from_seed::(BOB); - - println!(" RelayChain last events \n"); + } - // print relay Bob account - println!(" Relay Bob: {:?} \n",bob); - PolkadotSystem::events().iter().for_each(|e| println!("{:#?}",e)); - }) + // This test checks reverting txn, sends xcm message to refund the tokens being held in vane soverign account. + #[test] + fn reverting_works(){ } -} +} \ No newline at end of file diff --git a/runtime/vane-parachain-runtime/src/xcm_sim_testing/asset_hub.rs b/runtime/vane-parachain-runtime/src/xcm_sim_testing/asset_hub.rs new file mode 100644 index 000000000..aa1e19179 --- /dev/null +++ b/runtime/vane-parachain-runtime/src/xcm_sim_testing/asset_hub.rs @@ -0,0 +1,472 @@ +use assets_common::matching::FromSiblingParachain; +use codec::{Decode, Encode}; +use frame_support::{construct_runtime, match_types, parameter_types, traits::{EnsureOrigin, EnsureOriginWithArg, Everything, EverythingBut, Nothing, ContainsPair}, weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}}; + +use frame_system::EnsureRoot; +use sp_core::{ConstU32, H256, Get}; +use sp_runtime::{ + testing::Header, + traits::{Hash, IdentityLookup}, + AccountId32, +}; +use sp_std::prelude::*; +use vane_xcm_transfer_system; + + +use pallet_xcm::XcmPassthrough; +use polkadot_core_primitives::BlockNumber as RelayBlockNumber; +use polkadot_parachain_primitives::primitives::{ + DmpMessageHandler, Id as ParaId, Sibling, XcmpMessageFormat, XcmpMessageHandler, +}; +use staging_xcm::{latest::prelude::*, VersionedXcm}; +use staging_xcm_builder::{Account32Hash, AccountId32Aliases, AliasForeignAccountId32, AllowUnpaidExecutionFrom, ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, IsConcrete, NativeAsset, NoChecking, NonFungiblesAdapter, ParentIsPreset, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation}; +use staging_xcm_executor::{ + traits::JustTry, + Config, XcmExecutor, +}; +use xcm_simulator::PhantomData; +use assets_common::foreign_creators::ForeignCreators; + +use vane_xcm_transfer_system::{CurrencyId, MultiCurrencyAsset, MultiCurrencyConverter, VaneDerivedAssets, VaneForeignCreators}; +use staging_xcm_executor::traits::MatchesFungible; +use sp_runtime::traits::{CheckedConversion, Convert}; +// `EnsureOriginWithArg` impl for `CreateOrigin` which allows only XCM origins +// which are locations containing the class location. +use staging_xcm_executor::traits::ConvertLocation; +use crate::{ApprovalDeposit, ForeignAssetsAssetAccountDeposit, ForeignAssetsAssetDeposit, ForeignAssetsMetadataDepositBase, ForeignCreatorsSovereignAccountOf, MetadataDepositPerByte, StringLimit, weights, xcm_config}; +use crate::xcm_sim_testing::Vane; + +// pub struct ForeignCreators; +// impl EnsureOriginWithArg for ForeignCreators { +// type Success = AccountId; +// +// fn try_origin( +// o: RuntimeOrigin, +// a: &MultiLocation, +// ) -> Result { +// let origin_location = pallet_xcm::EnsureXcm::::try_origin(o.clone())?; +// if !a.starts_with(&origin_location) { +// return Err(o) +// } +// SovereignAccountOf::convert_location(&origin_location).ok_or(o) +// } +// +// #[cfg(feature = "runtime-benchmarks")] +// fn try_successful_origin(a: &MultiLocation) -> Result { +// Ok(pallet_xcm::Origin::Xcm(a.clone()).into()) +// } +// } + +parameter_types! { + pub const ReservedXcmpWeight: Weight = Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4), 0); + pub const ReservedDmpWeight: Weight = Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4), 0); +} + +parameter_types! { + pub const KsmLocation: MultiLocation = MultiLocation::parent(); + pub const RelayNetwork: NetworkId = NetworkId::Kusama; + pub UniversalLocation: InteriorMultiLocation = Parachain(MsgQueue::parachain_id().into()).into(); +} + +pub type LocationToAccountId = ( + ParentIsPreset, + // SiblingParachainConvertsVia, + AccountId32Aliases, + Account32Hash<(), AccountId>, +); + +pub type XcmOriginToCallOrigin = ( + SovereignSignedViaLocation, + SignedAccountId32AsNative, + //XcmPassthrough, +); + +parameter_types! { + pub const UnitWeightCost: Weight = Weight::from_parts(1, 1); + pub KsmPerSecondPerByte: (AssetId, u128, u128) = (Concrete(Parent.into()), 1, 1); + pub const MaxInstructions: u32 = 100; + pub const MaxAssetsIntoHolding: u32 = 64; + pub ForeignPrefix: MultiLocation = (Parent,).into(); +} + + +pub struct IsNativeConcrete(sp_std::marker::PhantomData<(CurrencyId, CurrencyIdConvert)>); +impl MatchesFungible for IsNativeConcrete + where + CurrencyIdConvert: Convert>, + Amount: TryFrom, +{ + fn matches_fungible(a: &MultiAsset) -> Option { + if let (Fungible(ref amount), Concrete(ref location)) = (&a.fun, &a.id) { + if CurrencyIdConvert::convert(*location).is_some() { + return CheckedConversion::checked_from(*amount); + } + } + None + } +} + + +pub type LocalAssetTransactor = vane_xcm_transfer_system::VaneMultiCurrencyAdapter< + MultiCurrencyAsset, + (), // handler for unknown assets + IsNativeConcrete>, + AccountId, + LocationToAccountId, + CurrencyId, + MultiCurrencyConverter, + // HandlingFailedDeposits +>; + +pub type SovereignAccountOf = ( + SiblingParachainConvertsVia, + AccountId32Aliases, + ParentIsPreset, +); + +pub type AccountId = AccountId32; +pub type Balance = u128; + +parameter_types! { + pub const BlockHashCount: u64 = 250; +} + +impl frame_system::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type BaseCallFilter = Everything; + type BlockWeights = (); + type BlockLength = (); + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type Nonce = u64; + type Hash = H256; + type Hashing = sp_runtime::traits::BlakeTwo256; + type AccountId = AccountId; + type Lookup = IdentityLookup; + type Block = Block; + type BlockHashCount = BlockHashCount; + type DbWeight = (); + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = ConstU32<16>; +} + +parameter_types! { + pub ExistentialDeposit: Balance = 1; + pub const MaxLocks: u32 = 50; + pub const MaxReserves: u32 = 50; + +} + +impl pallet_balances::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); + type Balance = Balance; + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type ReserveIdentifier = [u8; 8]; + type RuntimeHoldReason = RuntimeHoldReason; + type FreezeIdentifier = (); + type MaxLocks = MaxLocks; + type MaxReserves = MaxReserves; + type MaxHolds = ConstU32<0>; + type MaxFreezes = ConstU32<0>; +} + + +pub type XcmRouter = super::ParachainXcmRouter; +pub type Barrier = AllowUnpaidExecutionFrom; + +match_types! { + pub type SiblingPrefix: impl Contains = { + MultiLocation { parents: 1, interior: X1(Parachain(_)) } + }; + pub type ChildPrefix: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(_)) } + }; + pub type ParentPrefix: impl Contains = { + MultiLocation { parents: 1, interior: Here } + }; +} + + + +use asset_hub_kusama_runtime::{xcm_config::AssetTransactors}; + +pub struct XcmConfig; +impl Config for XcmConfig { + type RuntimeCall = RuntimeCall; + type XcmSender = XcmRouter; + type AssetTransactor = AssetTransactors; + type OriginConverter = XcmOriginToCallOrigin; + type IsReserve = VaneDerivedAssets; + type IsTeleporter = NativeAsset; + type Aliasers = AliasForeignAccountId32; // test for both Parent and AssetHub Prefix + type UniversalLocation = UniversalLocation; + type Barrier = Barrier; + type Weigher = FixedWeightBounds; + type Trader = FixedRateOfFungible; + type ResponseHandler = (); + type AssetTrap = (); + type AssetLocker = PolkadotXcm; + type AssetExchanger = (); + type AssetClaims = (); + type SubscriptionService = (); + type PalletInstancesInfo = (); + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; +} + + +#[frame_support::pallet] +pub mod mock_msg_queue { + use super::*; + use frame_support::pallet_prelude::*; + + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type XcmExecutor: ExecuteXcm; + } + + #[pallet::call] + impl Pallet {} + + #[pallet::pallet] + #[pallet::without_storage_info] + pub struct Pallet(_); + + #[pallet::storage] + #[pallet::getter(fn parachain_id)] + pub(super) type ParachainId = StorageValue<_, ParaId, ValueQuery>; + + #[pallet::storage] + #[pallet::getter(fn received_dmp)] + /// A queue of received DMP messages + pub(super) type ReceivedDmp = StorageValue<_, Vec>, ValueQuery>; + + impl Get for Pallet { + fn get() -> ParaId { + Self::parachain_id() + } + } + + pub type MessageId = [u8; 32]; + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + // XCMP + /// Some XCM was executed OK. + Success(Option), + /// Some XCM failed. + Fail(Option, XcmError), + /// Bad XCM version used. + BadVersion(Option), + /// Bad XCM format used. + BadFormat(Option), + + // DMP + /// Downward message is invalid XCM. + InvalidFormat(MessageId), + /// Downward message is unsupported version of XCM. + UnsupportedVersion(MessageId), + /// Downward message executed with the given outcome. + ExecutedDownward(MessageId, Outcome), + } + + impl Pallet { + pub fn set_para_id(para_id: ParaId) { + ParachainId::::put(para_id); + } + + fn handle_xcmp_message( + sender: ParaId, + _sent_at: RelayBlockNumber, + xcm: VersionedXcm, + max_weight: Weight, + ) -> Result { + let hash = Encode::using_encoded(&xcm, T::Hashing::hash); + let message_hash = Encode::using_encoded(&xcm, sp_io::hashing::blake2_256); + let (result, event) = match Xcm::::try_from(xcm) { + Ok(xcm) => { + let location = (Parent, Parachain(sender.into())); + match T::XcmExecutor::execute_xcm(location, xcm, message_hash, max_weight) { + Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)), + Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))), + // As far as the caller is concerned, this was dispatched without error, so + // we just report the weight used. + Outcome::Incomplete(w, e) => (Ok(w), Event::Fail(Some(hash), e)), + } + }, + Err(()) => (Err(XcmError::UnhandledXcmVersion), Event::BadVersion(Some(hash))), + }; + Self::deposit_event(event); + result + } + } + + impl XcmpMessageHandler for Pallet { + fn handle_xcmp_messages<'a, I: Iterator>( + iter: I, + max_weight: Weight, + ) -> Weight { + for (sender, sent_at, data) in iter { + let mut data_ref = data; + let _ = XcmpMessageFormat::decode(&mut data_ref) + .expect("Simulator encodes with versioned xcm format; qed"); + + let mut remaining_fragments = &data_ref[..]; + while !remaining_fragments.is_empty() { + if let Ok(xcm) = + VersionedXcm::::decode(&mut remaining_fragments) + { + let _ = Self::handle_xcmp_message(sender, sent_at, xcm, max_weight); + } else { + debug_assert!(false, "Invalid incoming XCMP message data"); + } + } + } + max_weight + } + } + + impl DmpMessageHandler for Pallet { + fn handle_dmp_messages( + iter: impl Iterator)>, + limit: Weight, + ) -> Weight { + for (_i, (_sent_at, data)) in iter.enumerate() { + let id = sp_io::hashing::blake2_256(&data[..]); + let maybe_versioned = VersionedXcm::::decode(&mut &data[..]); + match maybe_versioned { + Err(_) => { + Self::deposit_event(Event::InvalidFormat(id)); + }, + Ok(versioned) => match Xcm::try_from(versioned) { + Err(()) => Self::deposit_event(Event::UnsupportedVersion(id)), + Ok(x) => { + let outcome = T::XcmExecutor::execute_xcm(Parent, x.clone(), id, limit); + >::append(x); + Self::deposit_event(Event::ExecutedDownward(id, outcome)); + }, + }, + } + } + limit + } + } +} + + + + + +impl mock_msg_queue::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type XcmExecutor = XcmExecutor; +} + +pub type LocalOriginToLocation = SignedToAccountId32; + + +pub struct TrustedLockerCase(PhantomData); +impl> ContainsPair + for TrustedLockerCase +{ + fn contains(origin: &MultiLocation, asset: &MultiAsset) -> bool { + let (o, a) = T::get(); + a.matches(asset) && &o == origin + } +} + +parameter_types! { + pub RelayTokenForRelay: (MultiLocation, MultiAssetFilter) = (Parent.into(), Wild(AllOf { id: Concrete(Parent.into()), fun: WildFungible })); +} + +pub type TrustedLockers = TrustedLockerCase; + +impl pallet_xcm::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type CurrencyMatcher = (); + type SendXcmOrigin = EnsureXcmOrigin; + type XcmRouter = XcmRouter; + type ExecuteXcmOrigin = EnsureXcmOrigin; + type XcmExecuteFilter = Everything; + type XcmExecutor = XcmExecutor; + type XcmTeleportFilter = Nothing; + type XcmReserveTransferFilter = Everything; + type Weigher = FixedWeightBounds; + type UniversalLocation = UniversalLocation; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; + type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type AdminOrigin = EnsureRoot; + type TrustedLockers = TrustedLockers; + type SovereignAccountOf = LocationToAccountId; + type MaxLockers = ConstU32<8>; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); + type WeightInfo = pallet_xcm::TestWeightInfo; +} + + + +impl parachain_info::Config for Runtime {} + +impl pallet_assets::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type RemoveItemsLimit = ConstU32<1000>; + type AssetId = CurrencyId; + type AssetIdParameter = CurrencyId; + type Currency = Balances; + type CreateOrigin = VaneForeignCreators< + VaneDerivedAssets, + ForeignCreatorsSovereignAccountOf, + AccountId, + >; + type ForceOrigin = EnsureRoot; + type AssetDeposit = ForeignAssetsAssetDeposit; + type AssetAccountDeposit = ForeignAssetsAssetAccountDeposit; + type MetadataDepositBase = ForeignAssetsMetadataDepositBase; + type MetadataDepositPerByte = MetadataDepositPerByte; + type ApprovalDeposit = ApprovalDeposit; + type StringLimit = StringLimit; + type Freezer = (); + type Extra = (); + type CallbackHandle = (); + type WeightInfo = weights::vane_asset_weights::WeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = xcm_config::XcmBenchmarkHelper; +} + + + +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Block = frame_system::mocking::MockBlock; + +// Construct Runtime +construct_runtime!( + pub enum Runtime + { + System: frame_system::{Pallet, Call, Storage, Config, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + MsgQueue: mock_msg_queue::{Pallet, Storage, Event}, + PolkadotXcm: pallet_xcm::{Pallet, Call, Event, Origin}, + Assets: pallet_assets = 10 + } +); \ No newline at end of file diff --git a/runtime/vane-parachain-runtime/src/xcm_sim_testing/mod.rs b/runtime/vane-parachain-runtime/src/xcm_sim_testing/mod.rs index 4f30695b3..d745bd9f3 100644 --- a/runtime/vane-parachain-runtime/src/xcm_sim_testing/mod.rs +++ b/runtime/vane-parachain-runtime/src/xcm_sim_testing/mod.rs @@ -2,12 +2,16 @@ mod parachain; mod relay_chain; +mod asset_hub; -use frame_support::sp_tracing; + +use xcm_emulator::sp_tracing; use sp_runtime::BuildStorage; -use xcm::prelude::*; +use staging_xcm::prelude::*; use xcm_simulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain, TestExt}; use std::sync::Once; +use frame_support::assert_ok; +use xcm_emulator::bx; pub const ALICE: sp_runtime::AccountId32 = sp_runtime::AccountId32::new([0u8; 32]); @@ -24,8 +28,8 @@ fn init_tracing() { INIT.call_once(|| { // Add test tracing (from sp_tracing::init_for_tests()) but filtering for xcm logs only let _ = tracing_subscriber::fmt() - //.with_max_level(tracing::Level::TRACE) - //.with_env_filter("xcm=trace,system::events=trace") // Comment out this line to see all traces + .with_max_level(tracing::Level::TRACE) + .with_env_filter("xcm=trace,system::events=trace") // Comment out this line to see all traces .with_test_writer() .init(); }); @@ -41,7 +45,38 @@ decl_test_parachain! { } } - +// AssetHub +decl_test_parachain! { + // An asset reserve parachain (Statemine) + pub struct AssetHub { + Runtime = asset_hub::Runtime, + XcmpMessageHandler = asset_hub::MsgQueue, + DmpMessageHandler = asset_hub::MsgQueue, + new_ext = { + // Initialise parachain-specific genesis state + use asset_hub::{MsgQueue, Runtime, System}; + + const INITIAL_BALANCE: u128 = ::AssetDeposit::get() * 2; + + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); + + pallet_balances::GenesisConfig:: { balances: vec![ + // (ALICE, 10000000000), + (child_account_id(1000), INITIAL_BALANCE) + ]} + .assimilate_storage(&mut t) + .unwrap(); + + let mut ext = sp_io::TestExternalities::new(t); + ext.execute_with(|| { + sp_tracing::try_init_simple(); + System::set_block_number(1); + MsgQueue::set_para_id(1000.into()); + }); + ext + }, + } +} decl_test_relay_chain! { pub struct Relay { @@ -59,6 +94,7 @@ decl_test_network! { pub struct MockNet { relay_chain = Relay, parachains = vec![ + (1000, AssetHub), (2000, Vane), ], } @@ -66,8 +102,8 @@ decl_test_network! { -use xcm_executor::traits::ConvertLocation; -use vane_primitive::CurrencyId; +use staging_xcm_executor::traits::ConvertLocation; +use vane_xcm_transfer_system::CurrencyId; pub fn parent_account_id() -> parachain::AccountId { let location = (Parent,); @@ -114,7 +150,7 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { balances: vec![ // (ALICE,INITIAL_BALANCE), - // (parent_account_id(), INITIAL_BALANCE) + (child_account_id(2000), INITIAL_BALANCE) ], }.assimilate_storage(&mut t).unwrap(); @@ -135,13 +171,13 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { pallet_assets::GenesisConfig:: { metadata: vec![(CurrencyId::DOT,asset1_name.clone(),asset1_name,10)], - assets: vec![(CurrencyId::DOT,child_account_id(1),true,1)], - accounts: vec![(CurrencyId::DOT,child_account_id(1),0)] + assets: vec![(CurrencyId::DOT,child_account_id(2000),true,1)], + accounts: vec![(CurrencyId::DOT,child_account_id(2000),0)] }.assimilate_storage(&mut t).unwrap(); - vane_xcm::GenesisConfig:: { - para_account: Some(child_account_id(1)), + vane_xcm_transfer_system::GenesisConfig:: { + para_account: Some(child_account_id(2000)), }.assimilate_storage(&mut t).unwrap(); let mut ext = sp_io::TestExternalities::new(t); @@ -154,6 +190,9 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { } +// pub fn asset_hub() -> sp_io::TestExternalities { + +// } pub fn relay_ext() -> sp_io::TestExternalities { @@ -163,8 +202,8 @@ pub fn relay_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { balances: vec![ - (ALICE, 100_000), - (child_account_id(1), 1000), + (ALICE, 1_000_000), + (child_account_id(2000), 10), ], } @@ -183,734 +222,270 @@ pub type RelayChainPalletXcm = pallet_xcm::Pallet; pub type VanePalletXcm = pallet_xcm::Pallet; pub type VanePalletAsset = pallet_assets::Pallet; pub type VanePalletBalances = pallet_balances::Pallet; -pub type VanePalletVaneXcm = vane_xcm::Pallet; +pub type VaneXcmTransferSystem = vane_xcm_transfer_system::Pallet; +pub type FrameSystem = frame_system::Pallet; + + +pub type HubPalletBalances = pallet_balances::Pallet; #[cfg(test)] mod tests { - use super::*; + +use vane_xcm_transfer_system::{Token, Confirm}; + +use super::*; - use frame_support::{assert_ok}; - use frame_support::macro_magic::__private::syn::token::In; - use frame_support::traits::fungibles::Inspect; - use sp_runtime::traits::Dispatchable; - use xcm::v3::OriginKind::{Native, SovereignAccount}; - use xcm_emulator::bx; - use xcm_simulator::TestExt; - use vane_payment::Confirm; - use vane_payment::helper::Token; // Helper function for forming buy execution message fn buy_execution(fees: impl Into) -> Instruction { BuyExecution { fees: fees.into(), weight_limit: Unlimited } } - #[test] - fn vane_remote_soln1_native_token_works(){ - - // Alice --> RC RC - // - (Reserve transfer) ^ - // ˯ - - // Reserve Chain Reserve Chain - // - (Deposit Equivalent) ^ - // ˯ - - // Vane --------> MultiSig(Alice,Bob) --------> VaneXcm - // - ^ - // - ----------> Confirmation - - // - - - // --->Ms(A,B)--->Bob ------------- - sp_tracing::init_for_tests(); + // This test check that the Xcm Reserve Transfered Dot token from Relay Chain being deposited to the multi_id form between Alice & Bob + // And all the necessary storage entities are taking place. + // This functionality of directly depositing into multi id can be found in the implemented AssetTransactor::transfer. + // AssetTransactor is responsible for handling token behaviour inside destination chain ( Note: check in staging_xcm_executor) + #[test] + fn transfer_dot_from_relay_to_vane_deposits_into_multi_id_works(){ + init_tracing(); MockNet::reset(); let amount = 100_000u128; let asset_amount = 1000u128; - //Relay Chain enviroment - // Reserve Transfer native vane token from Relay to Vane Parachain Relay::execute_with(||{ - assert_ok!(RelayChainPalletXcm::reserve_transfer_assets( - relay_chain::RuntimeOrigin::signed(ALICE), - Box::new(Parachain(1).into()), - Box::new(AccountId32 { network: None, id: ALICE.into() }.into()), - Box::new((Here, amount).into()), - 0, - )); - - // Transfer reserve manually - let inner_msg = Xcm::<()>(vec![ - - ]); - - let message = Xcm::<()>(vec![ - TransferReserveAsset { - assets: (Here,amount).into(), - dest: Parachain(1).into(), - xcm: inner_msg, - } - ]); - - // assert_ok!( - // RelayChainPalletXcm::send( - // relay_chain::RuntimeOrigin::signed(ALICE), - // bx!(Parachain(1).into()), - // bx!(VersionedXcm::V3(message)) - // ) - // ); - - // Relay chain events - relay_chain::System::events().iter().for_each(|e| println!("{:#?}",e)); - - // Assert if the tokens are in Vane sovereign Account in the relay chain - assert_eq!( - relay_chain::Balances::free_balance(&child_account_id(2000)), - amount + 1000 - ); - }); - // - // let asset1 = MultiLocation{ - // parents: 0, - // interior: X2(PalletInstance(10),GeneralIndex(1)).into() - // }; - // - // - println!("Vane Area \n"); - - Vane::execute_with(||{ - assert_eq!( - VanePalletBalances::free_balance(ALICE), - amount - ); - // - // // Test custom asset transfer - // assert_ok!( - // VanePalletAsset::transfer_keep_alive( - // parachain::RuntimeOrigin::signed(VANE), - // asset1, - // MRISHO.into(), - // 1000 - // ) - // ); - // - // assert_eq!( - // VanePalletAsset::balance(asset1,VANE), - // 100_000 - 1000 - // ); - // assert_eq!( - // VanePalletAsset::balance(asset1,MRISHO), - // 1000 - // ); - // - // // Test custom asset transfer with local xcm execute - // let asset_call = parachain::RuntimeCall::VaneAssets(pallet_assets::Call::transfer_keep_alive { - // id: asset1, - // target: BOB.into(), - // amount: asset_amount, - // }); - // - // let local_asset_message = Xcm::(vec![ - // Transact { - // origin_kind: SovereignAccount, - // require_weight_at_most: Weight::from_parts(1_000_000_000,1024*1024), - // call:asset_call.encode().into() - // } - // - // ]); - // - // assert_ok!( - // VanePalletXcm::execute( - // parachain::RuntimeOrigin::signed(VANE), - // Box::new(VersionedXcm::V3(local_asset_message)), - // Weight::from_parts(1_000_000_005, 1025 * 1024) - // ) - // ); - // - // assert_eq!( - // VanePalletAsset::balance(asset1,VANE), - // 100_000 - asset_amount*2 - // ); - // assert_eq!( - // VanePalletAsset::balance(asset1,BOB), - // 1000 - // ); - parachain::System::events().iter().for_each(|e| println!("{:#?}",e)); + + - }); - - } + let inner_asset_messages = Xcm::<()>( + vec![ - #[test] - fn vane_remote_soln1_custom_asset_derivitive_works(){ - MockNet::reset(); - - - // Test minting - Vane::execute_with(||{ - assert_ok!(VanePalletAsset::mint( - parachain::RuntimeOrigin::signed(child_account_id(1)), - CurrencyId::DOT, - MRISHO.into(), - 1000 - )); - - // Check if the asset is minted - assert_eq!( - VanePalletAsset::balance(CurrencyId::DOT,MRISHO), - 1000 - ); - // Check total issuance & supply - assert_eq!( - VanePalletAsset::total_supply(CurrencyId::DOT) + VanePalletAsset::total_issuance(CurrencyId::DOT), - 2000 + buy_execution((Here, amount)), + DepositAsset { assets: All.into(), beneficiary: AccountId32 { network: None, id: BOB.into() }.into() } + // TransferAsset { assets: (MultiAsset::from(10::1)), beneficiary: AccountId32 { network: None, id: BOB.into() }.into() } + ] ); - - // Test minting with xcm_execute - let asset_mint_call = parachain::RuntimeCall::VaneAssets(pallet_assets::Call::mint { - id: CurrencyId::DOT, - beneficiary: BOB.into(), - amount: 1000, - }); - - let local_asset_message = Xcm::(vec![ - Transact { - origin_kind: SovereignAccount, - require_weight_at_most: Weight::from_parts(1_000_000_000,1024*1024), - call:asset_mint_call.encode().into() + let asset_message = Xcm::<()>(vec![ + TransferReserveAsset { + assets: (Here, amount).into(), + dest: (Parachain(2000).into()), + xcm: inner_asset_messages } ]); - assert_ok!( - VanePalletXcm::execute( - parachain::RuntimeOrigin::signed(child_account_id(1)), - Box::new(VersionedXcm::V3(local_asset_message)), - Weight::from_parts(1_000_000_005, 1025 * 1024) - ) - ); - - // Check if the asset is minted - assert_eq!( - VanePalletAsset::balance(CurrencyId::DOT,BOB), - 1000 - ); - // Check total issuance & supply - assert_eq!( - VanePalletAsset::total_supply(CurrencyId::DOT) + VanePalletAsset::total_issuance(CurrencyId::DOT), - 4000 - ); - - }); + + // Normal ReserveAssetTransfer - } - - #[test] - fn vane_remote_soln1_custom_asset_derivitive_xcm_works(){ - MockNet::reset(); - - //init_tracing(); - // Alice in relay chain initiates reserve based transfer - Relay::execute_with(||{ - - - let asset_mint_call = parachain::RuntimeCall::VaneAssets(pallet_assets::Call::mint { - id: CurrencyId::DOT, - beneficiary: ALICE.into(), - amount: 1000, - }); - - let test_storing = parachain::RuntimeCall::VaneXcm(vane_xcm::Call::test_storing { - acc: ALICE, - num: 50, - }); - - let test_transfer = parachain::RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { - dest: BOB.into(), - value: 1000, - }); - - let inner_message = Xcm::<()>(vec![ - Transact { - origin_kind: SovereignAccount, // Try native & sovereign - require_weight_at_most: Weight::from_parts(1_000_000_000,1024*1024), - call: test_storing.encode().into(), - } - ]); - - let xcm_dummy = Xcm::<()>(vec![ - - ]); - - // let outer_message = Xcm::<()>(vec![ - // TransferReserveAsset { - // assets: (Here,1000).into(), - // dest: Parachain(1).into(), - // xcm: xcm_dummy, - // }] + // Alice -> vane sovereign ---> Polkadot Relay + // following instructions -> Buy execution on vane para and deposit equivalent asset to beneficiary account inside vane + // assert_ok!( + // relay_chain::XcmPallet::reserve_transfer_assets( + // relay_chain::RuntimeOrigin::signed(ALICE), + // bx!(Parachain(2000).into()), + // bx!(AccountId32 { network: None, id: ALICE.into() }.into()), + // bx!((Here, amount).into()), + // 0 + // ) // ); - // let outer_message_2 = Xcm::(vec![ - // WithdrawAsset((Here,1000).into()), - // DepositAsset { - // assets: AllCounted(1).into(), - // beneficiary: (Parachain(1).into()), - // }, - // // InitiateReserveWithdraw { - // // assets: AllCounted(1).into(), - // // reserve: (Parachain(1).into()), - // // xcm: xcm_dummy, - // // } - // ]); - - assert_ok!( - RelayChainPalletXcm::send( - relay_chain::RuntimeOrigin::signed(ALICE), - Box::new(Parachain(1).into()), - Box::new(VersionedXcm::V3(inner_message.into())) - ) + // Transfer from Alice to Bob + let vDotAsset = ( + X2( + PalletInstance(10), + GeneralIndex(1) + ), + 10000 ); - // Call is filtered // assert_ok!( - // RelayChainPalletXcm::execute( + // relay_chain::XcmPallet::send( // relay_chain::RuntimeOrigin::signed(ALICE), - // Box::new(VersionedXcm::V3(outer_message_2)), - // Weight::from_parts(1_000_000_005,1025*1024), + // bx!(Parachain(1000).into()), + // bx!(VersionedXcm::V3(asset_message)) // ) // ); - relay_chain::System::events().iter().for_each(|e| println!("{:#?}",e)); - - // assert_eq!( - // relay_chain::Balances::free_balance(ALICE), - // INITIAL_BALANCE -1000 - // ); - - // assert_eq!( - // relay_chain::Balances::free_balance(&child_account_id(1)), - // 1000 + // Tsting batch xcms + // assert_ok!( + // relay_chain::XcmPallet::teleport_assets( + // relay_chain::RuntimeOrigin::signed(ALICE), + // bx!(Parachain(1000).into()), + // bx!(AccountId32 { network: None, id: ALICE.into() }.into()), + // bx!((Here, amount).into()), + // 0 + // ) // ); - }); - println!("Vane Area \n"); - // Relay chain sends Reserve Asset Deposited Instruction to Vana - // But we add Transact instruction to manually mint the tokens - Vane::execute_with(||{ + relay_chain::System::events().iter().for_each(|e| println!("{:#?}",e)); - parachain::System::events().iter().for_each(|e| println!("{:#?}",e)); + // Check the vane soverign account + // assert_eq!( + // RelayChainPalletBalances::free_balance(child_account_id(2000)), + // amount + // ) - assert_eq!( - VanePalletVaneXcm::get_test_stored(ALICE), - 50 - ); }); - } - - #[test] - fn vane_remote_soln1_custom_asset_derivitive_manual_xcm_works(){ - MockNet::reset(); - - - Relay::execute_with(||{ - - // 1. Alice -> Parachain(1) - assert_ok!( - RelayChainPalletBalances::transfer_keep_alive( - relay_chain::RuntimeOrigin::signed(ALICE), - child_account_id(1).into(), - 1000 - ) - ); - - // 2. Test remote signed transact instruction - let test_call = parachain::RuntimeCall::VaneXcm(vane_xcm::Call::test_storing { - acc: ALICE, - num: 1000, - }); - - - let asset_mint_call = parachain::RuntimeCall::VaneAssets(pallet_assets::Call::mint { - id: CurrencyId::DOT, - beneficiary: ALICE.into(), - amount: 1000, - }); - - let message = Xcm::<()>(vec![ - Transact { - origin_kind: SovereignAccount, - require_weight_at_most: Weight::from_parts(1_000_000_000,1024*1024), - call: test_call.encode().into(), - } - ]); - - // Will Try more on this - - // let transfer_msg = Xcm::<()>(vec![ - // Transact { - // origin_kind: SovereignAccount, - // require_weight_at_most: Weight::from_parts(1_000_000_000,1024*1024), - // call: test_call.encode().into(), - // }, - // WithdrawAsset((Here,1000).into()), - // InitiateReserveWithdraw { - // assets: All.into(), - // reserve: X1(Parachain(1)).into(), - // xcm: message, - // }, - // - // ]); - - assert_ok!( - RelayChainPalletXcm::send( - relay_chain::RuntimeOrigin::signed(ALICE), - Box::new(X1(Parachain(1)).into()), - Box::new(VersionedXcm::V3(message)) - ) - ); - + AssetHub::execute_with(||{ assert_eq!( - relay_chain::Balances::free_balance(&child_account_id(1)), - 1000 + HubPalletBalances::free_balance(ALICE), + amount ); - - - // - // let message_2 = Xcm::<()>(vec![ - // TransferAsset { - // assets: (Here, 1000).into(), - // beneficiary: X1(Parachain(1)).into(), - // } - // ]); - - // ------ ** This call is filtered and its annoying ** ---------------- - - // assert_ok!( - // RelayChainPalletXcm::execute( - // relay_chain::RuntimeOrigin::signed(ALICE), - // Box::new(VersionedXcm::V3(message_2)), - // Weight::from_parts(1_000_000_005,1025*1024) - // ) - // ); - - - relay_chain::System::events().iter().for_each(|e| println!("{:#?}",e)); - + asset_hub::System::events().iter().for_each(|e| println!("{:#?}",e)); }); - println!("Vane Area \n"); - + // Emit Vane parachain events Vane::execute_with(||{ - assert_eq!( - VanePalletVaneXcm::get_test_stored(ALICE), - 1000 - ); - - - // Mint the equivalent tokens - let asset_mint_call = parachain::RuntimeCall::VaneAssets(pallet_assets::Call::mint { - id: CurrencyId::DOT, - beneficiary: ALICE.into(), - amount: 1000, - }); - - let local_asset_message = Xcm::(vec![ - Transact { - origin_kind: SovereignAccount, - require_weight_at_most: Weight::from_parts(1_000_000_000,1024*1024), - call:asset_mint_call.encode().into() - } - - ]); - - assert_ok!( - VanePalletXcm::execute( - parachain::RuntimeOrigin::signed(child_account_id(1)), - Box::new(VersionedXcm::V3(local_asset_message)), - Weight::from_parts(1_000_000_005, 1025 * 1024) - ) - ); - - assert_eq!( - VanePalletAsset::balance(CurrencyId::DOT,ALICE), - 1000 - ); + //assert_ok!(VaneXcmTransferSystem::tester(parachain::RuntimeOrigin::signed(ALICE))); parachain::System::events().iter().for_each(|e| println!("{:#?}",e)); + // Check the multi_id created account in pallet asset + // assert_eq!( + // VanePalletAsset::total_supply(CurrencyId::DOT), + // 100000 + // ); - // UMP - // from Vane's Alice to RC's Alice - - //1. Burn local assets, 2. XCM message sending from SeoverignAcc to Alice - - let asset_burn_call = parachain::RuntimeCall::VaneAssets(pallet_assets::Call::burn { - id: CurrencyId::DOT, - amount: 1000, - who: ALICE.into(), - }); - - assert_ok!( - asset_burn_call.dispatch(parachain::RuntimeOrigin::signed(child_account_id(1))) - ); - - assert_eq!( - VanePalletAsset::balance(CurrencyId::DOT,ALICE), - 0 - ); - - // After burning - let return_message = Xcm::<()>(vec![ - TransferAsset { - assets: (Here,1000).into(), - beneficiary: AccountId32 { network: None, id: BOB.into() }.into(), - } - ]); - - assert_ok!( - VanePalletXcm::send_xcm( - Here, - Parent, - return_message - ) - ); + // assert_eq!( + // VanePalletAsset::balance(CurrencyId::DOT, ALICE), + // amount + // ); + // let txn_receipt = VaneXcmTransferSystem::get_payer_txn_receipt(ALICE,BOB); + // println!("{:?}",txn_receipt) }); - Relay::execute_with(||{ - //Check - assert_eq!( - relay_chain::Balances::free_balance(BOB), - 1000 + 100_000 - ); - - }) - } + + // This test checks transaction lifecycle from Relay Chain to Vane and back to Relay Chain with confirmations in place and fees token being deposited #[test] - fn vane_remote_soln1_custom_asset_derivitive_manual_xcm_pallet_works(){ + fn full_transaction_execution_and_confirmation_works(){ init_tracing(); MockNet::reset(); - // test AliasOrigin Instruction - Relay::execute_with(||{ - println!("Parent Account : {:?}",parent_account_id()); - - println!("Parent Account ALICE : {:?}",parent_account_account_id(ALICE)); - - println!("Parachain Account : {:?}", child_account_id(1)); - - // 1. Alice -> Parachain(1) - assert_ok!( - RelayChainPalletBalances::transfer_keep_alive( - relay_chain::RuntimeOrigin::signed(ALICE), - child_account_id(1).into(), - 1000 - ) - ); - - - - // 2. Test remote signed transact instruction - let test_transfer_call = parachain::RuntimeCall::VaneXcm(vane_xcm::Call::vane_transfer { - payee: BOB.into(), - amount: 1000, - currency: Token::DOT, - asset_id: CurrencyId::DOT, - }); + let amount = 100_000u128; + let asset_amount = 1000u128; - let message = Xcm::<()>(vec![ - DescendOrigin(AccountId32 {network: None, id: ALICE.into() }.into()), // look into remote derived accounts - Transact { - origin_kind: SovereignAccount, - require_weight_at_most: Weight::from_parts(1_000_000_000,1024*1024), - call: test_transfer_call.encode().into(), - } - ]); + let alice_relay_origin = relay_chain::RuntimeOrigin::signed(ALICE); + let alice_vane_origin = parachain::RuntimeOrigin::signed(ALICE); + let bob_vane_origin = parachain::RuntimeOrigin::signed(BOB); + Relay::execute_with(||{ + // Reserve transfer assert_ok!( - RelayChainPalletXcm::send( - relay_chain::RuntimeOrigin::signed(ALICE), - Box::new(X1(Parachain(1)).into()), - Box::new(VersionedXcm::V3(message)) + relay_chain::XcmPallet::reserve_transfer_assets( + alice_relay_origin, + bx!(Parachain(2000).into()), + bx!(AccountId32 { network: None, id: ALICE.into() }.into()), + bx!((Here, amount).into()), + 0 ) ); - - relay_chain::System::events().iter().for_each(|e| println!("{:#?}",e)); - }); - println!("Vane Area"); Vane::execute_with(||{ - - - parachain::System::events().iter().for_each(|e| println!("{:#?}",e)); - - }); - } - - #[test] - fn vane_remote_soln1_custom_asset_derivitive_manual_xcm_confirm_pallet_works(){ - sp_tracing::init_for_tests(); - - - MockNet::reset(); - - // test AliasOrigin Instruction - Relay::execute_with(||{ - - // 1. Alice -> Parachain(1) - assert_ok!( - RelayChainPalletBalances::transfer_keep_alive( - relay_chain::RuntimeOrigin::signed(ALICE), - child_account_id(1).into(), - 1000 - ) - ); - - // Check Sovereign Account balance assert_eq!( - relay_chain::Balances::free_balance(child_account_id(1)), - 1000 + VanePalletAsset::balance(CurrencyId::DOT, ALICE), + amount ); + // check the fees transfered into alice account + println!("Fees in Alice: {}", VanePalletBalances::free_balance(ALICE)); - - // 2. Test remote signed transact instruction - let test_transfer_call = parachain::RuntimeCall::VaneXcm(vane_xcm::Call::vane_transfer { - payee: BOB.into(), - amount: 1000, - currency: Token::DOT, - asset_id: CurrencyId::DOT, - }); - - println!(" Encoded Transfer Call : {:?}",test_transfer_call.encode()); - - let message = Xcm::<()>(vec![ - DescendOrigin(AccountId32 {network: None, id: ALICE.into() }.into()), // look into remote derived accounts - Transact { - origin_kind: SovereignAccount, - require_weight_at_most: Weight::from_parts(1_000_000_000,1024*1024), - call: test_transfer_call.encode().into(), - } - ]); - + // Tranfer to BOB assert_ok!( - RelayChainPalletXcm::send( - relay_chain::RuntimeOrigin::signed(ALICE), - Box::new(X1(Parachain(1)).into()), - Box::new(VersionedXcm::V3(message.clone())) + VaneXcmTransferSystem::vane_transfer( + alice_vane_origin.clone(), + BOB, + amount, + Token::DOT, + CurrencyId::DOT ) ); + // check the fees transfered into bob account + println!("Fees in Bob: {}", VanePalletBalances::free_balance(BOB)); + println!("Fees in Alice: {}", VanePalletBalances::free_balance(ALICE)); - }); - - println!("Vane Area"); - - Vane::execute_with(||{ - // Receiving the msg and executing - }); - - Vane::execute_with(||{ - - - // confirm the transaction - // Payee confirming on vane chain - // get the reference_no - //let receipt = vane_payment::PayerTxnReceipt::::get(ALICE,BOB); - - let tt = vane_payment::PayeeTxnReceipt::::get(BOB); - - //println!(" Receipts: {:#?}",tt[0].reference_no); + // Confirmation phase + let txn_receipt = VaneXcmTransferSystem::get_payer_txn_receipt(ALICE, BOB).unwrap(); + println!("{:?}",txn_receipt); + let multi_id = txn_receipt.multi_id; + let ref_no = txn_receipt.reference_no; + let amount = txn_receipt.amount; + //1. Bob confirmation assert_ok!( - VanePalletVaneXcm::vane_confirm( - parachain::RuntimeOrigin::signed(BOB), - Confirm::Payee, - tt[0].reference_no.to_vec(), - tt[0].amount, + parachain::VaneXcmTransfer::vane_confirm( + bob_vane_origin, + Confirm::Payee, + ref_no.clone().to_vec(), + amount, CurrencyId::DOT ) ); - }); - - println!("Relay Area"); - - Relay::execute_with(||{ - // Confirm for Payer - - - let hardcoded_ref = vec![ 179, 58, 27, 164, 106, 103]; - // 2. Test remote signed transact instruction - let test_confirm_call = parachain::RuntimeCall::VaneXcm(vane_xcm::Call::vane_confirm { - who: Confirm::Payer, - amount: 1000, // hardcoded but it should be taken from receipt - asset_id: CurrencyId::DOT, - reference_no: hardcoded_ref, - }); - - let message = Xcm::<()>(vec![ - DescendOrigin(AccountId32 {network: None, id: ALICE.into() }.into()), // look into remote derived accounts - Transact { - origin_kind: SovereignAccount, - require_weight_at_most: Weight::from_parts(1_000_000_000,1024*1024), - call: test_confirm_call.encode().into(), - } - ]); - + // Check confirmation storage + let confirmed_signers = VaneXcmTransferSystem::get_confirmed_signers(ref_no.to_vec()); + println!("Confirmed: {:?}", confirmed_signers); + // 2. Alice confirmation assert_ok!( - RelayChainPalletXcm::send( - relay_chain::RuntimeOrigin::signed(ALICE), - Box::new(X1(Parachain(1)).into()), - Box::new(VersionedXcm::V3(message.clone())) + parachain::VaneXcmTransfer::vane_confirm( + alice_vane_origin.clone(), + Confirm::Payer, + ref_no.to_vec(), + amount, + CurrencyId::DOT ) ); - relay_chain::System::events().iter().for_each(|e| println!("{:#?}",e)); - - }); - - println!("Vane Area"); - - Vane::execute_with(||{ - // Execution of Payer confirmation - parachain::System::events().iter().for_each(|e| println!("{:#?}",e)); - }); - // Check for BOB balance in Relay Chain Relay::execute_with(||{ + // Check Alice amount assert_eq!( - relay_chain::Balances::free_balance(BOB), - 999 + relay_chain::Balances::free_balance(ALICE), + 900000 ); + + // check Bob account assert_eq!( - relay_chain::Balances::free_balance(child_account_id(1)), - 1 + relay_chain::Balances::free_balance(BOB), + 90000 ); - }) + // Check Vane sovererign account + assert_eq!( + relay_chain::Balances::free_balance(child_account_id(2000)), + 10_010 + ) + + }); } + + // This test checks reverting txn, sends xcm message to refund the tokens being held in vane soverign account. #[test] - fn vane_remote_soln2_works(){ + fn reverting_works(){ } -} +} \ No newline at end of file diff --git a/runtime/vane-parachain-runtime/src/xcm_sim_testing/parachain.rs b/runtime/vane-parachain-runtime/src/xcm_sim_testing/parachain.rs index 05804e9d1..110f8438a 100644 --- a/runtime/vane-parachain-runtime/src/xcm_sim_testing/parachain.rs +++ b/runtime/vane-parachain-runtime/src/xcm_sim_testing/parachain.rs @@ -1,113 +1,46 @@ -use assets_common::matching::FromSiblingParachain; -use codec::{Decode, Encode}; -use frame_support::{construct_runtime, match_types, parameter_types, traits::{EnsureOrigin, EnsureOriginWithArg, Everything, EverythingBut, Nothing, ContainsPair}, weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}}; +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Polkadot. -use frame_system::EnsureRoot; -use sp_core::{ConstU32, H256, Get}; -use sp_runtime::{ - testing::Header, - traits::{Hash, IdentityLookup}, - AccountId32, -}; -use sp_std::prelude::*; -use vane_xcm; +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. -use vane_xcm::{orml_traits,orml_xcm_support}; +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. -use pallet_xcm::XcmPassthrough; -use polkadot_core_primitives::BlockNumber as RelayBlockNumber; -use polkadot_parachain::primitives::{ - DmpMessageHandler, Id as ParaId, Sibling, XcmpMessageFormat, XcmpMessageHandler, -}; -use xcm::{latest::prelude::*, VersionedXcm}; -use xcm_builder::{Account32Hash, AccountId32Aliases, AliasForeignAccountId32, AllowUnpaidExecutionFrom, ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, IsConcrete, NativeAsset, NoChecking, NonFungiblesAdapter, ParentIsPreset, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation}; -use xcm_executor::{ - traits::JustTry, - Config, XcmExecutor, -}; -use xcm_simulator::PhantomData; -use assets_common::foreign_creators::ForeignCreators; - -use vane_primitive::{CurrencyId, MultiCurrencyAsset, MultiCurrencyConverter, VaneDerivedAssets, VaneForeignCreators}; - - -// `EnsureOriginWithArg` impl for `CreateOrigin` which allows only XCM origins -// which are locations containing the class location. -use xcm_executor::traits::ConvertLocation; -use vane_xcm::orml_xcm_support::IsNativeConcrete; -use crate::{ApprovalDeposit, ForeignAssetsAssetAccountDeposit, ForeignAssetsAssetDeposit, ForeignAssetsMetadataDepositBase, ForeignCreatorsSovereignAccountOf, MetadataDepositPerByte, StringLimit, weights, xcm_config}; -use crate::xcm_sim_testing::Vane; - -// pub struct ForeignCreators; -// impl EnsureOriginWithArg for ForeignCreators { -// type Success = AccountId; -// -// fn try_origin( -// o: RuntimeOrigin, -// a: &MultiLocation, -// ) -> Result { -// let origin_location = pallet_xcm::EnsureXcm::::try_origin(o.clone())?; -// if !a.starts_with(&origin_location) { -// return Err(o) -// } -// SovereignAccountOf::convert_location(&origin_location).ok_or(o) -// } -// -// #[cfg(feature = "runtime-benchmarks")] -// fn try_successful_origin(a: &MultiLocation) -> Result { -// Ok(pallet_xcm::Origin::Xcm(a.clone()).into()) -// } -// } +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . -parameter_types! { - pub const ReservedXcmpWeight: Weight = Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4), 0); - pub const ReservedDmpWeight: Weight = Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4), 0); -} - -parameter_types! { - pub const KsmLocation: MultiLocation = MultiLocation::parent(); - pub const RelayNetwork: NetworkId = NetworkId::Kusama; - pub UniversalLocation: InteriorMultiLocation = Parachain(MsgQueue::parachain_id().into()).into(); -} +//! Relay chain runtime mock. -pub type LocationToAccountId = ( - ParentIsPreset, - // SiblingParachainConvertsVia, - AccountId32Aliases, - Account32Hash<(), AccountId>, -); - -pub type XcmOriginToCallOrigin = ( - SovereignSignedViaLocation, - SignedAccountId32AsNative, - //XcmPassthrough, -); - -parameter_types! { - pub const UnitWeightCost: Weight = Weight::from_parts(1, 1); - pub KsmPerSecondPerByte: (AssetId, u128, u128) = (Concrete(Parent.into()), 1, 1); - pub const MaxInstructions: u32 = 100; - pub const MaxAssetsIntoHolding: u32 = 64; - pub ForeignPrefix: MultiLocation = (Parent,).into(); -} - - -pub type LocalAssetTransactor = vane_primitive::VaneMultiCurrencyAdapter< - MultiCurrencyAsset, - (), // handler for unknown assets - IsNativeConcrete>, - AccountId, - LocationToAccountId, - CurrencyId, - MultiCurrencyConverter, - (), ->; +use frame_support::{ + construct_runtime, parameter_types, + traits::{AsEnsureOriginWithArg, Everything, Nothing, ProcessMessage, ProcessMessageError}, + weights::{Weight, WeightMeter}, +}; -pub type SovereignAccountOf = ( - SiblingParachainConvertsVia, - AccountId32Aliases, - ParentIsPreset, -); +use frame_system::EnsureRoot; +use sp_core::{ConstU32, H256}; +use sp_runtime::{traits::IdentityLookup, AccountId32}; + +use polkadot_parachain_primitives::primitives::Id as ParaId; +use polkadot_runtime_parachains::{ + configuration, + inclusion::{AggregateMessageOrigin, UmpQueueId}, + origin, shared, +}; +use staging_xcm::latest::prelude::*; +use staging_xcm_builder::{ + Account32Hash, AccountId32Aliases, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex, + ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, + ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, + FixedWeightBounds, IsConcrete, NoChecking, NonFungiblesAdapter, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, +}; +use staging_xcm_executor::{traits::JustTry, Config, XcmExecutor}; pub type AccountId = AccountId32; pub type Balance = u128; @@ -117,25 +50,25 @@ parameter_types! { } impl frame_system::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type BaseCallFilter = Everything; - type BlockWeights = (); - type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Nonce = u64; type Hash = H256; - type Hashing = sp_runtime::traits::BlakeTwo256; + type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; type Block = Block; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; - type DbWeight = (); + type BlockWeights = (); + type BlockLength = (); type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); + type DbWeight = (); + type BaseCallFilter = Everything; type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); @@ -149,329 +82,177 @@ parameter_types! { } impl pallet_balances::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); + type MaxLocks = MaxLocks; type Balance = Balance; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; + type WeightInfo = (); + type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); - type MaxLocks = MaxLocks; - type MaxReserves = MaxReserves; type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } -pub type XcmRouter = super::ParachainXcmRouter; -pub type Barrier = AllowUnpaidExecutionFrom; +impl shared::Config for Runtime {} -match_types! { - pub type SiblingPrefix: impl Contains = { - MultiLocation { parents: 1, interior: X1(Parachain(_)) } - }; - pub type ChildPrefix: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(_)) } - }; - pub type ParentPrefix: impl Contains = { - MultiLocation { parents: 1, interior: Here } - }; +impl configuration::Config for Runtime { + type WeightInfo = configuration::TestWeightInfo; } +parameter_types! { + pub const TokenLocation: MultiLocation = Here.into_location(); + pub RelayNetwork: NetworkId = ByGenesis([0; 32]); + pub const AnyNetwork: Option = None; + pub UniversalLocation: InteriorMultiLocation = Here; + pub UnitWeightCost: u64 = 1_000; +} + +pub type LocationToAccountId = ( + ChildParachainConvertsVia, + AccountId32Aliases, + Account32Hash<(), AccountId>, +); + +pub type LocalAssetTransactor = ( + XcmCurrencyAdapter, LocationToAccountId, AccountId, ()> +); + +type LocalOriginConverter = ( + SovereignSignedViaLocation, + ChildParachainAsNative, + SignedAccountId32AsNative, + ChildSystemParachainAsSuperuser, +); +parameter_types! { + pub const BaseXcmWeight: Weight = Weight::from_parts(1_000, 1_000); + pub TokensPerSecondPerByte: (AssetId, u128, u128) = + (Concrete(TokenLocation::get()), 1_000_000_000_000, 1024 * 1024); + pub const MaxInstructions: u32 = 100; + pub const MaxAssetsIntoHolding: u32 = 64; +} +pub type XcmRouter = super::RelayChainXcmRouter; +pub type Barrier = AllowUnpaidExecutionFrom; pub struct XcmConfig; impl Config for XcmConfig { type RuntimeCall = RuntimeCall; type XcmSender = XcmRouter; type AssetTransactor = LocalAssetTransactor; - type OriginConverter = XcmOriginToCallOrigin; - type IsReserve = vane_primitive::VaneDerivedAssets; + type OriginConverter = LocalOriginConverter; + type IsReserve = (); type IsTeleporter = (); - type Aliasers = AliasForeignAccountId32; // test for both Parent and AssetHub Prefix type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds; - type Trader = FixedRateOfFungible; + type Weigher = FixedWeightBounds; + type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); - type AssetLocker = PolkadotXcm; + type AssetLocker = XcmPallet; type AssetExchanger = (); type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); - type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type FeeManager = (); + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; -} - - -#[frame_support::pallet] -pub mod mock_msg_queue { - use super::*; - use frame_support::pallet_prelude::*; - - #[pallet::config] - pub trait Config: frame_system::Config { - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - type XcmExecutor: ExecuteXcm; - } - - #[pallet::call] - impl Pallet {} - - #[pallet::pallet] - #[pallet::without_storage_info] - pub struct Pallet(_); - - #[pallet::storage] - #[pallet::getter(fn parachain_id)] - pub(super) type ParachainId = StorageValue<_, ParaId, ValueQuery>; - - #[pallet::storage] - #[pallet::getter(fn received_dmp)] - /// A queue of received DMP messages - pub(super) type ReceivedDmp = StorageValue<_, Vec>, ValueQuery>; - - impl Get for Pallet { - fn get() -> ParaId { - Self::parachain_id() - } - } - - pub type MessageId = [u8; 32]; - - #[pallet::event] - #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { - // XCMP - /// Some XCM was executed OK. - Success(Option), - /// Some XCM failed. - Fail(Option, XcmError), - /// Bad XCM version used. - BadVersion(Option), - /// Bad XCM format used. - BadFormat(Option), - - // DMP - /// Downward message is invalid XCM. - InvalidFormat(MessageId), - /// Downward message is unsupported version of XCM. - UnsupportedVersion(MessageId), - /// Downward message executed with the given outcome. - ExecutedDownward(MessageId, Outcome), - } - - impl Pallet { - pub fn set_para_id(para_id: ParaId) { - ParachainId::::put(para_id); - } - - fn handle_xcmp_message( - sender: ParaId, - _sent_at: RelayBlockNumber, - xcm: VersionedXcm, - max_weight: Weight, - ) -> Result { - let hash = Encode::using_encoded(&xcm, T::Hashing::hash); - let message_hash = Encode::using_encoded(&xcm, sp_io::hashing::blake2_256); - let (result, event) = match Xcm::::try_from(xcm) { - Ok(xcm) => { - let location = (Parent, Parachain(sender.into())); - match T::XcmExecutor::execute_xcm(location, xcm, message_hash, max_weight) { - Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)), - Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))), - // As far as the caller is concerned, this was dispatched without error, so - // we just report the weight used. - Outcome::Incomplete(w, e) => (Ok(w), Event::Fail(Some(hash), e)), - } - }, - Err(()) => (Err(XcmError::UnhandledXcmVersion), Event::BadVersion(Some(hash))), - }; - Self::deposit_event(event); - result - } - } - - impl XcmpMessageHandler for Pallet { - fn handle_xcmp_messages<'a, I: Iterator>( - iter: I, - max_weight: Weight, - ) -> Weight { - for (sender, sent_at, data) in iter { - let mut data_ref = data; - let _ = XcmpMessageFormat::decode(&mut data_ref) - .expect("Simulator encodes with versioned xcm format; qed"); - - let mut remaining_fragments = &data_ref[..]; - while !remaining_fragments.is_empty() { - if let Ok(xcm) = - VersionedXcm::::decode(&mut remaining_fragments) - { - let _ = Self::handle_xcmp_message(sender, sent_at, xcm, max_weight); - } else { - debug_assert!(false, "Invalid incoming XCMP message data"); - } - } - } - max_weight - } - } - - impl DmpMessageHandler for Pallet { - fn handle_dmp_messages( - iter: impl Iterator)>, - limit: Weight, - ) -> Weight { - for (_i, (_sent_at, data)) in iter.enumerate() { - let id = sp_io::hashing::blake2_256(&data[..]); - let maybe_versioned = VersionedXcm::::decode(&mut &data[..]); - match maybe_versioned { - Err(_) => { - Self::deposit_event(Event::InvalidFormat(id)); - }, - Ok(versioned) => match Xcm::try_from(versioned) { - Err(()) => Self::deposit_event(Event::UnsupportedVersion(id)), - Ok(x) => { - let outcome = T::XcmExecutor::execute_xcm(Parent, x.clone(), id, limit); - >::append(x); - Self::deposit_event(Event::ExecutedDownward(id, outcome)); - }, - }, - } - } - limit - } - } -} - - - - - -impl mock_msg_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; + type Aliasers = Nothing; } pub type LocalOriginToLocation = SignedToAccountId32; - -pub struct TrustedLockerCase(PhantomData); -impl> ContainsPair - for TrustedLockerCase -{ - fn contains(origin: &MultiLocation, asset: &MultiAsset) -> bool { - let (o, a) = T::get(); - a.matches(asset) && &o == origin - } -} - -parameter_types! { - pub RelayTokenForRelay: (MultiLocation, MultiAssetFilter) = (Parent.into(), Wild(AllOf { id: Concrete(Parent.into()), fun: WildFungible })); -} - -pub type TrustedLockers = TrustedLockerCase; - impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type CurrencyMatcher = (); - type SendXcmOrigin = EnsureXcmOrigin; + type SendXcmOrigin = staging_xcm_builder::EnsureXcmOrigin; type XcmRouter = XcmRouter; - type ExecuteXcmOrigin = EnsureXcmOrigin; - type XcmExecuteFilter = Everything; + // Anyone can execute XCM messages locally... + type ExecuteXcmOrigin = staging_xcm_builder::EnsureXcmOrigin; + type XcmExecuteFilter = Nothing; type XcmExecutor = XcmExecutor; - type XcmTeleportFilter = Nothing; + type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; - type AdminOrigin = EnsureRoot; - type TrustedLockers = TrustedLockers; + type Currency = Balances; + type CurrencyMatcher = IsConcrete; + type TrustedLockers = (); type SovereignAccountOf = LocationToAccountId; type MaxLockers = ConstU32<8>; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); type WeightInfo = pallet_xcm::TestWeightInfo; + type AdminOrigin = EnsureRoot; } - -impl vane_order::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; +parameter_types! { + pub const FirstMessageFactorPercent: u64 = 100; } -impl vane_payment::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; -} +impl origin::Config for Runtime {} -impl vane_register::Config for Runtime { - type Currency = Balances; - type RuntimeEvent = RuntimeEvent; +type Block = frame_system::mocking::MockBlock; + +parameter_types! { + /// Amount of weight that can be spent per block to service messages. + pub MessageQueueServiceWeight: Weight = Weight::from_parts(1_000_000_000, 1_000_000); + pub const MessageQueueHeapSize: u32 = 65_536; + pub const MessageQueueMaxStale: u32 = 16; } -impl vane_xcm::Config for Runtime { - type RuntimeEvent = RuntimeEvent; +/// Message processor to handle any messages that were enqueued into the `MessageQueue` pallet. +pub struct MessageProcessor; +impl ProcessMessage for MessageProcessor { + type Origin = AggregateMessageOrigin; + + fn process_message( + message: &[u8], + origin: Self::Origin, + meter: &mut WeightMeter, + id: &mut [u8; 32], + ) -> Result { + let para = match origin { + AggregateMessageOrigin::Ump(UmpQueueId::Para(para)) => para, + }; + staging_xcm_builder::ProcessXcmMessage::< + Junction, + staging_xcm_executor::XcmExecutor, + RuntimeCall, + >::process_message(message, Junction::Parachain(para.into()), meter, id) + } } -impl parachain_info::Config for Runtime {} -impl pallet_assets::Config for Runtime { +impl pallet_message_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Balance = Balance; - type RemoveItemsLimit = ConstU32<1000>; - type AssetId = CurrencyId; - type AssetIdParameter = CurrencyId; - type Currency = Balances; - type CreateOrigin = VaneForeignCreators< - VaneDerivedAssets, - ForeignCreatorsSovereignAccountOf, - AccountId, - >; - type ForceOrigin = EnsureRoot; - type AssetDeposit = ForeignAssetsAssetDeposit; - type AssetAccountDeposit = ForeignAssetsAssetAccountDeposit; - type MetadataDepositBase = ForeignAssetsMetadataDepositBase; - type MetadataDepositPerByte = MetadataDepositPerByte; - type ApprovalDeposit = ApprovalDeposit; - type StringLimit = StringLimit; - type Freezer = (); - type Extra = (); - type CallbackHandle = (); - type WeightInfo = weights::vane_asset_weights::WeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = xcm_config::XcmBenchmarkHelper; + type Size = u32; + type HeapSize = MessageQueueHeapSize; + type MaxStale = MessageQueueMaxStale; + type ServiceWeight = MessageQueueServiceWeight; + type MessageProcessor = MessageProcessor; + type QueueChangeHandler = (); + type QueuePausedQuery = (); + type WeightInfo = (); } - -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; - -// Construct Runtime construct_runtime!( pub enum Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - MsgQueue: mock_msg_queue::{Pallet, Storage, Event}, - PolkadotXcm: pallet_xcm::{Pallet, Call, Event, Origin}, - VaneRegister: vane_register, - VanePayment: vane_payment, - VaneOrder: vane_order, - VaneXcm: vane_xcm, - VaneAssets: pallet_assets = 10 + ParasOrigin: origin::{Pallet, Origin}, + XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event, Origin}, + MessageQueue: pallet_message_queue::{Pallet, Event}, } -); - - +); \ No newline at end of file diff --git a/runtime/vane-parachain-runtime/src/xcm_sim_testing/relay_chain.rs b/runtime/vane-parachain-runtime/src/xcm_sim_testing/relay_chain.rs index c7416071b..110f8438a 100644 --- a/runtime/vane-parachain-runtime/src/xcm_sim_testing/relay_chain.rs +++ b/runtime/vane-parachain-runtime/src/xcm_sim_testing/relay_chain.rs @@ -26,21 +26,21 @@ use frame_system::EnsureRoot; use sp_core::{ConstU32, H256}; use sp_runtime::{traits::IdentityLookup, AccountId32}; -use polkadot_parachain::primitives::Id as ParaId; +use polkadot_parachain_primitives::primitives::Id as ParaId; use polkadot_runtime_parachains::{ configuration, inclusion::{AggregateMessageOrigin, UmpQueueId}, origin, shared, }; -use xcm::latest::prelude::*; -use xcm_builder::{ +use staging_xcm::latest::prelude::*; +use staging_xcm_builder::{ Account32Hash, AccountId32Aliases, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds, IsConcrete, NoChecking, NonFungiblesAdapter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, }; -use xcm_executor::{traits::JustTry, Config, XcmExecutor}; +use staging_xcm_executor::{traits::JustTry, Config, XcmExecutor}; pub type AccountId = AccountId32; pub type Balance = u128; @@ -97,6 +97,7 @@ impl pallet_balances::Config for Runtime { type MaxFreezes = ConstU32<0>; } + impl shared::Config for Runtime {} impl configuration::Config for Runtime { @@ -119,7 +120,6 @@ pub type LocationToAccountId = ( pub type LocalAssetTransactor = ( XcmCurrencyAdapter, LocationToAccountId, AccountId, ()> - ); type LocalOriginConverter = ( @@ -170,17 +170,12 @@ impl Config for XcmConfig { pub type LocalOriginToLocation = SignedToAccountId32; -#[cfg(feature = "runtime-benchmarks")] -parameter_types! { - pub ReachableDest: Option = Some(Parachain(1).into()); -} - impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; + type SendXcmOrigin = staging_xcm_builder::EnsureXcmOrigin; type XcmRouter = XcmRouter; // Anyone can execute XCM messages locally... - type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; + type ExecuteXcmOrigin = staging_xcm_builder::EnsureXcmOrigin; type XcmExecuteFilter = Nothing; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; @@ -199,8 +194,6 @@ impl pallet_xcm::Config for Runtime { type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); type WeightInfo = pallet_xcm::TestWeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type ReachableDest = ReachableDest; type AdminOrigin = EnsureRoot; } @@ -233,9 +226,9 @@ impl ProcessMessage for MessageProcessor { let para = match origin { AggregateMessageOrigin::Ump(UmpQueueId::Para(para)) => para, }; - xcm_builder::ProcessXcmMessage::< + staging_xcm_builder::ProcessXcmMessage::< Junction, - xcm_executor::XcmExecutor, + staging_xcm_executor::XcmExecutor, RuntimeCall, >::process_message(message, Junction::Parachain(para.into()), meter, id) } @@ -262,4 +255,4 @@ construct_runtime!( XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event, Origin}, MessageQueue: pallet_message_queue::{Pallet, Event}, } -); +); \ No newline at end of file