Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix notify inactive collators failures at the end of a round #3128

Conversation

manuelmauro
Copy link
Contributor

What does it do?

Addresses issue #3100 for which "notify_inactive_collator" only works at the beginning of a round.

What important points reviewers should know?

Is there something left for follow-up PRs?

What alternative implementations were considered?

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

What value does it bring to the blockchain users?

Copy link
Contributor

github-actions bot commented Jan 8, 2025

WASM runtime size check:

Compared to target branch

Moonbase runtime: 2284 KB (no changes) ✅

Moonbeam runtime: 2256 KB (no changes) ✅

Moonriver runtime: 2256 KB (no changes) ✅

Compared to latest release (runtime-3400)

Moonbase runtime: 2284 KB (+256 KB compared to latest release) ⚠️

Moonbeam runtime: 2256 KB (+244 KB compared to latest release) ⚠️

Moonriver runtime: 2256 KB (+244 KB compared to latest release) ⚠️

@manuelmauro manuelmauro marked this pull request as ready for review January 9, 2025 14:12
@RomarQ RomarQ added the B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes label Jan 9, 2025
@crystalin
Copy link
Collaborator

For optimization purposes (knowing that Storage/PoV is usually the limiting factor), shouldn't we store those who didn't have stake. Instead of HadStake we could have WasInactive ? (What do you think @RomarQ ?)

Copy link
Contributor

github-actions bot commented Jan 9, 2025

Coverage Report

@@                                             Coverage Diff                                             @@
##           master   manuel/notify-inactive-collators-works-only-at-the-beginning-of-a-round      +/-   ##
===========================================================================================================
+ Coverage   74.40%                                                                    74.44%   +0.04%     
  Files         376                                                                       376              
+ Lines       95432                                                                     95632     +200     
===========================================================================================================
+ Hits        70998                                                                     71193     +195     
+ Misses      24434                                                                     24439       +5     
Files Changed Coverage
/pallets/parachain-staking/src/lib.rs 91.95% (+0.16%) 🔼
/pallets/parachain-staking/src/mock.rs 97.76% (+0.06%) 🔼
/pallets/parachain-staking/src/tests.rs 90.89% (+0.04%) 🔼
/pallets/parachain-staking/src/weights.rs 40.27% (+1.92%) 🔼
/runtime/moonbase/src/weights/pallet_parachain_staking.rs 21.95% (+2.50%) 🔼
/runtime/moonbeam/src/weights/pallet_parachain_staking.rs 21.85% (+2.49%) 🔼
/runtime/moonriver/src/weights/pallet_parachain_staking.rs 21.85% (+2.49%) 🔼

Coverage generated Tue Jan 14 11:26:38 UTC 2025

@RomarQ
Copy link
Contributor

RomarQ commented Jan 9, 2025

For optimization purposes (knowing that Storage/PoV is usually the limiting factor), shouldn't we store those who didn't have stake. Instead of HadStake we could have WasInactive ? (What do you think @RomarQ ?)

Yes, having a WasInactive storage map is preferable:

pub type WasInactive<T: Config> =
		StorageDoubleMap<_, Twox64Concat, RoundIndex, Twox64Concat, T::AccountId, (), OptionQuery>;

When starting a new round, we would check the inactivity like the example below, where stake.is_some() && pts.is_zero() would mean that the collator is inactive. We would check it against every candidate.

let stake = <AtStake<T>>::get(r, &collator);
let pts = <AwardedPts<T>>::get(r, &collator);
if stake.is_some() && pts.is_zero() {

We would still clear the storage after MaxOfflineRounds

@RomarQ RomarQ added the not-breaking Does not need to be mentioned in breaking changes label Jan 9, 2025
@manuelmauro
Copy link
Contributor Author

For optimization purposes (knowing that Storage/PoV is usually the limiting factor), shouldn't we store those who didn't have stake. Instead of HadStake we could have WasInactive ? (What do you think @RomarQ ?)

Addressed comment, as described by @RomarQ, in b4f4c00.
Now fixing weights.

@RomarQ RomarQ added the D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed. label Jan 13, 2025
Copy link
Contributor

@RomarQ RomarQ left a comment

Choose a reason for hiding this comment

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

After putting some thought into the mark_collators_as_inactive weights, the over-estimation is probably not necessary, instead we should add a num_of_collators argument to the mark_collators_as_inactive benchmark.

@manuelmauro
Copy link
Contributor Author

After putting some thought into the mark_collators_as_inactive weights, the over-estimation is probably not necessary, instead we should add a num_of_collators argument to the mark_collators_as_inactive benchmark.

Nice! Addressed in b66ec1f

@RomarQ RomarQ requested a review from TarekkMA January 14, 2025 11:41
@RomarQ RomarQ added D9-needsaudit👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited and removed D9-needsaudit👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited labels Jan 14, 2025
@RomarQ RomarQ merged commit dc75e3b into master Jan 14, 2025
43 of 44 checks passed
@RomarQ RomarQ deleted the manuel/notify-inactive-collators-works-only-at-the-beginning-of-a-round branch January 14, 2025 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed. not-breaking Does not need to be mentioned in breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants