The Tezos protocol does a lot of bookkeeping at the end of a cycle to manage its validator set. According to our own research and that of others we came up with a list of assumptions that suggest the following events happen in the order described below:
- balance updates are applied (like at every other block)
- a balance snapshot is taken (on mainnet with 4096 blocks per cycle this is snapshot index 15)
- seed nonces published in cycle
- a new random number generator seed is generated from these nonces (and previous state I assume)
- validators are slashed for not publishing seed nonces
- a snapshot index is selected for cycle
- baking and endorsing rights for cycle
N+6are generated based on the seed and a previous roll snapshot in
N-1at the selected index
- validator grace period is checked and unresponsive validators are deactivated
- frozen rewards, deposits and fees from cycle
- (when applicable) a finished voting period is closed, potentially updating quorum
- (when applicable) a new voting period is opened
- (when applicable) a snapshot of eligible voters and their rolls is taken
- (when applicable) a new protocol is activated and migrations are applied
From the perspective of an outside observer all these steps happen atomically. Only the final result that can be observed on the RPC level.
As there are subtle inter-dependencies between these steps knowing the exact order of events is essential to avoid confusion for downstream tools like payout libraries, indexers and possible more.
Q1: Is the order of events above correct? Q2: Are there any other steps I might have missed?