Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify fork choice's calculate_committee_fraction #4211

Closed
michaelsproul opened this issue Apr 19, 2023 · 3 comments
Closed

Simplify fork choice's calculate_committee_fraction #4211

michaelsproul opened this issue Apr 19, 2023 · 3 comments
Labels
code-quality consensus An issue/PR that touches consensus code, such as state_processing or block verification. v4.2.0 Q2 2023

Comments

@michaelsproul
Copy link
Member

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

@michaelsproul michaelsproul added code-quality consensus An issue/PR that touches consensus code, such as state_processing or block verification. v4.2.0 Q2 2023 labels Apr 19, 2023
@eserilev
Copy link
Collaborator

eserilev commented Apr 19, 2023

@michaelsproul hi, i'd like to pick this one up

so if I'm understanding the spec correctly, the additional calculations of average_balance and committee_size can be removed

instead committee_weight is just simply total_effective_balance which is the sum of the effective balance of all validators in the network that are in a given "justified" state

@michaelsproul
Copy link
Member Author

yep!

bors bot pushed a commit that referenced this issue May 3, 2023
## Issue Addressed

[#4211](#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.
@michaelsproul
Copy link
Member Author

Closed by #4213

ghost pushed a commit to oone-world/lighthouse that referenced this issue Jul 13, 2023
## Issue Addressed

[sigp#4211](sigp#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.
Woodpile37 pushed a commit to Woodpile37/lighthouse that referenced this issue Jan 6, 2024
## Issue Addressed

[sigp#4211](sigp#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.
Woodpile37 pushed a commit to Woodpile37/lighthouse that referenced this issue Jan 6, 2024
## Issue Addressed

[sigp#4211](sigp#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-quality consensus An issue/PR that touches consensus code, such as state_processing or block verification. v4.2.0 Q2 2023
Projects
None yet
Development

No branches or pull requests

2 participants