matter-labs/hardhat-zksync

memory leak during zk-solc compilation

Closed this issue · 6 comments

I tried to migrate the https://github.com/GridexProtocol/core project according to the migration tutorial on the official website (https://era.zksync.io/docs/api/hardhat/migrating-to-zksync.html), but there was a memory leak problem.

image

It seems that rewriting the assembly code in https://github.com/GridexProtocol/core/blob/d2bf72bf7354251b70042515d7f6df5b55326bb0/contracts/libraries/BoundaryMath.sol#L131 as Solidity code fixed the memory leak issue during zk-solc compilation.

@grey0100 thanks for the report!
Could you publish a repo fork with your changed hardhat.config.ts and the command to reproduce the issue?
Thanks!

@grey0100 are you using --force-evmla by any chance?

@grey0100 thanks for the report!
Could you publish a repo fork with your changed hardhat.config.ts and the command to reproduce the issue?
Thanks!

code: https://github.com/grey0100/core/tree/zksync
system: macOS 13.3.1 (22E261)
command: PRIVATE_KEY=0000000000000000000000000000000000000000000000000000000000000000 yarn hardhat compile --network zkSyncTestnet

@grey0100 are you using --force-evmla by any chance?

No, I didn't even know there was a --force-evmla option🤣.

Hey @grey0100, it's not zksolc, but solc goes in OOM. In fact it's my personal record in eating up all the RAM on my machine.

We use the new IR codegen by default, and it can be buggy in old solc versions.
Two solutions for this, good and bad:

  1. Update solc and zksolc to the latest version (0.8.19 and 1.3.10 respectively).
  2. If the first still not working with solc 0.8.19, use --force-evmla to switch back to the old solc codegen. Note that recursion on the stack and internal function pointers won't compile in this mode.

Screenshot_20230427_185607

@hedgar2017 Thanks! The first one works well!