Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix web version (infinite loop) #379

Closed
mitschabaude opened this issue Sep 1, 2022 · 8 comments
Closed

Fix web version (infinite loop) #379

mitschabaude opened this issue Sep 1, 2022 · 8 comments
Assignees

Comments

@mitschabaude
Copy link
Member

mitschabaude commented Sep 1, 2022

The web version of snarkyjs is reported to go into an infinite loop when compiling, cc @maht0rz @jackryanservia

one difference to node is that for web, there's some manually written "table" of functions that are run from workers. if that table got out of date, we had the web version break sometimes
here: https://github.com/o1-labs/snarkyjs/blob/main/src/chrome_bindings/worker_run.js

@maht0rz
Copy link
Contributor

maht0rz commented Sep 2, 2022

Are there any pointers as to how this can be fixed? I'd like to help

@mitschabaude
Copy link
Member Author

I see two possible strategies for fixing:

  1. Look at the recent history of the file bindings.js in the Mina repo, to see if functions where added / changed that got out of date with that function table mentioned above. Try to fix by updating the table
  2. Try to figure out where the infinite loop happens. I usually do that with "log bisection". That probably requires to build snarkyjs from source and put print_endline statements in ocaml code (e.g. snarky_js_bindings_lib.ml in the Mina repo). Snarkyjs is built by running 'make snarkyjs' from the Mina repo

@maht0rz
Copy link
Contributor

maht0rz commented Sep 7, 2022

@mitschabaude is this the file you've mentioned above? I'll try comparing it manually
https://github.com/MinaProtocol/mina/blob/develop/src/lib/crypto/kimchi_bindings/js/bindings.js

@mitschabaude
Copy link
Member Author

@mitschabaude is this the file you've mentioned above? I'll try comparing it manually https://github.com/MinaProtocol/mina/blob/develop/src/lib/crypto/kimchi_bindings/js/bindings.js

Yes, @maht0rz, this is it! That file is huge so I recommend looking at its recent git history for guessing relevant changes.

@maht0rz
Copy link
Contributor

maht0rz commented Sep 7, 2022

Thanks to @gregor#5446's instructions i've noticed a discrepancy in the web/chrome bindings, introduced in the following commit: MinaProtocol/mina@99dc99e#diff-c2c0ff175c607b726ab7857e08ab0d7389d6c6f2b2fb1039583a0505c47b28e9R1217

Seems to me like caml_pasta_fp_plonk_index_create now also accepts a new argument prev_challenges, but this isn't reflected in worker_run.js

Attempting to fix 🎢

@maht0rz
Copy link
Contributor

maht0rz commented Sep 7, 2022

Here are two profiler outputs from firefox, before the fix and after the attempted fix.

I've added undefined since i was not able to find a coresponding WASM-ish value in the plonk_wasm argument.

caml_pasta_fp_plonk_index_create: {
        args: [
          plonk_wasm.WasmFpGateVector,
          undefined /* number */,
          undefined, // this is what i've added
          plonk_wasm.WasmFpSrs,
        ],
        res: plonk_wasm.WasmPastaFpPlonkIndex,
      },

You can see the stack trace / calls changing after i've added the extra argument in the binding but i am still unable to compile my contract.

@mitschabaude
Copy link
Member Author

awesome! undefined seems to be fine because prev_challenges is an integer. I think you just need to fix caml_pasta_fq_plonk_index_create in addition to caml_pasta_fp_plonk_index_create (note: fq vs fp)

@maht0rz
Copy link
Contributor

maht0rz commented Sep 7, 2022

It works, i will issue a PR right now! :)

mitschabaude added a commit that referenced this issue Sep 7, 2022
…e-loop

Added prev_challenges to plonk_index_create bindings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants