mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-08 00:34:37 +00:00
Merge pull request #3050 from mcdee/withdrawal-add-validator
Add validator_index to Withdrawal
This commit is contained in:
commit
46e4473cb4
@ -110,6 +110,7 @@ We define the following Python custom types for type hinting and readability:
|
|||||||
```python
|
```python
|
||||||
class Withdrawal(Container):
|
class Withdrawal(Container):
|
||||||
index: WithdrawalIndex
|
index: WithdrawalIndex
|
||||||
|
validator_index: ValidatorIndex
|
||||||
address: ExecutionAddress
|
address: ExecutionAddress
|
||||||
amount: Gwei
|
amount: Gwei
|
||||||
```
|
```
|
||||||
@ -258,6 +259,7 @@ def withdraw_balance(state: BeaconState, validator_index: ValidatorIndex, amount
|
|||||||
# Create a corresponding withdrawal receipt
|
# Create a corresponding withdrawal receipt
|
||||||
withdrawal = Withdrawal(
|
withdrawal = Withdrawal(
|
||||||
index=state.next_withdrawal_index,
|
index=state.next_withdrawal_index,
|
||||||
|
validator_index=validator_index,
|
||||||
address=ExecutionAddress(state.validators[validator_index].withdrawal_credentials[12:]),
|
address=ExecutionAddress(state.validators[validator_index].withdrawal_credentials[12:]),
|
||||||
amount=amount,
|
amount=amount,
|
||||||
)
|
)
|
||||||
|
@ -9,10 +9,11 @@ from eth2spec.test.helpers.state import next_slot
|
|||||||
|
|
||||||
def prepare_withdrawal_queue(spec, state, num_withdrawals):
|
def prepare_withdrawal_queue(spec, state, num_withdrawals):
|
||||||
pre_queue_len = len(state.withdrawal_queue)
|
pre_queue_len = len(state.withdrawal_queue)
|
||||||
|
validator_len = len(state.validators)
|
||||||
for i in range(num_withdrawals):
|
for i in range(num_withdrawals):
|
||||||
withdrawal = spec.Withdrawal(
|
withdrawal = spec.Withdrawal(
|
||||||
index=i + 5,
|
index=i + 5,
|
||||||
|
validator_index=(i + 1000) % validator_len,
|
||||||
address=b'\x42' * 20,
|
address=b'\x42' * 20,
|
||||||
amount=200000 + i,
|
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)
|
execution_payload = build_empty_execution_payload(spec, state)
|
||||||
withdrawal = spec.Withdrawal(
|
withdrawal = spec.Withdrawal(
|
||||||
index=0,
|
index=0,
|
||||||
|
validator_index=0,
|
||||||
address=b'\x30' * 20,
|
address=b'\x30' * 20,
|
||||||
amount=420,
|
amount=420,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user