diff --git a/parachains/runtimes/assets/statemint/src/lib.rs b/parachains/runtimes/assets/statemint/src/lib.rs index 3184f37e768..51fd78a1e8a 100644 --- a/parachains/runtimes/assets/statemint/src/lib.rs +++ b/parachains/runtimes/assets/statemint/src/lib.rs @@ -800,6 +800,9 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; + type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; + let mut list = Vec::::new(); list_benchmarks!(list, extra); @@ -810,7 +813,7 @@ impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, BenchmarkError}; use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime {} @@ -818,6 +821,81 @@ impl_runtime_apis! { use cumulus_pallet_session_benchmarking::Pallet as SessionBench; impl cumulus_pallet_session_benchmarking::Config for Runtime {} + use xcm::latest::{ + AssetId::*, Fungibility::*, Junctions::*, MultiAsset, MultiAssets, MultiLocation, + Response, + }; + use xcm_config::{Local, DotLocation}; + + impl pallet_xcm_benchmarks::Config for Runtime { + type XcmConfig = xcm_config::XcmConfig; + type AccountIdConverter = xcm_config::LocationToAccountId; + fn valid_destination() -> Result { + Ok(DotLocation::get()) + } + fn worst_case_holding() -> MultiAssets { + // Statemint only knows about DOT (?). + vec![MultiAsset{ + id: Concrete(Local::get()), + fun: Fungible(1_000_000 * UNITS), + }].into() + } + } + + //TODO: Not sure how this should work + parameter_types! { + pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( + Local::get(), + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(DotLocation::get()) }, + )); + pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( + Local::get(), + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(DotLocation::get()) }, + )); + } + + impl pallet_xcm_benchmarks::fungible::Config for Runtime { + type TransactAsset = Balances; + + type CheckedAccount = xcm_config::CheckingAccount; + type TrustedTeleporter = TrustedTeleporter; + type TrustedReserve = TrustedReserve; + + fn get_multi_asset() -> MultiAsset { + MultiAsset { + id: Concrete(DotLocation::get()), + fun: Fungible(1 * UNITS), + } + } + } + + impl pallet_xcm_benchmarks::generic::Config for Runtime { + type Call = Call; + + fn worst_case_response() -> (u64, Response) { + (0u64, Response::Version(Default::default())) + } + + fn transact_origin() -> Result { + Ok(DotLocation::get()) + } + + fn subscribe_origin() -> Result { + Ok(DotLocation::get()) + } + + fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { + let origin = DotLocation::get(); + let assets: MultiAssets = (Concrete(Local::get()), 1_000 * UNITS).into(); + let ticket = MultiLocation { parents: 0, interior: Here }; + Ok((origin, ticket, assets)) + } + } + + 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(),