get_active_validator_indicesWe use current_epoch and previous_epoch when calling get_active_validator_indices in many places rather than using current_shuffling_epoch and previous_shuffling_epoch.
In some places, this functionality is equivalent either way, but the calls to get_active_validator_indices that use previous_epoch rather than previous_shuffling_epoch are incorrect.
For example:
get_previous_total_balance uses previous_epoch instead of previous_shuffling_epoch and so in many cases the total balance gathered here would be from the incorrect validator set.compute_normal_justification_and_finalization_deltas we iterate through the previous validator set but are using previous_epoch. This can causes a mismatch between the v-set iterated through and the actual v-set attesting for that previous epoch.I suggest that we use current_shuffling_epoch and previous_shuffling_epoch throughout when calling `get_active_validator_indices
latest_active_index_rootsA related issue...
The way we are setting the latest_active_index_roots means that often the root store in the state cache is different from the actual active validator root.
In final updates we set latest_active_index_roots to be the active validator set for the epoch ACTIVE_EXIT_DELAY epochs in the future. Are we concerned that this isn't the _actual_ active validator set during that epoch given that the shuffling epoch could lag behind? In the extreme case when a registry change does not happen for more than LATEST_ACTIVE_INDEX_ROOTS_LENGTH, the state would not even have the correct active_index_root cached anymore.
previous_shuffling_epoch. Should we keep it?previous_shuffling_epoch just always equals previous_epoch, as shuffling happens every epoch. This _seems_ like it resolves all of these issues.closed due to #808 !
Most helpful comment
808 removes it because
previous_shuffling_epochjust always equalsprevious_epoch, as shuffling happens every epoch. This _seems_ like it resolves all of these issues.