Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Bound RewardPoints in pallet-staking #12125

Closed
wants to merge 2 commits into from

Conversation

Doordashcon
Copy link
Contributor

@Doordashcon Doordashcon commented Aug 26, 2022

previously #12039

@@ -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>;
Copy link
Contributor

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.

Copy link
Contributor Author

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>;
Copy link
Contributor

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.

Copy link
Contributor

@kianenigma kianenigma left a 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.

@kianenigma
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
points += reward_points;
points = points.saturating_add(reward_points);

@Doordashcon
Copy link
Contributor Author

Doordashcon commented Sep 5, 2022

@kianenigma there is still panicking code in the runtime, I am working on it.

@kianenigma
Copy link
Contributor

@Doordashcon see #9724 (comment).

@Doordashcon Doordashcon closed this Sep 6, 2022
@Doordashcon Doordashcon changed the title Bound RewardPointsin pallet-staking Bound RewardPoints in pallet-staking Nov 4, 2022
@Doordashcon Doordashcon changed the title Bound RewardPoints in pallet-staking Bound RewardPoints in pallet-staking Nov 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants