-
Notifications
You must be signed in to change notification settings - Fork 335
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
[Manual] Marking offline collators not producing blocks during X rounds #2259
Conversation
Another good solution is to replace the extrinsic by a non mandatory inherent, It would still be more interesting than the automatic approach for 3 reasons:
And obviously the non mandatory inherent approach has a big advantage over the extrinsic: collators do not need to run a 2nd specific program to submit the extrinsic, submission is natively managed by the inherent system EDIT: we can also keep both the inherent ant the extrinsic |
Sounds good. If you agree, we could open another PR for that case, and merge this one with the manual solution before diving into the inherents one. What do you think? |
I discussed my inherent idea with @crystalin, and in fact the collators have incentive to not mark other collators offline, so the inherent would not work (it would work for a while, until someone maintains a different binary to optimize the interest of the collators, like the MeV on ethereum mainnet). |
Coverage generated "Fri Oct 6 16:08:31 UTC 2023": Master coverage: 87.39% |
@notlesh do the weights of the |
I added some locally generated ones in 85301b1 and b5ea5cd. They should be regenerated on proper hardware. |
…ndation/moonbeam into agustin-mark-offline-manual
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.
🎉
…ds (#2259) * begin manual mark-offline * remove CandidateLastActive * fix precompile staking * comments and fmt * fix do_go_offline() weight * make it compile * apply some suggestions * test case MaxOfflineRounds < RewardPaymentDelay * fix test * add killswitch for marking offline feature * fix mock config in parachain staking precompile * add benchmark for notify_inactive_collator extrinsic * refactor benchmark * fix call to select_top_candidates in benchmark * minor changes in benchmark * add killswitch as a storage item * fmt * remove ConstBool * enable killswitch in benchmark * add enable_marking_offline extrinsic * optmize collators_len read and benchmark * Add locally-generated benchmark for notify_inactive_collator * Hook up newly added benchmark to pallet call * add extra check for current round * minor changes in tests * add test * modify rounds_to_check syntax --------- Co-authored-by: Stephen Shelton <steve@brewcraft.org>
What does it do?
This PR introduces the manual design (via extrinsics) of marking a collator offline if it doesn’t produce blocks within a specific number of rounds. This number is declared as a constant (
MaxOfflineRounds
) and it’s different depending on which runtime we are situated on. In Moonbeam this constant is equal only to1
round while in Moonbase and Moonriver gets the value of2
rounds. It is important to note that this constant (in the case of the manual design) must be less than or equal to the constantRewardPaymentDelay
due to this design takes into account the rewards, and wouldn't work if we use them after they are reset.Proposed solution
Create a new extrinsic called
notify_inactive_collator
that anyone can call to inform a collator is inactive (not producing blocks during X consecutive rounds).This extrinsic performs a few checks. If we are in round 10 for instance, these checks will be applied to rounds 9 and 8 (in case
MaxOfflineRounds
is 2). For each round it checks:AtStake<>
storage key associated for the round. This means the candidate was selected as a collator in that round.AwardedPts<>
storage. This means the collator hasn't produced any block during that round.Also, at the beginning of the extrinsic, there is an additional check to ensure the collators set length is not lower than 66% of the value stored in
TotalSelected
. This is done to prevent collators set going empty and make the chain stop producing blocks.Once all these conditions are met, the extrinsic uses a custom handler called
OnInactiveCollator
to inform the runtime that a collator is inactive, and let the runtime decides what to do with it. The default behavior is to mark the collator as offline, but if we are dealing with moonbeam-orbiters for instance, we will probably use a different implementation.pallet-parachain-staking
.notify_inactive_collator
extrinsic.AtStake<>
to be of typeOptionQuery
instead of previousValueQuery
.OnInactiveCollator
to notify the runtime when a collator is inactive.