From b02ecf318654fb81927bd0ef9e839c545338ed35 Mon Sep 17 00:00:00 2001 From: Rust Ninja <102041955+RustNinja@users.noreply.github.com> Date: Fri, 31 Mar 2023 19:38:51 +0100 Subject: [PATCH] use xcm emulator instead of xcm simulator from polkadot repo. (#194) --- Cargo.lock | 27 ++ runtime/integration-tests/pendulum/Cargo.toml | 1 + runtime/integration-tests/pendulum/src/lib.rs | 305 ++--------------- .../pendulum/src/parachain.rs | 316 ------------------ .../pendulum/src/relay_chain.rs | 174 ---------- 5 files changed, 54 insertions(+), 769 deletions(-) delete mode 100644 runtime/integration-tests/pendulum/src/parachain.rs delete mode 100644 runtime/integration-tests/pendulum/src/relay_chain.rs diff --git a/Cargo.lock b/Cargo.lock index 1e2511c4b..c91898241 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14360,6 +14360,32 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "xcm-emulator" +version = "0.1.0" +source = "git+https://github.com/shaunxw/xcm-simulator?rev=6847a58888e483f0ed2e0b72f90e00767ea0ecac#6847a58888e483f0ed2e0b72f90e00767ea0ecac" +dependencies = [ + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-test-relay-sproof-builder", + "frame-support", + "frame-system", + "parachain-info", + "parity-scale-codec", + "paste", + "polkadot-primitives", + "polkadot-runtime-parachains", + "quote", + "sp-arithmetic", + "sp-io", + "sp-std", + "xcm", + "xcm-executor", +] + [[package]] name = "xcm-executor" version = "0.9.37" @@ -14430,6 +14456,7 @@ dependencies = [ "sp-std", "xcm", "xcm-builder", + "xcm-emulator", "xcm-executor", "xcm-simulator", ] diff --git a/runtime/integration-tests/pendulum/Cargo.toml b/runtime/integration-tests/pendulum/Cargo.toml index af93a70f1..1ccd89c11 100644 --- a/runtime/integration-tests/pendulum/Cargo.toml +++ b/runtime/integration-tests/pendulum/Cargo.toml @@ -30,5 +30,6 @@ polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } +xcm-emulator = { git = "https://github.com/shaunxw/xcm-simulator", rev = "6847a58888e483f0ed2e0b72f90e00767ea0ecac" } pendulum-runtime = { path = "../../pendulum"} diff --git a/runtime/integration-tests/pendulum/src/lib.rs b/runtime/integration-tests/pendulum/src/lib.rs index 5948aca10..c96a50e2b 100644 --- a/runtime/integration-tests/pendulum/src/lib.rs +++ b/runtime/integration-tests/pendulum/src/lib.rs @@ -1,6 +1,3 @@ -// mod parachain; -// mod relay_chain; - use frame_support::{ assert_ok, traits::{fungibles::Inspect, GenesisBuild}, @@ -11,13 +8,19 @@ use polkadot_parachain::primitives::Id as ParaId; use polkadot_primitives::v2::{MAX_CODE_SIZE, MAX_POV_SIZE}; use polkadot_runtime_parachains::configuration::HostConfiguration; use sp_runtime::traits::AccountIdConversion; -use xcm::v1::{Junction, Junction::Parachain}; -use xcm_simulator::{ - decl_test_network, decl_test_parachain, decl_test_relay_chain, Junctions, Junctions::Here, - MultiLocation, NetworkId, TestExt, Weight, WeightLimit, +use xcm::{ + latest::{ + AssetId, Fungibility, Junction, Junction::*, Junctions::*, MultiAsset, MultiLocation, + NetworkId, WeightLimit, + }, + v2::{Instruction::WithdrawAsset, Xcm}, + VersionedMultiLocation, +}; + +use xcm_emulator::{ + decl_test_network, decl_test_parachain, decl_test_relay_chain, Junctions, TestExt, Weight, }; -// pub const ALICE: sp_runtime::AccountId32 = sp_runtime::AccountId32::new([0u8; 32]); pub const ALICE: [u8; 32] = [4u8; 32]; pub const BOB: [u8; 32] = [5u8; 32]; pub const INITIAL_BALANCE: u128 = 1_000_000_000; @@ -33,6 +36,7 @@ decl_test_relay_chain! { decl_test_parachain! { pub struct PendulumParachain { Runtime = pendulum_runtime::Runtime, + RuntimeOrigin = pendulum_runtime::RuntimeOrigin, XcmpMessageHandler = pendulum_runtime::XcmpQueue, DmpMessageHandler = pendulum_runtime::DmpQueue, new_ext = para_ext_pendulum(2094), @@ -56,10 +60,10 @@ pub fn relay_ext() -> sp_io::TestExternalities { use polkadot_runtime::{Runtime, System}; let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); pallet_balances::GenesisConfig:: { - balances: vec![(AccountId::from(ALICE), dot(100000)), - (ParaId::from(2094).into_account_truncating(), 10 * dot(100000)), + balances: vec![ + (AccountId::from(ALICE), dot(100000)), + (ParaId::from(2094).into_account_truncating(), 10 * dot(100000)), ], - } .assimilate_storage(&mut t) .unwrap(); @@ -174,19 +178,9 @@ pub fn one(decimals: u32) -> Balance { 10u128.saturating_pow(decimals.into()) } -// pub type RelayChainPalletXcm = pallet_xcm::Pallet; -// pub type ParachainPalletXcm = pallet_xcm::Pallet; - -#[cfg(test)] -mod tests { - #[test] - fn dmp() {} -} - #[test] fn transfer_ksm_from_relay_chain_to_pendulum() { - MockNet::reset(); let transfer_amount: Balance = dot(2); println!("transfer KSM amount : {} ", transfer_amount); @@ -203,7 +197,6 @@ fn transfer_ksm_from_relay_chain_to_pendulum() { }); Relay::execute_with(|| { - assert_ok!(polkadot_runtime::XcmPallet::reserve_transfer_assets( polkadot_runtime::RuntimeOrigin::signed(ALICE.into()), Box::new(Parachain(2094).into().into()), @@ -211,67 +204,39 @@ fn transfer_ksm_from_relay_chain_to_pendulum() { Box::new((Here, transfer_amount).into()), 0 )); - - use polkadot_runtime::{RuntimeEvent, System}; - for i in System::events().iter(){ - println!("polkadot_runtime 1 {:?}", i); - } - }); - - const DOT_FEE: Balance = 3200000000; - PendulumParachain::execute_with(|| { - - use pendulum_runtime::{RuntimeEvent, System}; - for i in System::events().iter(){ - println!(" Pendulum_runtime 4 {:?}", i); - } - assert_eq!( - pendulum_runtime::Tokens::balance( - pendulum_runtime::PendulumCurrencyId::XCM(0), - &ALICE.into() - ), - // orml_tokens_before + transfer_amount - DOT_FEE - 0 - ); }); Relay::execute_with(|| { use polkadot_runtime::{RuntimeEvent, System}; - for i in System::events().iter(){ + for i in System::events().iter() { println!("polkadot_runtime 2 {:?}", i); } }); PendulumParachain::execute_with(|| { use pendulum_runtime::{RuntimeEvent, System}; - for i in System::events().iter(){ + for i in System::events().iter() { println!(" Pendulum_runtime 3 {:?}", i); } }); - - - - - return; + const DOT_FEE: Balance = 3200000000; PendulumParachain::execute_with(|| { - - use pendulum_runtime::{RuntimeEvent, System}; - for i in System::events().iter(){ - println!(" Pendulum_runtime 5 {:?}", i); - } + assert_eq!( + pendulum_runtime::Tokens::balance( + pendulum_runtime::PendulumCurrencyId::XCM(0), + &ALICE.into() + ), + orml_tokens_before + transfer_amount - DOT_FEE + ); }); - use pendulum_runtime::{RuntimeEvent, System}; - for i in System::events().iter(){ - println!(" Pendulum_runtime 6 {:?}", i); - } - Relay::execute_with(|| { let before_bob_free_balance = polkadot_runtime::Balances::free_balance(&BOB.into()); println!("BOB KSM BEFORE balance on relay chain {} ", before_bob_free_balance); assert_eq!(before_bob_free_balance, 0); }); + PendulumParachain::execute_with(|| { assert_ok!(pendulum_runtime::XTokens::transfer( pendulum_runtime::RuntimeOrigin::signed(ALICE.into()), @@ -295,221 +260,3 @@ fn transfer_ksm_from_relay_chain_to_pendulum() { assert_eq!(after_bob_free_balance, 999988476752); }); } - -// #[cfg(test)] -// mod tests { -// use super::*; - -// use codec::Encode; -// use frame_support::assert_ok; -// use xcm::latest::prelude::*; -// use xcm_simulator::TestExt; - -// // Helper function for forming buy execution message -// fn buy_execution(fees: impl Into) -> Instruction { -// BuyExecution { fees: fees.into(), weight_limit: Unlimited } -// } - -// #[test] -// fn dmp() { -// MockNet::reset(); - -// let remark = parachain::RuntimeCall::System( -// frame_system::Call::::remark_with_event { remark: vec![1, 2, 3] }, -// ); -// Relay::execute_with(|| { -// assert_ok!(RelayChainPalletXcm::send_xcm( -// Here, -// Parachain(1), -// Xcm(vec![Transact { -// origin_type: OriginKind::SovereignAccount, -// require_weight_at_most: INITIAL_BALANCE as u64, -// call: remark.encode().into(), -// }]), -// )); -// }); - -// ParaA::execute_with(|| { -// use parachain::{RuntimeEvent, System}; -// assert!(System::events().iter().any(|r| matches!( -// r.event, -// RuntimeEvent::System(frame_system::Event::Remarked { .. }) -// ))); -// }); -// } - -// #[test] -// fn ump() { -// MockNet::reset(); - -// let remark = relay_chain::RuntimeCall::System( -// frame_system::Call::::remark_with_event { remark: vec![1, 2, 3] }, -// ); -// ParaA::execute_with(|| { -// assert_ok!(ParachainPalletXcm::send_xcm( -// Here, -// Parent, -// Xcm(vec![Transact { -// origin_type: OriginKind::SovereignAccount, -// require_weight_at_most: INITIAL_BALANCE as u64, -// call: remark.encode().into(), -// }]), -// )); -// }); - -// Relay::execute_with(|| { -// use relay_chain::{RuntimeEvent, System}; -// assert!(System::events().iter().any(|r| matches!( -// r.event, -// RuntimeEvent::System(frame_system::Event::Remarked { .. }) -// ))); -// }); -// } - -// #[test] -// fn xcmp() { -// MockNet::reset(); - -// let remark = parachain::RuntimeCall::System( -// frame_system::Call::::remark_with_event { remark: vec![1, 2, 3] }, -// ); -// ParaA::execute_with(|| { -// assert_ok!(ParachainPalletXcm::send_xcm( -// Here, -// (Parent, Parachain(2)), -// Xcm(vec![Transact { -// origin_type: OriginKind::SovereignAccount, -// require_weight_at_most: INITIAL_BALANCE as u64, -// call: remark.encode().into(), -// }]), -// )); -// }); - -// ParaB::execute_with(|| { -// use parachain::{RuntimeEvent, System}; -// assert!(System::events().iter().any(|r| matches!( -// r.event, -// RuntimeEvent::System(frame_system::Event::Remarked { .. }) -// ))); -// }); -// } - -// #[test] -// fn reserve_transfer() { -// MockNet::reset(); - -// let withdraw_amount = 123; - -// Relay::execute_with(|| { -// assert_ok!(RelayChainPalletXcm::reserve_transfer_assets( -// relay_chain::RuntimeOrigin::signed(ALICE), -// Box::new(X1(Parachain(1)).into().into()), -// Box::new(X1(AccountId32 { network: Any, id: ALICE.into() }).into().into()), -// Box::new((Here, withdraw_amount).into()), -// 0, -// )); -// assert_eq!( -// parachain::Balances::free_balance(¶_account_id(1)), -// INITIAL_BALANCE + withdraw_amount -// ); -// }); - -// ParaA::execute_with(|| { -// // free execution, full amount received -// assert_eq!( -// pallet_balances::Pallet::::free_balance(&ALICE), -// INITIAL_BALANCE + withdraw_amount -// ); -// }); -// } - -// /// Scenario: -// /// A parachain transfers funds on the relay chain to another parachain account. -// /// -// /// Asserts that the parachain accounts are updated as expected. -// #[test] -// fn withdraw_and_deposit() { -// MockNet::reset(); - -// let send_amount = 10; - -// ParaA::execute_with(|| { -// let message = Xcm(vec![ -// WithdrawAsset((Here, send_amount).into()), -// buy_execution((Here, send_amount)), -// DepositAsset { -// assets: All.into(), -// max_assets: 1, -// beneficiary: Parachain(2).into(), -// }, -// ]); -// // Send withdraw and deposit -// assert_ok!(ParachainPalletXcm::send_xcm(Here, Parent, message.clone())); -// }); - -// Relay::execute_with(|| { -// assert_eq!( -// relay_chain::Balances::free_balance(para_account_id(1)), -// INITIAL_BALANCE - send_amount -// ); -// assert_eq!(relay_chain::Balances::free_balance(para_account_id(2)), send_amount); -// }); -// } - -// /// Scenario: -// /// A parachain wants to be notified that a transfer worked correctly. -// /// It sends a `QueryHolding` after the deposit to get notified on success. -// /// -// /// Asserts that the balances are updated correctly and the expected XCM is sent. -// #[test] -// fn query_holding() { -// MockNet::reset(); - -// let send_amount = 10; -// let query_id_set = 2094; - -// // Send a message which fully succeeds on the relay chain -// ParaA::execute_with(|| { -// let message = Xcm(vec![ -// WithdrawAsset((Here, send_amount).into()), -// buy_execution((Here, send_amount)), -// DepositAsset { -// assets: All.into(), -// max_assets: 1, -// beneficiary: Parachain(2).into(), -// }, -// QueryHolding { -// query_id: query_id_set, -// dest: Parachain(1).into(), -// assets: All.into(), -// max_response_weight: 1_000_000_000, -// }, -// ]); -// // Send withdraw and deposit with query holding -// assert_ok!(ParachainPalletXcm::send_xcm(Here, Parent, message.clone(),)); -// }); - -// // Check that transfer was executed -// Relay::execute_with(|| { -// // Withdraw executed -// assert_eq!( -// relay_chain::Balances::free_balance(para_account_id(1)), -// INITIAL_BALANCE - send_amount -// ); -// // Deposit executed -// assert_eq!(relay_chain::Balances::free_balance(para_account_id(2)), send_amount); -// }); - -// // Check that QueryResponse message was received -// ParaA::execute_with(|| { -// assert_eq!( -// parachain::MsgQueue::received_dmp(), -// vec![Xcm(vec![QueryResponse { -// query_id: query_id_set, -// response: Response::Assets(MultiAssets::new()), -// max_weight: 1_000_000_000, -// }])], -// ); -// }); -// } -// } diff --git a/runtime/integration-tests/pendulum/src/parachain.rs b/runtime/integration-tests/pendulum/src/parachain.rs deleted file mode 100644 index ac791102f..000000000 --- a/runtime/integration-tests/pendulum/src/parachain.rs +++ /dev/null @@ -1,316 +0,0 @@ -// use codec::{Decode, Encode}; -// use frame_support::{ -// construct_runtime, parameter_types, -// traits::{Everything, Nothing}, -// weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, -// }; -// use sp_core::H256; -// use sp_runtime::{ -// testing::Header, -// traits::{Hash, IdentityLookup}, -// AccountId32, -// }; -// use sp_std::prelude::*; - -// 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::{ -// AccountId32Aliases, AllowUnpaidExecutionFrom, CurrencyAdapter as XcmCurrencyAdapter, -// EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, IsConcrete, LocationInverter, -// NativeAsset, ParentIsPreset, SiblingParachainConvertsVia, SignedAccountId32AsNative, -// SignedToAccountId32, SovereignSignedViaLocation, -// }; -// use xcm_executor::{Config, XcmExecutor}; - -// pub type AccountId = AccountId32; -// pub type Balance = u128; - -// parameter_types! { -// pub const BlockHashCount: u64 = 250; -// } - -// impl frame_system::Config for Runtime { -// type RuntimeOrigin = RuntimeOrigin; -// type RuntimeCall = RuntimeCall; -// type Index = u64; -// type BlockNumber = u64; -// type Hash = H256; -// type Hashing = ::sp_runtime::traits::BlakeTwo256; -// type AccountId = AccountId; -// type Lookup = IdentityLookup; -// type Header = Header; -// type RuntimeEvent = RuntimeEvent; -// type BlockHashCount = BlockHashCount; -// 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 = (); -// type MaxConsumers = frame_support::traits::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 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]; -// } - -// parameter_types! { -// pub const ReservedXcmpWeight: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4)); -// pub const ReservedDmpWeight: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4)); -// } - -// parameter_types! { -// pub const KsmLocation: MultiLocation = MultiLocation::parent(); -// pub const RelayNetwork: NetworkId = NetworkId::Kusama; -// pub Ancestry: MultiLocation = Parachain(MsgQueue::parachain_id().into()).into(); -// } - -// pub type LocationToAccountId = ( -// ParentIsPreset, -// SiblingParachainConvertsVia, -// AccountId32Aliases, -// ); - -// pub type XcmOriginToCallOrigin = ( -// SovereignSignedViaLocation, -// SignedAccountId32AsNative, -// XcmPassthrough, -// ); - -// parameter_types! { -// pub const UnitWeightCost: u64 = 1; -// pub KsmPerSecond: (AssetId, u128) = (Concrete(Parent.into()), 1); -// pub const MaxInstructions: u32 = 100; -// } - -// pub type LocalAssetTransactor = -// XcmCurrencyAdapter, LocationToAccountId, AccountId, ()>; - -// pub type XcmRouter = super::ParachainXcmRouter; -// 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 = NativeAsset; -// type IsTeleporter = (); -// type LocationInverter = LocationInverter; -// type Barrier = Barrier; -// type Weigher = FixedWeightBounds; -// type Trader = FixedRateOfFungible; -// type ResponseHandler = (); -// type AssetTrap = (); -// type AssetClaims = (); -// type SubscriptionService = (); -// } - -// #[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::generate_store(pub(super) trait Store)] -// #[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 (result, event) = match Xcm::::try_from(xcm) { -// Ok(xcm) => { -// let location = (1, Parachain(sender.into())); -// match T::XcmExecutor::execute_xcm(location, xcm, max_weight.ref_time()) { -// Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)), -// Outcome::Complete(w) => -// (Ok(Weight::from_ref_time(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(Weight::from_ref_time(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_msg = VersionedXcm::::decode(&mut &data[..]) -// .map(Xcm::::try_from); -// match maybe_msg { -// Err(_) => { -// Self::deposit_event(Event::InvalidFormat(id)); -// }, -// Ok(Err(())) => { -// Self::deposit_event(Event::UnsupportedVersion(id)); -// }, -// Ok(Ok(x)) => { -// let outcome = -// T::XcmExecutor::execute_xcm(Parent, x.clone(), limit.ref_time()); -// >::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; - -// impl pallet_xcm::Config for Runtime { -// type RuntimeEvent = RuntimeEvent; -// 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 LocationInverter = LocationInverter; -// type RuntimeOrigin = RuntimeOrigin; -// type RuntimeCall = RuntimeCall; -// const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; -// type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; -// } - -// type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -// type Block = frame_system::mocking::MockBlock; - -// construct_runtime!( -// pub enum Runtime where -// Block = Block, -// NodeBlock = Block, -// UncheckedExtrinsic = UncheckedExtrinsic, -// { -// 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}, -// } -// ); diff --git a/runtime/integration-tests/pendulum/src/relay_chain.rs b/runtime/integration-tests/pendulum/src/relay_chain.rs deleted file mode 100644 index 11dd8b74a..000000000 --- a/runtime/integration-tests/pendulum/src/relay_chain.rs +++ /dev/null @@ -1,174 +0,0 @@ -// use frame_support::{ -// construct_runtime, parameter_types, -// traits::{Everything, Nothing}, -// }; -// use sp_core::H256; -// use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; - -// use polkadot_parachain::primitives::Id as ParaId; -// use polkadot_runtime_parachains::{configuration, origin, shared, ump}; -// use xcm::latest::prelude::*; -// use xcm_builder::{ -// AccountId32Aliases, AllowUnpaidExecutionFrom, ChildParachainAsNative, -// ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, -// CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds, IsConcrete, -// LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, -// }; -// use xcm_executor::{Config, XcmExecutor}; - -// pub type AccountId = AccountId32; -// pub type Balance = u128; - -// parameter_types! { -// pub const BlockHashCount: u64 = 250; -// } - -// impl frame_system::Config for Runtime { -// type RuntimeOrigin = RuntimeOrigin; -// type RuntimeCall = RuntimeCall; -// type Index = u64; -// type BlockNumber = u64; -// type Hash = H256; -// type Hashing = ::sp_runtime::traits::BlakeTwo256; -// type AccountId = AccountId; -// type Lookup = IdentityLookup; -// type Header = Header; -// type RuntimeEvent = RuntimeEvent; -// type BlockHashCount = BlockHashCount; -// 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 = (); -// type MaxConsumers = frame_support::traits::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 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]; -// } - -// impl shared::Config for Runtime {} - -// impl configuration::Config for Runtime { -// type WeightInfo = configuration::TestWeightInfo; -// } - -// parameter_types! { -// pub const KsmLocation: MultiLocation = Here.into(); -// pub const KusamaNetwork: NetworkId = NetworkId::Kusama; -// pub const AnyNetwork: NetworkId = NetworkId::Any; -// pub Ancestry: MultiLocation = Here.into(); -// pub UnitWeightCost: u64 = 1_000; -// } - -// pub type SovereignAccountOf = -// (ChildParachainConvertsVia, AccountId32Aliases); - -// pub type LocalAssetTransactor = -// XcmCurrencyAdapter, SovereignAccountOf, AccountId, ()>; - -// type LocalOriginConverter = ( -// SovereignSignedViaLocation, -// ChildParachainAsNative, -// SignedAccountId32AsNative, -// ChildSystemParachainAsSuperuser, -// ); - -// parameter_types! { -// pub const BaseXcmWeight: u64 = 1_000; -// pub KsmPerSecond: (AssetId, u128) = (Concrete(KsmLocation::get()), 1); -// pub const MaxInstructions: u32 = 100; -// } - -// 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 = LocalOriginConverter; -// type IsReserve = (); -// type IsTeleporter = (); -// type LocationInverter = LocationInverter; -// type Barrier = Barrier; -// type Weigher = FixedWeightBounds; -// type Trader = FixedRateOfFungible; -// type ResponseHandler = (); -// type AssetTrap = (); -// type AssetClaims = (); -// type SubscriptionService = (); -// } - -// pub type LocalOriginToLocation = SignedToAccountId32; - -// impl pallet_xcm::Config for Runtime { -// type RuntimeEvent = RuntimeEvent; -// type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; -// type XcmRouter = XcmRouter; -// // Anyone can execute XCM messages locally... -// type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; -// type XcmExecuteFilter = Nothing; -// type XcmExecutor = XcmExecutor; -// type XcmTeleportFilter = Everything; -// type XcmReserveTransferFilter = Everything; -// type Weigher = FixedWeightBounds; -// type LocationInverter = LocationInverter; -// type RuntimeOrigin = RuntimeOrigin; -// type RuntimeCall = RuntimeCall; -// const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; -// type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; -// } - -// parameter_types! { -// pub const FirstMessageFactorPercent: u64 = 100; -// } - -// impl ump::Config for Runtime { -// type RuntimeEvent = RuntimeEvent; -// type UmpSink = ump::XcmSink, Runtime>; -// type FirstMessageFactorPercent = FirstMessageFactorPercent; -// type ExecuteOverweightOrigin = frame_system::EnsureRoot; -// type WeightInfo = ump::TestWeightInfo; -// } - -// impl origin::Config for Runtime {} - -// type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -// type Block = frame_system::mocking::MockBlock; - -// construct_runtime!( -// pub enum Runtime where -// Block = Block, -// NodeBlock = Block, -// UncheckedExtrinsic = UncheckedExtrinsic, -// { -// System: frame_system::{Pallet, Call, Storage, Config, Event}, -// Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, -// ParasOrigin: origin::{Pallet, Origin}, -// ParasUmp: ump::{Pallet, Call, Storage, Event}, -// XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event, Origin}, -// } -// );