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

Enable WASM-compat and monitor it in the CI #142

Merged
merged 12 commits into from
Aug 17, 2024
Merged

Enable WASM-compat and monitor it in the CI #142

merged 12 commits into from
Aug 17, 2024

Conversation

CPerezz
Copy link
Member

@CPerezz CPerezz commented Aug 12, 2024

This PR resolves: #137

  • Implements target-pointer-size cfg to allow for usize de/serialization.
  • Updates Cargo.toml such that all features from deps and folding-chemes features allow for WASM compilation.
  • Adds docs about features and WASM-compatibility to README.md
  • Adds CI jobs to always monitor WASM-compat.

Depends on arnaucube/circom-compat#2

There are some parts of the code where is needed to de/serialze
`usize`s. These, have sizes that vary depending on the target
achitecture the code is compiled for.

Hence, this adapts the de/serialization to the specific pointer size for
which the crate is being compiled to.
In order to support Wasm-compat and to simplify and improve `Cargo.toml`
readability, the follwing changes have been made:

- All the deps that can use `parallel` feature, do so. As `rayon`
  supports non-threaded targets with a fallback option. See: https://docs.rs/rayon-core/1.12.1/rayon_core/index.html#global-fallback-when-threading-is-unsupported
- `ark-grumpking` has been brought to `0.5.0-alpha.0` as `0.4.0` appears
  to not be in `crates.io` anymore. See: https://crates.io/crates/ark-grumpkin/versions
- By default, the crate uses `"ark-circom/default"` which selects the
  `wasmer/sys` feature such that it knows where wasmer is
  suposed to be run`.
- Added a `wasm` feature which forces `ark-circom/wasm` to be used
  instead. Which internally selects the `wasmer/js` backend to be used
  such that in-browser execution is possible.
- Added `getrandom` with `js` feature as dependency when `wasm32-unknown-unknown` target is selected such
  that compilation of the crate for testing or simply building is possible. Notice that with `wasi` and other wasm targets,
  this is not the case as they're automatically supported.
  For more info, please check: https://docs.rs/getrandom/latest/getrandom/#webassembly-support
Add support for both testing the build of `sonobe/folding-schemes` for
WASM-targets and also, it's build as a dependency for a WASM-crate.

This includes a build job for the three main supported rust-WASM targets
and the same but for a thrid crate creted on-the-fly which uses
`sonobe/folding-schemes` as a dependency.
@CPerezz CPerezz changed the title Feat/wasm compat Enable WASM-compat and monitor it in the CI Aug 12, 2024
@CPerezz CPerezz marked this pull request as ready for review August 12, 2024 15:46
@CPerezz CPerezz mentioned this pull request Aug 16, 2024
4 tasks
As mentioned in
#146
there's a big issue that involves some dependencies of the crate.

As a temporary fix, this forces the workspace to rely on a
"non-existing" version of `ark-grumpkin` which is immediately patched at
workspace-level for a custom version that @arnaucube owns with some
cherry-picked commits.

While this allows the CI to pass and crate to build, a better solution
is needed.
Copy link
Collaborator

@arnaucube arnaucube left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! This is great ^^
LGTM!

@CPerezz CPerezz added this pull request to the merge queue Aug 17, 2024
Merged via the queue into main with commit 5ec9c2c Aug 17, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WASM compilation
2 participants