-
Notifications
You must be signed in to change notification settings - Fork 43
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 bug in cairo tests (test_u256_div_mod_n) #498
Fix bug in cairo tests (test_u256_div_mod_n) #498
Conversation
@edg-l feel free to review this PR now |
A few comments:
|
Nevermind 3, the test is still failing: https://github.com/lambdaclass/cairo_native/actions/runs/8413665899/job/23056870188?pr=498#step:11:5547 |
Hi @Oppen The first thing I noticed was that Then using
It wasn't still clear to me what the issue was so decided to look into the I still needed to debug so I decided to take a look at the // Helper for making a non-zero value.
fn nz<N, +TryInto<N, NonZero<N>>, +Copy<N>, +Display<N>, +Drop<N>, +Debug<N>>(n: N) -> NonZero<N>{
let value = n.try_into();
println!("value after try_into: {:?}", value);
let value2 = value.unwrap();
value2
} and that's where I saw this error message
I thought I was making progress and the issue was with the For some reason after that the tests passed Here's a recent screenshot of all the So that was basically my process. At this point, I'm realizing it does not make sense and the issue has to be somewhere else. I'll continue researching and trying it and see if I can fix it What still not clear to me is why is it that the tests pass sometimes Please let me know if you have any suggestion or comment about this |
The test must not be changed, it's taken from the corelib tests, so if it doesn't pass it's an error we must fix on native, not adapt the test for it to pass. |
@edg-l That's something that I noticed this past weekend. The issue seems to be on the |
d6db794
to
716490c
Compare
HI guys @edg-l @Oppen @azteca1998 I did change the logic of that function locally and seems like I made it work. I made use of another function that we have on the same file to find the inverse of a modulo n named Now, since this file (math.cairo) is part of the core Cairo code I don't know how to proceed 😅 . Now, I also noticed that the problem in this project (cairo_native) could be the way I'm still looking into this last one but it's taking me longer to understand that logic I would appreciate some guidance, comments (because that might not be the best approach), and help. Please let me know if the change makes sense and If I have to proceed and apply the change to the core Cairo lib. Thanks |
Hello, and thanks for your time. Those tests are passing when ran through the VM, which is our reference implementation and therefore considered the correct behaviour. Cairo native must match that behaviour. The fact that the same code executed with Cairo Native makes the test fail means that we have a bug, which is what this issue is for. Ideally, everything that works in the VM should work here too. Regardless of whether the corelib is correct or not we're not the ones in charge of that. We cannot accept changes made there because those files aren't ours, they're from the Cairo language's standard library (corelib). |
716490c
to
ee75915
Compare
Hi @azteca1998 And you are right, the corelib is something different and I shouldn't focus on that I'm trying to add tests to refactor the |
I think #569 solves the |
Hi @tcoratger |
This is already fixed in main by another pr, closing this, but thanks for your time! |
This PR fixes the bug reported in #472
The issue was a problem with the
nz
function.It was an issue with the usage of
.unwrap()
in cases where it failed and with the Display and Debug traits on that function.I did modify the implementation of that function and seems to be working now.
Checklist
Screenshots