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

@@ -171,11 +171,18 @@ pub enum Error {
InvalidPayloadBody(String),
InvalidPayloadConversion,
InvalidBlobConversion(String),
SszTypesError(ssz_types::Error),
BeaconStateError(BeaconStateError),
PayloadTypeMismatch,
VerifyingVersionedHashes(versioned_hashes::Error),
}
impl From<ssz_types::Error> for Error {
fn from(e: ssz_types::Error) -> Self {
Error::SszTypesError(e)
}
}
impl From<BeaconStateError> for Error {
fn from(e: BeaconStateError) -> Self {
Error::BeaconStateError(e)
@@ -2102,6 +2109,7 @@ enum InvalidBuilderPayload {
payload: u64,
expected: u64,
},
SszTypesError(ssz_types::Error),
}
impl fmt::Display for InvalidBuilderPayload {
@@ -2143,6 +2151,7 @@ impl fmt::Display for InvalidBuilderPayload {
InvalidBuilderPayload::GasLimitMismatch { payload, expected } => {
write!(f, "payload gas limit was {} not {}", payload, expected)
}
Self::SszTypesError(e) => write!(f, "{:?}", e),
}
}
}
@@ -2198,7 +2207,13 @@ fn verify_builder_bid<E: EthSpec>(
.withdrawals()
.ok()
.cloned()
.map(|withdrawals| Withdrawals::<E>::from(withdrawals).tree_hash_root());
.map(|withdrawals| {
Withdrawals::<E>::try_from(withdrawals)
.map_err(InvalidBuilderPayload::SszTypesError)
.map(|w| w.tree_hash_root())
})
.transpose()?;
let payload_withdrawals_root = header.withdrawals_root().ok();
let expected_gas_limit = proposer_gas_limit
.and_then(|target_gas_limit| expected_gas_limit(parent_gas_limit, target_gas_limit, spec));