From bf4e02e2cc8f6e0bb42ed6c41956760dbbe99302 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Tue, 1 Jun 2021 06:59:43 +0000 Subject: [PATCH] Return a specific error for frozen attn states (#2384) ## Issue Addressed NA ## Proposed Changes Return a very specific error when at attestation reads shuffling from a frozen `BeaconState`. Previously, this was returning `MissingBeaconState` which indicates a much more serious issue. ## Additional Info Since `get_inconsistent_state_for_attestation_verification_only` is only called once in `BeaconChain::with_committee_cache`, it is quite easy to reason about the impact of this change. --- beacon_node/store/src/hot_cold_store.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index 4105c393f..02a88b331 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -106,6 +106,11 @@ pub enum HotColdDBError { IterationError { unexpected_key: BytesKey, }, + AttestationStateIsFinalized { + split_slot: Slot, + request_slot: Option, + state_root: Hash256, + }, } impl HotColdDB, MemoryStore> { @@ -345,8 +350,15 @@ impl, Cold: ItemStore> HotColdDB ) -> Result>, Error> { metrics::inc_counter(&metrics::BEACON_STATE_GET_COUNT); - if slot.map_or(false, |slot| slot < self.get_split_slot()) { - Ok(None) + let split_slot = self.get_split_slot(); + + if slot.map_or(false, |slot| slot < split_slot) { + Err(HotColdDBError::AttestationStateIsFinalized { + split_slot, + request_slot: slot, + state_root: *state_root, + } + .into()) } else { self.load_hot_state(state_root, BlockReplay::InconsistentStateRoots) }