-
Notifications
You must be signed in to change notification settings - Fork 44
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
Note possible checked_sub cases #57
Conversation
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 need to make another pass on the merkle code but this is great!
I think we are fine to just add comments like you have done; I would consider calling them out explicitly with a |
Co-authored-by: Alex Stokes <r.alex.stokes@gmail.com>
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #57 +/- ##
===========================================
+ Coverage 44.28% 75.26% +30.97%
===========================================
Files 20 18 -2
Lines 1409 857 -552
===========================================
+ Hits 624 645 +21
+ Misses 785 212 -573
☔ View full report in Codecov by Sentry. |
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.
had a question about offset checking for container deserialization
and still need to look at the merkle code
but everything else is looking great!
ssz-rs/src/merkleization/mod.rs
Outdated
for i in chunks.len()..leaf_count { | ||
let start = leaf_start + (i * BYTES_PER_CHUNK); | ||
let end = leaf_start + (i + 1) * BYTES_PER_CHUNK; | ||
buffer[start..end].copy_from_slice(&zero_chunk); | ||
} |
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 don't think the bounds on this iterator are correct chunks.len()..leaf_count
and it was fine only bc we are just writing zeros to memory that was already zero (initialized in buffer
)
I deleted it anyway bc it didn't seem to be doing anything
For #22, I've looked through the places we've used subtraction and haven't found any cases where
checked_sub
is strictly necessary. The constraints for each case are documented in comments before the subtraction. I've also added a few constraints where necessary.Opening as a draft since I'm not sure whether we want to use checked_sub anyway, just in case the constraints change and we miss something. There is a small performance cost to checked_sub and I'm fairly certain it's unnecessary, so it's down to a cautiousness vs performance tradeoff.