-
Notifications
You must be signed in to change notification settings - Fork 53
Add bounds for out of range check in get_block_hash syscall #1167
Conversation
self.handle_syscall_request(gas, "get_block_hash")?; | ||
|
||
let current_block_number = dbg!(self.block_context.block_info.block_number); | ||
if block_number > current_block_number - 10 { |
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 operation can panick, lets check that current_block_number is >= 10
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.
Or you can do this instead:
if block_number > current_block_number - 10 { | |
if block_number > current_block_number.saturating_sub(10) { |
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.
Or compare with an addition instead:
if block_number > current_block_number - 10 { | |
if block_number + 10 > current_block_number { |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1167 +/- ##
==========================================
- Coverage 89.61% 89.47% -0.15%
==========================================
Files 50 50
Lines 14370 14369 -1
==========================================
- Hits 12878 12856 -22
- Misses 1492 1513 +21
|
48bf482
to
8f91882
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.
🚀
TITLE
Description
This PR fixes #1166
Description of the pull request changes and motivation.
Checklist