From f2c37a39c3133e2c6965b16de70c93e9d7af6ed6 Mon Sep 17 00:00:00 2001 From: Bernardo Cardoso Date: Wed, 9 Mar 2022 18:33:11 +0100 Subject: [PATCH] Ensure min validator commission when election happens off-chain --- frame/staking/src/pallet/impls.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index e1481cf135eb1..cf5834f0f0cd0 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -494,8 +494,14 @@ impl Pallet { >::insert(&new_planned_era, total_stake); // Collect the pref of all winners. + let min_comm = MinValidatorCommission::::get(); for stash in &elected_stashes { - let pref = Self::validators(stash); + let mut pref = Self::validators(stash); + // Ensure minimum commission in case a validator chills + // after the election snapshot but before the election happens + if pref.commission < min_comm { + pref.commission = min_comm + } >::insert(&new_planned_era, stash, pref); }