rename to latest_withdrawal_validator_index

This commit is contained in:
Potuz 2022-11-03 20:23:35 -03:00
parent b530dc09aa
commit 6e913ecbd2
3 changed files with 6 additions and 5 deletions

View File

@ -221,7 +221,7 @@ class BeaconState(Container):
latest_execution_payload_header: ExecutionPayloadHeader
# Withdrawals
next_withdrawal_index: WithdrawalIndex # [New in Capella]
last_withdrawal_validator_index: ValidatorIndex # [New in Capella]
latest_withdrawal_validator_index: ValidatorIndex # [New in Capella]
```
## Helpers
@ -286,7 +286,7 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None:
def get_expected_withdrawals(state: BeaconState) -> Sequence[Withdrawal]:
epoch = get_current_epoch(state)
withdrawal_index = state.next_withdrawal_index
index = state.last_withdrawal_validator_index
index = state.latest_withdrawal_validator_index
withdrawals: List[Withdrawal] = []
for _ in range(len(state.validators)):
index = ValidatorIndex((index + 1) % len(state.validators))
@ -325,7 +325,7 @@ def process_withdrawals(state: BeaconState, payload: ExecutionPayload) -> None:
decrease_balance(state, withdrawal.validator_index, withdrawal.amount)
if len(expected_withdrawals) > 0:
state.next_withdrawal_index = WithdrawalIndex(withdrawal.index + 1)
state.last_withdrawal_validator_index = withdrawal.validator_index
state.latest_withdrawal_validator_index = withdrawal.validator_index
```
#### Modified `process_execution_payload`

View File

@ -129,7 +129,8 @@ def upgrade_to_capella(pre: bellatrix.BeaconState) -> BeaconState:
# Execution-layer
latest_execution_payload_header=latest_execution_payload_header,
# Withdrawals
last_withdrawal_validator_index=ValidatorIndex(0),
next_withdrawal_index=WithdrawalIndex(0),
latest_withdrawal_validator_index=ValidatorIndex(0),
)
return post

View File

@ -745,7 +745,7 @@ def run_random_partial_withdrawals_test(spec, state, rng):
randomize_state(spec, state, rng)
num_validators = len(state.validators)
state.last_withdrawal_validator_index = rng.randint(0, num_validators - 1)
state.latest_withdrawal_validator_index = rng.randint(0, num_validators - 1)
num_partially_withdrawable = rng.randint(0, num_validators - 1)
partially_withdrawable_indices = rng.sample(range(num_validators), num_partially_withdrawable)