-
I am trying to figure out how the SessionManager works with the new_session method. fn new_session(new_index: SessionIndex) -> Option<Vec<ValidatorId>>; The argument new_index starts from the value '0' for the first session in the Substrate. substrate/frame/session/src/lib.rs Line 450 in 37a7727 And after that, each execution of the new_session() method corresponds to the execution of the on_finalize() function. fn on_finalize(block_number: T::BlockNumber) So, I have assumed the following approximate formula for the 'new_index'.
Period - Ends the session after a fixed period of blocks. substrate/frame/session/src/lib.rs Line 139 in 37a7727 Am I right with this formula ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The formula doesn't include the Generally speaking SessionManager is used like this: But I'm surprised why you need to compute the block number from the session index ? as said previously depending on the |
Beta Was this translation helpful? Give feedback.
The formula doesn't include the
Offset
information of the periodic session implementation. Formula needs to include it in its general case.(also formula is only correct for periodic session, if the chain uses Babe to end session then the formula doesn't stand anymore).
Generally speaking SessionManager is used like this:
at the end of session 10:
SessionManager::end_session(10)
is called,SessionManager::start_session(11)
is called, andSessionManager::new_session(12)
is called and if it result in a new validator set then it is stored in order to be used at session 12.But I'm surprised why you need to compute the block number from the session index ? as said previously depending on the
S…