kkrt-labs / kakarot

Kakarot is a zkEVM written in Cairo, leveraging the STARK proof system.
https://kakarot.org
MIT License
974 stars 287 forks source link

dev: add profiling for solidity loops #1249

Closed greged93 closed 2 months ago

greged93 commented 3 months ago

Loops seem to take a lot of steps on execution. I think we can highly optimise them by profiling what takes the more steps in a loop. The below solidity contract can be used as a bench:

pragma solidity >=0.8.0;

contract Loop {
    function loop(uint256 max) pure public {
        uint256 val = 0;
        for (uint256 i =0; i<max; i++){
            val += i;
        }
    }
}

For reference, the execution of the loop for the above contract currently takes 14_093_197 steps when ran with max = 400 (check starkli transaction-receipt 0x142c47b0d4000f9c37490237b36a1e5cdf455b9e2a17cf4fa70974e19a5ecac on Kakarot Sepolia).

elielnfinic commented 3 months ago

Can I take this task?

onlydustapp[bot] commented 3 months ago

Hey @elielnfinic! Thanks for showing interest. We've created an application for you to contribute to Kakarot zkEVM. Go check it out on OnlyDust!

greged93 commented 3 months ago

Hey @elielnfinic, I think this would be a little complicated for someone who hasn't yet worked on our repo.

elielnfinic commented 3 months ago

Alright @greged93, no problem.