Skip to content

Commit

Permalink
Limit consolidating balance by validator.effective_balance
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalinin committed Dec 3, 2024
1 parent 85b4d00 commit d66ef16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -957,8 +957,8 @@ def process_pending_consolidations(state: BeaconState) -> None:
break

# Calculate the consolidated balance
max_effective_balance = get_max_effective_balance(source_validator)
source_effective_balance = min(state.balances[pending_consolidation.source_index], max_effective_balance)
source_effective_balance = min(
state.balances[pending_consolidation.source_index], source_validator.effective_balance)

# Move active balance to target. Excess balance is withdrawable.
decrease_balance(state, pending_consolidation.source_index, source_effective_balance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,12 @@ def test_pending_consolidation_compounding_creds(spec, state):

# Pending consolidation was successfully processed
expected_target_balance = (
state_before_consolidation.balances[source_index] + state_before_consolidation.balances[target_index]
spec.MIN_ACTIVATION_BALANCE + state_before_consolidation.balances[target_index]
)
assert state.balances[target_index] == expected_target_balance
# All source balance is active and moved to the target,
# because the source validator has compounding credentials
assert state.balances[source_index] == 0
assert state.balances[source_index] == state_before_consolidation.balances[source_index] - spec.MIN_ACTIVATION_BALANCE
assert state.pending_consolidations == []

# Pending balance deposit to the target is not created,
Expand Down Expand Up @@ -297,10 +297,10 @@ def test_pending_consolidation_with_pending_deposit(spec, state):

# Pending consolidation was successfully processed
expected_target_balance = (
state_before_consolidation.balances[source_index] + state_before_consolidation.balances[target_index]
spec.MIN_ACTIVATION_BALANCE + state_before_consolidation.balances[target_index]
)
assert state.balances[target_index] == expected_target_balance
assert state.balances[source_index] == 0
assert state.balances[source_index] == state_before_consolidation.balances[source_index] - spec.MIN_ACTIVATION_BALANCE
assert state.pending_consolidations == []

# Pending deposit to the source was not processed.
Expand Down

0 comments on commit d66ef16

Please sign in to comment.