From 8f6699beadc220503721db3e60d0cfaa21f81b64 Mon Sep 17 00:00:00 2001 From: Ankan <10196091+Ank4n@users.noreply.github.com> Date: Wed, 11 Sep 2024 20:12:44 +0200 Subject: [PATCH] [Staking] Propagate actual system error while staking::bond (#5627) Trivial and self explanatory changes. Wrapping err such as these makes debugging harder as well as does not really give any meaningful reason why this happened. The increment of consumer can genuinely fail if there are no providers (account does not exist) or it reaches max consumers. In both cases, its better to propagate the actual System err. --- substrate/frame/staking/src/pallet/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index 79f9d298ada7..8a4482f52ad5 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1027,7 +1027,8 @@ pub mod pallet { return Err(Error::::InsufficientBond.into()) } - frame_system::Pallet::::inc_consumers(&stash).map_err(|_| Error::::BadState)?; + // Would fail if account has no provider. + frame_system::Pallet::::inc_consumers(&stash)?; let stash_balance = T::Currency::free_balance(&stash); let value = value.min(stash_balance);