foundry-zksync: zkforge zkbuild Error: Failed to compile smart contracts with zksolc

Component

zkForge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (4307bfb 2024-03-20T06:25:29.717831000Z)

What command(s) is the bug in?

zkforge zkbuild and zkforge test

Operating System

macOS (Apple Silicon)

Describe the bug

When I run zkforge zkbuild I get the error:

Error: 
Failed to compile smart contracts with zksolc: Could not assign standard_json to writer

How do I resolve this? Is there a flag or anything required here.

About this issue

  • Original URL
  • State: open
  • Created 3 months ago
  • Comments: 17

Most upvoted comments

Hey folks 👋

We are in the process of releasing a new version of our Foundry implementation that will handle these situations much better. I apologize for the inconvenience currently being experienced, as this is an early alpha version we appreciate the reported issue. We are tracking to make a pre-release of the new version this week.

@yohanelly95 What I see you tried to specify zksol compiler with --use option. But this option is for sol compiler, see zkforge zkbuild --help. Try to use --use-zksolc instead. And, also, if I am not mistaken you can’t currently specify the path to the zksol compiler (despite --help saying it), only the version is supported.

@yohanelly95 Try to remove the zkout in the project with contracts, that appear after zkforge zkbuild and contain artifacts. Remove zksolc compiler, which should be at ~/.zksync/zksolc-<OS>-<ARCH>-<ZKSOLC_VERSION>. And try to rebuild with specifying options --use and --use-zksolc. In my case I’ve used zkforge zkbuild --use 0.8.13 --use-zksolc v1.4.0.

when I run zkforge zkbuild --use 0.8.13 --use-zksolc v1.4.0 I get the error

Message:  called `Result::unwrap()` on an `Err` value: Error("missing field `contracts`", line: 1, column: 3944)
Location: crates/common/src/zk_compile.rs:1165

This is a bug. Consider reporting it at https://github.com/foundry-rs/foundry

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
[1]    54284 abort      zkforge zkbuild --use 0.8.13 --use-zksolc v1.4.0

I have shared the repo details in the message above @OmegaTymbJIep

I have the exact same error running zkforge test (I assume it throws during a compilation phase!).

The problem occurs during just running zkforge test in a newly scaffolded project (ran zkforge init sampletest to generate a new project).

same here, the error comes up when running zkforge commands in a scaffolded project. In my case bridge_v2

When will it be solved?

@yohanelly95 What I see you tried to specify zksol compiler with --use option. But this option is for sol compiler, see zkforge zkbuild --help. Try to use --use-zksolc instead. And, also, if I am not mistaken you can’t currently specify the path to the zksol compiler (despite --help saying it), only the version is supported.

@OmegaTymbJIep I see, what is the fix/workaround required then? This error persists

Error: 
Failed to compile smart contracts with zksolc: Could not assign standard_json to writer

Issue seems to occur with all zkforge related commands. How do I fix this compiler issue? @bxpana