From 9dd4b2110a187c46b503be5192fe1320f210b629 Mon Sep 17 00:00:00 2001 From: Justin Date: Fri, 26 Apr 2019 18:46:35 +0400 Subject: [PATCH] Fix two effective_balance bugs * Initialisation bug: initial `effective_balance` be not greater than `MAX_EFFECTIVE_BALANCE` * Hysteresis bug: do not prevent `effective_balance` to go from `MAX_EFFECTIVE_BALANCE - 1` to `MAX_EFFECTIVE_BALANCE` --- specs/core/0_beacon-chain.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 55791e25f..90144b50b 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1603,10 +1603,10 @@ def process_final_updates(state: BeaconState) -> None: state.eth1_data_votes = [] # Update effective balances with hysteresis for index, validator in enumerate(state.validator_registry): - balance = min(state.balances[index], MAX_EFFECTIVE_BALANCE) + balance = state.balances[index] HALF_INCREMENT = EFFECTIVE_BALANCE_INCREMENT // 2 if balance < validator.effective_balance or validator.effective_balance + 3 * HALF_INCREMENT < balance: - validator.effective_balance = balance - balance % EFFECTIVE_BALANCE_INCREMENT + validator.effective_balance = min(balance - balance % EFFECTIVE_BALANCE_INCREMENT, MAX_EFFECTIVE_BALANCE) # Update start shard state.latest_start_shard = (state.latest_start_shard + get_shard_delta(state, current_epoch)) % SHARD_COUNT # Set active index root @@ -1840,7 +1840,7 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None: activation_epoch=FAR_FUTURE_EPOCH, exit_epoch=FAR_FUTURE_EPOCH, withdrawable_epoch=FAR_FUTURE_EPOCH, - effective_balance=amount - amount % EFFECTIVE_BALANCE_INCREMENT + effective_balance=min(amount - amount % EFFECTIVE_BALANCE_INCREMENT, MAX_EFFECTIVE_BALANCE) )) state.balances.append(amount) else: