Skip to content

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

@michaelsproul

Description

@michaelsproul

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.

Metadata

Metadata

Assignees

Labels

HTTP-APIbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions