Skip to content

Commit 411c502

Browse files
paritytech-release-backport-bot[bot]acatangiukarolk91EgorPopelyaev
authored
[stable2506] Backport #9445 (#9449)
Backport #9445 into `stable2506` from acatangiu. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> Signed-off-by: Adrian Catangiu <[email protected]> Co-authored-by: Adrian Catangiu <[email protected]> Co-authored-by: Karol Kokoszka <[email protected]> Co-authored-by: Egor_P <[email protected]>
1 parent 15a0c8b commit 411c502

File tree

2 files changed

+58
-9
lines changed

2 files changed

+58
-9
lines changed

polkadot/xcm/pallet-xcm/src/benchmarking.rs

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -603,11 +603,18 @@ mod benchmarks {
603603
let origin = RawOrigin::Signed(who.clone());
604604
let origin_location: VersionedLocation =
605605
T::ExecuteXcmOrigin::try_origin(origin.clone().into())
606-
.map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?
606+
.map_err(|_| {
607+
tracing::error!(
608+
target: "xcm::benchmarking::pallet_xcm::add_authorized_alias",
609+
?origin,
610+
"try_origin failed",
611+
);
612+
BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX))
613+
})?
607614
.into();
608615

609616
// Give some multiple of ED
610-
let balance = T::ExistentialDeposit::get() * 1000u32.into();
617+
let balance = T::ExistentialDeposit::get() * 1000000u32.into();
611618
let _ =
612619
<pallet_balances::Pallet::<T> as frame_support::traits::Currency<_>>::make_free_balance_be(&who, balance);
613620

@@ -620,8 +627,17 @@ mod benchmarks {
620627
let aliaser = OriginAliaser { location: alias, expiry: None };
621628
existing_aliases.try_push(aliaser).unwrap()
622629
}
623-
let ticket = TicketOf::<T>::new(&who, aliasers_footprint(existing_aliases.len()))
624-
.map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?;
630+
let footprint = aliasers_footprint(existing_aliases.len());
631+
let ticket = TicketOf::<T>::new(&who, footprint).map_err(|e| {
632+
tracing::error!(
633+
target: "xcm::benchmarking::pallet_xcm::add_authorized_alias",
634+
?who,
635+
?footprint,
636+
error=?e,
637+
"could not create ticket",
638+
);
639+
BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX))
640+
})?;
625641
let entry = AuthorizedAliasesEntry { aliasers: existing_aliases, ticket };
626642
AuthorizedAliases::<T>::insert(&origin_location, entry);
627643

@@ -642,17 +658,31 @@ mod benchmarks {
642658
let origin = RawOrigin::Signed(who.clone());
643659
let error = BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX));
644660
let origin_location =
645-
T::ExecuteXcmOrigin::try_origin(origin.clone().into()).map_err(|_| error.clone())?;
661+
T::ExecuteXcmOrigin::try_origin(origin.clone().into()).map_err(|_| {
662+
tracing::error!(
663+
target: "xcm::benchmarking::pallet_xcm::remove_authorized_alias",
664+
?origin,
665+
"try_origin failed",
666+
);
667+
error.clone()
668+
})?;
646669
// remove `network` from inner `AccountId32` for easier matching of automatic AccountId ->
647670
// Location conversions.
648671
let origin_location: VersionedLocation = match origin_location.unpack() {
649672
(0, [AccountId32 { network: _, id }]) =>
650673
Location::new(0, [AccountId32 { network: None, id: *id }]).into(),
651-
_ => return Err(error.clone()),
674+
_ => {
675+
tracing::error!(
676+
target: "xcm::benchmarking::pallet_xcm::remove_authorized_alias",
677+
?origin_location,
678+
"unexpected origin failed",
679+
);
680+
return Err(error.clone())
681+
},
652682
};
653683

654684
// Give some multiple of ED
655-
let balance = T::ExistentialDeposit::get() * 1000u32.into();
685+
let balance = T::ExistentialDeposit::get() * 1000000u32.into();
656686
let _ =
657687
<pallet_balances::Pallet::<T> as frame_support::traits::Currency<_>>::make_free_balance_be(&who, balance);
658688

@@ -665,8 +695,17 @@ mod benchmarks {
665695
let aliaser = OriginAliaser { location: alias, expiry: None };
666696
existing_aliases.try_push(aliaser).unwrap()
667697
}
668-
let ticket = TicketOf::<T>::new(&who, aliasers_footprint(existing_aliases.len()))
669-
.map_err(|_| error)?;
698+
let footprint = aliasers_footprint(existing_aliases.len());
699+
let ticket = TicketOf::<T>::new(&who, footprint).map_err(|e| {
700+
tracing::error!(
701+
target: "xcm::benchmarking::pallet_xcm::remove_authorized_alias",
702+
?who,
703+
?footprint,
704+
error=?e,
705+
"could not create ticket",
706+
);
707+
error
708+
})?;
670709
let entry = AuthorizedAliasesEntry { aliasers: existing_aliases, ticket };
671710
AuthorizedAliases::<T>::insert(&origin_location, entry);
672711

prdoc/pr_9445.prdoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
title: "pallet-xcm: fix authorized_alias benchmarks"
2+
3+
doc:
4+
- audience: Runtime Dev
5+
description: |-
6+
Depending on runtime configuration of ED and storage deposits, the old benchmark code did not set up enough funds to cover authorized aliases storage deposits. Fix it by adding more funds as part of benchmark setup.
7+
8+
crates:
9+
- name: pallet-xcm
10+
bump: patch

0 commit comments

Comments
 (0)