projectsophon / hardhat-circom

Hardhat plugin to integrate Circom and SnarkJS into your build process.
GNU General Public License v3.0
116 stars 18 forks source link

Doesn't work on Windows, "invalid input file" #78

Open nth-commit opened 1 year ago

nth-commit commented 1 year ago

I haven't done a deep investigation into why, just reporting first in case anyone has any insights or any other Windows users are out there going insane wondering what they've done wrong.

Reproduction

  1. Clone https://github.com/0xPARC/circom-starter, follow getting started guide
  2. Run yarn circom:dev --show-stack-traces
yarn run v1.22.19
$ hardhat circom --deterministic --debug --verbose --show-stack-traces
  hardhat:core:config Loading Hardhat config from C:\dev\circom-starter\hardhat.config.js +0ms
  hardhat:core:hre Creating HardhatRuntimeEnvironment +0ms
  hardhat:core:hre Running task circom +1ms
  hardhat-circom:info Using cached Powers of Tau file at C:\dev\circom-starter\artifacts\circom\hermezptau.blob.core.windows.net_ptau_powersOfTau28_hez_final_15.ptau +0ms
  hardhat-circom:error invalid input file
  hardhat-circom:error previous errors were found +0ms
Error in plugin hardhat-circom: Unable to compile circuit named: division

HardhatPluginError: Unable to compile circuit named: division
    at SimpleTaskDefinition.circomCompile [as action] (C:\dev\circom-starter\node_modules\hardhat-circom\dist\index.js:478:19)
    at Environment._runTaskDefinition (C:\dev\circom-starter\node_modules\hardhat\src\internal\core\runtime-environment.ts:308:14)
    at Environment.run (C:\dev\circom-starter\node_modules\hardhat\src\internal\core\runtime-environment.ts:156:14)
    at main (C:\dev\circom-starter\node_modules\hardhat\src\internal\cli\cli.ts:272:7)

    Caused by: Error: invalid input file
    previous errors were found
        at Union.writeSync (C:\dev\circom-starter\node_modules\hardhat-circom\dist\index.js:276:31)
        at C:\dev\circom-starter\node_modules\circom2\vendor\wasi.js:561:38
        at Array.forEach (<anonymous>)
        at C:\dev\circom-starter\node_modules\circom2\vendor\wasi.js:558:40
        at C:\dev\circom-starter\node_modules\circom2\vendor\wasi.js:82:20
        at null.<anonymous> (wasm://wasm/01a7a0d2:1:3696999)
        at null.<anonymous> (wasm://wasm/01a7a0d2:1:3678595)
        at null.<anonymous> (wasm://wasm/01a7a0d2:1:3655123)
        at null.<anonymous> (wasm://wasm/01a7a0d2:1:3766550)
        at null.<anonymous> (wasm://wasm/01a7a0d2:1:3652391)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
nth-commit commented 1 year ago

Note: using the exact same setup, I can confirm it works using WSL.

phated commented 1 year ago

Does the rust circom work on Windows? I could see them failing on CRLF line endings or something.

nth-commit commented 1 year ago

I can try and look into that.

I can confirm it's not a line endings thing though, as I use LF line endings. And also, I tested using WSL in the same local repo. and WSL uses the exact same filesystem.

Might be a windows path thing? Either in Node or in circom?

nth-commit commented 1 year ago

I copied the circom args passed through WASI verbatim;

circom C:\\dev\\circom-starter\\circuits\\division.circom --r1cs --wat --wasm --sym -o
 C:\\dev\\circom-starter\\circuits
template instances: 1
non-linear constraints: 1
linear constraints: 0
public inputs: 1
public outputs: 1
private inputs: 3
private outputs: 0
wires: 6
labels: 8
Written successfully: C:\\dev\\circom-starter\\circuits\division.r1cs
Written successfully: C:\\dev\\circom-starter\\circuits\division.sym
Written successfully: C:\\dev\\circom-starter\\circuits\division_js\division.wat
Written successfully: C:\\dev\\circom-starter\\circuits\division_js\division.wasm
Everything went okay, circom safe
phated commented 1 year ago

Thanks for testing! The wasm build uses a custom patch that hasn't been thoroughly tested, available at https://github.com/iden3/circom/pull/46/files

I wonder if there's a bug in that.

nth-commit commented 1 year ago

Just tested - that branch of circom works too.

phated commented 1 year ago

Appreciate you checking. I don't have Windows to debug this further. Maybe someone else can dig in 🤔

nth-commit commented 1 year ago

I would have a go myself but my knowledge of the area is so limited, it would most likely take me a long time.

If you have the appetite for getting this fixed, and can't find anyone else, I'm happy to jump on a screen share and pair for a little bit.

tmonty12 commented 1 year ago

Hey @nth-commit, I ran into the same exact issue. Is there any other solution that you have found than using WSL?

nth-commit commented 1 year ago

Ah, sorry @tmonty12, I've been meaning to dive in again but haven't had the chance yet. Best of luck!

benreichman commented 1 year ago

Ran into the same exact issue. Identical setup works perfectly on a mac machine, but get the same "Invalid input file" when running on my windows machine.

phated commented 1 year ago

Like I said, I don't have a windows machine. Additionally, people would rather airdrop farm than contribute to my gitcoin, so I have no incentive to work on this.