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

fuels-types are not wasm compatible #837

Closed
segfault-magnet opened this issue Feb 15, 2023 · 0 comments · Fixed by #839
Closed

fuels-types are not wasm compatible #837

segfault-magnet opened this issue Feb 15, 2023 · 0 comments · Fixed by #839
Assignees
Labels
bug Something isn't working

Comments

@segfault-magnet
Copy link
Contributor

The indexer team is having issues due to fuels-types not being wasm compatible.

The cause is the dependency on fuel-core-client which, after a while, depends on mio which isn't wasm compatible.

The solution is to turn off parts of the fuels-types that aren't wasm compatible, hiding it behind a flag (that will be part of the crate's defaults).

@segfault-magnet segfault-magnet added the bug Something isn't working label Feb 15, 2023
@segfault-magnet segfault-magnet self-assigned this Feb 15, 2023
digorithm pushed a commit that referenced this issue Feb 23, 2023
closes: #837 
closes: #854

A big thank you to @hal3e for help with the CI. 

The wasm offending functionality is now hidden behind the feature `std`
in `fuels-types` and in `fuels-core` as well.

### Breakage:
@digorithm 
It is part of the crate's default features, so most users shouldn't feel
the change -- especially since there weren't other other features that
would have made somebody do `default-features = false` in their
`Cargo.toml`.

But if they did for whatever reason, then they might see parts of
`fuels-types` disappear since the `std` feature would not be enabled. So
that makes it a theoretically breaking change.

Also `fuels` had two feature flags: `fuel-core` and `fuel-core-lib`.
`fuel-core` is removed since it was implicitly added because the
optional dependency `fuel-core` had not been referred to by prepending
`dep:` to it.

`fuel-core` used to enable the fuel-core-lib only partially and was not
the right flag to use.

### About the implementation
Cargo features should be additive by design. This means that you cannot
remove dependencies by adding features.

This further means that wasm support is generally implemented by
*hiding* wasm-offending code behind a feature (such as `std`).

In our case, if we want to be WASM compatible, we must not enable the
`std` feature on any `fuels-*` crates our project might depend on.

Feature unification makes this a bit difficult. If there is even one
dependency that enabled `std` on some `fuels-*` crate, all other crates
that are part of that compilation will also have the `std` feature
enabled for that crate.

Because of this, I've made it default for our workspace dependencies to
start off without defaults (and thus without the `std` flag).

If any of our crates need it, they will have to enable the feature
explicitly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant