diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 3f92e8b6f..352fccf76 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1320,17 +1320,18 @@ def initiate_validator_exit(state: BeaconState, index: ValidatorIndex) -> None: if validator.exit_epoch != FAR_FUTURE_EPOCH: return - # Compute exit queue parameters - exit_queue_epoch = sorted([validator.exit_epoch for validator in state.validator_registry if - validator.exit_epoch != FAR_FUTURE_EPOCH - ].append(GENESIS_EPOCH), key=lambda index: state.validator_registry[index].exit_epoch)[-1] + # Compute exit queue parameters (pad with GENESIS_EPOCH in case empty) + exit_queue_epoch = sorted([ + validator.exit_epoch for validator in state.validator_registry + if validator.exit_epoch != FAR_FUTURE_EPOCH + ] + [GENESIS_EPOCH])[-1] delayed_activation_exit_epoch = get_delayed_activation_exit_epoch(get_current_epoch(state)) if exit_queue_epoch < delayed_activation_exit_epoch: exit_queue_epoch = delayed_activation_exit_epoch exit_queue_churn = len([v for v in state.validator_registry if v.exit_epoch == exit_queue_epoch]) - if exit_queue_churn > get_churn_limit(state): + if exit_queue_churn >= get_churn_limit(state): exit_queue_epoch += 1 # Set validator exit epoch and withdrawable epoch diff --git a/tests/phase0/block_processing/test_voluntary_exit.py b/tests/phase0/block_processing/test_voluntary_exit.py index b8af85a97..eb01c2a8a 100644 --- a/tests/phase0/block_processing/test_voluntary_exit.py +++ b/tests/phase0/block_processing/test_voluntary_exit.py @@ -78,10 +78,6 @@ def test_success_exit_queue(state): ) pre_state, post_state = run_voluntary_exit_processing(post_state, voluntary_exit) - assert post_state.exit_queue_churn > pre_state.exit_queue_churn - assert post_state.exit_queue_epoch >= pre_state.exit_queue_epoch - - assert post_state.exit_queue_epoch == pre_state.exit_queue_epoch # exit an additional validator validator_index = get_active_validator_indices(state, current_epoch)[-1] @@ -99,9 +95,6 @@ def test_success_exit_queue(state): post_state.validator_registry[validator_index].exit_epoch == post_state.validator_registry[initial_indices[0]].exit_epoch + 1 ) - assert post_state.exit_queue_churn == 0 - assert post_state.exit_queue_epoch == pre_state.exit_queue_epoch + 1 - return pre_state, voluntary_exit, post_state diff --git a/tests/phase0/test_sanity.py b/tests/phase0/test_sanity.py index f9e62620c..08c7610c0 100644 --- a/tests/phase0/test_sanity.py +++ b/tests/phase0/test_sanity.py @@ -346,8 +346,6 @@ def test_no_exit_churn_too_long_since_change(state): state_transition(post_state, block) assert post_state.validator_registry[validator_index].exit_epoch == spec.FAR_FUTURE_EPOCH - assert post_state.exit_queue_churn == pre_state.exit_queue_churn - assert post_state.exit_queue_epoch == pre_state.exit_queue_epoch return pre_state, [block], post_state