Skip to content

Commit f0669ad

Browse files
authored
Merge pull request #575 from lidofinance/feat/new-max-effective-balance
feat: new max effective balance
2 parents f8324b8 + 90f04b2 commit f0669ad

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/constants.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#gwei-values
1212
EFFECTIVE_BALANCE_INCREMENT = 2 ** 0 * 10 ** 9
1313
MAX_EFFECTIVE_BALANCE = 32 * 10 ** 9
14+
MIN_ACTIVATION_BALANCE = 32 * 10 ** 9
1415
MAX_EFFECTIVE_BALANCE_ELECTRA = 2048 * 10 ** 9
1516
# https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#execution
1617
MAX_WITHDRAWALS_PER_PAYLOAD = 2 ** 4

src/modules/ejector/ejector.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
from src.constants import (
99
FAR_FUTURE_EPOCH,
10-
MAX_EFFECTIVE_BALANCE,
1110
MAX_WITHDRAWALS_PER_PAYLOAD,
11+
MIN_ACTIVATION_BALANCE,
1212
MIN_VALIDATOR_WITHDRAWABILITY_DELAY,
1313
)
1414
from src.metrics.prometheus.business import CONTRACT_ON_PAUSE
@@ -219,7 +219,7 @@ def get_total_withdrawable_balance(balance: Wei, validator: Validator) -> Wei:
219219
return result
220220

221221
def _get_predicted_withdrawable_balance(self, validator: Validator) -> Wei:
222-
return self.w3.to_wei(min(int(validator.balance), MAX_EFFECTIVE_BALANCE), 'gwei')
222+
return self.w3.to_wei(min(int(validator.balance), MIN_ACTIVATION_BALANCE), 'gwei')
223223

224224
@lru_cache(maxsize=1)
225225
def _get_total_el_balance(self, blockstamp: BlockStamp) -> Wei:

src/services/bunker_cases/abnormal_cl_rebase.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from web3.contract.contract import ContractEvent
77
from web3.types import EventData
88

9-
from src.constants import MAX_EFFECTIVE_BALANCE, EFFECTIVE_BALANCE_INCREMENT
9+
from src.constants import EFFECTIVE_BALANCE_INCREMENT, MIN_ACTIVATION_BALANCE
1010
from src.modules.submodules.types import ChainConfig
1111
from src.providers.consensus.types import Validator
1212
from src.providers.keys.types import LidoKey
@@ -93,6 +93,7 @@ def _calculate_lido_normal_cl_rebase(self, blockstamp: ReferenceBlockStamp) -> G
9393
self.lido_keys, last_report_all_validators
9494
)
9595

96+
# Calculate mean sum of effective balance for all validators and Lido validators (ACTIVE only)
9697
mean_sum_of_all_effective_balance = AbnormalClRebase.get_mean_sum_of_effective_balance(
9798
last_report_blockstamp, blockstamp, last_report_all_validators, self.all_validators
9899
)
@@ -289,7 +290,7 @@ def calculate_validators_count_diff_in_gwei(
289290
validators_diff = len(ref_validators) - len(prev_validators)
290291
if validators_diff < 0:
291292
raise ValueError("Validators count diff should be positive or 0. Something went wrong with CL API")
292-
return Gwei(validators_diff * MAX_EFFECTIVE_BALANCE)
293+
return Gwei(validators_diff * MIN_ACTIVATION_BALANCE)
293294

294295
@staticmethod
295296
def get_mean_sum_of_effective_balance(

0 commit comments

Comments
 (0)