|
54 | 54 | T-2 (stake_t_2) is used for the stake in clock calculations. |
55 | 55 | T-1 (stake_t_1) is used for the stake in Tower's threshold switch checks. |
56 | 56 | - rewards: this information is only used at the epoch boundary. |
57 | | -*/ |
| 57 | +
|
| 58 | + NOTE: The leader schedule epoch is almost always equal to the current |
| 59 | + epoch + 1. |
| 60 | + TODO: highlight the cases where this is not possible. |
| 61 | +
|
| 62 | + In the agave client, each bank holds its own epoch stakes (agave |
| 63 | + equivalent of vote_states). These are keyed by leader schedule epoch |
| 64 | + (which is almost always equal to epoch + 1). Old entries are removed |
| 65 | + and new entries are inserted at the epoch boundary. When we use the |
| 66 | + epoch stakes for consensus and for clock timestamp calculations, we |
| 67 | + query the epoch stakes by the current epoch we are executing in. |
| 68 | +
|
| 69 | + When we cross from Epoch E-1 to E, we compute our stakes assuming |
| 70 | + we are in E. At this point, because we are in epoch E, this means |
| 71 | + that the leader schedule epoch is E+1 so an epoch_stakes entry for |
| 72 | + epoch E+1 is inserted into epoch_stakes. |
| 73 | +
|
| 74 | + After we cross the boundary, in epoch E, we use the epoch stakes as |
| 75 | + keyed by epoch E for clock/consensus/leader schedule calculations. |
| 76 | + The stakes keyed by epoch E are actually the ones calculated at the |
| 77 | + boundary between epoch E-2 and E-1 since that's when the leader |
| 78 | + schedule epoch is E. Similiarly, when we are in epoch E+1 we use the |
| 79 | + stakes caclulated between epoch E-1 and E since that's when the leader |
| 80 | + schedule epoch is E+1. |
| 81 | +
|
| 82 | + The firedancer naming of vote states is instead done by reference to |
| 83 | + the epoch boundary that the stakes were calculated in. If we are |
| 84 | + currently in epoch E, we use the vote states calculated at the end of |
| 85 | + two epochs ago (E-2 -> E-1), hence vote_states_prev_prev. We store |
| 86 | + the vote states calculated at the end of the previous epoch |
| 87 | + (E-1 -> E) as vote_states_prev. This is also how we cache the stake |
| 88 | + values in the current vote states which are continually updated. */ |
58 | 89 |
|
59 | 90 | #define FD_VOTE_STATES_ALIGN (128UL) |
60 | 91 |
|
|
0 commit comments