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

Catch possible subtraction error in QUAD_BIT & DI_BIT hints #1185

Merged
merged 4 commits into from
May 29, 2023

Conversation

fmoletta
Copy link
Contributor

Now returns an error if ids.m is zero

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.

@fmoletta fmoletta linked an issue May 29, 2023 that may be closed by this pull request
@fmoletta fmoletta marked this pull request as ready for review May 29, 2023 19:19
@codecov
Copy link

codecov bot commented May 29, 2023

Codecov Report

Merging #1185 (4b2cd40) into main (45bf5c8) will decrease coverage by 0.01%.
The diff coverage is 94.44%.

@@            Coverage Diff             @@
##             main    #1185      +/-   ##
==========================================
- Coverage   97.70%   97.70%   -0.01%     
==========================================
  Files          89       89              
  Lines       35847    35865      +18     
==========================================
+ Hits        35025    35042      +17     
- Misses        822      823       +1     
Impacted Files Coverage Δ
..._processor/builtin_hint_processor/secp/ec_utils.rs 99.48% <94.44%> (-0.10%) ⬇️

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

@github-actions
Copy link

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 16.617 ± 0.303 16.257 17.198 1.02 ± 0.02
head blake2s_integration_benchmark 16.308 ± 0.136 16.051 16.498 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 5.551 ± 0.054 5.436 5.638 1.01 ± 0.02
head compare_arrays_200000 5.509 ± 0.101 5.369 5.723 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 3.664 ± 0.045 3.607 3.749 1.00 ± 0.01
head dict_integration_benchmark 3.647 ± 0.024 3.607 3.676 1.00
Command Mean [s] Min [s] Max [s] Relative
base factorial_multirun 5.829 ± 0.067 5.732 5.942 1.00
head factorial_multirun 5.939 ± 0.056 5.835 6.016 1.02 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base fibonacci_1000_multirun 5.033 ± 0.073 4.956 5.213 1.00
head fibonacci_1000_multirun 5.059 ± 0.058 4.979 5.175 1.01 ± 0.02
Command Mean [ms] Min [ms] Max [ms] Relative
base field_arithmetic_get_square_benchmark 222.5 ± 6.7 214.9 237.2 1.03 ± 0.04
head field_arithmetic_get_square_benchmark 217.0 ± 4.0 212.9 225.1 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 15.014 ± 0.713 14.481 16.893 1.00 ± 0.05
head integration_builtins 14.980 ± 0.186 14.642 15.307 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 16.884 ± 0.226 16.520 17.227 1.02 ± 0.02
head keccak_integration_benchmark 16.573 ± 0.172 16.218 16.751 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 5.558 ± 0.068 5.449 5.680 1.00
head linear_search 5.592 ± 0.068 5.503 5.758 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 3.979 ± 0.038 3.934 4.036 1.01 ± 0.01
head math_cmp_and_pow_integration_benchmark 3.923 ± 0.023 3.895 3.975 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 3.715 ± 0.071 3.613 3.894 1.00 ± 0.03
head math_integration_benchmark 3.708 ± 0.079 3.660 3.923 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 3.152 ± 0.034 3.116 3.231 1.01 ± 0.01
head memory_integration_benchmark 3.132 ± 0.032 3.091 3.195 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 3.557 ± 0.049 3.457 3.630 1.01 ± 0.02
head operations_with_data_structures_benchmarks 3.513 ± 0.022 3.477 3.546 1.00
Command Mean [s] Min [s] Max [s] Relative
base pedersen 1.201 ± 0.078 1.158 1.421 1.03 ± 0.07
head pedersen 1.170 ± 0.012 1.151 1.186 1.00
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 2.060 ± 0.028 2.028 2.118 1.00 ± 0.02
head poseidon_integration_benchmark 2.053 ± 0.013 2.035 2.078 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 4.545 ± 0.047 4.471 4.622 1.00 ± 0.02
head secp_integration_benchmark 4.544 ± 0.066 4.481 4.709 1.00
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 2.683 ± 0.059 2.637 2.809 1.01 ± 0.03
head set_integration_benchmark 2.646 ± 0.037 2.600 2.738 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 10.107 ± 0.138 9.947 10.343 1.00
head uint256_integration_benchmark 10.158 ± 0.127 9.985 10.406 1.00 ± 0.02

@@ -179,4 +179,6 @@ pub enum HintError {
RecoverYPointNotOnCurve(Felt252),
#[error("Invalid value for {0}. Got: {1}. Expected: {2}")]
InvalidValue(&'static str, Felt252, Felt252),
#[error("Attempt to subtract with overflow: ids.m - 1")]
NPairBitsMZero,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should use a more descriptive name to this new error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose this name as it is more useful when debugging, as it has the name of the function that fails and the failure case, while leaving the error string useful for users, a more descriptive name could be NPairBitsMMinusOneSubtractioOverflow or MMinusOneSubtractionOverflow but it doesn't sound that much useful

@pefontana pefontana added this pull request to the merge queue May 29, 2023
Merged via the queue into main with commit 0a14a99 May 29, 2023
@pefontana pefontana deleted the fix-n-pair-bits-possible-panick branch May 29, 2023 22:51
kariy pushed a commit to dojoengine/cairo-rs that referenced this pull request Jun 23, 2023
…daclass#1185)

* Catch possible sustraction error in QUAD_BIT & DI_BIT hints

* Fix changelog entry

* Typo

* Fix changelog entry
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.

Hints QUAD_BIT & DI_BIT panick if ids. m = 1
3 participants