diff --git a/beacon_chain/block_pools/candidate_chains.nim b/beacon_chain/block_pools/candidate_chains.nim index 70927b648..3c7316128 100644 --- a/beacon_chain/block_pools/candidate_chains.nim +++ b/beacon_chain/block_pools/candidate_chains.nim @@ -356,11 +356,14 @@ func putStateCache( # with the concomitant memory allocator and GC load. Instead, use a # more memory-intensive (but more conceptually straightforward, and # faster) strategy to just store, for the most recent slots. + if state.data.slot mod 2 != 0: + return + let stateCacheIndex = dag.getStateCacheIndex(blck.root, state.data.slot) if stateCacheIndex == -1: # Could use a deque or similar, but want simpler structure, and the data # items are small and few. - const MAX_CACHE_SIZE = 32 + const MAX_CACHE_SIZE = 16 let cacheLen = dag.cachedStates.len doAssert cacheLen <= MAX_CACHE_SIZE diff --git a/beacon_chain/spec/beaconstate.nim b/beacon_chain/spec/beaconstate.nim index 7de9b6460..d9ed9d431 100644 --- a/beacon_chain/spec/beaconstate.nim +++ b/beacon_chain/spec/beaconstate.nim @@ -174,12 +174,12 @@ proc slash_validator*(state: var BeaconState, slashed_index: ValidatorIndex, validator.effective_balance div MIN_SLASHING_PENALTY_QUOTIENT) # The rest doesn't make sense without there being any proposer index, so skip - # Apply proposer and whistleblower rewards let proposer_index = get_beacon_proposer_index(state, cache) if proposer_index.isNone: debug "No beacon proposer index and probably no active validators" return + # Apply proposer and whistleblower rewards let # Spec has whistleblower_index as optional param, but it's never used. whistleblower_index = proposer_index.get