Skip to content

Fix halo2_proofs features for wasm32 build & add ci for wasm build.#381

Merged
nuttycom merged 1 commit intozcash:mainfrom
nuttycom:fix_wasm32_build
Mar 20, 2023
Merged

Fix halo2_proofs features for wasm32 build & add ci for wasm build.#381
nuttycom merged 1 commit intozcash:mainfrom
nuttycom:fix_wasm32_build

Conversation

@nuttycom
Copy link
Contributor

No description provided.

@codecov-commenter
Copy link

Codecov Report

Patch and project coverage have no change.

Comparison is base (61a67f0) 83.43% compared to head (783db89) 83.43%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #381   +/-   ##
=======================================
  Coverage   83.43%   83.43%           
=======================================
  Files          32       32           
  Lines        2692     2692           
=======================================
  Hits         2246     2246           
  Misses        446      446           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

bench = false

[features]
default = ["halo2-batch", "halo2-multicore"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these need to be named differently from the downstream features? They are about batching and/or using multicore for Orchard Action proofs; the fact that those are Halo 2 proofs is an implementation detail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My concern here is that these feature flags don't actually change anything in orchard code; they're there exclusively because Rust doesn't allow you to disable default features of a transitive dependency in any other way. So they really are about halo2, not orchard.

Copy link
Contributor

Choose a reason for hiding this comment

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

If orchard did not require multicore for performance, then we would just leave it disabled here completely, and then leave it up to the end user to enable multicore on halo2_proofs if they so choose. But given that we know the default use case for orchard requires it for performance, we need it on by default, and thus exposed as orchard functionality.

Copy link
Contributor

Choose a reason for hiding this comment

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

Put another way, this is effectively the same as having a std flag. If a crate doesn't itself use std features, it can be no-std compatible by annotating itself as such and disabling any std feature flags on its dependencies. But if it does require std for its default use case, then it offers a std feature flag to allow downstreams to selectively disable it. We don't prefix std based on which of our dependencies requires it by default.

Copy link
Contributor Author

@nuttycom nuttycom Mar 20, 2023

Choose a reason for hiding this comment

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

Fixed in #383

Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

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

utACK with question.

Comment on lines +29 to +31
matrix:
target:
- wasm32-wasi
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious – are we expecting to have additional cross-targets, or is this simply to have consistent variable declarations? (as opposed to using env)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On a couple of the other crates we have additional targets; I only added this one because that's the only target that librustzcash has in its CI.

@nuttycom nuttycom requested a review from sellout March 20, 2023 19:18
Co-authored-by: Greg Pfeil <greg@technomadic.org>
group = { version = "0.13", features = ["wnaf-memuse"] }
halo2_gadgets = "0.2"
halo2_proofs = "0.2"
halo2_proofs = { version = "0.2", default-features = false, features = ["batch"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes the halo2-batch feature flag below unusable, because it marks halo2_proofs/batch as a required feature flag. But if WASM is working with this PR, that means the halo2-batch feature flag is unnecessary.


[features]
default = ["halo2-batch", "halo2-multicore"]
halo2-batch = ["halo2_proofs/batch"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Per above, I think this can be removed:

Suggested change
halo2-batch = ["halo2_proofs/batch"]

However, if we do retain it (and allow halo2_proofs/batch to be disabled), then orchard::circuit::Proof::add_to_batch needs to be placed behind this feature flag. And I agree with @daira that in this case, the feature flag should be the same as the upstream feature (so batch).

[features]
default = ["halo2-batch", "halo2-multicore"]
halo2-batch = ["halo2_proofs/batch"]
halo2-multicore = ["halo2_proofs/multicore"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
halo2-multicore = ["halo2_proofs/multicore"]
multicore = ["halo2_proofs/multicore"]

This is then the same thing we do in zcash_proofs: https://github.com/zcash/librustzcash/blob/0cff3c67ed4f16368b5f34986dbe1834390b340b/zcash_proofs/Cargo.toml#L54

@nuttycom nuttycom merged commit bb22122 into zcash:main Mar 20, 2023
@nuttycom
Copy link
Contributor Author

@str4d oops, I didn't see your request for changes; I will submit another PR to fix.

@nuttycom nuttycom deleted the fix_wasm32_build branch March 20, 2023 19:25
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

Successfully merging this pull request may close these issues.

5 participants