The delegation cycle comprises four (4) epochs:
The cycle starts when the stakeholder delegates his stake to a stake pool. This involves the creation of a Delegation Certificate that is then embedded in a transaction and registered in the blockchain. In our example below, this happens at any slot of Epoch N.
Then, the protocol captures a stake snapshot (stakedist) at the last slot of Epoch N, recording among other things, 3 important pieces of information:
- The balance of each stake key registered in the blockchain,
- To which stake pool each stake key is delegated,
- The parameters (pool cost, margin, pledge, etc) that each stake pool has set.
This snapshot is then used at the end of Epoch N+1 to randomly select the slot leaders for Epoch N+2. This process is the essence of Ouroboros as a Proof-of-Stake consensus algorithm: the bigger the stake, the more chances to be slot leader.
During Epoch N+2 the stake pools produce the blocks they are entitled to as per the slot leader election. Naturally, stake pools that control more stake will be entitled to more blocks.
In the transition between Epoch N+2 and Epoch N+3, a new snapshot registers the rewards collected. And the protocol uses the stake distribution recorded at the end of Epoch N to calculate how much of the rewards belongs to each stake key,
Finally, at the transition between Epoch N+3 and Epoch N+4 the protocol distributes the rewards to all stake keys. Which show up in Daedalus Shelley wallets at the very start of Epoch N+4 and credited to the wallet's balance and will count as part of the stake for the snapshot to be taken at the last slot of Epoch N+4