Skip to content

Commit 2d8c308

Browse files
committed
Update attestation rewards API for Electra
1 parent 06329ec commit 2d8c308

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

beacon_node/beacon_chain/src/attestation_rewards.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
175175
let base_reward_per_increment =
176176
BaseRewardPerIncrement::new(total_active_balance, spec)?;
177177

178-
for effective_balance_eth in 1..=self.max_effective_balance_increment_steps()? {
178+
for effective_balance_eth in
179+
1..=self.max_effective_balance_increment_steps(previous_epoch)?
180+
{
179181
let effective_balance =
180182
effective_balance_eth.safe_mul(spec.effective_balance_increment)?;
181183
let base_reward =
@@ -321,11 +323,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
321323
})
322324
}
323325

324-
fn max_effective_balance_increment_steps(&self) -> Result<u64, BeaconChainError> {
326+
fn max_effective_balance_increment_steps(
327+
&self,
328+
rewards_epoch: Epoch,
329+
) -> Result<u64, BeaconChainError> {
325330
let spec = &self.spec;
326-
let max_steps = spec
327-
.max_effective_balance
328-
.safe_div(spec.effective_balance_increment)?;
331+
let fork_name = spec.fork_name_at_epoch(rewards_epoch);
332+
let max_effective_balance = spec.max_effective_balance_for_fork(fork_name);
333+
let max_steps = max_effective_balance.safe_div(spec.effective_balance_increment)?;
329334
Ok(max_steps)
330335
}
331336

@@ -386,7 +391,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
386391

387392
let mut ideal_attestation_rewards_list = Vec::new();
388393
let sqrt_total_active_balance = SqrtTotalActiveBalance::new(total_balances.current_epoch());
389-
for effective_balance_step in 1..=self.max_effective_balance_increment_steps()? {
394+
for effective_balance_step in
395+
1..=self.max_effective_balance_increment_steps(previous_epoch)?
396+
{
390397
let effective_balance =
391398
effective_balance_step.safe_mul(spec.effective_balance_increment)?;
392399
let base_reward =

0 commit comments

Comments
 (0)