From 2132c9ca5053e533272a0b67499c5c801a45c589 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Thu, 26 Oct 2023 16:21:19 +1100 Subject: [PATCH] Handle out-of-order forks in epoch cache --- consensus/state_processing/src/epoch_cache.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/consensus/state_processing/src/epoch_cache.rs b/consensus/state_processing/src/epoch_cache.rs index a96cdc06c5d..e8f68ce8352 100644 --- a/consensus/state_processing/src/epoch_cache.rs +++ b/consensus/state_processing/src/epoch_cache.rs @@ -3,7 +3,7 @@ use crate::common::base::SqrtTotalActiveBalance; use crate::common::{altair, base}; use safe_arith::SafeArith; use types::epoch_cache::{EpochCache, EpochCacheError, EpochCacheKey}; -use types::{ActivationQueue, BeaconState, ChainSpec, EthSpec, Hash256}; +use types::{ActivationQueue, BeaconState, ChainSpec, EthSpec, ForkName, Hash256}; /// Precursor to an `EpochCache`. pub struct PreEpochCache { @@ -54,10 +54,7 @@ impl PreEpochCache { for effective_balance_eth in 0..=max_effective_balance_eth { let effective_balance = effective_balance_eth.safe_mul(effective_balance_increment)?; - let base_reward = if spec - .altair_fork_epoch - .map_or(false, |altair_epoch| epoch < altair_epoch) - { + let base_reward = if spec.fork_name_at_epoch(epoch) == ForkName::Base { base::get_base_reward(effective_balance, sqrt_total_active_balance, spec)? } else { altair::get_base_reward(effective_balance, base_reward_per_increment, spec)?