-
Notifications
You must be signed in to change notification settings - Fork 910
Bump ssz_types
to v0.12.1
#8032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: unstable
Are you sure you want to change the base?
Conversation
9e007fd
to
9565bac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
Just a few expects here and there that I wonder if we should remove
N: Unsigned, | ||
{ | ||
VariableList::try_from_iter(list.into_iter().map(Into::into)) | ||
.expect("conversion to JSON should preserve withdrawals length") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little spicy, but I think it's OK for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the expect
-less version: 6aa826b
consensus/types/src/attestation.rs
Outdated
attesting_indices: vec![self.attester_index].into(), | ||
attesting_indices: vec![self.attester_index] | ||
.try_into() | ||
.expect("Single index should not exceed MaxValidatorsPerSlot"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably fails clippy, maybe we should just make this method return a Result
. It probably isn't used in that many places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that initially, but to_indexed
gets used in attestation verification which then requires a new error variant. That error variant then needs to be covered in match statements in some networking code and it ended up being really ugly just for this one error which can never occur anyway. The expect
felt like the lesser of two evils. I'll keep trying and see if I can come up with something cleaner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect
-less version: 12c260a
Sorry @macladson, after discussing with Jimmy we decided it would be better to remove these |
bytes.truncate(MAX_ERROR_LEN as usize); | ||
Self( | ||
VariableList::try_from(bytes) | ||
.expect("length should not exceed MaxErrorLen after truncation"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I convert this whole impl to a TryFrom
?
|
||
let empty_data_columns_by_root_id = DataColumnsByRootIdentifier { | ||
block_root: Hash256::zero(), | ||
columns: VariableList::from(vec![0; E::number_of_columns()]), | ||
columns: VariableList::try_from(vec![0; E::number_of_columns()]) | ||
.expect("VariableList::try_from should succeed"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function could also be a Result<usize, Error>
Issue Addressed
#8012
Proposed Changes
Replace all instances of
VariableList::from
andFixedVector::from
to theirtry_from
variants.While I tried to use proper error handling in most cases, there were certain situations where adding an
expect
for situations wheretry_from
can trivially never fail avoided adding a lot of extra complexity.