Skip to content
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

Fix underflow bug #1430

Merged
merged 7 commits into from
Sep 1, 2023
Merged

Fix underflow bug #1430

merged 7 commits into from
Sep 1, 2023

Conversation

Juan-M-V
Copy link
Contributor

TITLE

Description

Fixes #1426

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.
    • CHANGELOG has been updated.

@codecov
Copy link

codecov bot commented Aug 30, 2023

Codecov Report

Merging #1430 (0cd3f14) into main (91eeff5) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1430   +/-   ##
=======================================
  Coverage   96.98%   96.98%           
=======================================
  Files          93       93           
  Lines       38504    38544   +40     
=======================================
+ Hits        37342    37382   +40     
  Misses       1162     1162           
Files Changed Coverage Δ
..._processor/builtin_hint_processor/uint256_utils.rs 99.19% <100.00%> (+0.04%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@pefontana pefontana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one @Juan-M-V !!!
Can we add an integration test with a cairo program?

@github-actions
Copy link

github-actions bot commented Aug 30, 2023

Benchmark Results for modified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
head big_factorial 3.619 ± 0.021 3.591 3.645 1.00
Command Mean [s] Min [s] Max [s] Relative
head big_fibonacci 3.108 ± 0.013 3.087 3.125 1.00
Command Mean [s] Min [s] Max [s] Relative
head blake2s_integration_benchmark 8.909 ± 0.087 8.826 9.076 1.00
Command Mean [s] Min [s] Max [s] Relative
head compare_arrays_200000 3.210 ± 0.058 3.164 3.341 1.00
Command Mean [s] Min [s] Max [s] Relative
head dict_integration_benchmark 2.167 ± 0.016 2.146 2.202 1.00
Command Mean [s] Min [s] Max [s] Relative
head field_arithmetic_get_square_benchmark 1.653 ± 0.007 1.642 1.663 1.00
Command Mean [s] Min [s] Max [s] Relative
head integration_builtins 9.029 ± 0.135 8.821 9.204 1.00
Command Mean [s] Min [s] Max [s] Relative
head keccak_integration_benchmark 9.164 ± 0.224 8.964 9.636 1.00
Command Mean [s] Min [s] Max [s] Relative
head linear_search 3.374 ± 0.062 3.243 3.490 1.00
Command Mean [s] Min [s] Max [s] Relative
head math_cmp_and_pow_integration_benchmark 2.319 ± 0.006 2.305 2.326 1.00
Command Mean [s] Min [s] Max [s] Relative
head math_integration_benchmark 2.091 ± 0.011 2.074 2.107 1.00
Command Mean [s] Min [s] Max [s] Relative
head memory_integration_benchmark 1.852 ± 0.011 1.832 1.872 1.00
Command Mean [s] Min [s] Max [s] Relative
head operations_with_data_structures_benchmarks 2.091 ± 0.088 2.051 2.338 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
head pedersen 775.2 ± 3.4 769.4 779.7 1.00
Command Mean [s] Min [s] Max [s] Relative
head poseidon_integration_benchmark 1.494 ± 0.017 1.482 1.539 1.00
Command Mean [s] Min [s] Max [s] Relative
head secp_integration_benchmark 2.528 ± 0.008 2.515 2.542 1.00
Command Mean [s] Min [s] Max [s] Relative
head set_integration_benchmark 1.333 ± 0.010 1.325 1.361 1.00
Command Mean [s] Min [s] Max [s] Relative
head uint256_integration_benchmark 5.852 ± 0.036 5.798 5.915 1.00

CHANGELOG.md Outdated
@@ -2,6 +2,8 @@

#### Upcoming Changes

* fix: Using UINT256_HINT no longer panics when b is greater than 2^256 [#1430]([htt](https://github.com/lambdaclass/cairo-vm/pull/1430)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* fix: Using UINT256_HINT no longer panics when b is greater than 2^256 [#1430]([htt](https://github.com/lambdaclass/cairo-vm/pull/1430)
* fix: Using UINT256_HINT no longer panics when b is greater than 2^256 [#1430](https://github.com/lambdaclass/cairo-vm/pull/1430)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved: 0cd3f14

@Juan-M-V
Copy link
Contributor Author

Nice one @Juan-M-V !!! Can we add an integration test with a cairo program?

I only added uint tests because normally the hint throws an error when b is too big. This happens on the python implementation. Now our VM throws an error instead of panicking.
Should I test the failure with a cairo program anyways?

Copy link
Member

@pefontana pefontana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@pefontana pefontana added this pull request to the merge queue Sep 1, 2023
Merged via the queue into main with commit 373a4fd Sep 1, 2023
39 checks passed
@pefontana pefontana deleted the fix-pack-underflow branch September 1, 2023 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uint256 sub can trigger an underflow
3 participants