Skip to content

Commit

Permalink
use correct max eb in epoch cache initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
realbigsean committed May 11, 2024
1 parent 261551e commit a75257f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions consensus/state_processing/src/epoch_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ impl PreEpochCache {
let base_reward_per_increment = BaseRewardPerIncrement::new(total_active_balance, spec)?;

let effective_balance_increment = spec.effective_balance_increment;
let max_effective_balance_eth = spec
.max_effective_balance
.safe_div(effective_balance_increment)?;
let max_effective_balance =
spec.max_effective_balance_for_fork(spec.fork_name_at_epoch(epoch));
let max_effective_balance_eth =
max_effective_balance.safe_div(effective_balance_increment)?;

let mut base_rewards = Vec::with_capacity(max_effective_balance_eth.safe_add(1)? as usize);

Expand Down
8 changes: 8 additions & 0 deletions consensus/types/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,14 @@ impl ChainSpec {
}
}

pub fn max_effective_balance_for_fork(&self, fork_name: ForkName) -> u64 {
if fork_name >= ForkName::Electra {
self.max_effective_balance_electra
} else {
self.max_effective_balance
}
}

/// Returns a full `Fork` struct for a given epoch.
pub fn fork_at_epoch(&self, epoch: Epoch) -> Fork {
let current_fork_name = self.fork_name_at_epoch(epoch);
Expand Down

0 comments on commit a75257f

Please sign in to comment.