Skip to content

Commit d36ebba

Browse files
Handle out-of-order forks in epoch cache (#4881)
1 parent 1aca484 commit d36ebba

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

consensus/state_processing/src/epoch_cache.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::common::base::SqrtTotalActiveBalance;
33
use crate::common::{altair, base};
44
use safe_arith::SafeArith;
55
use types::epoch_cache::{EpochCache, EpochCacheError, EpochCacheKey};
6-
use types::{ActivationQueue, BeaconState, ChainSpec, EthSpec, Hash256};
6+
use types::{ActivationQueue, BeaconState, ChainSpec, EthSpec, ForkName, Hash256};
77

88
/// Precursor to an `EpochCache`.
99
pub struct PreEpochCache {
@@ -54,10 +54,7 @@ impl PreEpochCache {
5454

5555
for effective_balance_eth in 0..=max_effective_balance_eth {
5656
let effective_balance = effective_balance_eth.safe_mul(effective_balance_increment)?;
57-
let base_reward = if spec
58-
.altair_fork_epoch
59-
.map_or(false, |altair_epoch| epoch < altair_epoch)
60-
{
57+
let base_reward = if spec.fork_name_at_epoch(epoch) == ForkName::Base {
6158
base::get_base_reward(effective_balance, sqrt_total_active_balance, spec)?
6259
} else {
6360
altair::get_base_reward(effective_balance, base_reward_per_increment, spec)?

0 commit comments

Comments
 (0)