9

When reasoning about a particular problem, I realized that I don't know how session changes work with chain reversions. To my knowledge session changes are based on time/slots and not on blocks. So let's assume the following chain:


                              Session N                          N + 1
------------------------------^--|--------------------------------!|------------------------------------
                

A reversion is triggered at ! back to ^, so the new chain looks like this:


       Still session N - 1                        
------------------------------^

We are back to session N - 1, but given that we can not revert time, we will change session on the very next block being produced, but how? Time wise we will already be in session N + 1. So what happens? Do we lose a session? Will we jump somehow to session N + 1 immediately? Will we have two session changes in direct sequence. (^- block will be session N and ^-- will be already session N + 1?)

Put differently: Are we catching up or skip or something else entirely?

1
  • Can you clarify which type of session change you are asking about? Are you talking about the validators (those that are able to author / check blocks)? Or about aura slots? Commented May 18, 2023 at 19:26

1 Answer 1

6

As you already said correctly, sessions are based on time. There is no logic to catch up or similar, we will just skip the sessions. For quite some time this would have been problematic for chains using BABE. They would have seen the famous "unexpected epoch change" error. However, the latest version of BABE also supports to skip sessions/epochs without rendering the chain invalid.

5
  • So in the example above, we would conceptually switch to session N+1, but we would still name it N (numbers stay consecutive - no gaps) and it would also look like the previously existing session N: We would use the same randomness, we would arrive at the same validator set, etc ... Thanks!
    – eskimor
    Commented May 22, 2023 at 8:14
  • 1
    Yeah the session index will just increment consecutively. However, BABE will "skip epochs" by calculating the epoch index based on the slot: github.com/paritytech/substrate/blob/…
    – bkchr
    Commented May 22, 2023 at 11:09
  • Nice, that comment explains it all. :-) Thank you!
    – eskimor
    Commented May 23, 2023 at 12:29
  • @bkchr, i used this commit for testing the epoch change, i didn't get unexpected epoch change but was also not able to do any transactions after an epoch is skipped any comments on this? github.com/paritytech/substrate/blob/… Commented Jun 13, 2023 at 11:45
  • Your post doesn't contain enough information. If you have an issue, you should open a github issue, but please include all the relevant info to reproduce it.
    – bkchr
    Commented Jun 13, 2023 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.