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

Attestation rewards API doesn't account for justification and finalization #4860

Closed
michaelsproul opened this issue Oct 19, 2023 · 2 comments
Assignees
Labels
bug Something isn't working HTTP-API

Comments

@michaelsproul
Copy link
Member

michaelsproul commented Oct 19, 2023

Description

The attestation rewards calculator has a bug where it doesn't update justification and finalization (process_justification_and_finalization) prior to calculating attestation rewards.

This causes faulty output for epoch N - 1 when finality is restored at the end of epoch N. In this case, the is_in_inactivity_leak predicate should be false (because finality has just been restored), but our code will set it to true because it hasn't computed justification & finalization.

On mainnet this occurs at epoch 200759 (i.e. finality restored at the end of 200760).

Relevant code (see earlier in this function for the lack of justification/finalization processing):

if !state.is_in_inactivity_leak(previous_epoch, spec)? {
ideal_rewards_hashmap
.insert((flag_index, effective_balance), (ideal_reward, penalty));
} else {
ideal_rewards_hashmap.insert((flag_index, effective_balance), (0, penalty));
}

Version

Lighthouse v4.5.0

Steps to resolve

We should probably just run process_justification_and_finalization at the start of attestation rewards calculation. I don't think this should interfere with the block v3 API, as it only needs to calculate the proposer's block reward, which is independent of is_in_inactivity_leak, and shouldn't share code with the attestation rewards calculations.

@michaelsproul michaelsproul added bug Something isn't working HTTP-API labels Oct 19, 2023
@michaelsproul michaelsproul changed the title Attestation rewards API doesn't update justification and finalization Attestation rewards API doesn't account for justification and finalization Oct 19, 2023
@zack-scott
Copy link
Contributor

@michaelsproul @jimmygchen I would like to work on this

@michaelsproul
Copy link
Member Author

Closed by #4877

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working HTTP-API
Projects
None yet
Development

No branches or pull requests

2 participants