Delete RuntimeVariableList::from_vec (#7930)

This method is a footgun because it truncates the list. It is the source of a recent bug:

- https://github.com/sigp/lighthouse/pull/7927


  - Delete uses of `RuntimeVariableList::from_vec` and replace them with `::new` which does validation and can fail.
- Propagate errors where possible, unwrap in tests and use `expect` for obviously-safe uses (in `chain_spec.rs`).
This commit is contained in:
Michael Sproul
2025-08-27 16:52:14 +10:00
committed by GitHub
parent ccf03e1c88
commit d235f2c697
15 changed files with 89 additions and 60 deletions

View File

@@ -25,6 +25,7 @@ redb = { version = "2.1.3", optional = true }
safe_arith = { workspace = true }
serde = { workspace = true }
smallvec = { workspace = true }
ssz_types = { workspace = true }
state_processing = { workspace = true }
strum = { workspace = true }
superstruct = { workspace = true }

View File

@@ -69,6 +69,7 @@ pub enum Error {
CacheBuildError(EpochCacheError),
RandaoMixOutOfBounds,
MilhouseError(milhouse::Error),
SszTypesError(ssz_types::Error),
Compression(std::io::Error),
FinalizedStateDecreasingSlot,
FinalizedStateUnaligned,
@@ -161,6 +162,12 @@ impl From<milhouse::Error> for Error {
}
}
impl From<ssz_types::Error> for Error {
fn from(e: ssz_types::Error) -> Self {
Self::SszTypesError(e)
}
}
impl From<hdiff::Error> for Error {
fn from(e: hdiff::Error) -> Self {
Self::Hdiff(e)

View File

@@ -2478,7 +2478,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
.first()
.map(|blob| self.spec.max_blobs_per_block(blob.epoch()))
{
let blobs = BlobSidecarList::from_vec(blobs, max_blobs_per_block as usize);
let blobs = BlobSidecarList::new(blobs, max_blobs_per_block as usize)?;
self.block_cache
.lock()
.put_blobs(*block_root, blobs.clone());