[Compilers]<zksolc Bug Report> #513
-
Which compiler are you using?
Which version of Solidity or Vyper?0.8.25 zksolc/zkvyper version?v1.4.1 Explain the issueWhile developing Solidity contracts in zkSync, I noticed that they compile differently. In Solidity, even if leftover data remains in memory, when returned as contract Foo {
uint256[] internal numbers;
function addNumber(uint256 number) public {
numbers.push(number);
}
function getNumber(uint256 index) public view returns (uint256) {
return numbers[_convertToUint40(index)];
}
function _convertToUint40(uint256 n) internal pure returns (uint40 result) {
assembly {
result := n
}
}
} This means the results of However, contracts compiled with zksolc do not truncate, so the actual index queried in the numbers array is the input value itself. Therefore, executing This could create a serious bug when deploying Solidity contracts that assume truncation onto zkSync. Link to your repo?No response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Thanks for the post. Will check this out and see what info I can find for you. |
Beta Was this translation helpful? Give feedback.
-
Forwarded to |
Beta Was this translation helpful? Give feedback.
@JhChoy zksolc uses the Yul codegen by default, and it is known for being more buggy.
Could you check if
--force-evmla
flag fixes the issue?