@@ -7,15 +7,18 @@ use state_processing::common::{
77use std:: collections:: HashMap ;
88use types:: {
99 beacon_state:: BeaconStateBase ,
10- consts:: altair:: { PARTICIPATION_FLAG_WEIGHTS , WEIGHT_DENOMINATOR } ,
10+ consts:: altair:: { PARTICIPATION_FLAG_WEIGHTS , PROPOSER_WEIGHT , WEIGHT_DENOMINATOR } ,
1111 Attestation , BeaconState , BitList , ChainSpec , EthSpec ,
1212} ;
1313
14+ pub const PROPOSER_REWARD_DENOMINATOR : u64 =
15+ ( WEIGHT_DENOMINATOR - PROPOSER_WEIGHT ) * WEIGHT_DENOMINATOR / PROPOSER_WEIGHT ;
16+
1417#[ derive( Debug , Clone ) ]
1518pub struct AttMaxCover < ' a , E : EthSpec > {
1619 /// Underlying attestation.
1720 pub att : CompactAttestationRef < ' a , E > ,
18- /// Mapping of validator indices and their rewards .
21+ /// Mapping of validator indices and their reward *numerators* .
1922 pub fresh_validators_rewards : HashMap < u64 , u64 > ,
2023}
2124
@@ -30,7 +33,7 @@ impl<'a, E: EthSpec> AttMaxCover<'a, E> {
3033 if let BeaconState :: Base ( ref base_state) = state {
3134 Self :: new_for_base ( att, state, base_state, total_active_balance, spec)
3235 } else {
33- Self :: new_for_altair_deneb ( att, state, reward_cache, spec)
36+ Self :: new_for_altair_or_later ( att, state, reward_cache, spec)
3437 }
3538 }
3639
@@ -68,7 +71,7 @@ impl<'a, E: EthSpec> AttMaxCover<'a, E> {
6871 }
6972
7073 /// Initialise an attestation cover object for Altair or later.
71- pub fn new_for_altair_deneb (
74+ pub fn new_for_altair_or_later (
7275 att : CompactAttestationRef < ' a , E > ,
7376 state : & BeaconState < E > ,
7477 reward_cache : & ' a RewardCache ,
@@ -103,10 +106,7 @@ impl<'a, E: EthSpec> AttMaxCover<'a, E> {
103106 }
104107 }
105108
106- let proposer_reward = proposer_reward_numerator
107- . checked_div ( WEIGHT_DENOMINATOR . checked_mul ( spec. proposer_reward_quotient ) ?) ?;
108-
109- Some ( ( index, proposer_reward) ) . filter ( |_| proposer_reward != 0 )
109+ Some ( ( index, proposer_reward_numerator) ) . filter ( |_| proposer_reward_numerator != 0 )
110110 } )
111111 . collect ( ) ;
112112
@@ -163,7 +163,7 @@ impl<'a, E: EthSpec> MaxCover for AttMaxCover<'a, E> {
163163 }
164164
165165 fn score ( & self ) -> usize {
166- self . fresh_validators_rewards . values ( ) . sum :: < u64 > ( ) as usize
166+ ( self . fresh_validators_rewards . values ( ) . sum :: < u64 > ( ) / PROPOSER_REWARD_DENOMINATOR ) as usize
167167 }
168168}
169169
0 commit comments