Skip to content

Commit cd92a89

Browse files
authored
In randomized tests, only do voluntary exit if no pending withdrawals (#4553)
Associated with: * #4531 Now that there are random pending withdrawals in the state, the function which adds random voluntary exits must be updated to not exit validators with pending withdrawals, which is disallowed via gossip & the protocol. This broke when generating reference tests.
1 parent fe5b388 commit cd92a89

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ def run(self) -> None:
285285
"specs": "specs",
286286
"sync": "sync",
287287
},
288-
packages=find_packages(where="tests/core/pyspec")
289-
+ ["configs", "presets", "specs", "presets", "sync"],
288+
packages=find_packages(where="tests/core/pyspec") + ["configs", "presets", "specs", "sync"],
290289
py_modules=["eth2spec"],
291290
cmdclass=commands,
292291
)

specs/electra/beacon-chain.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,6 @@ def process_voluntary_exit(state: BeaconState, signed_voluntary_exit: SignedVolu
16341634
assert get_current_epoch(state) >= validator.activation_epoch + SHARD_COMMITTEE_PERIOD
16351635
# [New in Electra:EIP7251]
16361636
# Only exit validator if it has no pending withdrawals in the queue
1637-
16381637
assert get_pending_balance_to_withdraw(state, voluntary_exit.validator_index) == 0
16391638
# Verify signature
16401639
domain = compute_domain(

tests/core/pyspec/eth2spec/test/helpers/multi_operations.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
)
88
from eth2spec.test.helpers.bls_to_execution_changes import get_signed_address_change
99
from eth2spec.test.helpers.deposits import build_deposit, deposit_from_context
10+
from eth2spec.test.helpers.forks import is_post_electra
1011
from eth2spec.test.helpers.keys import privkeys, pubkeys
1112
from eth2spec.test.helpers.proposer_slashings import get_valid_proposer_slashing
1213
from eth2spec.test.helpers.state import (
@@ -173,7 +174,11 @@ def _eligible_for_exit(spec, state, index):
173174

174175
not_exited = validator.exit_epoch == spec.FAR_FUTURE_EPOCH
175176

176-
return not_slashed and active_for_long_enough and not_exited
177+
no_pending_withdrawals = True
178+
if is_post_electra(spec):
179+
no_pending_withdrawals = spec.get_pending_balance_to_withdraw(state, index) == 0
180+
181+
return not_slashed and active_for_long_enough and not_exited and no_pending_withdrawals
177182

178183

179184
def get_random_voluntary_exits(spec, state, to_be_slashed_indices, rng):

0 commit comments

Comments
 (0)