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

Allow generate_message to be compiled to wasm #1149

Open
Tbaut opened this issue Jun 27, 2022 · 4 comments
Open

Allow generate_message to be compiled to wasm #1149

Tbaut opened this issue Jun 27, 2022 · 4 comments
Labels

Comments

@Tbaut
Copy link
Contributor

Tbaut commented Jun 27, 2022

This is a request for guidance as a rust noob.
I would like to use generate_message in a website or an extension to help decentralize the work done in the background of metadata portals. My idea was to compile generate_message to wasm. I gave it a try using wasm-pack, and started small with adding wasm-bindgen macro to fetch_info, and call wasm-pack build --target-web

The build fails with:

error[E0583]: file not found for module `sys`
   --> /home/thib/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/lib.rs:124:1
    |
124 | mod sys;
    | ^^^^^^^^
    |
    = help: to create the module `sys`, create file "/home/thib/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys.rs" or "/home/thib/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/mod.rs"

error: Socket2 doesn't support the compile target
   --> /home/thib/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/lib.rs:127:1

the cargo.lock tells me Socket2 is a dependancy of tokio. There are a bunch of github issues around this (like here), but no clear solution to me. I tried enabling only features = ["sync", "rt"] as hinted here but the build still fails with the same error.

Can you tell me what tokio is needed for, and if you see any way to get around this? I see it's a dep of other deps like jsonrpsee-* as well.

@niklasad1
Copy link

niklasad1 commented Jun 27, 2022

Hey @Tbaut

tokio is the underlying async executor/threadpool that drives "async IO" to completion which is required by jsonrpsee for everything except for the wasm client.

However with some conditional compilation/feature flags you should be able compile jsonrpsee-client to WASM without tokio, the easiest would be #[cfg(target_arch = "wasm32")] then use jsonrpsee-wasm-client = "0.14.0" instead but requires some refactoring in the crate to make tokio an optional dependency and so on.

@Slesarew
Copy link
Contributor

I think we just should add a no-std feature for generate_message eventually.

However, be careful here - fetching metadata in CI without checking might be dangerous, and if you are signing it - there is no way to revoke certificate key, so keep it really safe.

@Tbaut
Copy link
Contributor Author

Tbaut commented Jun 27, 2022

Thanks for the hints. I'd be up to take on the refactoring to have tokio optional, although I will probably need more guidance :) not sure if this is something that could be beneficial for this repo.

Regarding the QR generation, my plan for a first step is to not sign them. And then let users compare different independent sources. I forgot whether Signer shows a hash of the metadata upon import.

@ViktorKirjanov
Copy link

have the same error but with anchor-client = "0.25.0". it just dose not want to build. same errors

anchor-lang = "0.25.0"
anchor-spl = "0.25.0"
anchor-client = "0.25.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants