Skip to content

Commit

Permalink
Merge branch 'manta' into release-v4.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Dengjianping authored May 18, 2024
2 parents 60631be + faaf9dc commit 78b7af7
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 37 deletions.
13 changes: 7 additions & 6 deletions pallets/asset-manager/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use manta_primitives::{
types::Balance,
};
use scale_info::prelude::*;
use sp_runtime::traits::One;
use sp_std::vec;
use xcm::latest::prelude::*;

Expand All @@ -39,6 +40,9 @@ fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
}

pub fn register_asset_helper<T: Config>(location: MultiLocation, i: u32) {
if crate::LocationAssetId::<T>::contains_key(T::Location::from(location)) {
return;
}
let metadata = AssetRegistryMetadata::<Balance> {
metadata: AssetStorageMetadata {
name: format!("{}-name", i).into(),
Expand All @@ -51,12 +55,9 @@ pub fn register_asset_helper<T: Config>(location: MultiLocation, i: u32) {
};
Pallet::<T>::register_asset(RawOrigin::Root.into(), location.into(), metadata)
.expect("Filed to register asset");
Pallet::<T>::set_units_per_second(
RawOrigin::Root.into(),
<T as Config>::AssetId::from(i),
i.into(),
)
.expect("Filed to set ups");
let current_asset_id = crate::NextAssetId::<T>::get() - One::one();
Pallet::<T>::set_units_per_second(RawOrigin::Root.into(), current_asset_id, i.into())
.expect("Filed to set ups");
}

benchmarks! {
Expand Down
52 changes: 34 additions & 18 deletions runtime/calamari/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1162,9 +1162,8 @@ mod benches {
// always get this error(Unimplemented) while benchmarking pallet_xcm_benchmarks::fungible::initiate_teleport
// so this time we will use statemint's fungible weights
// and actually we don't support teleport now
// [pallet_xcm_benchmarks::generic, XcmGeneric]
// [pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::<Runtime>]
// [pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::<Runtime>]
[pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::<Runtime>]
// Nimbus pallets
// [pallet_author_inherent, AuthorInherent]
);
Expand Down Expand Up @@ -1519,9 +1518,6 @@ impl_runtime_apis! {
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
use frame_system_benchmarking::Pallet as SystemBench;

//type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
//type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;

let mut list = Vec::<BenchmarkList>::new();
list_benchmarks!(list, extra);

Expand Down Expand Up @@ -1551,7 +1547,6 @@ impl_runtime_apis! {
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
impl cumulus_pallet_session_benchmarking::Config for Runtime {}

use pallet_xcm_benchmarks::asset_instance_from;
use xcm_config::{LocationToAccountId, XcmExecutorConfig};

parameter_types! {
Expand Down Expand Up @@ -1580,7 +1575,22 @@ impl_runtime_apis! {
>;

fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
Ok(KsmLocation::get())
let assets = vec![
MultiAsset {
id: Concrete(KsmLocation::get()),
fun: Fungible(1_000_000 * KMA),
}
];

for (i, asset) in assets.iter().enumerate() {
if let MultiAsset {
id: Concrete(location),
fun: Fungible(_)
} = asset {
pallet_asset_manager::benchmarking::register_asset_helper::<Runtime>(*location, i as u32);
}
}
Ok(KsmLocation::get())
}

fn worst_case_holding(depositable_count: u32) -> MultiAssets {
Expand All @@ -1596,16 +1606,25 @@ impl_runtime_apis! {
}
})
.chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) }))
.chain((0..holding_non_fungibles).map(|i| MultiAsset {
id: Concrete(GeneralIndex(i as u128).into()),
fun: NonFungible(asset_instance_from(i)),
}))
.collect::<Vec<_>>();

assets.push(MultiAsset {
id: Concrete(KmaLocation::get()),
fun: Fungible(1_000_000 * KMA),
});
assets.push(MultiAsset {
id: Concrete(KsmLocation::get()),
fun: Fungible(1_000_000 * KMA),
});
assets.push(MultiAsset {
id: Concrete(KmaLocation::get()),
fun: Fungible(1_000_000 * KMA),
});

for (i, asset) in assets.iter().enumerate() {
if let MultiAsset {
id: Concrete(location),
fun: Fungible(_)
} = asset {
pallet_asset_manager::benchmarking::register_asset_helper::<Runtime>(*location, i as u32);
}
}
assets.into()
}
}
Expand Down Expand Up @@ -1670,9 +1689,6 @@ impl_runtime_apis! {
}
}

//type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
//type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;

let whitelist: Vec<TrackedStorageKey> = vec![
// Block Number
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
Expand Down
42 changes: 32 additions & 10 deletions runtime/manta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ mod benches {
// always get this error(Unimplemented) while benchmarking pallet_xcm_benchmarks::fungible::initiate_teleport
// so this time we will use statemint's fungible weights
// [pallet_xcm_benchmarks::fungible, XcmBalances]
// [pallet_xcm_benchmarks::generic, XcmGeneric]
[pallet_xcm_benchmarks::generic, XcmGeneric]
[pallet_session, SessionBench::<Runtime>]
// Manta pallets
[pallet_tx_pause, TransactionPause]
Expand Down Expand Up @@ -1448,8 +1448,7 @@ impl_runtime_apis! {
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
use frame_system_benchmarking::Pallet as SystemBench;

//type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
//type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;

let mut list = Vec::<BenchmarkList>::new();
list_benchmarks!(list, extra);
Expand Down Expand Up @@ -1479,7 +1478,6 @@ impl_runtime_apis! {
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
impl cumulus_pallet_session_benchmarking::Config for Runtime {}

use pallet_xcm_benchmarks::asset_instance_from;
use xcm_config::{LocationToAccountId, XcmExecutorConfig};

parameter_types! {
Expand Down Expand Up @@ -1512,6 +1510,21 @@ impl_runtime_apis! {
>;

fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
let assets = vec![
MultiAsset {
id: Concrete(DotLocation::get()),
fun: Fungible(1_000_000 * MANTA),
}
];

for (i, asset) in assets.iter().enumerate() {
if let MultiAsset {
id: Concrete(location),
fun: Fungible(_)
} = asset {
pallet_asset_manager::benchmarking::register_asset_helper::<Runtime>(*location, i as u32);
}
}
Ok(DotLocation::get())
}

Expand All @@ -1528,16 +1541,26 @@ impl_runtime_apis! {
}
})
.chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) }))
.chain((0..holding_non_fungibles).map(|i| MultiAsset {
id: Concrete(GeneralIndex(i as u128).into()),
fun: NonFungible(asset_instance_from(i)),
}))
.collect::<Vec<_>>();

assets.push(MultiAsset {
id: Concrete(DotLocation::get()),
fun: Fungible(1_000_000 * MANTA),
});
assets.push(MultiAsset {
id: Concrete(MantaLocation::get()),
fun: Fungible(1_000_000 * MANTA),
});

for (i, asset) in assets.iter().enumerate() {
if let MultiAsset {
id: Concrete(location),
fun: Fungible(_)
} = asset {
pallet_asset_manager::benchmarking::register_asset_helper::<Runtime>(*location, i as u32);
}
}

assets.into()
}
}
Expand Down Expand Up @@ -1601,8 +1624,7 @@ impl_runtime_apis! {
}
}

//type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
//type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;

let whitelist: Vec<TrackedStorageKey> = vec![
// Block Number
Expand Down
2 changes: 0 additions & 2 deletions scripts/benchmarking/run_all_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ MANTA=./target/production/manta
# Will fix it in next release
# currently, both pallets have problems on benchmarking
EXCLUDED_PALLETS=(
"frame_system"
"zenlink_protocol"
)

# Load all pallet names in an array.
Expand Down
2 changes: 1 addition & 1 deletion tests/check_parachain_lease_expiration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function createPromiseApi(nodeAddress: string) {

describe('Check Parachain_Lease_Expiration', () => {
it('Check Manta Parachain Lease', async () => {
const polkadotNode = 'wss://1rpc.io/dot';
const polkadotNode = 'wss://polkadot.api.onfinality.io/public-ws';
const polkadotApi = await createPromiseApi(polkadotNode);
const mantaParaId = 2104;
const oneDay = 3600 * 24;
Expand Down

0 comments on commit 78b7af7

Please sign in to comment.