|
53 | 53 | - [New `get_balance_churn_limit`](#new-get_balance_churn_limit) |
54 | 54 | - [New `get_activation_exit_churn_limit`](#new-get_activation_exit_churn_limit) |
55 | 55 | - [New `get_consolidation_churn_limit`](#new-get_consolidation_churn_limit) |
56 | | - - [New `get_active_balance`](#new-get_active_balance) |
57 | 56 | - [New `get_pending_balance_to_withdraw`](#new-get_pending_balance_to_withdraw) |
58 | 57 | - [Modified `get_attesting_indices`](#modified-get_attesting_indices) |
59 | 58 | - [Modified `get_next_sync_committee_indices`](#modified-get_next_sync_committee_indices) |
@@ -539,14 +538,6 @@ def get_consolidation_churn_limit(state: BeaconState) -> Gwei: |
539 | 538 | return get_balance_churn_limit(state) - get_activation_exit_churn_limit(state) |
540 | 539 | ``` |
541 | 540 |
|
542 | | -#### New `get_active_balance` |
543 | | - |
544 | | -```python |
545 | | -def get_active_balance(state: BeaconState, validator_index: ValidatorIndex) -> Gwei: |
546 | | - max_effective_balance = get_max_effective_balance(state.validators[validator_index]) |
547 | | - return min(state.balances[validator_index], max_effective_balance) |
548 | | -``` |
549 | | - |
550 | 541 | #### New `get_pending_balance_to_withdraw` |
551 | 542 |
|
552 | 543 | ```python |
@@ -884,10 +875,14 @@ def process_pending_consolidations(state: BeaconState) -> None: |
884 | 875 |
|
885 | 876 | # Churn any target excess active balance of target and raise its max |
886 | 877 | switch_to_compounding_validator(state, pending_consolidation.target_index) |
| 878 | + |
| 879 | + # Calculate the consolidated balance |
| 880 | + max_effective_balance = get_max_effective_balance(source_validator) |
| 881 | + source_effective_balance = min(state.balances[pending_consolidation.source_index], max_effective_balance) |
| 882 | + |
887 | 883 | # Move active balance to target. Excess balance is withdrawable. |
888 | | - active_balance = get_active_balance(state, pending_consolidation.source_index) |
889 | | - decrease_balance(state, pending_consolidation.source_index, active_balance) |
890 | | - increase_balance(state, pending_consolidation.target_index, active_balance) |
| 884 | + decrease_balance(state, pending_consolidation.source_index, source_effective_balance) |
| 885 | + increase_balance(state, pending_consolidation.target_index, source_effective_balance) |
891 | 886 | next_pending_consolidation += 1 |
892 | 887 |
|
893 | 888 | state.pending_consolidations = state.pending_consolidations[next_pending_consolidation:] |
|
0 commit comments