Society pallet supports non-consecutive block provider#9497
Conversation
| let phase = now % rotation_period; | ||
| if phase < voting_period { | ||
| if now > Self::next_intake_at() { | ||
| Period::IntakeDelay { elapsed: now - Self::next_intake_at() } |
There was a problem hiding this comment.
if delayed for too long we wanna make sure we do not inter the Voting period again
There was a problem hiding this comment.
I don't understand this comment, if delayed for too long I don't see any special case using the variant IntakeDelay, the inner field elapsed is never used.
I would expect the comment to say: "if some block haven't been seen, we still trigger the rotation on the first block after the next_intake_at."
| let prev_block = now.saturating_sub(BlockNumberFor::<T, I>::one()); | ||
| let rotation_period = T::VotingPeriod::get().saturating_add(T::ClaimPeriod::get()); | ||
| let elapsed = prev_block % rotation_period; | ||
| prev_block + (rotation_period - elapsed) |
There was a problem hiding this comment.
Note: the subtraction here cannot underflow since we do the % first. Otherwise if it could underflow it would result in a very big value since its using u32.
ggwpez
left a comment
There was a problem hiding this comment.
It looks alright but would be good to have a test for it with delayed / skipped blocks 😅
| /// | ||
| /// This supposed to be called once the current intake is executed. | ||
| fn set_next_intake_at() { | ||
| let prev_next_intake_at = Self::next_intake_at(); |
There was a problem hiding this comment.
You have to call the function here instead of directly using NextIntakeAt::get() because it could be that it is not yet migrated?
There was a problem hiding this comment.
with the current flow here it cannot be unset. but I think its safer and more correct to get it with that function since we have a lazy initialization for it
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
gui1117
left a comment
There was a problem hiding this comment.
Apart from this comment looks good to me
|
Successfully created backport PR for |
Society pallet supports non-consecutive block provider Society pallet correctly handles situations where `on_initialize` is invoked with block numbers that: - increase but are not strictly consecutive (e.g., jump from 5 → 10), or - are repeated (e.g., multiple blocks are built at the same Relay Chain parent block, all reporting the same BlockNumberProvider value). This situation may occur when the BlockNumberProvider is not local - for example, on a parachain using the Relay Chain block number provider. --------- Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> (cherry picked from commit 1a51257)
Society pallet supports non-consecutive block provider Society pallet correctly handles situations where `on_initialize` is invoked with block numbers that: - increase but are not strictly consecutive (e.g., jump from 5 → 10), or - are repeated (e.g., multiple blocks are built at the same Relay Chain parent block, all reporting the same BlockNumberProvider value). This situation may occur when the BlockNumberProvider is not local - for example, on a parachain using the Relay Chain block number provider. --------- Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Backport #9497 into `unstable2507` from muharem. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> Co-authored-by: muharem <ismailov.m.h@gmail.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Egor_P <egor@parity.io>
Society pallet supports non-consecutive block provider Society pallet correctly handles situations where `on_initialize` is invoked with block numbers that: - increase but are not strictly consecutive (e.g., jump from 5 → 10), or - are repeated (e.g., multiple blocks are built at the same Relay Chain parent block, all reporting the same BlockNumberProvider value). This situation may occur when the BlockNumberProvider is not local - for example, on a parachain using the Relay Chain block number provider. --------- Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Society pallet supports non-consecutive block provider
Society pallet correctly handles situations where
on_initializeis invoked with block numbers that:This situation may occur when the BlockNumberProvider is not local - for example, on a parachain using the Relay Chain block number provider.