diff --git a/pallets/asset-manager/src/benchmarking.rs b/pallets/asset-manager/src/benchmarking.rs index d13a61f99..60af7770f 100644 --- a/pallets/asset-manager/src/benchmarking.rs +++ b/pallets/asset-manager/src/benchmarking.rs @@ -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::*; @@ -39,6 +40,9 @@ fn assert_last_event(generic_event: ::RuntimeEvent) { } pub fn register_asset_helper(location: MultiLocation, i: u32) { + if crate::LocationAssetId::::contains_key(T::Location::from(location)) { + return; + } let metadata = AssetRegistryMetadata:: { metadata: AssetStorageMetadata { name: format!("{}-name", i).into(), @@ -51,12 +55,9 @@ pub fn register_asset_helper(location: MultiLocation, i: u32) { }; Pallet::::register_asset(RawOrigin::Root.into(), location.into(), metadata) .expect("Filed to register asset"); - Pallet::::set_units_per_second( - RawOrigin::Root.into(), - ::AssetId::from(i), - i.into(), - ) - .expect("Filed to set ups"); + let current_asset_id = crate::NextAssetId::::get() - One::one(); + Pallet::::set_units_per_second(RawOrigin::Root.into(), current_asset_id, i.into()) + .expect("Filed to set ups"); } benchmarks! { diff --git a/runtime/calamari/src/lib.rs b/runtime/calamari/src/lib.rs index 367731ebc..65ed96120 100644 --- a/runtime/calamari/src/lib.rs +++ b/runtime/calamari/src/lib.rs @@ -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::] - // [pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::] + [pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::] // Nimbus pallets // [pallet_author_inherent, AuthorInherent] ); @@ -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::; - //type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; - let mut list = Vec::::new(); list_benchmarks!(list, extra); @@ -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! { @@ -1580,7 +1575,22 @@ impl_runtime_apis! { >; fn valid_destination() -> Result { - 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::(*location, i as u32); + } + } + Ok(KsmLocation::get()) } fn worst_case_holding(depositable_count: u32) -> MultiAssets { @@ -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::>(); - 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::(*location, i as u32); + } + } assets.into() } } @@ -1670,9 +1689,6 @@ impl_runtime_apis! { } } - //type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; - //type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; - let whitelist: Vec = vec![ // Block Number hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), diff --git a/runtime/manta/src/lib.rs b/runtime/manta/src/lib.rs index db2a0a597..d46c66bcf 100644 --- a/runtime/manta/src/lib.rs +++ b/runtime/manta/src/lib.rs @@ -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::] // Manta pallets [pallet_tx_pause, TransactionPause] @@ -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::; - //type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; + type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; let mut list = Vec::::new(); list_benchmarks!(list, extra); @@ -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! { @@ -1512,6 +1510,21 @@ impl_runtime_apis! { >; fn valid_destination() -> Result { + 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::(*location, i as u32); + } + } Ok(DotLocation::get()) } @@ -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::>(); 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::(*location, i as u32); + } + } + assets.into() } } @@ -1601,8 +1624,7 @@ impl_runtime_apis! { } } - //type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; - //type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; + type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; let whitelist: Vec = vec![ // Block Number diff --git a/scripts/benchmarking/run_all_benchmarks.sh b/scripts/benchmarking/run_all_benchmarks.sh index 9846eeaf9..60643c253 100755 --- a/scripts/benchmarking/run_all_benchmarks.sh +++ b/scripts/benchmarking/run_all_benchmarks.sh @@ -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. diff --git a/tests/check_parachain_lease_expiration.ts b/tests/check_parachain_lease_expiration.ts index 55d379895..2396166e5 100644 --- a/tests/check_parachain_lease_expiration.ts +++ b/tests/check_parachain_lease_expiration.ts @@ -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;