Skip to content

Simplify fork choice's calculate_committee_fraction #4211

@michaelsproul

Description

@michaelsproul

Description

The v1.3.0 spec simplified the calculation of proposer boost in a way that is almost equivalent to the previous definition. We are still using the old definition but could update at any time to the simpler version.

Our impl:

pub fn calculate_committee_fraction<E: EthSpec>(
justified_balances: &JustifiedBalances,
proposer_score_boost: u64,
) -> Option<u64> {
let average_balance = 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)
}

Spec: https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/fork-choice.md#get_weight

Discussion: ethereum/consensus-specs#3034 (comment)

Version

v4.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-qualityconsensusAn issue/PR that touches consensus code, such as state_processing or block verification.v4.2.0Q2 2023

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions