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

ranked-collective: pub fns to demote and remove members#13377

Closed
muharem wants to merge 4 commits intomasterfrom
muharem-ranked-collective-pub-fns
Closed

ranked-collective: pub fns to demote and remove members#13377
muharem wants to merge 4 commits intomasterfrom
muharem-ranked-collective-pub-fns

Conversation

@muharem
Copy link
Contributor

@muharem muharem commented Feb 13, 2023

Fixes #12983

In the PR we adding new abstractions (public functions) to demote and promote members.
No new behaviour is introduced. The abstractions are identical to the existing ones for adding and promoting members.

For the reasoning please check the issue.

// TOOD add trait

@muharem muharem added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Feb 13, 2023
Comment on lines +695 to +696
/// A `maybe_max_rank` may be provided to check that the member does not get removed from
/// a certain rank. if `None` is provided, then the rank will be decremented without checks.
Copy link
Member

Choose a reason for hiding this comment

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

This is not really true, in the remove_member the max_rank describes the max_rank of the member the origin can remove. Meaning that if the member to remove has a higher rank, it will be rejected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

please check now.
note, its not necessary a member removing/demoting/promoting, its mostly a referenda on a certain track.

/// A `maybe_max_rank` may be provided to check that the member does not get removed from
/// a certain rank. if `None` is provided, then the rank will be decremented without checks.
pub fn do_remove_member(who: T::AccountId, maybe_max_rank: Option<Rank>) -> DispatchResult {
let MemberRecord { rank, .. } = Self::ensure_member(&who)?;
Copy link
Member

Choose a reason for hiding this comment

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

remove_member already calls this. We should come up with a way to not duplicate this call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I know this will result only one read from the storage, because of the overlay layer.
The logic was to not include the WitnessData check into do_* function, clients might not need it.
Other option could be to pass the actual rank as an argument, but since this function is public, I believe it must be sure (query by itself) about the actual rank, otherwise it might lead to the inconsistency.
@bkchr what you think?

Copy link
Member

Choose a reason for hiding this comment

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

i think it is probably fine

Comment on lines +669 to +670
/// A `maybe_max_rank` may be provided to check that the member does not get demoted beyond
/// a certain rank. Is `None` is provided, then the rank will be decremented without checks.
Copy link
Member

Choose a reason for hiding this comment

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

I find this comment also confusing. Without reading the code, I wouldn't really know what this is for.

@muharem muharem requested a review from bkchr February 20, 2023 11:01
@gavofyork
Copy link
Member

No trait added? I think that would be very useful - I expect I'll need such a trait in the near future for promotion and demotion logic potentially specific to the Core Technical Fellowship.

@muharem
Copy link
Contributor Author

muharem commented Feb 25, 2023

No trait added? I think that would be very useful - I expect I'll need such a trait in the near future for promotion and demotion logic potentially specific to the Core Technical Fellowship.

I will add the trait.

@muharem muharem added the A3-in_progress Pull request is in progress. No review needed at this stage. label Feb 25, 2023
@gavofyork
Copy link
Member

#13378 includes the same refactoring...

@muharem
Copy link
Contributor Author

muharem commented Mar 7, 2023

solved in this PR #13378

@muharem muharem closed this Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A0-please_review Pull request needs code review. A3-in_progress Pull request is in progress. No review needed at this stage. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Member and rank management of ranked_collective pallet.

4 participants