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,8 +390,10 @@ 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,
epoch,
) {
Ok(relative_epoch) Ok(relative_epoch)
if state.committee_cache_is_initialized( if state.committee_cache_is_initialized(
relative_epoch, relative_epoch,
@@ -405,39 +407,17 @@ pub fn get_beacon_state_committees<T: BeaconChainTypes>(
&chain.spec, &chain.spec,
), ),
} }
.map_err( .map_err(|e| match e {
|e| match e {
BeaconStateError::EpochOutOfBounds => { BeaconStateError::EpochOutOfBounds => {
let max_sprp = warp_utils::reject::custom_bad_request(format!(
T::EthSpec::slots_per_historical_root() "epoch {} out of bounds for state at {}",
as u64; epoch, current_epoch
let first_subsequent_restore_point_slot = ))
((epoch.start_slot(
T::EthSpec::slots_per_epoch(),
) / max_sprp)
+ 1)
* max_sprp;
if epoch < current_epoch {
warp_utils::reject::custom_bad_request(
format!(
"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( _ => warp_utils::reject::unhandled_error(
BeaconChainError::from(e), 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).