You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.
Despite the transactions showing successful execution, for and while loop tests failed to increment a counter at all when the number of iterations was set greater than a particular value. The number of iterations at which the behavior changed varied when tested at different times. For example, using 500 iterations produced both expected and unexpected behaviors at different times.
Steps to reproduce:
Setup:
Run a local Katana RPC using Docker.
Deploy the contract below using Remix with environment set to "Injected Provider - Metamask".
Test a for loop:
Run the testForLoop function passing 50 as input
Calling count returns 50
Now run the testForLoop function passing 5000 as input
Calling count returns 50
Test a while loop:
Run the testWhileLoop function passing 50 as input
Calling count returns 50
Now run the testForLoop function passing 5000 as input
Calling count returns 50
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract ControlStructureTest {
uint256 public count = 0;
function testForLoop(uint256 iterations) public {
count = 0;
for (uint256 i = 0; i < iterations; i++) {
count++;
}
}
function testWhileLoop(uint256 iterations) public {
count = 0;
while(count < iterations) {
count++;
}
}
}
Expected behavior:
Count should be equal to iterations after the transaction completes successfully. The expected behavior is observed when testing the same code in Remix's Shanghai VM.
Other information:
Increasing the gas limit didn't appear to change the behavior.
The text was updated successfully, but these errors were encountered:
Did some testing on Katana, when there are too many iterations the tx reverts with
Could not reach the end of the program. RunResources has no remaining steps.
The issue is more RPC related (which should propagate the error) than from Kakarot actually.
As a matter of fact, with few benchmark I've done:
while loop
100 iterations => 2448973 steps
200 iterations => 4506041 steps
300 iterations => failing with 6124644 Could not reach the end of the program. RunResources has no remaining steps.
for loop
100 => 3042592
200 => 5096151 & failing
I'm creating a PR to add the test to track perf, but this is not a kakarot issue per se, so closing this issue.
In any case, quite surprising as well to have katana failing with 6124644 while it's supposed to be started with --invoke-max-steps 16777216
Bug Report
Kakarot version:
Current behavior:
Despite the transactions showing successful execution, for and while loop tests failed to increment a counter at all when the number of iterations was set greater than a particular value. The number of iterations at which the behavior changed varied when tested at different times. For example, using 500 iterations produced both expected and unexpected behaviors at different times.
Steps to reproduce:
Setup:
Test a for loop:
testForLoop
function passing 50 as inputcount
returns 50testForLoop
function passing 5000 as inputcount
returns 50Test a while loop:
testWhileLoop
function passing 50 as inputcount
returns 50testForLoop
function passing 5000 as inputcount
returns 50Expected behavior:
Count should be equal to iterations after the transaction completes successfully. The expected behavior is observed when testing the same code in Remix's Shanghai VM.
Other information:
Increasing the gas limit didn't appear to change the behavior.
The text was updated successfully, but these errors were encountered: