succinctlabs / sp1

A performant, 100% open-source, contributor-friendly zkVM.
https://succinctlabs.github.io/sp1
Apache License 2.0
922 stars 276 forks source link

[feat] Please use different features to use different code #636

Open flyq opened 4 months ago

flyq commented 4 months ago

When I try to compile sp1's verifier into wasm, I get a bunch of the same errors. This error is caused by sp1 relying on the reqwest network library, as the mio crate is under the reqwest crate in output of cargo tree.

error[E0599]: no method named `reregister` found for struct `IoSource<std::net::UdpSocket>` in the current scope
   --> /Users/flyq/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/net/udp.rs:631:20
    |
631 |         self.inner.reregister(registry, token, interests)
    |                    ^^^^^^^^^^ method not found in `IoSource<UdpSocket>`
    |
   ::: /Users/flyq/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/io_source.rs:62:1
    |
62  | pub struct IoSource<T> {
    | ---------------------- method `reregister` not found for this struct
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `Source` defines an item `reregister`, perhaps you need to implement it
   --> /Users/flyq/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/event/source.rs:75:1
    |
75  | pub trait Source {
    | ^^^^^^^^^^^^^^^^

   Compiling typenum v1.17.0
   Compiling serde_json v1.0.116

Refer to rics0, which also relies on the reqwest network library, but the reqwest is only used under the dep:bonsai-sdk feature:

[features]
client = [
  "dep:bincode",
  "dep:bonsai-sdk",
  "dep:bytes",
  "dep:prost",
  "dep:prost-build",
  "dep:protobuf-src",
  "dep:tempfile",
  "std",
]

https://github.com/risc0/risc0/blob/c809f313d9ac84927c5fc683fe12f01c777fecf7/risc0/zkvm/Cargo.toml#L106-L115 So, when I use like this, it can compile to wasm:

risc0-zkvm = { version = "0.21.0", default-features = false, features = ["std"] }
matthiasgoergens commented 1 month ago

Could you please change the title of your issue to something more descriptive? Thanks!

flyq commented 1 month ago

I think this issue is gone with your code refactor let me test it in the night

taint160596 commented 1 month ago

Same problem