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

Alliance pallet: retirement notice call #11970

Merged
merged 17 commits into from
Aug 29, 2022

Conversation

muharem
Copy link
Contributor

@muharem muharem commented Aug 3, 2022

Fixes #11936

Current implementation of retirement has a bug, which makes it impossible to retire for a member if there was a not enacted proposal to kick the member.

In the PR we introducing a new retirement_notice call, required to be executed by a member before retiring.
The notice will start a 'retirement period' that has to pass in order to retire.
The required period prevents a misbehaving member to retire before it will be kicked and slashed.

The PR does not cover next use cases:

  • if alliance does not execute the voted proposal to kick a misbehaving member, the member can retire without being slashed;
  • a member can not revoke the retirement process if retirement notice was given. It must retire and join alliance again if desires;

Cumulus companion: paritytech/cumulus#1573

@github-actions github-actions bot added the A0-please_review Pull request needs code review. label Aug 3, 2022
@muharem muharem added B3-apinoteworthy C3-medium PR touches the given topic and has a medium impact on builders. labels Aug 3, 2022
@@ -1537,6 +1539,7 @@ parameter_types! {
pub const MaxFellows: u32 = AllianceMaxMembers::get() - MaxFounders::get();
pub const MaxAllies: u32 = 100;
pub const AllyDeposit: Balance = 10 * DOLLARS;
pub const RetirementPeriod: BlockNumber = ALLIANCE_MOTION_DURATION + (1 * DAYS);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine in the node template but when we introduce a Root call to force dissolve the Alliance, we should make this longer than the root voting period.

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding a bit to this, I think it's OK for the retirement period to be really long (e.g. >3 months). We expect Alliance members to be quite committed to the network and they shouldn't retire just because they want to unreserve their DOT the way that someone might unbond their DOT.

frame/alliance/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines +502 to +504
#[pallet::getter(fn retiring_members)]
pub type RetiringMembers<T: Config<I>, I: 'static = ()> =
StorageMap<_, Blake2_128Concat, T::AccountId, T::BlockNumber, OptionQuery>;
Copy link
Contributor

@joepetrowski joepetrowski Aug 4, 2022

Choose a reason for hiding this comment

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

Mostly just curious, why not store this in the MemberRole variant itself (i.e. Retiring(T::BlockNumber))? I'm not sure if we have FRAME guidance on which is more idiomatic or when one method is better than another for a given use case (@kianenigma or @shawntabrizi ?).

A storage item makes it easier for UIs to query all retiring members, but they could also periodically just check all the members and build that info from there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now there is one storage map to store all members, where the key is a member role and value is map of AccountIds (Members).
And this additional map to store the BlockNumber for retirement period.

@joepetrowski joepetrowski added C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit. and removed C3-medium PR touches the given topic and has a medium impact on builders. labels Aug 4, 2022
@muharem
Copy link
Contributor Author

muharem commented Aug 4, 2022

/bench pallet pallet_alliance

@ggwpez
Copy link
Member

ggwpez commented Aug 4, 2022

/cmd queue -c bench-bot $ pallet dev pallet_alliance

@muharem the syntax is here paritytech/pipeline-scripts#63

@command-bot
Copy link

command-bot bot commented Aug 4, 2022

@ggwpez https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1719871 was started for your command "$PIPELINE_SCRIPTS_DIR/bench-bot.sh" pallet dev pallet_alliance. Check out https://gitlab.parity.io/parity/mirrors/substrate/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment /cmd cancel 4-d46fb067-71de-480e-a40e-58ff9f432176 to cancel this command or /cmd cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Aug 4, 2022

@ggwpez Command "$PIPELINE_SCRIPTS_DIR/bench-bot.sh" pallet dev pallet_alliance has finished. Result: https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1719871 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1719871/artifacts/download.

@muharem
Copy link
Contributor Author

muharem commented Aug 4, 2022

/cmd queue -c bench-bot $ pallet dev pallet_alliance

@command-bot
Copy link

command-bot bot commented Aug 4, 2022

@muharem https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1721126 was started for your command "$PIPELINE_SCRIPTS_DIR/bench-bot.sh" pallet dev pallet_alliance. Check out https://gitlab.parity.io/parity/mirrors/substrate/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment /cmd cancel 6-ee0c4611-5302-4ae0-a583-b15a6cc45272 to cancel this command or /cmd cancel to cancel all commands in this pull request.

@paritytech paritytech deleted a comment from command-bot bot Aug 4, 2022
@paritytech paritytech deleted a comment from command-bot bot Aug 4, 2022
@ggwpez
Copy link
Member

ggwpez commented Aug 4, 2022

/cmd queue -c bench-bot $ pallet dev pallet_alliance

The benchbot does not push anything if you change the branch in between.

@command-bot
Copy link

command-bot bot commented Aug 4, 2022

@ggwpez https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1721128 was started for your command "$PIPELINE_SCRIPTS_DIR/bench-bot.sh" pallet dev pallet_alliance. Check out https://gitlab.parity.io/parity/mirrors/substrate/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment /cmd cancel 7-6de5d2ca-1b3f-438c-adc2-bc15050571b3 to cancel this command or /cmd cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Aug 4, 2022

@muharem Command "$PIPELINE_SCRIPTS_DIR/bench-bot.sh" pallet dev pallet_alliance has finished. Result: https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1721126 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1721126/artifacts/download.

@command-bot
Copy link

command-bot bot commented Aug 4, 2022

@ggwpez Command "$PIPELINE_SCRIPTS_DIR/bench-bot.sh" pallet dev pallet_alliance has finished. Result: https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1721128 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1721128/artifacts/download.

@muharem muharem removed the A0-please_review Pull request needs code review. label Aug 9, 2022
Co-authored-by: Squirrel <gilescope@gmail.com>
frame/alliance/src/lib.rs Outdated Show resolved Hide resolved
frame/alliance/src/mock.rs Outdated Show resolved Hide resolved
Self::add_member(&who, MemberRole::Retiring)?;
<RetiringMembers<T, I>>::insert(
&who,
frame_system::Pallet::<T>::block_number() + T::RetirementPeriod::get(),
Copy link
Contributor

Choose a reason for hiding this comment

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

saturating_add might be a good idea here just to be safe as @bkontur mentioned above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@ruseinov
Copy link
Contributor

Mostly looks good, but needs some minor fixes for clarity it seems.

Copy link
Contributor

@bkontur bkontur left a comment

Choose a reason for hiding this comment

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

lgtm,
I would just vote for renaming those two constants:
MOTION_DURATION -> MOTION_DURATION_IN_BLOCKS
ALLIANCE_MOTION_DURATION -> ALLIANCE_MOTION_DURATION_IN_BLOCKS

@muharem
Copy link
Contributor Author

muharem commented Aug 26, 2022

/cmd queue -c bench-bot $ pallet dev pallet_alliance

@command-bot
Copy link

command-bot bot commented Aug 26, 2022

@muharem https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1779299 was started for your command "$PIPELINE_SCRIPTS_DIR/bench-bot.sh" pallet dev pallet_alliance. Check out https://gitlab.parity.io/parity/mirrors/substrate/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment /cmd cancel 35-a8a5785a-c81c-40e5-b220-2c0876aaf06e to cancel this command or /cmd cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Aug 26, 2022

@muharem Command "$PIPELINE_SCRIPTS_DIR/bench-bot.sh" pallet dev pallet_alliance has finished. Result: https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1779299 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1779299/artifacts/download.

Copy link
Contributor

@ruseinov ruseinov left a comment

Choose a reason for hiding this comment

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

lgtm, one minor nit related to a comment

@@ -315,7 +315,7 @@ pub mod pallet {
/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;

/// The period required to pass from retirement notice for a member to retire.
/// The number of blocks a member must wait between giving a retirement notice and retiring.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: wait for*

* add negative tests

* remove tests powerless asserts checking against announcment origin

* assert bad origin from announcement origin checks

Co-authored-by: muharem <ismailov.m.h@gmail.com>
@muharem
Copy link
Contributor Author

muharem commented Aug 29, 2022

bot merge

@paritytech-processbot paritytech-processbot bot merged commit 5cdb054 into master Aug 29, 2022
@paritytech-processbot paritytech-processbot bot deleted the pallet-alliance-retirement-notice branch August 29, 2022 16:02
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
* Alliance pallet: retirement notice

* add alliance pallet to benchmark list for dev chain

* fix type

* ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance

* ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance

* link weight generated by bench for retirement_notice method

* migration to clear UpForKicking storage prefix

* rename migration from v1 to v0_to_v1

* Apply suggestions from code review

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* rename `retirement-notice to give-retirement-notice

* Apply suggestions from code review

Co-authored-by: Squirrel <gilescope@gmail.com>

* review fixes: update doc, saturating add, BlockNumber type alias

* add suffix to duratin consts *_IN_BLOCKS

* ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance

* add negative tests (paritytech#11995)

* add negative tests

* remove tests powerless asserts checking against announcment origin

* assert bad origin from announcement origin checks

Co-authored-by: muharem <ismailov.m.h@gmail.com>

Co-authored-by: command-bot <>
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
Co-authored-by: Squirrel <gilescope@gmail.com>
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. C1-low PR touches the given topic and has a low impact on builders. D2-breaksapi D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alliance: member can't retire if was set once up for kicking
6 participants