mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 22:08:30 +00:00
Fix phase0 block reward in rewards API (#5101)
* Added Block Rewards * added new type * added enum * Fix phase0 block reward in rewards API (#4929) * Merge 'guav00a/proposer-rewards-api' * Merge unstable * Revamp phase0 reward API tests - Add test_rewards_base_slashings (testing #5101) - Improve fix to not include proposer reward in attestation reward API calculation (#4856) - Adjust test approach for phase0 tests: Pad with empty epochs to include all rewards in calculation - Simplify and unify code across all reward tests * Merge branch 'unstable' into fix-4929 * Merge branch 'unstable' into fix-4929 * Merge remote-tracking branch 'origin/unstable' into fix-4929 * Fix merge fallout * Remove junk revived in merge * Address review - check for attestations with lower inclusion delay - check for double attestations in block - add test * Merge branch 'unstable' into fix-4929 * Merge branch 'unstable' into fix-4929
This commit is contained in:
@@ -11,7 +11,7 @@ use state_processing::per_epoch_processing::altair::{
|
||||
};
|
||||
use state_processing::per_epoch_processing::base::rewards_and_penalties::{
|
||||
get_attestation_component_delta, get_attestation_deltas_all, get_attestation_deltas_subset,
|
||||
get_inactivity_penalty_delta, get_inclusion_delay_delta,
|
||||
get_inactivity_penalty_delta, get_inclusion_delay_delta, ProposerRewardCalculation,
|
||||
};
|
||||
use state_processing::per_epoch_processing::base::validator_statuses::InclusionInfo;
|
||||
use state_processing::per_epoch_processing::base::{
|
||||
@@ -81,13 +81,24 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
self.compute_ideal_rewards_base(&state, &validator_statuses.total_balances)?;
|
||||
|
||||
let indices_to_attestation_delta = if validators.is_empty() {
|
||||
get_attestation_deltas_all(&state, &validator_statuses, spec)?
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.collect()
|
||||
get_attestation_deltas_all(
|
||||
&state,
|
||||
&validator_statuses,
|
||||
ProposerRewardCalculation::Exclude,
|
||||
spec,
|
||||
)?
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.collect()
|
||||
} else {
|
||||
let validator_indices = Self::validators_ids_to_indices(&mut state, validators)?;
|
||||
get_attestation_deltas_subset(&state, &validator_statuses, &validator_indices, spec)?
|
||||
get_attestation_deltas_subset(
|
||||
&state,
|
||||
&validator_statuses,
|
||||
ProposerRewardCalculation::Exclude,
|
||||
&validator_indices,
|
||||
spec,
|
||||
)?
|
||||
};
|
||||
|
||||
let mut total_rewards = vec![];
|
||||
|
||||
Reference in New Issue
Block a user