Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Withdrawals push #2836

Merged
merged 39 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c81c27e
Merge pull request #2733 from ethereum/dev
djrtwo Nov 24, 2021
4f24fe4
basic capella withdrawal in place
djrtwo Dec 1, 2021
155863d
add capella to circleci build
djrtwo Dec 1, 2021
b7308e0
remove capella built files
djrtwo Dec 1, 2021
78d5583
fix tsts
djrtwo Dec 1, 2021
ca74094
Apply suggestions from code review
djrtwo Dec 2, 2021
3024dc8
add withdrawn_epoch to capella validators
djrtwo Dec 2, 2021
2010994
add capella circleci workflow
djrtwo Dec 2, 2021
180abb9
clean up some withdrawal logic and add tests
djrtwo Dec 2, 2021
6969c8a
lint
djrtwo Dec 2, 2021
59d4821
fix forkchoice tests
djrtwo Dec 2, 2021
365b1f4
remove unnecessary definitions from CapellaSpecBuilder
djrtwo Dec 2, 2021
93c933c
Merge pull request #2771 from ethereum/dev
hwwhww Dec 22, 2021
180855b
Merge pull request #2778 from ethereum/dev
hwwhww Dec 24, 2021
171a9cc
Resolve conflicts
hwwhww Dec 27, 2021
3b474eb
Add capella to test coverage report target
hwwhww Dec 27, 2021
cbf314c
Move capella fork tests to the correct folder and resolve conflicts
hwwhww Dec 27, 2021
e80a142
modified withdrawals for push
djrtwo Feb 23, 2022
2026103
Merge branch 'dev' into withdrawals-push
djrtwo Feb 23, 2022
e49f73c
fix tx type
djrtwo Feb 23, 2022
eef2dbb
Ensure that the SSZ classes are ordered
hwwhww Feb 24, 2022
0b89c7f
Update specs/capella/beacon-chain.md
ralexstokes Feb 24, 2022
fb90451
Merge pull request #2837 from ethereum/fix-build_spec
djrtwo Feb 24, 2022
d513f5c
fix lint
djrtwo Feb 24, 2022
f5dab5b
fix fully withdrawal tests
djrtwo Feb 24, 2022
0a55f06
fix execution paylaod tests
djrtwo Feb 24, 2022
e1b9cf9
add withdrawal index to wihdrawal transaction
djrtwo Mar 3, 2022
507f550
Merge branch 'dev' into withdrawals-push
djrtwo Mar 10, 2022
3dd83cf
minor withdrawals renamings
djrtwo Mar 10, 2022
255e942
add validator and fork-choice mods for withdrawals in capella
djrtwo Mar 16, 2022
36aae1d
add tests for process_withdrawals
djrtwo Mar 16, 2022
493b169
refine naming for withdrawals
djrtwo Mar 22, 2022
9a8ff4f
topo sort
djrtwo Mar 22, 2022
03f9503
Apply suggestions from code review
djrtwo Mar 22, 2022
43ce98b
Merge branch 'withdrawals-push' of github.com:ethereum/eth2.0-specs i…
djrtwo Mar 22, 2022
c10d219
Merge branch 'dev' into withdrawals-push
djrtwo Mar 22, 2022
a2db446
build
djrtwo Mar 22, 2022
b469593
toc
djrtwo Mar 22, 2022
8a388f2
toc
hwwhww Mar 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refine naming for withdrawals
  • Loading branch information
djrtwo committed Mar 22, 2022
commit 493b16902276c44bcda1e6cf26ff38ec7d92919e
10 changes: 5 additions & 5 deletions specs/capella/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Validator(Container):
activation_epoch: Epoch
exit_epoch: Epoch
withdrawable_epoch: Epoch # When validator can withdraw funds
withdrawn_epoch: Epoch # [New in Capella]
fully_withdrawn_epoch: Epoch # [New in Capella]
```

#### `BeaconState`
Expand Down Expand Up @@ -173,7 +173,7 @@ class Withdrawal(Container):
#### `withdraw`

```python
def withdraw(state: BeaconState, index: ValidatorIndex, amount: Gwei) -> None:
def withdraw_balance(state: BeaconState, index: ValidatorIndex, amount: Gwei) -> None:
# Decrease the validator's balance
decrease_balance(state, index, amount)
# Create a corresponding withdrawal receipt
Expand All @@ -196,7 +196,7 @@ def is_fully_withdrawable_validator(validator: Validator, epoch: Epoch) -> bool:
Check if ``validator`` is fully withdrawable.
"""
is_eth1_withdrawal_prefix = validator.withdrawal_credentials[0:1] == ETH1_ADDRESS_WITHDRAWAL_PREFIX
return is_eth1_withdrawal_prefix and validator.withdrawable_epoch <= epoch < validator.withdrawn_epoch
return is_eth1_withdrawal_prefix and validator.withdrawable_epoch <= epoch < validator.fully_withdrawn_epoch
```

## Beacon chain state transition function
Expand Down Expand Up @@ -230,8 +230,8 @@ def process_full_withdrawals(state: BeaconState) -> None:
for index, validator in enumerate(state.validators):
if is_fully_withdrawable_validator(validator, current_epoch):
# TODO, consider the zero-balance case
withdraw(state, ValidatorIndex(index), state.balances[index])
validator.withdrawn_epoch = current_epoch
withdraw_balance(state, ValidatorIndex(index), state.balances[index])
validator.fully_withdrawn_epoch = current_epoch
```

### Block processing
Expand Down
2 changes: 1 addition & 1 deletion specs/capella/fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def upgrade_to_capella(pre: bellatrix.BeaconState) -> BeaconState:
activation_epoch=pre_validator.activation_epoch,
exit_epoch=pre_validator.exit_epoch,
withdrawable_epoch=pre_validator.withdrawable_epoch,
withdrawn_epoch=FAR_FUTURE_EPOCH,
fully_withdrawn_epoch=FAR_FUTURE_EPOCH,
)
post.validators.append(post_validator)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def run_process_full_withdrawals(spec, state, num_expected_withdrawals=None):

for index in to_be_withdrawn_indices:
validator = state.validators[index]
assert validator.withdrawn_epoch == spec.get_current_epoch(state)
assert validator.fully_withdrawn_epoch == spec.get_current_epoch(state)
assert state.balances[index] == 0

assert len(state.withdrawals_queue) == len(pre_withdrawals_queue) + num_expected_withdrawals
Expand Down
2 changes: 1 addition & 1 deletion tests/core/pyspec/eth2spec/test/helpers/genesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def build_mock_validator(spec, i: int, balance: int):
)

if spec.fork not in FORKS_BEFORE_CAPELLA:
validator.withdrawn_epoch = spec.FAR_FUTURE_EPOCH
validator.fully_withdrawn_epoch = spec.FAR_FUTURE_EPOCH

return validator

Expand Down