Skip to content

Commit

Permalink
[Staking] Propagate actual system error while staking::bond (#5627)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ank4n authored Sep 11, 2024
1 parent 4e7c9e7 commit 8f6699b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion substrate/frame/staking/src/pallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,8 @@ pub mod pallet {
return Err(Error::<T>::InsufficientBond.into())
}

frame_system::Pallet::<T>::inc_consumers(&stash).map_err(|_| Error::<T>::BadState)?;
// Would fail if account has no provider.
frame_system::Pallet::<T>::inc_consumers(&stash)?;

let stash_balance = T::Currency::free_balance(&stash);
let value = value.min(stash_balance);
Expand Down

0 comments on commit 8f6699b

Please sign in to comment.