This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 380
min collator check #498
Merged
Merged
min collator check #498
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8e4c266
min collator check
JesseAbram 9321045
change statemint/mine min candidates
JesseAbram d4ffcfc
Ci pass
JesseAbram abc663e
Update pallets/collator-selection/src/lib.rs
JesseAbram e409ca8
Update pallets/collator-selection/src/lib.rs
JesseAbram 325cf3b
Apply suggestions from code review
shawntabrizi bfa603a
build fixes
JesseAbram b4c8405
add error messages to errors
JesseAbram f3f66b3
added validator register check
JesseAbram File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -127,6 +127,12 @@ pub mod pallet { | |||||
/// This does not take into account the invulnerables. | ||||||
type MaxCandidates: Get<u32>; | ||||||
|
||||||
/// Minimum number of candidates that we should have. This is used for disaster recovery. | ||||||
/// | ||||||
/// This does not take into account the invulnerables. | ||||||
type MinCandidates: Get<usize>; | ||||||
JesseAbram marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
|
||||||
/// Maximum number of invulnerables. | ||||||
/// | ||||||
/// Used only for benchmarking. | ||||||
|
@@ -239,6 +245,7 @@ pub mod pallet { | |||||
#[pallet::error] | ||||||
pub enum Error<T> { | ||||||
TooManyCandidates, | ||||||
TooFewCandidates, | ||||||
Unknown, | ||||||
Permission, | ||||||
AlreadyCandidate, | ||||||
JesseAbram marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
@@ -323,7 +330,7 @@ pub mod pallet { | |||||
#[pallet::weight(T::WeightInfo::leave_intent(T::MaxCandidates::get()))] | ||||||
pub fn leave_intent(origin: OriginFor<T>) -> DispatchResultWithPostInfo { | ||||||
let who = ensure_signed(origin)?; | ||||||
|
||||||
ensure!(Self::candidates().len() > T::MinCandidates::get(), Error::<T>::TooFewCandidates); | ||||||
JesseAbram marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
let current_count = Self::try_remove_candidate(&who)?; | ||||||
|
||||||
Ok(Some(T::WeightInfo::leave_intent(current_count as u32)).into()) | ||||||
|
@@ -365,7 +372,7 @@ pub mod pallet { | |||||
let new_candidates = candidates.into_iter().filter_map(|c| { | ||||||
let last_block = <LastAuthoredBlock<T>>::get(c.who.clone()); | ||||||
let since_last = now.saturating_sub(last_block); | ||||||
if since_last < kick_threshold { | ||||||
if since_last < kick_threshold || Self::candidates().len() <= T::MinCandidates::get() { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Why are you reading candidates here but also getting candidates from the input params of this function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so the candidates input does not get changed, it gets at the end collected into new_candidates, so if 5 people get removed, it does not know that, however the global candidates is tracking this, so it would for each candidate have the current knowledge of how many are left after the previous have been kicked |
||||||
Some(c.who) | ||||||
} else { | ||||||
let outcome = Self::try_remove_candidate(&c.who); | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You are saying this count is the number of people required not including any existing invulnerables?
I think that is over doing it. Invulnerables existing should satisfy the requirement for a minimum number of collators.
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.
I agree in theory but invulnerables can be removed all at once (through a permissioned call) I was thinking this would be more of a assume invulnerables would be removed soon thing would be an easier transition, but open to changing
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.
Invulnerables should eventually be removed and by then minimum number of collators will be super useful