matter-labs / foundry-zksync

Fork of Foundry tailored for zkSync environment
Apache License 2.0
299 stars 130 forks source link

Compile fails with `Stack too deep` error #380

Closed aon closed 5 months ago

aon commented 6 months ago

Component

Forge

Have you ensured that all of these are up to date?

What version of Foundry are you on?

forge 0.0.2 (13497a5 2024-05-15T00:25:37.094964000Z)

What command(s) is the bug in?

forge build --zksync

Operating System

macOS (Apple Silicon)

Describe the bug

forge build --zksync fails compiling https://github.com/matter-labs/era-contracts/tree/main/system-contracts with Stack too deep error:

image

Following suggestion from compiler using --via-ir flag, compile still fails with a different error:

image

dutterbutter commented 6 months ago

@aon this needs to be compiled with the -is-system flag set to true. Not sure if you are doing so.

Karrq commented 5 months ago

There are several factors at play here, but in particular here it seems you'd need to use matter-labs's custom version of solc (available here).

You will need to configure forge to use it via zk_solc_path (since #406)

Karrq commented 5 months ago

We now have better Yul support with #421. Please use the latest zksolc compiler (1.5.0) and make sure you are using the zksync's solc fork (any appropriate version ending with -1.0.1)