Skip to content

Commit

Permalink
Merge pull request #4075 from jtraglia/new-upgrade-to-electra-test
Browse files Browse the repository at this point in the history
Add fork test with inactive, compounding validator with excess balance
  • Loading branch information
jtraglia authored Jan 9, 2025
2 parents 141ad47 + 3fced09 commit 4808c8d
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,40 @@ def test_fork_has_compounding_withdrawal_credential(spec, phases, state):
)]


@with_phases(phases=[DENEB], other_phases=[ELECTRA])
@spec_test
@with_state
@with_meta_tags(ELECTRA_FORK_TEST_META_TAGS)
def test_fork_inactive_compounding_validator_with_excess_balance(spec, phases, state):
index = 0
post_spec = phases[ELECTRA]
validator = state.validators[index]

# set validator balance greater than min_activation_balance
state.balances[index] = post_spec.MIN_ACTIVATION_BALANCE + 1
# set validator as not active yet
validator.activation_epoch = spec.FAR_FUTURE_EPOCH
# set validator activation eligibility epoch to the latest finalized epoch
validator.activation_eligibility_epoch = state.finalized_checkpoint.epoch
# give the validator compounding withdrawal credentials
validator.withdrawal_credentials = post_spec.COMPOUNDING_WITHDRAWAL_PREFIX + validator.withdrawal_credentials[1:]

post_state = yield from run_fork_test(post_spec, state)

# the validator cannot be activated again
assert post_state.validators[index].activation_eligibility_epoch == spec.FAR_FUTURE_EPOCH
# the validator should now have a zero balance
assert post_state.balances[index] == 0
# there should be a single pending deposit for this validator
assert post_state.pending_deposits == [post_spec.PendingDeposit(
pubkey=validator.pubkey,
withdrawal_credentials=validator.withdrawal_credentials,
amount=state.balances[index],
signature=spec.bls.G2_POINT_AT_INFINITY,
slot=spec.GENESIS_SLOT,
)]


@with_phases(phases=[DENEB], other_phases=[ELECTRA])
@spec_test
@with_state
Expand Down

0 comments on commit 4808c8d

Please sign in to comment.