Skip to content

Commit

Permalink
Nits
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur authored and KiChjang committed Aug 29, 2023
1 parent 2f64173 commit caa703c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
6 changes: 3 additions & 3 deletions polkadot/runtime/common/src/xcm_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl<
origin_ref: &MultiLocation,
_dest: &MultiLocation,
fee_reason: xcm_executor::traits::FeeReason,
) -> Option<xcm_executor::FeesMode> {
) -> (Option<xcm_executor::FeesMode>, Option<MultiAssets>) {
use xcm_executor::{
traits::{FeeManager, TransactAsset},
FeesMode,
Expand Down Expand Up @@ -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)
}
}

Expand Down
10 changes: 9 additions & 1 deletion polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ pub fn account_and_location<T: Config>(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<FeesMode>;
) -> (Option<FeesMode>, Option<MultiAssets>);
}

/// `()` implementation does nothing which means no special requirements for environment.
Expand All @@ -133,8 +135,8 @@ impl EnsureDelivery for () {
_origin_ref: &MultiLocation,
_dest: &MultiLocation,
_fee_reason: FeeReason,
) -> Option<FeesMode> {
) -> (Option<FeesMode>, Option<MultiAssets>) {
// doing nothing
None
(None, None)
}
}
2 changes: 1 addition & 1 deletion polkadot/xcm/pallet-xcm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
));
Expand Down

0 comments on commit caa703c

Please sign in to comment.