name change and increment operator

This commit is contained in:
Potuz 2022-11-04 07:20:26 -03:00
parent 6e913ecbd2
commit 22f803a038
1 changed files with 8 additions and 8 deletions

View File

@ -286,28 +286,28 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None:
def get_expected_withdrawals(state: BeaconState) -> Sequence[Withdrawal]: def get_expected_withdrawals(state: BeaconState) -> Sequence[Withdrawal]:
epoch = get_current_epoch(state) epoch = get_current_epoch(state)
withdrawal_index = state.next_withdrawal_index withdrawal_index = state.next_withdrawal_index
index = state.latest_withdrawal_validator_index validator_index = state.latest_withdrawal_validator_index
withdrawals: List[Withdrawal] = [] withdrawals: List[Withdrawal] = []
for _ in range(len(state.validators)): for _ in range(len(state.validators)):
index = ValidatorIndex((index + 1) % len(state.validators)) validator_index = ValidatorIndex((validator_index + 1) % len(state.validators))
val = state.validators[index] val = state.validators[validator_index]
balance = state.balances[index] balance = state.balances[validator_index]
if is_fully_withdrawable_validator(val, balance, epoch): if is_fully_withdrawable_validator(val, balance, epoch):
withdrawals.append(Withdrawal( withdrawals.append(Withdrawal(
index=withdrawal_index, index=withdrawal_index,
validator_index=index, validator_index=validator_index,
address=ExecutionAddress(val.withdrawal_credentials[12:]), address=ExecutionAddress(val.withdrawal_credentials[12:]),
amount=balance, amount=balance,
)) ))
withdrawal_index = WithdrawalIndex(withdrawal_index + 1) withdrawal_index += 1
elif is_partially_withdrawable_validator(val, balance): elif is_partially_withdrawable_validator(val, balance):
withdrawals.append(Withdrawal( withdrawals.append(Withdrawal(
index=withdrawal_index, index=withdrawal_index,
validator_index=index, validator_index=validator_index,
address=ExecutionAddress(val.withdrawal_credentials[12:]), address=ExecutionAddress(val.withdrawal_credentials[12:]),
amount=balance - MAX_EFFECTIVE_BALANCE, amount=balance - MAX_EFFECTIVE_BALANCE,
)) ))
withdrawal_index = WithdrawalIndex(withdrawal_index + 1) withdrawal_index += 1
if len(withdrawals) == MAX_WITHDRAWALS_PER_PAYLOAD: if len(withdrawals) == MAX_WITHDRAWALS_PER_PAYLOAD:
break break
return withdrawals return withdrawals