-
Notifications
You must be signed in to change notification settings - Fork 50
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
feat: Replace secp_utils usage of big.Int
with uint256 library.
#355
Conversation
@rodrigo-pino i have a few questions : should i also modify Also, |
Hey @TAdev0! Yes please add both functions since their values are never bigger than the 256 bits space. Regarding the code that uses them, it must be updated as well since we need the CI to pass in order to merge. In case the consecuences of using uint64 library are very hard to integrate we can do smth good enough now and follow it up with another PR focused on that |
@rodrigo-pino ready for a first review. Not sure everything is correct with my syntax. |
There are some errors. Especially compilations one. Could you please fix them. Also you can test most of the CI by doing |
@rodrigo-pino yeah thank you! i'm installing Go right now, will do that. |
@rodrigo-pino I have residual mismatch issues, for example:
I double checked that i correctly defined constants in I suspect that the issue comes from |
I see that's weird, maybe something to do with references? My tip for debugging would be testing the failing functions one by one with some prints scattered around. You'll eventually find the wrong piece of code |
@rodrigo-pino comments addressed. I still need to figure out this issue. |
Ok left some other small ones, regarding the issue, I'll try to look it later. Can you debug it manually with prints? |
@rodrigo-pino ok so basically, i fail for all
I even tried keeping BigInt for |
I did a super quick check. In Before:
After:
The failing tests seem to be using quite large values though. Could it be the test values are just unrealistic? Though I would say the results should match the python vm regardless. |
By looking at the python VM code you immediately realize that input values are always less than 256 bits, and output values are always smaller as well. This means that assuming the current implementation is correct, the one with big.Ints was flawed. It is possible the tests are actually not returning a correct value by using wrong inputs. The python and the go vm should always return the same value, but if the python vm expect always it's input to be in the 256 bits range, whatever we throw at it bigger than it is not valid for comparison. We are loooking to match the python vm in the 256 bit range not on bigger stuff, assuming of course, that to the python VM you could feed bigger stuff, to which there is not test to show it. |
If there is a test that inputs a number bigger than 256 bits or returns as an output a number bigger than 256 bits, that test is not correct. |
The first failing seems to be related to this code:
error is not thrown while it should
Their might be an issue related to the |
I dont think so. I tried changing just that part:
And it passed. |
I also tried for DivMod it passes as well |
Lets just remove the test. I was trying to make the results always be consistent with the python vm. If we are using uint256 then might as well assume the value will always be a uint256 written to scope. The test which fails makes no sense in that context. |
@har777 you want to remove all failing tests? what is the reason for the 2 others failing? I cannot find any reason for now. |
Just this one:
|
mmh i dont understand. If i remove this test, i still have many tests failing. |
@rodrigo-pino @har777 I annotated all failing tests so that tests pass for the CI. For now, I use uint256 instead of bigint everywhere for utils It includes :
|
@rodrigo-pino comments addressed. I left the type where it makes sense to leave it, and remove in all other places |
…ev0/cairo-vm-go into replace_big_int_with_uint256
@rodrigo-pino had a few conflicts, i have other tests failing now. It is getting a bit difficult to understand whats going on, maybe should we close this and do it once all hints are implemented? Or maybe merging this soon, because there will be additionnal conflicts after PR are merged |
Hey @TAdev0 the solution is good, let's put it on hold until we can asses with clarity the |
sure |
I'm adding the |
We want to wait until the hints are all merged, this means there are going to be a lot of conflicts to fix and a lot more of code to modify. I'm closing this PR for the moment, we can open a new one with fresh changes |
No description provided.