lighthouse
lighthouse copied to clipboard
Fix phase0 block reward in rewards API
Issues Addressed
- #4929
- #4856
Proposed Changes
Instead of relying on compute_block_reward for phase0, a new custom implementation for compute_beacon_block_attestation_reward_base is used, which handles edge cases like attestations from validators that were slashed after attesting and proposals in the epoch before Altair correctly.
Additionally, this PR incorporates and improves the changes proposed in PR #4882.
Additional Info
Some points I'm unsure about:
- I use
BeaconChain::state_at_slotto obtain needed states (at most twice per calculation). Another approach is using theBlockReplayerto advance the passedstate, which would avoid (maybe) expensive lookups from the cold DB. However I am unsure if the added complexity is worth it, and maybe this is even a non-issue due to smart caching or something else I am unaware of. - I build the committee caches for the states I fetch, but only because I need the total active balance.
BeaconState::build_total_active_balance_cacheis notpub, is that intentional?
Ready for review - Happy to receive feedback, especially regarding the points listed in "Additional Info".