mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 04:31:08 +00:00
Nomination pools: disallow setting above global max commission (#14496)
* add CommissionExceedsGlobalMaximum * rename test * amend set_commission_max_works_with_error_tests * fmt
This commit is contained in:
@@ -749,6 +749,10 @@ impl<T: Config> Commission<T> {
|
||||
None => None,
|
||||
Some((commission, payee)) => {
|
||||
ensure!(!self.throttling(commission), Error::<T>::CommissionChangeThrottled);
|
||||
ensure!(
|
||||
commission <= &GlobalMaxCommission::<T>::get().unwrap_or(Bounded::max_value()),
|
||||
Error::<T>::CommissionExceedsGlobalMaximum
|
||||
);
|
||||
ensure!(
|
||||
self.max.map_or(true, |m| commission <= &m),
|
||||
Error::<T>::CommissionExceedsMaximum
|
||||
@@ -773,6 +777,10 @@ impl<T: Config> Commission<T> {
|
||||
/// updated to the new maximum. This will also register a `throttle_from` update.
|
||||
/// A `PoolCommissionUpdated` event is triggered if `current.0` is updated.
|
||||
fn try_update_max(&mut self, pool_id: PoolId, new_max: Perbill) -> DispatchResult {
|
||||
ensure!(
|
||||
new_max <= GlobalMaxCommission::<T>::get().unwrap_or(Bounded::max_value()),
|
||||
Error::<T>::CommissionExceedsGlobalMaximum
|
||||
);
|
||||
if let Some(old) = self.max.as_mut() {
|
||||
if new_max > *old {
|
||||
return Err(Error::<T>::MaxCommissionRestricted.into())
|
||||
@@ -1824,6 +1832,8 @@ pub mod pallet {
|
||||
MaxCommissionRestricted,
|
||||
/// The supplied commission exceeds the max allowed commission.
|
||||
CommissionExceedsMaximum,
|
||||
/// The supplied commission exceeds global maximum commission.
|
||||
CommissionExceedsGlobalMaximum,
|
||||
/// Not enough blocks have surpassed since the last commission update.
|
||||
CommissionChangeThrottled,
|
||||
/// The submitted changes to commission change rate are not allowed.
|
||||
|
||||
Reference in New Issue
Block a user