Skip to content

Commit

Permalink
Merge pull request ethereum#3679 from ralexstokes/electra/restore-par…
Browse files Browse the repository at this point in the history
…tial-withdrawals-handling

Electra:EIP-7002/7251: clarify pending partial withdrawals handling
  • Loading branch information
ralexstokes authored Apr 18, 2024
2 parents b02be79 + 8213308 commit 6845546
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions presets/mainnet/electra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ MAX_CONSOLIDATIONS: 1
MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD: 8192
# 2**4 (= 16) withdrawal requests
MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD: 16

# Withdrawals processing
# ---------------------------------------------------------------
# 2**3 ( = 8) pending withdrawals
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 8
5 changes: 5 additions & 0 deletions presets/minimal/electra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ MAX_CONSOLIDATIONS: 1
MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD: 4
# [customized] 2**1 (= 2) withdrawal requests
MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD: 2

# Withdrawals processing
# ---------------------------------------------------------------
# 2**0 ( = 1) pending withdrawals
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 1
9 changes: 8 additions & 1 deletion specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- [State list lengths](#state-list-lengths)
- [Max operations per block](#max-operations-per-block)
- [Execution](#execution)
- [Withdrawals processing](#withdrawals-processing)
- [Configuration](#configuration)
- [Validator cycle](#validator-cycle)
- [Containers](#containers)
Expand Down Expand Up @@ -174,6 +175,12 @@ The following values are (non-configurable) constants used throughout the specif
| `MAX_ATTESTATIONS_ELECTRA` | `2**3` (= 8) | *[New in Electra:EIP7549]* |
| `MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD` | `uint64(2**4)` (= 16)| *[New in Electra:EIP7002]* Maximum number of execution layer withdrawal requests in each payload |

### Withdrawals processing

| Name | Value | Description |
| - | - | - |
| `MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP` | `uint64(2**3)` (= 8)| *[New in Electra:EIP7002]* Maximum number of pending partial withdrawals to process per payload |

## Configuration

### Validator cycle
Expand Down Expand Up @@ -881,7 +888,7 @@ def get_expected_withdrawals(state: BeaconState) -> Tuple[Sequence[Withdrawal],

# [New in Electra:EIP7251] Consume pending partial withdrawals
for withdrawal in state.pending_partial_withdrawals:
if withdrawal.withdrawable_epoch > epoch or len(withdrawals) == MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD:
if withdrawal.withdrawable_epoch > epoch or len(withdrawals) == MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP:
break

validator = state.validators[withdrawal.index]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
@with_electra_and_later
@spec_test
@single_phase
def test_withdrawals(spec):
assert spec.MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD < spec.MAX_WITHDRAWALS_PER_PAYLOAD
def test_processing_pending_partial_withdrawals(spec):
assert (
spec.MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP
< spec.MAX_WITHDRAWALS_PER_PAYLOAD
)

0 comments on commit 6845546

Please sign in to comment.