diff --git a/beacon_node/beacon_chain/src/beacon_block_reward.rs b/beacon_node/beacon_chain/src/beacon_block_reward.rs index 3a3592f77b6..9ee5ec41eed 100644 --- a/beacon_node/beacon_chain/src/beacon_block_reward.rs +++ b/beacon_node/beacon_chain/src/beacon_block_reward.rs @@ -5,6 +5,7 @@ use safe_arith::SafeArith; use slog::error; use state_processing::{ common::{get_attestation_participation_flag_indices, get_attesting_indices_from_state}, + epoch_cache::initialize_epoch_cache, per_block_processing::{ altair::sync_committee::compute_sync_aggregate_rewards, get_slashable_indices, }, @@ -30,6 +31,7 @@ impl BeaconChain { state.build_committee_cache(RelativeEpoch::Previous, &self.spec)?; state.build_committee_cache(RelativeEpoch::Current, &self.spec)?; + initialize_epoch_cache(state, &self.spec)?; self.compute_beacon_block_reward_with_cache(block, block_root, state) } @@ -229,12 +231,8 @@ impl BeaconChain { && !validator_participation.has_flag(flag_index)? { validator_participation.add_flag(flag_index)?; - proposer_reward_numerator.safe_add_assign( - state - .get_base_reward(index) - .map_err(|_| BeaconChainError::BlockRewardAttestationError)? - .safe_mul(weight)?, - )?; + proposer_reward_numerator + .safe_add_assign(state.get_base_reward(index)?.safe_mul(weight)?)?; } } } diff --git a/beacon_node/beacon_chain/src/canonical_head.rs b/beacon_node/beacon_chain/src/canonical_head.rs index 12980d6a802..e76ae576234 100644 --- a/beacon_node/beacon_chain/src/canonical_head.rs +++ b/beacon_node/beacon_chain/src/canonical_head.rs @@ -672,10 +672,7 @@ impl BeaconChain { // Regardless of where we got the state from, attempt to build all the // caches except the tree hash cache. - new_snapshot - .beacon_state - .build_all_caches(&self.spec) - .map_err(Error::HeadCacheError)?; + new_snapshot.beacon_state.build_all_caches(&self.spec)?; let new_cached_head = CachedHead { snapshot: Arc::new(new_snapshot), diff --git a/beacon_node/beacon_chain/src/errors.rs b/beacon_node/beacon_chain/src/errors.rs index 1059bb42f87..2251e8df6ca 100644 --- a/beacon_node/beacon_chain/src/errors.rs +++ b/beacon_node/beacon_chain/src/errors.rs @@ -55,7 +55,7 @@ pub enum BeaconChainError { SlotClockDidNotStart, NoStateForSlot(Slot), BeaconStateError(BeaconStateError), - HeadCacheError(EpochCacheError), + EpochCacheError(EpochCacheError), DBInconsistent(String), DBError(store::Error), ForkChoiceError(ForkChoiceError), @@ -246,6 +246,7 @@ easy_from_to!(StateAdvanceError, BeaconChainError); easy_from_to!(BlockReplayError, BeaconChainError); easy_from_to!(InconsistentFork, BeaconChainError); easy_from_to!(AvailabilityCheckError, BeaconChainError); +easy_from_to!(EpochCacheError, BeaconChainError); #[derive(Debug)] pub enum BlockProductionError {