-
Notifications
You must be signed in to change notification settings - Fork 210
feat: Add feature lambdaworks-felt to felt & cairo-vm crates
#1281
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
Merged
Merged
Changes from 122 commits
Commits
Show all changes
135 commits
Select commit
Hold shift + click to select a range
061064e
wip
pefontana cb0ee30
Manually implement some common derives
MegaRedHand 2d1659e
Implement FromPrimitive
MegaRedHand fbe3676
Implement ToPrimitive
MegaRedHand 9cf6988
Add BitAnd/Xor/Or implementations
MegaRedHand e0f18f4
Implement bit shift operators
MegaRedHand 6747209
Remove Signed implementation
MegaRedHand d653271
Remove Integer impl
MegaRedHand fc0ca5e
Impl Bounded
MegaRedHand e164ef5
Impl from_str_radix
MegaRedHand 1a45f45
Add iter_u64_digits impl
MegaRedHand a74de07
Add Add impls
MegaRedHand 3a32072
Add Sub impls
MegaRedHand 2088c18
Patch arbitrary
MegaRedHand 0093e6f
Fix some warnings
MegaRedHand c2a2c2c
Implement parse_bytes
MegaRedHand bbb1758
Implement utility methods for tests
MegaRedHand 84dec45
Fix test compilation errors
MegaRedHand 4ad7493
Add From impl for signed primitive nums
MegaRedHand c854aa5
Impl From<BigInt>
MegaRedHand a8a8aa5
Re-add bits fn
MegaRedHand 8228211
Impl Signed
MegaRedHand 7a44c1a
Impl (De)Serialize
MegaRedHand 0f23d8e
Fix compile errors and clippy suggestions
MegaRedHand c8e51c8
Pin cairo 1 compiler version
MegaRedHand ff3f93e
Reorder impls
MegaRedHand 4c38bac
Fix compile error
MegaRedHand 5185ea8
Fix various errors (tests pass!)
MegaRedHand b6ad868
Remove to_bytes_be
MegaRedHand a1e6b74
Fix panicky from_bytes_be
MegaRedHand ae927b7
Fix is_positive
MegaRedHand 37ef285
Fix str conversions
MegaRedHand f49f2f7
Add documentation
MegaRedHand 92f57a8
Fix from_i64 accepting negative numbers
MegaRedHand 5881d8c
Use BigUint in from_bytes_be
MegaRedHand a150ac7
Remove unneded field macro
MegaRedHand a5c25ff
Pin lambdaworks commit
MegaRedHand 3978a4a
Fix keccak
MegaRedHand 70f28b8
Fix from_i64 condition was reversed
MegaRedHand 37e9a45
Change Debug::fmt to return number in decimal
MegaRedHand a2b003e
Appease clippy in felt crate
MegaRedHand 168ba45
Merge branch 'main' into lambdaworks-felt
MegaRedHand 647345b
Silence clippy warning (for now)
MegaRedHand ed67ccc
Fix nostd error
MegaRedHand 7b6ecfd
Update lambdaworks to latest revision
MegaRedHand 06d206f
Update rust version in CI
MegaRedHand 0d0c0b2
Merge branch 'main' into lambdaworks-felt
MegaRedHand c2ca57b
Change sqrt for lambdaworks'
MegaRedHand 647ff67
Manually build BigDigits on to_biguint
MegaRedHand aa15dc5
Merge branch 'main' into lambdaworks-felt
MegaRedHand 5b2d505
Use a bigger number of iterations for square bench
MegaRedHand c2ee0cf
Update lambdaworks-math revision
MegaRedHand 4a17dc1
Fix sqrt tests and Shl/Shr impl (+add tests)
MegaRedHand 939ee06
Update Cargo.lock
MegaRedHand 175289a
Appease clippy and fix Shr<usize>
MegaRedHand 4667b3e
Square input instead of using prop_assume
MegaRedHand 63d1360
Revert the change to Shr
MegaRedHand 5db1ebe
Merge branch 'main' into lambdaworks-felt
MegaRedHand 413b813
Appease clippy
MegaRedHand 808c803
Use bits instead of shl in range check
MegaRedHand 6a8ca26
Remove `FeltBigInt`
MegaRedHand f3a7a0d
Add lamdaworks-benchmarks.sh
pefontana 987a114
Add lamdaworks-benchmarks.md
pefontana 7dd7d58
Update lamdaworks-benchmarks.md
pefontana 60b3e37
Update commits
pefontana 906adfd
Update .md commits
pefontana c2b7f18
Looooong benchmark
Oppen 3ec78e4
Remove bigbox clippy allow
MegaRedHand 96f12a4
Update lambdaworks to latest, and change AddAssign
MegaRedHand b64b0ca
Remove `-P` option in `xargs`
MegaRedHand 400effe
Change `to_(b|l)e_bytes` to not use lw primitives
MegaRedHand 9ba90c3
Change comments in `Add<&Felt252> for u64`
MegaRedHand 03cb2dd
Fix: wasn't indexing properly :P
MegaRedHand 171520c
Override default `div_mod_floor` impl for Felt252
MegaRedHand 0be0200
Merge branch 'main' into lambdaworks-felt
pefontana 11bc48a
Disable swap memory before benchmarking
MegaRedHand 0b1a15e
Reduce number of warmups and runs
MegaRedHand 9bec2cf
Merge branch 'main' into lambdaworks-felt
MegaRedHand 82e5882
Optimize `assert_le_felt`
MegaRedHand 5a366e9
Avoid calling `BigInt::abs`
MegaRedHand 8602139
Update changelog
MegaRedHand 6009eba
Add tests for felt
MegaRedHand 9411f03
Add TODO
MegaRedHand b310376
Add other texts
MegaRedHand 58920da
Merge branch 'main' into lambdaworks-felt
MegaRedHand bba3a59
Update lambdaworks to latest
MegaRedHand c276737
Revert hyperfine arguments to main
MegaRedHand 4bce996
Remove unneeded clones and into_owneds
MegaRedHand fbfa88c
Remove unneeded references and clones
MegaRedHand 3e67fbb
Add BREAKING note to changelog
MegaRedHand 026ebce
Merge branch 'main' into lambdaworks-felt
MegaRedHand 308f580
Make Felt252::one just copy a constant
MegaRedHand 6508d21
Impl From<bool> for Felt252
MegaRedHand 06b0c82
Change some uses of get_ref with get_mut_ref
MegaRedHand 37ba2a4
Unify mem*_continue_* functions
MegaRedHand ed2cd48
Run benchmarks sequentially to avoid mem issues
MegaRedHand 6c00c45
Use div_mod_floor instead of div and mod
MegaRedHand 073f44c
Use BigUint for non-modular calculations
MegaRedHand 376c723
Add TODO
MegaRedHand b441d2f
Merge branch 'main' into lambdaworks-felt
MegaRedHand 5926939
Merge branch 'main' into lambdaworks-felt
MegaRedHand 4793edb
Merge branch 'main' into lambdaworks-felt
MegaRedHand 6f73dba
Merge branch 'main' into lambdaworks-felt
MegaRedHand 766a67c
Merge branch 'main' into lambdaworks-felt
MegaRedHand eeecc8b
Merge branch 'main' into lambdaworks-felt
pefontana 90c48de
Merge branch 'main' into lambdaworks-felt
pefontana 785f5c9
Merge branch 'main' into lambdaworks-felt
pefontana 041da94
Include both lib.rs
fmoletta 2dd2be4
Fix lib_bigint_felt
fmoletta dff778f
Merge branch 'main' of github.com:lambdaclass/cairo-rs into lambdawor…
fmoletta dc6ecae
Add test-lambdaworks-felt workflow
fmoletta 2ccb08e
Fix failling example
fmoletta 10814cc
Move extern crate import to lib.rs
fmoletta ddff68b
Update changelog
fmoletta b85a6c3
Merge branch 'main' of github.com:lambdaclass/cairo-rs into lambdawor…
fmoletta cfb15d9
Fix changelog
fmoletta bdb5452
Fix example
fmoletta 59218ab
Remove benchmark docs
fmoletta 057d94e
Remove clone
fmoletta 4add087
Move crate-level attribute to lib.rs
fmoletta f528c5e
Fix changelog
fmoletta 2182ea8
Remove blank line in toml
fmoletta 4a47e1a
Use one line cfg directives
fmoletta bb5c2a2
Merge branch 'main' of github.com:lambdaclass/cairo-rs into lambdawor…
fmoletta ac8cb98
Remove reference
fmoletta dd7b797
Restore clone
fmoletta ef6f1a5
Fix doc test
fmoletta ed2ed3c
Add `lambdaworks-felt` feature to vm crate
fmoletta 779da51
Add instructions to (de)activate the new feature
MegaRedHand 6639d81
Use different matrix group for lambdaworks felt in CI
fmoletta c264536
Merge branch 'lambdaworks-felt-feature' of github.com:lambdaclass/cai…
fmoletta b01bc2b
Move the sections a bit
MegaRedHand 3818bbe
Update lambdaworks-math version to 0.1.1
fmoletta 55b73da
Merge branch 'lambdaworks-felt-feature' of github.com:lambdaclass/cai…
fmoletta acc1a36
Invert the part talking about features
MegaRedHand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,9 +74,7 @@ jobs: | |
|
|
||
| - name: Install Rust | ||
| if: ${{ steps.cache.outputs.cache-hit != 'true' }} | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| toolchain: 1.66.1 | ||
| uses: dtolnay/[email protected] | ||
|
|
||
| - name: Checkout | ||
| if: ${{ steps.cache.outputs.cache-hit != 'true' }} | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,11 +9,7 @@ jobs: | |
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - name: Install Rust | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| toolchain: 1.66.1 | ||
| override: true | ||
| profile: minimal | ||
| uses: dtolnay/[email protected] | ||
| - name: Python3 Build | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,11 +9,7 @@ jobs: | |
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - name: Install Rust | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| toolchain: 1.66.1 | ||
| override: true | ||
| profile: minimal | ||
| uses: dtolnay/[email protected] | ||
| - name: Python3 Build | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
|
|
@@ -46,11 +42,7 @@ jobs: | |
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - name: Install Rust | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| toolchain: 1.66.1 | ||
| override: true | ||
| profile: minimal | ||
| uses: dtolnay/[email protected] | ||
| - name: Python3 Build | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,11 +13,7 @@ jobs: | |
| - name: Checkout sources | ||
| uses: actions/checkout@v2 | ||
| - name: Install stable toolchain | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| profile: minimal | ||
| toolchain: stable | ||
| override: true | ||
| uses: dtolnay/[email protected] | ||
| - name: Publish crate cairo-take_until_unbalanced | ||
| env: | ||
| CRATES_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
|
|
@@ -34,4 +30,3 @@ jobs: | |
| env: | ||
| CRATES_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: cargo publish --token ${CRATES_TOKEN} --all-features -p cairo-vm | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| use lambdaworks_math::{field::element::FieldElement, unsigned_integer::element::UnsignedInteger}; | ||
| use num_traits::Zero; | ||
| use proptest::prelude::*; | ||
|
|
||
| use crate::{Felt252, FIELD_HIGH, FIELD_LOW}; | ||
|
|
||
| /// Returns a [`Strategy`] that generates any valid Felt252 | ||
| fn any_felt252() -> impl Strategy<Value = Felt252> { | ||
| (0..=FIELD_HIGH) | ||
| // turn range into `impl Strategy` | ||
| .prop_map(|x| x) | ||
| // choose second 128-bit limb capped by first one | ||
| .prop_flat_map(|high| { | ||
| let low = if high == FIELD_HIGH { | ||
| (0..FIELD_LOW).prop_map(|x| x).sboxed() | ||
| } else { | ||
| any::<u128>().sboxed() | ||
| }; | ||
| (Just(high), low) | ||
| }) | ||
| // turn (u128, u128) into limbs array and then into Felt252 | ||
| .prop_map(|(high, low)| { | ||
| let limbs = [ | ||
| (high >> 64) as u64, | ||
| (high & ((1 << 64) - 1)) as u64, | ||
| (low >> 64) as u64, | ||
| (low & ((1 << 64) - 1)) as u64, | ||
| ]; | ||
| FieldElement::new(UnsignedInteger::from_limbs(limbs)) | ||
| }) | ||
| .prop_map(|value| Felt252 { value }) | ||
| } | ||
|
|
||
| /// Returns a [`Strategy`] that generates any nonzero Felt252 | ||
| pub fn nonzero_felt252() -> impl Strategy<Value = Felt252> { | ||
| any_felt252().prop_filter("is zero", |x| !x.is_zero()) | ||
| } | ||
|
|
||
| impl Arbitrary for Felt252 { | ||
| type Parameters = (); | ||
|
|
||
| fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy { | ||
| any_felt252().sboxed() | ||
| } | ||
|
|
||
| type Strategy = SBoxedStrategy<Self>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.