0

We're having issues with remix. It crashes on third iteration in for loop. When we try to run verify method, it successfully runs 2 iterations of for loop. However, in third iteration remix crashes. Here is part of our code:

function verifyFairness (string memory clientSeed, string memory privateKey, uint minRange, uint maxRange, uint256[] memory results) public pure returns (bool) {
    string memory newPrivateKey = "";
    for(uint i=0; i<results.length; i++){
        if(i == 0) {
            newPrivateKey = privateKey;
        }
        if (results[i] == calculateNumber (clientSeed, newPrivateKey, minRange, maxRange)){
            newPrivateKey = string(abi.encodePacked(calculateServerSecretHash(results[i], newPrivateKey)));
        } else {
            return false;
        }
    }
    return true;
}

CalculateNumber and CalculateServerHash are our methods. In one we use keccak256 and in other is one for loop.

1
  • What's the question? Remix runs inside a browser so it is limited by the browser sandbox. In the past it crashed while doing complex computations. I'd recommend to try running the contracts under ganache, geth, openethereum or besu which should work for regular transactions.
    – Ismael
    Apr 13 at 2:37
0

In the compiler configuration, make sure you select "Enable Optimization". That will give you a little more headroom, but it's not a long term solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.