Bump ssz_types to v0.12.2 (#8032)

https://github.com/sigp/lighthouse/issues/8012


  Replace all instances of `VariableList::from` and `FixedVector::from` to their `try_from` variants.

While I tried to use proper error handling in most cases, there were certain situations where adding an `expect` for situations where `try_from` can trivially never fail avoided adding a lot of extra complexity.


Co-Authored-By: Mac L <mjladson@pm.me>

Co-Authored-By: Michael Sproul <michaelsproul@users.noreply.github.com>

Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
Mac L
2025-10-28 08:01:09 +04:00
committed by GitHub
parent 5840004c36
commit f5809aff87
39 changed files with 758 additions and 465 deletions

View File

@@ -57,7 +57,7 @@ use state_processing::{
};
use std::borrow::Cow;
use strum::AsRefStr;
use tracing::debug;
use tracing::{debug, error};
use tree_hash::TreeHash;
use types::{
Attestation, AttestationData, AttestationRef, BeaconCommittee,
@@ -267,6 +267,14 @@ pub enum Error {
/// We were unable to process this attestation due to an internal error. It's unclear if the
/// attestation is valid.
BeaconChainError(Box<BeaconChainError>),
/// A critical error occurred while converting SSZ types.
/// This can only occur when a VariableList was not able to be constructed from a single
/// attestation.
///
/// ## Peer scoring
///
/// The peer has sent an invalid message.
SszTypesError(ssz_types::Error),
}
impl From<BeaconChainError> for Error {
@@ -275,6 +283,12 @@ impl From<BeaconChainError> for Error {
}
}
impl From<ssz_types::Error> for Error {
fn from(e: ssz_types::Error) -> Self {
Self::SszTypesError(e)
}
}
/// Used to avoid double-checking signatures.
#[derive(Copy, Clone)]
enum CheckAttestationSignature {
@@ -442,7 +456,18 @@ fn process_slash_info<T: BeaconChainTypes>(
.spec
.fork_name_at_slot::<T::EthSpec>(attestation.data.slot);
let indexed_attestation = attestation.to_indexed(fork_name);
let indexed_attestation = match attestation.to_indexed(fork_name) {
Ok(indexed) => indexed,
Err(e) => {
error!(
attestation_root = ?attestation.data.tree_hash_root(),
error = ?e,
"Unable to construct VariableList from a single attestation. \
This indicates a serious bug in SSZ handling"
);
return Error::SszTypesError(e);
}
};
(indexed_attestation, true, err)
}
SignatureNotCheckedIndexed(indexed, err) => (indexed, true, err),
@@ -932,7 +957,9 @@ impl<'a, T: BeaconChainTypes> IndexedUnaggregatedAttestation<'a, T> {
.spec
.fork_name_at_slot::<T::EthSpec>(attestation.data.slot);
let indexed_attestation = attestation.to_indexed(fork_name);
let indexed_attestation = attestation
.to_indexed(fork_name)
.map_err(|e| SignatureNotCheckedSingle(attestation, Error::SszTypesError(e)))?;
let validator_index = match Self::verify_middle_checks(attestation, chain) {
Ok(t) => t,