DelphinusLab / zkWasm

Apache License 2.0
479 stars 95 forks source link

test_cli stops during execution #117

Closed alimahmedov79 closed 1 year ago

alimahmedov79 commented 1 year ago

Just started learning zkWASM and can't properly execute test.cli . Getting same thing every time

aliali@workspace:~/zkwasm_module$ ./test_cli.sh 
+ RUST_LOG=info
+ cargo run --release -- --function bsearch --output ./output --wasm wasm/bsearch_64.wasm single-prove --public 3:i64
    Finished release [optimized] target(s) in 0.95s
     Running `target/release/cli --function bsearch --output ./output --wasm wasm/bsearch_64.wasm single-prove --public '3:i64'`
[2023-04-30T13:34:15Z INFO  delphinus_zkwasm::cli::exec] Mock test...
[2023-04-30T13:34:36Z INFO  delphinus_zkwasm::cli::exec] Mock test passed
read params K=18 from "./output/K18.params"
read vkey from "./output/zkwasm.0.vkey.data"
quotient_poly_degree 8
Start:   generate pkey
End:     generate pkey .............................................................22.098s
Start:   create proof
··Start:   instance
··End:     instance ................................................................539.513ms
··Start:   advice
··End:     advice ..................................................................28.068s
··Start:   lookups
··End:     lookups .................................................................13.721s
··Start:   permutations comitted
··End:     permutations comitted ...................................................750.610ms
··Start:   lookups commited
··End:     lookups commited ........................................................25.203s
··Start:   vanishing commit
··End:     vanishing commit ........................................................1.012s
··Start:   h_poly
./test_cli.sh: line 11: 751557 Killed                  RUST_LOG=info cargo run --release -- --function bsearch --output ./output --wasm wasm/bsearch_64.wasm single-prove --public 3:i64
junyu0312 commented 1 year ago

I guess the reason is out of memory. Could you provide the message of command sudo dmesg .

alimahmedov79 commented 1 year ago

I guess the reason is out of memory. Could you provide the message of command sudo dmesg .

okay, here's my sudo dmesg output right after Killed status:

[157780.933659] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=thermald.service,mems_allowed=0,global_oom,task_memcg=/user.slice/user-1000.slice/user@1000.service/app.slice/app-gnome-code-750416.scope,task=cli,pid=920567,uid=1000
[157780.933693] Out of memory: Killed process 920567 (cli) total-vm:12312708kB, anon-rss:9810060kB, file-rss:4kB, shmem-rss:0kB, UID:1000 pgtables:20328kB oom_score_adj:0
[157781.233747] oom_reaper: reaped process 920567 (cli), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
[158281.904355] rtw_8822be 0000:03:00.0: failed to send h2c command
[158281.907466] rtw_8822be 0000:03:00.0: failed to send h2c command
[158281.910503] rtw_8822be 0000:03:00.0: failed to send h2c command
[158650.956845] rtw_8822be 0000:03:00.0: failed to send h2c command

woah so now I see that I haven't enough RAM memory. Does that mean I can't generate proofs until I increase ram or there's a way to resolve this(maybe memory swapping)?

junyu0312 commented 1 year ago

Yes, increasing the swap size can solve the problem.

alimahmedov79 commented 1 year ago

Yes, increasing the swap size can solve the problem.

16Gb ram mem 48Gb swap and I still get: ./test_cli.sh: line 18: 14119 Killed RUST_LOG=info cargo run --release -- --function bsearch --output ./output --wasm wasm/bsearch_64.wasm aggregate-prove --public 3:i64 how much memory does it need..?

junyu0312 commented 1 year ago

16G free memory should work. Could you provide free -g output before generating proof?

alimahmedov79 commented 1 year ago

16G free memory should work. Could you provide free -g output before generating proof?

               total        used        free      shared  buff/cache   available
Mem:              15           3           8           0           3          11
Swap:             47           0          47
alimahmedov79 commented 1 year ago

I force quit Visual studio after this command:

RUST_LOG=info cargo run --release -- --function bsearch --output ./output --wasm wasm/bsearch_64.wasm aggregate-prove --public 3:i64

to be exact after h_poly expressions

free -g output:

               total        used        free      shared  buff/cache   available
Mem:              15          14           0           0           0           0
Swap:             47          47           0
junyu0312 commented 1 year ago

After increasing the swap size, the single-prove is successfully passed. Now the failed command is aggregate-prove.

The circuit size(K) of single-prove is 18 by default while the K of aggregate-prove is 23. The latter consumes much more memory and 64G is not enough.

I don't have the exact required memory size for the aggregate-prove command, but I have 128G of RAM and it works fine.