Skip to content

Commit

Permalink
Return a specific error for frozen attn states (#2384)
Browse files Browse the repository at this point in the history
## 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.
  • Loading branch information
paulhauner committed Jun 1, 2021
1 parent ba9c4c5 commit bf4e02e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions beacon_node/store/src/hot_cold_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ pub enum HotColdDBError {
IterationError {
unexpected_key: BytesKey,
},
AttestationStateIsFinalized {
split_slot: Slot,
request_slot: Option<Slot>,
state_root: Hash256,
},
}

impl<E: EthSpec> HotColdDB<E, MemoryStore<E>, MemoryStore<E>> {
Expand Down Expand Up @@ -345,8 +350,15 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
) -> Result<Option<BeaconState<E>>, 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)
}
Expand Down

0 comments on commit bf4e02e

Please sign in to comment.