Skip to content

Commit

Permalink
rename to latest_withdrawal_validator_index
Browse files Browse the repository at this point in the history
  • Loading branch information
potuz committed Nov 3, 2022
1 parent b530dc0 commit 6e913ec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions specs/capella/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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`
Expand Down
3 changes: 2 additions & 1 deletion specs/capella/fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6e913ec

Please sign in to comment.