Add validator_index to Withdrawal.

This commit is contained in:
Jim McDonald 2022-10-18 15:35:06 +01:00
parent d8e74090cf
commit 0345b2284a
No known key found for this signature in database
GPG Key ID: 89CEB61B2AD2A5E7
2 changed files with 4 additions and 0 deletions

View File

@ -111,6 +111,7 @@ We define the following Python custom types for type hinting and readability:
```python
class Withdrawal(Container):
index: WithdrawalIndex
validator_index: ValidatorIndex
address: ExecutionAddress
amount: Gwei
```
@ -275,6 +276,7 @@ def withdraw_balance(state: BeaconState, validator_index: ValidatorIndex, amount
# Create a corresponding withdrawal receipt
withdrawal = Withdrawal(
index=state.next_withdrawal_index,
validator_index=validator_index,
address=ExecutionAddress(state.validators[validator_index].withdrawal_credentials[12:]),
amount=amount,
)

View File

@ -13,6 +13,7 @@ def prepare_withdrawal_queue(spec, state, num_withdrawals):
for i in range(num_withdrawals):
withdrawal = spec.Withdrawal(
index=i + 5,
validator_index=i + 1000,
address=b'\x42' * 20,
amount=200000 + i,
)
@ -110,6 +111,7 @@ def test_fail_empty_queue_non_empty_withdrawals(spec, state):
execution_payload = build_empty_execution_payload(spec, state)
withdrawal = spec.Withdrawal(
index=0,
validator_index=0,
address=b'\x30' * 20,
amount=420,
)