Add missing XCM benchmarks for ReserveAssetDeposited (#4923)

* Add missing XCM benchmarks for ReserveAssetDeposited

* Check whether checking account is zero before minting

* Try and prevent overflow

* Remove minting currencies into the checking account

* cargo run --quiet --profile=production  --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=pallet_xcm_benchmarks::fungible --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --template=./xcm/pallet-xcm-benchmarks/template.hbs --output=./runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs

* Use a smaller divisor

* Mint a smaller amount still

* cargo run --quiet --profile=production  --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=pallet_xcm_benchmarks::fungible --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --template=./xcm/pallet-xcm-benchmarks/template.hbs --output=./runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs

* Remove logic for minting assets to the checking account

* Configure a smaller amount of reserve asset used for testing

* Try unwrapping the result of an execution

* Set the origin properly

* Revert "Set the origin properly"

This reverts commit c748a05733173fb7072878c19b10a583675a5f54.

* Update license year

* cargo run --quiet --profile=production  --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=pallet_xcm_benchmarks::fungible --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --template=./xcm/pallet-xcm-benchmarks/template.hbs --output=./runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs

* Update license year

Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
Keith Yeung
2022-03-07 21:09:44 -08:00
committed by GitHub
parent dc25b326ba
commit 5f3497830a
7 changed files with 55 additions and 17 deletions
@@ -107,6 +107,25 @@ benchmarks_instance_pallet! {
// TODO: Check sender queue is not empty. #4426
}
reserve_asset_deposited {
let (trusted_reserve, transferable_reserve_asset) = T::TrustedReserve::get()
.ok_or(BenchmarkError::Skip)?;
let assets: MultiAssets = vec![ transferable_reserve_asset ].into();
let mut executor = new_executor::<T>(trusted_reserve);
let instruction = Instruction::ReserveAssetDeposited(assets.clone());
let xcm = Xcm(vec![instruction]);
}: {
executor.execute(xcm).map_err(|_| {
BenchmarkError::Override(
BenchmarkResult::from_weight(T::BlockWeights::get().max_block)
)
})?;
} verify {
assert!(executor.holding.ensure_contains(&assets).is_ok());
}
receive_teleported_asset {
// If there is no trusted teleporter, then we skip this benchmark.
let (trusted_teleporter, teleportable_asset) = T::TrustedTeleporter::get()
@@ -132,7 +132,7 @@ impl xcm_executor::Config for XcmConfig {
type XcmSender = DevNull;
type AssetTransactor = AssetTransactor;
type OriginConverter = ();
type IsReserve = ();
type IsReserve = TrustedReserves;
type IsTeleporter = TrustedTeleporters;
type LocationInverter = xcm_builder::LocationInverter<Ancestry>;
type Barrier = AllowUnpaidExecutionFrom<Everything>;
@@ -159,6 +159,7 @@ impl crate::Config for Test {
}
pub type TrustedTeleporters = (xcm_builder::Case<TeleConcreteFung>,);
pub type TrustedReserves = (xcm_builder::Case<RsrvConcreteFung>,);
parameter_types! {
pub const CheckedAccount: Option<u64> = Some(100);
@@ -167,14 +168,21 @@ parameter_types! {
ChildTeleporter::get(),
MultiAsset { id: Concrete(Here.into()), fun: Fungible(100) },
));
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some((
ChildTeleporter::get(),
MultiAsset { id: Concrete(Here.into()), fun: Fungible(100) },
));
pub const TeleConcreteFung: (MultiAssetFilter, MultiLocation) =
(Wild(AllOf { fun: WildFungible, id: Concrete(Here.into()) }), ChildTeleporter::get());
pub const RsrvConcreteFung: (MultiAssetFilter, MultiLocation) =
(Wild(AllOf { fun: WildFungible, id: Concrete(Here.into()) }), ChildTeleporter::get());
}
impl xcm_balances_benchmark::Config for Test {
type TransactAsset = Balances;
type CheckedAccount = CheckedAccount;
type TrustedTeleporter = TrustedTeleporter;
type TrustedReserve = TrustedReserve;
fn get_multi_asset() -> MultiAsset {
let amount =
@@ -38,6 +38,10 @@ pub mod pallet {
/// A trusted location which we allow teleports from, and the asset we allow to teleport.
type TrustedTeleporter: Get<Option<(xcm::latest::MultiLocation, xcm::latest::MultiAsset)>>;
/// A trusted location where reserve assets are stored, and the asset we allow to be
/// reserves.
type TrustedReserve: Get<Option<(xcm::latest::MultiLocation, xcm::latest::MultiAsset)>>;
/// Give me a fungible asset that your asset transactor is going to accept.
fn get_multi_asset() -> xcm::latest::MultiAsset;
}