mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 10:11:44 +00:00
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:
@@ -628,7 +628,12 @@ pub fn get_expected_withdrawals<E: EthSpec>(
|
||||
.safe_rem(state.validators().len() as u64)?;
|
||||
}
|
||||
|
||||
Ok((withdrawals.into(), processed_partial_withdrawals_count))
|
||||
Ok((
|
||||
withdrawals
|
||||
.try_into()
|
||||
.map_err(BlockProcessingError::SszTypesError)?,
|
||||
processed_partial_withdrawals_count,
|
||||
))
|
||||
}
|
||||
|
||||
/// Apply withdrawals to the state.
|
||||
|
||||
@@ -213,7 +213,7 @@ async fn valid_4_deposits() {
|
||||
let mut state = harness.get_current_state();
|
||||
|
||||
let (deposits, state) = harness.make_deposits(&mut state, 4, None, None);
|
||||
let deposits = VariableList::from(deposits);
|
||||
let deposits = VariableList::try_from(deposits).unwrap();
|
||||
|
||||
let mut head_block = harness
|
||||
.chain
|
||||
@@ -237,7 +237,7 @@ async fn invalid_deposit_deposit_count_too_big() {
|
||||
let mut state = harness.get_current_state();
|
||||
|
||||
let (deposits, state) = harness.make_deposits(&mut state, 1, None, None);
|
||||
let deposits = VariableList::from(deposits);
|
||||
let deposits = VariableList::try_from(deposits).unwrap();
|
||||
|
||||
let mut head_block = harness
|
||||
.chain
|
||||
@@ -269,7 +269,7 @@ async fn invalid_deposit_count_too_small() {
|
||||
let mut state = harness.get_current_state();
|
||||
|
||||
let (deposits, state) = harness.make_deposits(&mut state, 1, None, None);
|
||||
let deposits = VariableList::from(deposits);
|
||||
let deposits = VariableList::try_from(deposits).unwrap();
|
||||
|
||||
let mut head_block = harness
|
||||
.chain
|
||||
@@ -301,7 +301,7 @@ async fn invalid_deposit_bad_merkle_proof() {
|
||||
let mut state = harness.get_current_state();
|
||||
|
||||
let (deposits, state) = harness.make_deposits(&mut state, 1, None, None);
|
||||
let deposits = VariableList::from(deposits);
|
||||
let deposits = VariableList::try_from(deposits).unwrap();
|
||||
|
||||
let mut head_block = harness
|
||||
.chain
|
||||
@@ -336,7 +336,7 @@ async fn invalid_deposit_wrong_sig() {
|
||||
|
||||
let (deposits, state) =
|
||||
harness.make_deposits(&mut state, 1, None, Some(SignatureBytes::empty()));
|
||||
let deposits = VariableList::from(deposits);
|
||||
let deposits = VariableList::try_from(deposits).unwrap();
|
||||
|
||||
let mut head_block = harness
|
||||
.chain
|
||||
@@ -360,7 +360,7 @@ async fn invalid_deposit_invalid_pub_key() {
|
||||
|
||||
let (deposits, state) =
|
||||
harness.make_deposits(&mut state, 1, Some(PublicKeyBytes::empty()), None);
|
||||
let deposits = VariableList::from(deposits);
|
||||
let deposits = VariableList::try_from(deposits).unwrap();
|
||||
|
||||
let mut head_block = harness
|
||||
.chain
|
||||
@@ -753,10 +753,12 @@ async fn invalid_attester_slashing_1_invalid() {
|
||||
let mut attester_slashing = harness.make_attester_slashing(vec![1, 2]);
|
||||
match &mut attester_slashing {
|
||||
AttesterSlashing::Base(attester_slashing) => {
|
||||
attester_slashing.attestation_1.attesting_indices = VariableList::from(vec![2, 1]);
|
||||
attester_slashing.attestation_1.attesting_indices =
|
||||
VariableList::try_from(vec![2, 1]).unwrap();
|
||||
}
|
||||
AttesterSlashing::Electra(attester_slashing) => {
|
||||
attester_slashing.attestation_1.attesting_indices = VariableList::from(vec![2, 1]);
|
||||
attester_slashing.attestation_1.attesting_indices =
|
||||
VariableList::try_from(vec![2, 1]).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -791,10 +793,12 @@ async fn invalid_attester_slashing_2_invalid() {
|
||||
let mut attester_slashing = harness.make_attester_slashing(vec![1, 2]);
|
||||
match &mut attester_slashing {
|
||||
AttesterSlashing::Base(attester_slashing) => {
|
||||
attester_slashing.attestation_2.attesting_indices = VariableList::from(vec![2, 1]);
|
||||
attester_slashing.attestation_2.attesting_indices =
|
||||
VariableList::try_from(vec![2, 1]).unwrap();
|
||||
}
|
||||
AttesterSlashing::Electra(attester_slashing) => {
|
||||
attester_slashing.attestation_2.attesting_indices = VariableList::from(vec![2, 1]);
|
||||
attester_slashing.attestation_2.attesting_indices =
|
||||
VariableList::try_from(vec![2, 1]).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user