diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index aa9fc1e7f..a834a1cde 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -2089,7 +2089,7 @@ def update_validator_registry(state: BeaconState) -> None: activate_validator(state, index, is_genesis=False) # Exit validators within the allowable balance churn - if state.current_epoch < state.validator_registry_update_epoch + LATEST_SLASHED_EXIT_LENGTH: + if current_epoch < state.validator_registry_update_epoch + LATEST_SLASHED_EXIT_LENGTH: balance_churn = ( state.latest_slashed_balances[state.validator_registry_update_epoch % LATEST_SLASHED_EXIT_LENGTH] - state.latest_slashed_balances[current_epoch % LATEST_SLASHED_EXIT_LENGTH] diff --git a/tests/phase0/test_sanity.py b/tests/phase0/test_sanity.py index d1811cd00..56c1c1a64 100644 --- a/tests/phase0/test_sanity.py +++ b/tests/phase0/test_sanity.py @@ -316,12 +316,18 @@ def test_attestation(state, pubkeys, privkeys): def test_voluntary_exit(state, pubkeys, privkeys): pre_state = deepcopy(state) - validator_index = get_active_validator_indices(pre_state.validator_registry, get_current_epoch(pre_state))[-1] + validator_index = get_active_validator_indices( + pre_state.validator_registry, + get_current_epoch(pre_state) + )[-1] # move state forward PERSISTENT_COMMITTEE_PERIOD epochs to allow for exit pre_state.slot += spec.PERSISTENT_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH # artificially trigger registry update at next epoch transition - pre_state.validator_registry_update_epoch -= 1 + pre_state.finalized_epoch = get_current_epoch(pre_state) - 1 + for crosslink in pre_state.latest_crosslinks: + crosslink.epoch = pre_state.finalized_epoch + pre_state.validator_registry_update_epoch = pre_state.finalized_epoch - 1 post_state = deepcopy(pre_state)