From caa703c8c280265d9510b3798fa84822bb6455e2 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Wed, 16 Aug 2023 23:09:41 +0200 Subject: [PATCH] Nits --- polkadot/runtime/common/src/xcm_sender.rs | 6 +++--- .../pallet-xcm-benchmarks/src/fungible/benchmarking.rs | 10 +++++++++- polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs | 10 ++++++---- polkadot/xcm/pallet-xcm/src/tests.rs | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/polkadot/runtime/common/src/xcm_sender.rs b/polkadot/runtime/common/src/xcm_sender.rs index 4e560516f8ff..1dfa83f57deb 100644 --- a/polkadot/runtime/common/src/xcm_sender.rs +++ b/polkadot/runtime/common/src/xcm_sender.rs @@ -150,7 +150,7 @@ impl< origin_ref: &MultiLocation, _dest: &MultiLocation, fee_reason: xcm_executor::traits::FeeReason, - ) -> Option { + ) -> (Option, Option) { use xcm_executor::{ traits::{FeeManager, TransactAsset}, FeesMode, @@ -180,10 +180,10 @@ impl< // allow more initialization for target parachain ToParachainHelper::ensure(Parachain::get()); - // expected worst case + // expected worst case - direct withdraw fees_mode = Some(FeesMode { jit_withdraw: true }); } - fees_mode + (fees_mode, None) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs index e5e77ea88216..89c6e5e4325c 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs @@ -88,7 +88,11 @@ benchmarks_instance_pallet! { let dest_account = T::AccountIdConverter::convert_location(&dest_location).unwrap(); use crate::EnsureDelivery; - let expected_fees_mode = T::DeliveryHelper::ensure_successful_delivery(&sender_location, &dest_location, FeeReason::TransferReserveAsset); + let (expected_fees_mode, expected_assets_in_holding) = T::DeliveryHelper::ensure_successful_delivery( + &sender_location, + &dest_location, + FeeReason::TransferReserveAsset + ); let sender_account_balance_before = T::TransactAsset::balance(&sender_account); let asset = T::get_multi_asset(); @@ -101,6 +105,10 @@ benchmarks_instance_pallet! { if let Some(expected_fees_mode) = expected_fees_mode { executor.set_fees_mode(expected_fees_mode); } + if let Some(expected_assets_in_holding) = expected_assets_in_holding { + executor.set_holding(expected_assets_in_holding.into()); + } + let instruction = Instruction::TransferReserveAsset { assets, dest: dest_location, diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs index 60786a3ede13..3bf4aea1b25e 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -119,12 +119,14 @@ pub fn account_and_location(index: u32) -> (T::AccountId, MultiLocati /// layers. pub trait EnsureDelivery { /// Prepare all requirements for successful `XcmSender: SendXcm` passing (accounts, balances, - /// channels ...). Returns possible `FeesMode` which is expected to be set to executor. + /// channels ...). Returns: + /// - possible `FeesMode` which is expected to be set to executor + /// - possible `MultiAssets` which are expected to be subsume to the Holding Register fn ensure_successful_delivery( origin_ref: &MultiLocation, dest: &MultiLocation, fee_reason: FeeReason, - ) -> Option; + ) -> (Option, Option); } /// `()` implementation does nothing which means no special requirements for environment. @@ -133,8 +135,8 @@ impl EnsureDelivery for () { _origin_ref: &MultiLocation, _dest: &MultiLocation, _fee_reason: FeeReason, - ) -> Option { + ) -> (Option, Option) { // doing nothing - None + (None, None) } } diff --git a/polkadot/xcm/pallet-xcm/src/tests.rs b/polkadot/xcm/pallet-xcm/src/tests.rs index 0f067110bed1..88454c1758a6 100644 --- a/polkadot/xcm/pallet-xcm/src/tests.rs +++ b/polkadot/xcm/pallet-xcm/src/tests.rs @@ -546,7 +546,7 @@ fn reserve_transfer_assets_with_paid_router_works() { assert_ok!(XcmPallet::reserve_transfer_assets( RuntimeOrigin::signed(user_account.clone()), Box::new(Parachain(paid_para_id).into()), - Box::new(dest.clone().into()), + Box::new(dest.into()), Box::new((Here, SEND_AMOUNT).into()), 0, ));