near / wasmtime

Standalone JIT-style runtime for WebAssembly, using Cranelift
https://wasmtime.dev/
Apache License 2.0
3 stars 4 forks source link

Make zkasm runner working with any current working directory #238

Closed MCJOHN974 closed 7 months ago

MCJOHN974 commented 7 months ago

I'm calling zkasm_runner::run_zkasm from filetests::src::test_run_zkasm::TestRunZkasm::run_target and get this error:

FAIL filetests/filetests/runtests/simple.clif: panicked in worker #2: called `Result::unwrap()` on an `Err` value: Failed to run `npm`: exit status: 254; stderr: npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/mcjohn974/pagoda/tests/zkasm/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/mcjohn974/pagoda/tests/zkasm/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/mcjohn974/.npm/_logs/2024-02-29T14_52_05_716Z-debug-0.log

Mentioned log contains this:

0 verbose cli /home/mcjohn974/.nvm/versions/node/v18.14.1/bin/node /home/mcjohn974/.nvm/versions/node/v18.14.1/bin/npm
1 info using npm@9.3.1
2 info using node@v18.14.1
3 timing npm:load:whichnode Completed in 2ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/home/mcjohn974/.nvm/versions/node/v18.14.1/lib/node_modules/npm/npmrc Completed in 0ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/home/mcjohn974/pagoda/tests/zkasm/.npmrc Completed in 0ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:/home/mcjohn974/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/home/mcjohn974/pagoda/tests/zkasm/etc/npmrc Completed in 1ms
14 timing config:load:global Completed in 1ms
15 timing config:load:setEnvs Completed in 0ms
16 timing config:load Completed in 5ms
17 timing npm:load:configload Completed in 5ms
18 timing npm:load:mkdirpcache Completed in 1ms
19 timing npm:load:mkdirplogs Completed in 0ms
20 verbose title npm test /tmp/.tmpz9dyIK/code.zkasm /tmp/.tmpuUSTLl
21 verbose argv "--prefix" "../../tests/zkasm" "test" "/tmp/.tmpz9dyIK/code.zkasm" "/tmp/.tmpuUSTLl"
22 timing npm:load:setTitle Completed in 1ms
23 timing config:load:flatten Completed in 2ms
24 timing npm:load:display Completed in 3ms
25 verbose logfile logs-max:10 dir:/home/mcjohn974/.npm/_logs/2024-02-29T14_42_10_372Z-
26 verbose logfile /home/mcjohn974/.npm/_logs/2024-02-29T14_42_10_372Z-debug-0.log
27 timing npm:load:logFile Completed in 3ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 15ms
31 silly logfile start cleaning logs, removing 2 files
32 timing command:run-script Completed in 2ms
33 timing command:test Completed in 4ms
34 verbose stack Error: ENOENT: no such file or directory, open '/home/mcjohn974/pagoda/tests/zkasm/package.json'
35 verbose cwd /home/mcjohn974/pagoda/wasmtime/cranelift
36 verbose Linux 5.15.0-89-generic
37 verbose node v18.14.1
38 verbose npm  v9.3.1
39 error code ENOENT
40 error syscall open
41 error path /home/mcjohn974/pagoda/tests/zkasm/package.json
42 error errno -2
43 error enoent ENOENT: no such file or directory, open '/home/mcjohn974/pagoda/tests/zkasm/package.json'
44 error enoent This is related to npm not being able to find a file.
44 error enoent
45 verbose exit -2
46 timing npm Completed in 26ms
47 verbose code -2
48 error A complete log of this run can be found in:
48 error     /home/mcjohn974/.npm/_logs/2024-02-29T14_42_10_372Z-debug-0.log

I don't even have /home/mcjohn974/pagoda/tests/ and the code is runned by cargo run -- test filetests/filetests/runtests/simple.clif from cranelift.

Am I doing something wrong? Maybe we need some comments\docs about how to use runner? My code

aborg-dev commented 7 months ago

Can you please check whether you can run the tests in zkasm_runner.rs with

cargo test --package cranelift-filetests --lib -- test_run_zkasm --nocapture

That should exercise the code that uses npm and should give a good error message. Also, make sure that you are running this from the root of the wasmtime repository.

Also posting the result of running pwd in the root of wasmtime would be useful.

MCJOHN974 commented 7 months ago
mcjohn974@mcjohn974-ASUS-TUF-Gaming-A15-FA506IV-FA506IV:~/pagoda/wasmtime$ cargo test --package cranelift-filetests --lib -- test_run_zkasm --nocapture
   Compiling cranelift-codegen v0.106.0 (/home/mcjohn974/pagoda/wasmtime/cranelift/codegen)
   Compiling cranelift-native v0.106.0 (/home/mcjohn974/pagoda/wasmtime/cranelift/native)
   Compiling cranelift-frontend v0.106.0 (/home/mcjohn974/pagoda/wasmtime/cranelift/frontend)
   Compiling cranelift-module v0.106.0 (/home/mcjohn974/pagoda/wasmtime/cranelift/module)
   Compiling cranelift-reader v0.106.0 (/home/mcjohn974/pagoda/wasmtime/cranelift/reader)
   Compiling cranelift-interpreter v0.106.0 (/home/mcjohn974/pagoda/wasmtime/cranelift/interpreter)
   Compiling wasmtime-cranelift-shared v19.0.0 (/home/mcjohn974/pagoda/wasmtime/crates/cranelift-shared)
   Compiling cranelift-jit v0.106.0 (/home/mcjohn974/pagoda/wasmtime/cranelift/jit)
   Compiling cranelift-wasm v0.106.0 (/home/mcjohn974/pagoda/wasmtime/cranelift/wasm)
   Compiling cranelift v0.106.0 (/home/mcjohn974/pagoda/wasmtime/cranelift/umbrella)
   Compiling wasmtime-cranelift v19.0.0 (/home/mcjohn974/pagoda/wasmtime/crates/cranelift)
   Compiling wasmtime v19.0.0 (/home/mcjohn974/pagoda/wasmtime/crates/wasmtime)
   Compiling cranelift-filetests v0.0.0 (/home/mcjohn974/pagoda/wasmtime/cranelift/filetests)
    Finished test [unoptimized + debuginfo] target(s) in 20.50s
     Running unittests src/lib.rs (target/debug/deps/cranelift_filetests-207ec478eb4f6132)

running 2 tests
test zkasm_runner::tests::test_run_zkasm_success ... ok
test zkasm_runner::tests::test_run_zkasm_runtime_error ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 34 filtered out; finished in 1.18s

mcjohn974@mcjohn974-ASUS-TUF-Gaming-A15-FA506IV-FA506IV:~/pagoda/wasmtime$ pwd
/home/mcjohn974/pagoda/wasmtime
MCJOHN974 commented 7 months ago

Can you please check whether you can run the tests in zkasm_runner.rs with

cargo test --package cranelift-filetests --lib -- test_run_zkasm --nocapture

That should exercise the code that uses npm and should give a good error message. Also, make sure that you are running this from the root of the wasmtime repository.

Also posting the result of running pwd in the root of wasmtime would be useful.

Above are results of this commands. And I rerunned my filetest, still same error

aborg-dev commented 7 months ago

Can you please check whether you can run the tests in zkasm_runner.rs with

cargo test --package cranelift-filetests --lib -- test_run_zkasm --nocapture

That should exercise the code that uses npm and should give a good error message. Also, make sure that you are running this from the root of the wasmtime repository. Also posting the result of running pwd in the root of wasmtime would be useful.

Above are results of this commands. And I rerunned my filetest, still same error

Ok, that is good - it means that zkasm_runner.rs works on your machine and the problem is in the way that it is used in the filetests. Can you try to find the difference between the setup in the tests that I've linked and your usage of zkasm_runner.rs? The most likely culprit seems to be a different current working directory, can you check that by modifying "--prefix" "../../tests/zkasm" argument?

MCJOHN974 commented 7 months ago

Ok, that is good - it means that zkasm_runner.rs works on your machine and the problem is in the way that it is used in the filetests. Can you try to find the difference between the setup in the tests that I've linked and your usage of zkasm_runner.rs? The most likely culprit seems to be a different current working directory, can you check that by modifying "--prefix" "../../tests/zkasm" argument?

Thanks, I resolved this issue. Should we rename it to "Make zkasm runner working with any current working directory"

aborg-dev commented 7 months ago

Ok, that is good - it means that zkasm_runner.rs works on your machine and the problem is in the way that it is used in the filetests. Can you try to find the difference between the setup in the tests that I've linked and your usage of zkasm_runner.rs? The most likely culprit seems to be a different current working directory, can you check that by modifying "--prefix" "../../tests/zkasm" argument?

Thanks, I resolved this issue. Should we rename it to "Make zkasm runner working with any current working directory"

Yes! Let me see if I can quickly fix this.