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

bug: EXP will run out of resources on high exponent #700

Closed
Tracked by #28 ...
greged93 opened this issue Aug 25, 2023 · 0 comments · Fixed by #809
Closed
Tracked by #28 ...

bug: EXP will run out of resources on high exponent #700

greged93 opened this issue Aug 25, 2023 · 0 comments · Fixed by #809
Assignees

Comments

@greged93
Copy link
Contributor

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:

let (b_minus_one) = uint256_sub(b, one_uint);
let temp_pow = internal_exp(a=a, b=b_minus_one);
let (res, _) = uint256_mul(a, temp_pow);
return res;
}

Expected behavior:
Exponentiation should work for high value of exponent.

Steps to reproduce:

TARGET=expPower256_d0g0v0_Shanghai cargo test -p ef-testing --features ef-tests -- --nocapture

Failing output should be:

2023-08-25T09:40:07.242339Z  WARN katana_core::backend::executor: Transaction execution error: "Error in the called contract (0x04e2460d0debdacdde372cb598b4e4403939ca112c8720e1c2aca13f6ac09b9a):
Error at pc=0:7:
Got an exception while executing a hint.
Cairo traceback (most recent call last):
Unknown location (pc=0:163)
Unknown location (pc=0:149)

Error in the called contract (0x04e2460d0debdacdde372cb598b4e4403939ca112c8720e1c2aca13f6ac09b9a):
Error at pc=0:31:
Got an exception while executing a hint.
Cairo traceback (most recent call last):
Unknown location (pc=0:4606)
Unknown location (pc=0:4545)
Unknown location (pc=0:4374)
Unknown location (pc=0:376)

Error in the called contract (0x049c085e55e5ab05ea46e16706720852421e86c1f8aeeab2be257313c4e290f4):
Error at pc=0:490:
Could not reach the end of the program. RunResources has no remaining steps.
Cairo traceback (most recent call last):
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18120)
Unknown location (pc=0:18022)
Unknown location (pc=0:17250)
Unknown location (pc=0:9424)
"
[!] Case ~/code/rust/ef-tests/crates/ef-testing/ethereum-tests/BlockchainTests/GeneralStateTests/VMTests/vmArithmeticTest/expPower256.json failed (description: expPower256): Test failed: failed test expPower256_d0g0v0_Shanghai: expected storage value 0x0000000000000000000000000000000000000000000000000000000000000001, got 0x0000000000000000000000000000000000000000000000000000000000000000
@github-project-automation github-project-automation bot moved this to 🆕 Backlog in Kakarot on Starknet Aug 25, 2023
@Eikix Eikix added this to the Official Ethereum Conformance milestone Aug 29, 2023
@Eikix Eikix mentioned this issue Nov 14, 2023
7 tasks
@Eikix Eikix self-assigned this Nov 14, 2023
@Eikix Eikix moved this from 🆕 Backlog to 🏗 In progress in Kakarot on Starknet Nov 14, 2023
Eikix added a commit that referenced this issue Nov 16, 2023
<!--- Please provide a general summary of your changes in the title
above -->

<!-- Give an estimate of the time you spent on this PR in terms of work
days.
Did you spend 0.5 days on this PR or rather 2 days?  -->

Time spent on this PR:

## Pull request type

<!-- Please try to limit your pull request to one type,
submit multiple pull requests if needed. -->

Please check the type of change your PR introduces:

- [ ] Bugfix
- [x] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying,
or link to a relevant issue. -->

Resolves #700 

## What is the new behavior?
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Kakarot on Starknet Nov 16, 2023
matthieuauger pushed a commit to matthieuauger/kakarot that referenced this issue Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants