From 493b16902276c44bcda1e6cf26ff38ec7d92919e Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Tue, 22 Mar 2022 07:55:45 -0600 Subject: [PATCH] refine naming for withdrawals --- specs/capella/beacon-chain.md | 10 +++++----- specs/capella/fork.md | 2 +- .../epoch_processing/test_process_full_withdrawals.py | 2 +- tests/core/pyspec/eth2spec/test/helpers/genesis.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/specs/capella/beacon-chain.md b/specs/capella/beacon-chain.md index e912f608e..c7b4fe897 100644 --- a/specs/capella/beacon-chain.md +++ b/specs/capella/beacon-chain.md @@ -61,7 +61,7 @@ class Validator(Container): activation_epoch: Epoch exit_epoch: Epoch withdrawable_epoch: Epoch # When validator can withdraw funds - withdrawn_epoch: Epoch # [New in Capella] + fully_withdrawn_epoch: Epoch # [New in Capella] ``` #### `BeaconState` @@ -173,7 +173,7 @@ class Withdrawal(Container): #### `withdraw` ```python -def withdraw(state: BeaconState, index: ValidatorIndex, amount: Gwei) -> None: +def withdraw_balance(state: BeaconState, index: ValidatorIndex, amount: Gwei) -> None: # Decrease the validator's balance decrease_balance(state, index, amount) # Create a corresponding withdrawal receipt @@ -196,7 +196,7 @@ def is_fully_withdrawable_validator(validator: Validator, epoch: Epoch) -> bool: Check if ``validator`` is fully withdrawable. """ is_eth1_withdrawal_prefix = validator.withdrawal_credentials[0:1] == ETH1_ADDRESS_WITHDRAWAL_PREFIX - return is_eth1_withdrawal_prefix and validator.withdrawable_epoch <= epoch < validator.withdrawn_epoch + return is_eth1_withdrawal_prefix and validator.withdrawable_epoch <= epoch < validator.fully_withdrawn_epoch ``` ## Beacon chain state transition function @@ -230,8 +230,8 @@ def process_full_withdrawals(state: BeaconState) -> None: for index, validator in enumerate(state.validators): if is_fully_withdrawable_validator(validator, current_epoch): # TODO, consider the zero-balance case - withdraw(state, ValidatorIndex(index), state.balances[index]) - validator.withdrawn_epoch = current_epoch + withdraw_balance(state, ValidatorIndex(index), state.balances[index]) + validator.fully_withdrawn_epoch = current_epoch ``` ### Block processing diff --git a/specs/capella/fork.md b/specs/capella/fork.md index 8585eddf4..c0363727d 100644 --- a/specs/capella/fork.md +++ b/specs/capella/fork.md @@ -97,7 +97,7 @@ def upgrade_to_capella(pre: bellatrix.BeaconState) -> BeaconState: activation_epoch=pre_validator.activation_epoch, exit_epoch=pre_validator.exit_epoch, withdrawable_epoch=pre_validator.withdrawable_epoch, - withdrawn_epoch=FAR_FUTURE_EPOCH, + fully_withdrawn_epoch=FAR_FUTURE_EPOCH, ) post.validators.append(post_validator) diff --git a/tests/core/pyspec/eth2spec/test/capella/epoch_processing/test_process_full_withdrawals.py b/tests/core/pyspec/eth2spec/test/capella/epoch_processing/test_process_full_withdrawals.py index 64aba5f6d..305f6e1ba 100644 --- a/tests/core/pyspec/eth2spec/test/capella/epoch_processing/test_process_full_withdrawals.py +++ b/tests/core/pyspec/eth2spec/test/capella/epoch_processing/test_process_full_withdrawals.py @@ -31,7 +31,7 @@ def run_process_full_withdrawals(spec, state, num_expected_withdrawals=None): for index in to_be_withdrawn_indices: validator = state.validators[index] - assert validator.withdrawn_epoch == spec.get_current_epoch(state) + assert validator.fully_withdrawn_epoch == spec.get_current_epoch(state) assert state.balances[index] == 0 assert len(state.withdrawals_queue) == len(pre_withdrawals_queue) + num_expected_withdrawals diff --git a/tests/core/pyspec/eth2spec/test/helpers/genesis.py b/tests/core/pyspec/eth2spec/test/helpers/genesis.py index e92d3ead9..1ca408598 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/genesis.py +++ b/tests/core/pyspec/eth2spec/test/helpers/genesis.py @@ -20,7 +20,7 @@ def build_mock_validator(spec, i: int, balance: int): ) if spec.fork not in FORKS_BEFORE_CAPELLA: - validator.withdrawn_epoch = spec.FAR_FUTURE_EPOCH + validator.fully_withdrawn_epoch = spec.FAR_FUTURE_EPOCH return validator