Merge pull request #3679 from ralexstokes/electra/restore-partial-withdrawals-handling

Electra:EIP-7002/7251: clarify pending partial withdrawals handling
This commit is contained in:
Alex Stokes 2024-04-17 18:09:13 -06:00 committed by GitHub
commit 6845546f6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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)
@ -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
@ -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]

View File

@ -8,5 +8,8 @@ from eth2spec.test.context import (
@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
)