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

SMRL Session: Potentially unnecessarily removing original authorities from a session #1290

Closed
ltfschoen opened this issue Dec 19, 2018 · 1 comment

Comments

@ltfschoen
Copy link
Contributor

ltfschoen commented Dec 19, 2018

In the Session SMRL we change (rotate) each Session at the end of the final block of the current Session Length using the on_finalise method https://github.com/paritytech/substrate/blob/master/srml/session/src/lib.rs#L112 (that is called by either an origin or internally from another SRML at the end of each block) that calls check_rotate_session. At the start of the next session we allocated it with a Session Index and record the timestamp when it started.

Lastly we iterate through each of current set of Validator Account IDs by index and check if a Session Key was created for it with set_key in the previous session, and if so we call set_authority https://github.com/paritytech/substrate/blob/master/srml/consensus/src/lib.rs#L266 of the Consensus SRML where we check if the Session Key of this current authority matches the Session Key (if any) stored under their index in the AuthorityStorageVec mapping, and if not we store their index to Session Key and we call save_original_authorities https://github.com/paritytech/substrate/blob/master/srml/consensus/src/lib.rs#L269 with an argument None. Then if there are authorities already saved in OriginalAuthorities we return, otherwise we try to update OriginalAuthorities with a value of None.

Is it necessary for us to have to set the value of OriginalAuthorities to a value of None multiple times?

Additionally, there is a comment above the set_validators method of SRML Session
https://github.com/paritytech/substrate/blob/master/srml/session/src/lib.rs#L171, which is used to set the current set of validators. It says:

next_session should be called after this in order to update the session keys to the next validator set.

set_validators also calls set_authority of the Consensus SRML, but instead of passing None, it passes a set of Session Keys (which it gets from the provided list of Account IDs of the new validators that are to be set that each map to a corresponding Session Key).

And there isn't a next_session function like the comment suggests. I assume it means rotate_session, which is called by the on_finalise method that is called at the end of each block and which calls check_rotate_session each time, and where check_rotate_session calls rotate_session.

Reference: https://hackmd.io/nr6kPD2sR4urmljtvHs0CQ?view#Session-Module

@ltfschoen
Copy link
Contributor Author

Closing as this is a question and the issue is too minor

liuchengxu pushed a commit to liuchengxu/substrate that referenced this issue May 31, 2023
…mits

Adjust networking parameters for DSN.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant