Skip to content

Commit

Permalink
Avoid using xcm::v4 and use latest instead for AssetHub benchmarks (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur authored May 24, 2024
1 parent f469fbf commit e192b76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
#[cfg(feature = "runtime-benchmarks")]
use xcm::latest::prelude::{
Asset, Fungible, Here, InteriorLocation, Junction, Junction::*, Location, NetworkId,
NonFungible, Parent, ParentThen, Response, XCM_VERSION,
Asset, Assets as XcmAssets, Fungible, Here, InteriorLocation, Junction, Junction::*, Location,
NetworkId, NonFungible, Parent, ParentThen, Response, XCM_VERSION,
};
use xcm::{
latest::prelude::{AssetId, BodyId},
Expand Down Expand Up @@ -1535,7 +1535,7 @@ impl_runtime_apis! {
}

fn set_up_complex_asset_transfer(
) -> Option<(xcm::v4::Assets, u32, Location, Box<dyn FnOnce()>)> {
) -> Option<(XcmAssets, u32, Location, Box<dyn FnOnce()>)> {
// Transfer to Relay some local AH asset (local-reserve-transfer) while paying
// fees using teleported native token.
// (We don't care that Relay doesn't accept incoming unknown AH local asset)
Expand Down Expand Up @@ -1566,7 +1566,7 @@ impl_runtime_apis! {
);
let transfer_asset: Asset = (asset_location, asset_amount).into();

let assets: xcm::v4::Assets = vec![fee_asset.clone(), transfer_asset].into();
let assets: XcmAssets = vec![fee_asset.clone(), transfer_asset].into();
let fee_index = if assets.get(0).unwrap().eq(&fee_asset) { 0 } else { 1 };

// verify transferred successfully
Expand Down Expand Up @@ -1634,7 +1634,7 @@ impl_runtime_apis! {
fn valid_destination() -> Result<Location, BenchmarkError> {
Ok(TokenLocation::get())
}
fn worst_case_holding(depositable_count: u32) -> xcm::v4::Assets {
fn worst_case_holding(depositable_count: u32) -> XcmAssets {
// A mix of fungible, non-fungible, and concrete assets.
let holding_non_fungibles = MaxAssetsIntoHolding::get() / 2 - depositable_count;
let holding_fungibles = holding_non_fungibles.saturating_sub(2); // -2 for two `iter::once` bellow
Expand Down Expand Up @@ -1695,7 +1695,7 @@ impl_runtime_apis! {
(0u64, Response::Version(Default::default()))
}

fn worst_case_asset_exchange() -> Result<(xcm::v4::Assets, xcm::v4::Assets), BenchmarkError> {
fn worst_case_asset_exchange() -> Result<(XcmAssets, XcmAssets), BenchmarkError> {
Err(BenchmarkError::Skip)
}

Expand All @@ -1714,9 +1714,9 @@ impl_runtime_apis! {
Ok(TokenLocation::get())
}

fn claimable_asset() -> Result<(Location, Location, xcm::v4::Assets), BenchmarkError> {
fn claimable_asset() -> Result<(Location, Location, XcmAssets), BenchmarkError> {
let origin = TokenLocation::get();
let assets: xcm::v4::Assets = (TokenLocation::get(), 1_000 * UNITS).into();
let assets: XcmAssets = (TokenLocation::get(), 1_000 * UNITS).into();
let ticket = Location { parents: 0, interior: Here };
Ok((origin, ticket, assets))
}
Expand Down
16 changes: 8 additions & 8 deletions cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ use xcm::latest::prelude::AssetId;

#[cfg(feature = "runtime-benchmarks")]
use xcm::latest::prelude::{
Asset, Fungible, Here, InteriorLocation, Junction, Junction::*, Location, NetworkId,
NonFungible, Parent, ParentThen, Response, XCM_VERSION,
Asset, Assets as XcmAssets, Fungible, Here, InteriorLocation, Junction, Junction::*, Location,
NetworkId, NonFungible, Parent, ParentThen, Response, XCM_VERSION,
};

use xcm_fee_payment_runtime_api::{
Expand Down Expand Up @@ -1629,7 +1629,7 @@ impl_runtime_apis! {
}

fn set_up_complex_asset_transfer(
) -> Option<(xcm::v4::Assets, u32, Location, Box<dyn FnOnce()>)> {
) -> Option<(XcmAssets, u32, Location, Box<dyn FnOnce()>)> {
// Transfer to Relay some local AH asset (local-reserve-transfer) while paying
// fees using teleported native token.
// (We don't care that Relay doesn't accept incoming unknown AH local asset)
Expand Down Expand Up @@ -1660,7 +1660,7 @@ impl_runtime_apis! {
);
let transfer_asset: Asset = (asset_location, asset_amount).into();

let assets: xcm::v4::Assets = vec![fee_asset.clone(), transfer_asset].into();
let assets: XcmAssets = vec![fee_asset.clone(), transfer_asset].into();
let fee_index = if assets.get(0).unwrap().eq(&fee_asset) { 0 } else { 1 };

// verify transferred successfully
Expand Down Expand Up @@ -1733,7 +1733,7 @@ impl_runtime_apis! {
fn valid_destination() -> Result<Location, BenchmarkError> {
Ok(WestendLocation::get())
}
fn worst_case_holding(depositable_count: u32) -> xcm::v4::Assets {
fn worst_case_holding(depositable_count: u32) -> XcmAssets {
// A mix of fungible, non-fungible, and concrete assets.
let holding_non_fungibles = MaxAssetsIntoHolding::get() / 2 - depositable_count;
let holding_fungibles = holding_non_fungibles - 2; // -2 for two `iter::once` bellow
Expand Down Expand Up @@ -1794,7 +1794,7 @@ impl_runtime_apis! {
(0u64, Response::Version(Default::default()))
}

fn worst_case_asset_exchange() -> Result<(xcm::v4::Assets, xcm::v4::Assets), BenchmarkError> {
fn worst_case_asset_exchange() -> Result<(XcmAssets, XcmAssets), BenchmarkError> {
Err(BenchmarkError::Skip)
}

Expand All @@ -1813,9 +1813,9 @@ impl_runtime_apis! {
Ok(WestendLocation::get())
}

fn claimable_asset() -> Result<(Location, Location, xcm::v4::Assets), BenchmarkError> {
fn claimable_asset() -> Result<(Location, Location, XcmAssets), BenchmarkError> {
let origin = WestendLocation::get();
let assets: xcm::v4::Assets = (AssetId(WestendLocation::get()), 1_000 * UNITS).into();
let assets: XcmAssets = (AssetId(WestendLocation::get()), 1_000 * UNITS).into();
let ticket = Location { parents: 0, interior: Here };
Ok((origin, ticket, assets))
}
Expand Down

0 comments on commit e192b76

Please sign in to comment.