Address PR review
This commit is contained in:
parent
314b040fff
commit
f696b30608
|
@ -1,4 +1,4 @@
|
||||||
# Reuse indexes -- The Beacon Chain
|
# Reuse indices -- The Beacon Chain
|
||||||
|
|
||||||
## Table of contents
|
## Table of contents
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ This is the beacon chain specification to assign new deposits to existing valida
|
||||||
|
|
||||||
| Name | Value | Unit | Duration |
|
| 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
|
## 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.
|
Check if ``validator`` index can be re-assigned to a new deposit.
|
||||||
"""
|
"""
|
||||||
return (
|
return (
|
||||||
epoch > REUSE_VALIDATOR_INDEX_DELAY
|
epoch > validator.withdrawable_epoch + REUSE_VALIDATOR_INDEX_DELAY
|
||||||
and validator.withdrawable_epoch < epoch - REUSE_VALIDATOR_INDEX_DELAY
|
|
||||||
and balance == 0
|
and balance == 0
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
@ -58,9 +57,9 @@ def is_reusable_validator(validator: Validator, balance: Gwei, epoch: Epoch) ->
|
||||||
#### Modified `get_index_for_new_validator`
|
#### Modified `get_index_for_new_validator`
|
||||||
|
|
||||||
```python
|
```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):
|
for index, validator in enumerate(state.validators):
|
||||||
if is_reusable_validator(validator, state.balances[index], get_current_epoch(state)):
|
if is_reusable_validator(validator, state.balances[index], get_current_epoch(state)):
|
||||||
return index
|
return ValidatorIndex(index)
|
||||||
return len(state.validators)
|
return ValidatorIndex(len(state.validators))
|
||||||
```
|
```
|
||||||
|
|
|
@ -525,11 +525,11 @@ def apply_deposit(state: BeaconState,
|
||||||
increase_balance(state, index, amount)
|
increase_balance(state, index, amount)
|
||||||
|
|
||||||
|
|
||||||
def get_index_for_new_validator(state: BeaconState) -> int:
|
def get_index_for_new_validator(state: BeaconState) -> ValidatorIndex:
|
||||||
return len(state.validators)
|
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):
|
if index == len(list):
|
||||||
list.append(value)
|
list.append(value)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue