Remove outdated SPRP hint (#9312)

While working on this code in another branch I noticed we had this messy, complicated and incorrect code about SPRP (slots-per-restore-point), which is no longer a relevant concept since the introduction of hot state diffs.

In the name of simplicity, I've removed any kind of hinting here in favour of a simple out of bounds error. The benefit of adding complex hinting code (which is not tested) to such a function is not worth it IMO. Users will work it out (or ask) if we just tell them their request is out of bounds.


Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
Michael Sproul
2026-05-19 11:35:31 +10:00
committed by GitHub
parent 1a68631180
commit fd0852a8e5

View File

@@ -390,54 +390,34 @@ pub fn get_beacon_state_committees<T: BeaconChainTypes>(
if let Some(shuffling) = maybe_cached_shuffling { if let Some(shuffling) = maybe_cached_shuffling {
shuffling shuffling
} else { } else {
let possibly_built_cache = let possibly_built_cache = match RelativeEpoch::from_epoch(
match RelativeEpoch::from_epoch(current_epoch, epoch) { current_epoch,
Ok(relative_epoch) epoch,
if state.committee_cache_is_initialized( ) {
relative_epoch, Ok(relative_epoch)
) => if state.committee_cache_is_initialized(
{ relative_epoch,
state.committee_cache(relative_epoch).cloned() ) =>
} {
_ => CommitteeCache::initialized( state.committee_cache(relative_epoch).cloned()
state,
epoch,
&chain.spec,
),
} }
.map_err( _ => CommitteeCache::initialized(
|e| match e { state,
BeaconStateError::EpochOutOfBounds => { epoch,
let max_sprp = &chain.spec,
T::EthSpec::slots_per_historical_root() ),
as u64; }
let first_subsequent_restore_point_slot = .map_err(|e| match e {
((epoch.start_slot( BeaconStateError::EpochOutOfBounds => {
T::EthSpec::slots_per_epoch(), warp_utils::reject::custom_bad_request(format!(
) / max_sprp) "epoch {} out of bounds for state at {}",
+ 1) epoch, current_epoch
* max_sprp; ))
if epoch < current_epoch { }
warp_utils::reject::custom_bad_request( _ => warp_utils::reject::unhandled_error(
format!( BeaconChainError::from(e),
"epoch out of bounds, \ ),
try state at slot {}", })?;
first_subsequent_restore_point_slot,
),
)
} else {
warp_utils::reject::custom_bad_request(
"epoch out of bounds, \
too far in future"
.into(),
)
}
}
_ => warp_utils::reject::unhandled_error(
BeaconChainError::from(e),
),
},
)?;
// Attempt to write to the beacon cache (only if the cache // Attempt to write to the beacon cache (only if the cache
// size is not the default value). // size is not the default value).