-
Notifications
You must be signed in to change notification settings - Fork 84
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
bug: exponentiation will run indef. for high exponent - Issue Imported from Kakarot Cairo0 #184
Comments
This issue applies to Kakarot SSJ as well, we chose an algorithm in O(n) instead of O(log(n)) because for reasonably small values, division is more expensive than recursively multiplying more times in Cairo.
|
solution -> codegen tests comparing |
Important update: we are gathering some bugs in the Kakarot v0 codebase, we need to make sure each issue and each PR in Kakarot-ssj is aware of the lists of known bugs. Look at this link everytime you take an issue and check your issue isn't targeted by a known bug. |
Important update: we are gathering some bugs in the Kakarot v0 codebase, we need to make sure each issue and each PR in Kakarot-ssj is aware of the lists of known bugs. Look at this tracking issue everytime you take an issue and check your issue isn't targeted by a known bug. Will add this reminder in many places to make sure we keep track of known bugs. |
@enitrat are you working on this? I can take over otherwise |
You can take it, @enitrat is working on sstore rn |
nice! |
Sounds good to open a PR and perform "either or" techniques depending if n > 10 or < |
since |
I was checking the codebase: do we need |
It looks like It also looks like only U256WrappingPow is used - I propose that we clean unused implems from the codebase. I think these implems became useless once we moved to hardcoded POW_2 constant, and we haven't cleaned them. So not having pow for felt252 doesn't matter anymore 😄 |
Bug Report
Kakarot version: ee6458a
Current behavior:
Given a high exponent value when calling the EXP opcode, the transaction will run out of resources. This is due to the fact that we don't use the fast powering algorithm for high exponent values. See code below:
https://github.com/kkrt-labs/kakarot/blob/95df46cf88a4225d26e7a642fe2d149b41c55249/src/kakarot/instructions/stop_and_arithmetic_operations.cairo#L462-L466
Expected behavior:
Exponentiation should work for high value of exponent.
Steps to reproduce:
Failing output should be:
The text was updated successfully, but these errors were encountered: