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

Add missing methods to lambdaworks implementation #1290

Merged
merged 6 commits into from Jun 28, 2023
Merged

Conversation

MegaRedHand
Copy link
Contributor

Description

This PR adds the missing methods on the LambdaWorks Felt252 implementation and marks them as #[deprecated] in both implementations.

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 Jun 27, 2023

Codecov Report

Merging #1290 (bdfa0a0) into main (05f2f4a) will decrease coverage by 0.04%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main    #1290      +/-   ##
==========================================
- Coverage   97.94%   97.90%   -0.04%     
==========================================
  Files          89       89              
  Lines       35452    35465      +13     
==========================================
  Hits        34723    34723              
- Misses        729      742      +13     
Impacted Files Coverage Δ
felt/src/lib_lambdaworks.rs 97.79% <0.00%> (-1.10%) ⬇️

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

@github-actions
Copy link

github-actions bot commented Jun 27, 2023

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 10.868 ± 0.026 10.834 10.905 1.00 ± 0.00
head blake2s_integration_benchmark 10.847 ± 0.028 10.814 10.895 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 3.655 ± 0.015 3.628 3.686 1.00
head compare_arrays_200000 3.656 ± 0.018 3.639 3.695 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 2.450 ± 0.019 2.431 2.494 1.00 ± 0.01
head dict_integration_benchmark 2.442 ± 0.005 2.430 2.447 1.00
Command Mean [s] Min [s] Max [s] Relative
base factorial_multirun 3.850 ± 0.018 3.830 3.887 1.00
head factorial_multirun 3.855 ± 0.022 3.828 3.892 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base fibonacci_1000_multirun 3.322 ± 0.007 3.312 3.332 1.00 ± 0.00
head fibonacci_1000_multirun 3.306 ± 0.011 3.292 3.334 1.00
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.918 ± 0.007 1.911 1.930 1.00
head field_arithmetic_get_square_benchmark 1.922 ± 0.010 1.911 1.939 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 9.781 ± 0.052 9.730 9.902 1.00
head integration_builtins 9.781 ± 0.046 9.735 9.897 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 11.010 ± 0.150 10.900 11.374 1.00 ± 0.02
head keccak_integration_benchmark 10.976 ± 0.091 10.908 11.155 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 3.694 ± 0.006 3.685 3.704 1.00 ± 0.00
head linear_search 3.688 ± 0.010 3.675 3.709 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 2.571 ± 0.013 2.551 2.599 1.00 ± 0.01
head math_cmp_and_pow_integration_benchmark 2.569 ± 0.007 2.557 2.579 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 2.400 ± 0.024 2.374 2.455 1.01 ± 0.01
head math_integration_benchmark 2.379 ± 0.014 2.352 2.399 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 2.075 ± 0.007 2.065 2.088 1.00
head memory_integration_benchmark 2.078 ± 0.007 2.070 2.088 1.00 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 2.355 ± 0.012 2.342 2.376 1.00
head operations_with_data_structures_benchmarks 2.361 ± 0.010 2.347 2.377 1.00 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 839.8 ± 0.7 838.6 841.2 1.00 ± 0.00
head pedersen 839.3 ± 2.1 836.1 842.3 1.00
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.579 ± 0.007 1.571 1.594 1.00
head poseidon_integration_benchmark 1.581 ± 0.006 1.573 1.593 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 2.746 ± 0.020 2.725 2.793 1.00 ± 0.01
head secp_integration_benchmark 2.742 ± 0.013 2.727 2.762 1.00
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 1.308 ± 0.019 1.297 1.356 1.01 ± 0.01
head set_integration_benchmark 1.298 ± 0.003 1.293 1.303 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 6.977 ± 0.069 6.935 7.167 1.00
head uint256_integration_benchmark 6.979 ± 0.031 6.940 7.039 1.00 ± 0.01

Copy link
Member

@juanbono juanbono left a comment

Choose a reason for hiding this comment

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

I'm ok with just returning an &[u8; 32] instead of vec. The main issue is that the name was modified and as a consequence it broke the interface.

So I think that another option can be to just change the name to the impl that returns a &[u8;32].

@MegaRedHand
Copy link
Contributor Author

Did some changes. The diff would be:

  • Added From<&BigUint> for Felt252 (this was already in the old felt, but wasn't migrated to the LW felt)
  • Added to_bytes_be to the LW felt
  • Both to_signed_bytes_le and modpow were marked as deprecated in the old felt (they won't be migrated to the new one)

@MegaRedHand MegaRedHand added this pull request to the merge queue Jun 28, 2023
Merged via the queue into main with commit d46d2b6 Jun 28, 2023
33 of 34 checks passed
@MegaRedHand MegaRedHand deleted the unify-felt-apis branch June 28, 2023 20:49
kariy pushed a commit to dojoengine/cairo-rs that referenced this pull request Jul 4, 2023
* Add missing methods to lambdaworks impl

* Remove `modpow` and `to_signed_bytes_le` from lw-felt

* Add `From<&Big(U)Int>` to lw-felt
* Move comments out of `FeltOps` and remove trait

* Fix build

* Update changelog

* Uncomment deprecated tags
kariy pushed a commit to dojoengine/cairo-rs that referenced this pull request Jul 4, 2023
* Add missing methods to lambdaworks impl

* Remove `modpow` and `to_signed_bytes_le` from lw-felt

* Add `From<&Big(U)Int>` to lw-felt
* Move comments out of `FeltOps` and remove trait

* Fix build

* Update changelog

* Uncomment deprecated tags
kariy pushed a commit to dojoengine/cairo-rs that referenced this pull request Jul 25, 2023
* Add missing methods to lambdaworks impl

* Remove `modpow` and `to_signed_bytes_le` from lw-felt

* Add `From<&Big(U)Int>` to lw-felt
* Move comments out of `FeltOps` and remove trait

* Fix build

* Update changelog

* Uncomment deprecated tags
kariy pushed a commit to dojoengine/cairo-rs that referenced this pull request Jul 25, 2023
* Add missing methods to lambdaworks impl

* Remove `modpow` and `to_signed_bytes_le` from lw-felt

* Add `From<&Big(U)Int>` to lw-felt
* Move comments out of `FeltOps` and remove trait

* Fix build

* Update changelog

* Uncomment deprecated tags
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.

None yet

3 participants