-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Alliance pallet: retirement notice call #11970
Alliance pallet: retirement notice call #11970
Conversation
bin/node/runtime/src/lib.rs
Outdated
@@ -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); |
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.
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.
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.
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.
#[pallet::getter(fn retiring_members)] | ||
pub type RetiringMembers<T: Config<I>, I: 'static = ()> = | ||
StorageMap<_, Blake2_128Concat, T::AccountId, T::BlockNumber, OptionQuery>; |
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.
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.
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.
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.
/bench pallet pallet_alliance |
/cmd queue -c bench-bot $ pallet dev pallet_alliance @muharem the syntax is here paritytech/pipeline-scripts#63 |
@ggwpez https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1719871 was started for your command Comment |
@ggwpez Command |
/cmd queue -c bench-bot $ pallet dev pallet_alliance |
@muharem https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1721126 was started for your command Comment |
/cmd queue -c bench-bot $ pallet dev pallet_alliance The benchbot does not push anything if you change the branch in between. |
@ggwpez https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1721128 was started for your command Comment |
@muharem Command |
@ggwpez Command |
Co-authored-by: Squirrel <gilescope@gmail.com>
frame/alliance/src/lib.rs
Outdated
Self::add_member(&who, MemberRole::Retiring)?; | ||
<RetiringMembers<T, I>>::insert( | ||
&who, | ||
frame_system::Pallet::<T>::block_number() + T::RetirementPeriod::get(), |
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.
saturating_add
might be a good idea here just to be safe as @bkontur mentioned above.
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.
updated
Mostly looks good, but needs some minor fixes for clarity it seems. |
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.
lgtm,
I would just vote for renaming those two constants:
MOTION_DURATION -> MOTION_DURATION_IN_BLOCKS
ALLIANCE_MOTION_DURATION -> ALLIANCE_MOTION_DURATION_IN_BLOCKS
/cmd queue -c bench-bot $ pallet dev pallet_alliance |
@muharem https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1779299 was started for your command Comment |
@muharem Command |
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.
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. |
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.
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>
bot merge |
* 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>
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:
Cumulus companion: paritytech/cumulus#1573