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!: wasm compatibility for fuels-types #839

Merged
merged 20 commits into from
Feb 23, 2023

Conversation

segfault-magnet
Copy link
Contributor

@segfault-magnet segfault-magnet commented Feb 15, 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.

@segfault-magnet segfault-magnet added the bug Something isn't working label Feb 15, 2023
@segfault-magnet segfault-magnet requested a review from a team February 15, 2023 11:28
@segfault-magnet segfault-magnet self-assigned this Feb 15, 2023
hal3e
hal3e previously approved these changes Feb 20, 2023
Copy link
Contributor

@hal3e hal3e left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for sorting this out!

`fuel-core` feature was created by mentioning `fuel-core` inside the
`fuel-core-lib` feature without using `dep:`. This has a consequence
that if somebody should enable `fuel-core` as a feature, thinking that
would get them the fuel-core-lib, it would only do half the job because
the real feature for that is `fuel-core-lib`.
Copy link
Contributor

@hal3e hal3e left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@Salka1988 Salka1988 left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Member

@digorithm digorithm left a comment

Choose a reason for hiding this comment

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

Aaaah, very nice work. This makes a lot of sense.

@digorithm digorithm merged commit 43e907d into master Feb 23, 2023
@digorithm digorithm deleted the segfault_magnet/wasm_friendly_abigen branch February 23, 2023 00:30
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 this pull request may close these issues.

bug: doc checking in CI needlessly repeated fuels-types are not wasm compatible
4 participants