-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
frame/session/src/lib.rs
Outdated
) -> Option<Vec<ValidatorId>>; | ||
/// The returned validator set, if any, will not be applied until `new_index`. | ||
/// `new_index` must be strictly superior from previous call. | ||
fn on_new_session(new_index: SessionIndex) -> Option<Vec<ValidatorId>>; |
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.
Does it have to be interleaved with calls to on_session_ending
?
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.
not necessarily, if we want to increase or decrease dynamically the number of session queued in pallet-session we can call on_new_session multiple times or no time respectively.
I wasn't aware of SessionHandler trait, this seems to duplicate with OnSessionEnding. |
13618f6
to
3b7db30
Compare
Self::ensure_storage_upgraded(); | ||
Self::new_session(start_session - 1).map(|(new, _old)| new) | ||
if new_index == 0 { |
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.
we need to provide the validator set for the first session, this doesn't change the behavior of staking module.
if new_index == 0 { | ||
return <Module<T>>::select_validators().1 | ||
} | ||
Self::new_session(new_index - 1) |
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 new session will trigger the reward for the previous session and create a new one, this is wrong and is intented to be fixed by #4474
This PR doesn't the behavior of staking module
One problem for offchain Phragmen that I will soon get to is that: I need staking to be able to know the current Validator set. Will this become possible by either of these two PRs? currently, Staking has only a |
The current validator set (currently producing and validating) is available with |
pub struct Module<T: Trait> for enum Call where origin: T::Origin { } | ||
pub struct Module<T: Trait> for enum Call where origin: T::Origin { | ||
fn on_initialize(_n: T::BlockNumber) { | ||
CachedObsolete::<T>::remove_all(); |
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.
does that actually work? it's a regular map
, which AFAIK is not iterable
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.
Everything is now prefixed with Module
++ StorageEntryName
. So, it is iterable :)
@@ -385,7 +370,7 @@ mod tests { | |||
|
|||
assert_eq!(StoredRange::get(), Some((0, 100))); |
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.
We started session 98
, but 100
is in our stored range? what information do we have available about session 100?
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.
we have stored range [0; 100)
and because we delay by one session in this test runtime, the validator of next session is available. so we have information of session 99 when we start session 98
Thanks Guillaume! New API looking much cleaner. |
PR for polkadot update here paritytech/polkadot#782 (Also I'm not completely against keeping InitialValidatorSet trait, at some point I feel it might be better not to confuse the first validator set build for genesis config and the first new_session. So instead of calling new_session(0) we just ask for the initial validator set.) |
Context
Currently the Session pallet query new validator set for future session using the trait OnSessionEnding, this trait is:
Though the documentation doesn't say if will_apply_at is allowed to decrease between call, or must be equal or superior to the one in the previous call.
In order be able to make the number of session planned in the future dynamic I propose to decouple the ending of a session and the planning of a future session, thus this API:
Done
this is because the session 0 and 1 can simply be query using the new API
SessionManager::new_session(0 and 1)
. Makine this trait obsolete.as planned session are now final, we can just generate the proof for this session when it is planned, no need for CachedObsolete structure anymore.
Not Done
its behavior must have not changed at all.