mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 03:31:45 +00:00
simplify calculate_committee_fraction (#4213)
## Issue Addressed [#4211](https://github.com/sigp/lighthouse/issues/4211) ## Proposed Changes This PR conforms the helper function `calculate_committee_fraction` to the [v1.3.0 spec](https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/fork-choice.md#get_weight) ## Additional Info the old definition of `calculate_committee_fraction` is almost identical, but the new definition is simpler.
This commit is contained in:
@@ -1055,13 +1055,9 @@ pub fn calculate_committee_fraction<E: EthSpec>(
|
||||
justified_balances: &JustifiedBalances,
|
||||
proposer_score_boost: u64,
|
||||
) -> Option<u64> {
|
||||
let average_balance = justified_balances
|
||||
let committee_weight = justified_balances
|
||||
.total_effective_balance
|
||||
.checked_div(justified_balances.num_active_validators)?;
|
||||
let committee_size = justified_balances
|
||||
.num_active_validators
|
||||
.checked_div(E::slots_per_epoch())?;
|
||||
let committee_weight = committee_size.checked_mul(average_balance)?;
|
||||
committee_weight
|
||||
.checked_mul(proposer_score_boost)?
|
||||
.checked_div(100)
|
||||
|
||||
Reference in New Issue
Block a user