diff --git a/specs/_features/reuse_indexes/beacon-chain.md b/specs/_features/reuse_indexes/beacon-chain.md index 3efa0c869..5ec08ed19 100644 --- a/specs/_features/reuse_indexes/beacon-chain.md +++ b/specs/_features/reuse_indexes/beacon-chain.md @@ -1,4 +1,4 @@ -# Reuse indexes -- The Beacon Chain +# Reuse indices -- The Beacon Chain ## Table of contents @@ -31,7 +31,7 @@ This is the beacon chain specification to assign new deposits to existing valida | Name | Value | Unit | Duration | | - | - | - | -| `REUSE_VALIDATOR_INDEX_DELAY` | `uint64(2**16)` (= 65,536) | epochs | ~1 year | +| `REUSE_VALIDATOR_INDEX_DELAY` | `uint64(2**16)` (= 65,536) | epochs | ~0.8 year | ## Helper functions @@ -45,8 +45,7 @@ def is_reusable_validator(validator: Validator, balance: Gwei, epoch: Epoch) -> Check if ``validator`` index can be re-assigned to a new deposit. """ return ( - epoch > REUSE_VALIDATOR_INDEX_DELAY - and validator.withdrawable_epoch < epoch - REUSE_VALIDATOR_INDEX_DELAY + epoch > validator.withdrawable_epoch + REUSE_VALIDATOR_INDEX_DELAY and balance == 0 ) ``` @@ -58,9 +57,9 @@ def is_reusable_validator(validator: Validator, balance: Gwei, epoch: Epoch) -> #### Modified `get_index_for_new_validator` ```python -def get_index_for_new_validator(state: BeaconState) -> int: +def get_index_for_new_validator(state: BeaconState) -> ValidatorIndex: for index, validator in enumerate(state.validators): if is_reusable_validator(validator, state.balances[index], get_current_epoch(state)): - return index - return len(state.validators) + return ValidatorIndex(index) + return ValidatorIndex(len(state.validators)) ``` diff --git a/specs/altair/beacon-chain.md b/specs/altair/beacon-chain.md index 9d7c8180e..df65d984c 100644 --- a/specs/altair/beacon-chain.md +++ b/specs/altair/beacon-chain.md @@ -525,11 +525,11 @@ def apply_deposit(state: BeaconState, increase_balance(state, index, amount) -def get_index_for_new_validator(state: BeaconState) -> int: - return len(state.validators) +def get_index_for_new_validator(state: BeaconState) -> ValidatorIndex: + return ValidatorIndex(len(state.validators)) -def update_or_append_to_list(list: List, index: int, value: Any) -> None: +def update_or_append_to_list(list: List, index: ValidatorIndex, value: Any) -> None: if index == len(list): list.append(value) else: