-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Bound RewardPoints
in pallet-staking
#12125
Conversation
bin/node/runtime/src/lib.rs
Outdated
@@ -569,6 +569,7 @@ impl pallet_staking::Config for Runtime { | |||
type OnStakerSlash = NominationPools; | |||
type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>; | |||
type BenchmarkingConfig = StakingBenchmarkingConfig; | |||
type MaxRewardPoints = ConstU32<300>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number of keys in this map is the number of validators -- staking should have a single MaxValidators
, and use that as the bound for this type as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was wondering about that, thanks!
|
||
// Maximum number of validators. | ||
#[pallet::constant] | ||
type MaxValidators: Get<u32>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we set the ValidatorCount
, we should make sure we are not above this limit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good, I will review closer later.
overlaps with #11967 |
impl<T: Config> EraRewardPoints<T> { | ||
fn add_points(&mut self, validator: T::AccountId, reward_points: u32) -> Result<(), Error<T>> { | ||
let mut points = self.individual.get(&validator).map(|x| *x).unwrap_or_default(); | ||
points += reward_points; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
points += reward_points; | |
points = points.saturating_add(reward_points); |
@kianenigma there is still panicking code in the runtime, I am working on it. |
RewardPoints
in pallet-staking
previously #12039