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

feat/question: support compilation to wasm32 with std #991

Open
dzmitry-lahoda opened this issue Nov 27, 2023 · 6 comments · Fixed by #992
Open

feat/question: support compilation to wasm32 with std #991

dzmitry-lahoda opened this issue Nov 27, 2023 · 6 comments · Fixed by #992
Labels
A: blocked Admin: blocked by another (internal/external) issue or PR S: wasm Scope: support Wasm envs

Comments

@dzmitry-lahoda
Copy link
Contributor

dzmitry-lahoda commented Nov 27, 2023

Feature Summary

cargo check --package ibc  --target wasm32-unknown-unknown  --features=std

should work.

But I get now

error: the wasm*-unknown-unknown targets are not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support
   --> /home/dz/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.11/src/lib.rs:290:9
    |
290 | /         compile_error!("the wasm*-unknown-unknown targets are not supported by \
291 | |                         default, you may need to enable the \"js\" feature. \
292 | |                         For more information see: \
293 | |                         https://docs.rs/getrandom/#webassembly-support");
    | |________________________________________________________________________^

error[E0433]: failed to resolve: use of undeclared crate or module `imp`
   --> /home/dz/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.11/src/lib.rs:346:9
    |
346 |         imp::getrandom_inner(dest)?;
    |         ^^^ use of undeclared crate or module `imp`

For more information about this error, try `rustc --explain E0433`.

Proposal

Fix it, or suggest what to do.

I not sure. Would it all work if I just use ibc without std when compiling std CosmWasm contract.

This is typical for Polkadot SDK when trying to compile runtime to wasm, but in no_std. Not sure so what combination gives error in std/wasm.

May be fix should have been done long ago in getrandom. Just feature them with proper no_std/std wasm support...

@dzmitry-lahoda
Copy link
Contributor Author

dzmitry-lahoda commented Nov 27, 2023

Oh it comes from

primitive-types = { version = "0.12.2", default-features = false, features = ["serde_no_std"] }

So need to talk to Parity to remove this check or condition serde_no_std.

@Farhad-Shabani
Copy link
Member

I was about to point out that this usually comes from two upstream crates: tendermint-rs and primitive-types. The primitive-types one is pulled in because of the ICS-20 implementation.
But if you're compiling any chunk of the ibc-rs implementation other than ICS-20, you can roll with sub-crates like ibc-core and ibc-clients or their sub-libraries. This way, you won't have to pull in getrandom unnecessarily.

@dzmitry-lahoda
Copy link
Contributor Author

dzmitry-lahoda commented Nov 27, 2023

Currently wasm32 uses same crates inside as core and alloc, and reexports, so fix should work. As real no_std (Solana?) will not use std target, things should work. Comment to PR.

@dzmitry-lahoda
Copy link
Contributor Author

tbh I have no idea why parity preventing std wasm32 paritytech/parity-common#801 . no idea what is proper fix now.

@Farhad-Shabani
Copy link
Member

Currently blocked on: paritytech/parity-common#805

@Farhad-Shabani Farhad-Shabani reopened this Dec 1, 2023
@github-project-automation github-project-automation bot moved this from ✅ Done to 📥 To Do in ibc-rs Dec 1, 2023
@Farhad-Shabani Farhad-Shabani added the A: blocked Admin: blocked by another (internal/external) issue or PR label Dec 1, 2023
@dzmitry-lahoda
Copy link
Contributor Author

dzmitry-lahoda commented Apr 23, 2024

I patched parity, they merged, but not released yet. So all deps on deps still broken. Neither got merged #1162 as workaround.

seem blocked by all parties/sides

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: blocked Admin: blocked by another (internal/external) issue or PR S: wasm Scope: support Wasm envs
Projects
Status: 📥 To Do
Development

Successfully merging a pull request may close this issue.

2 participants