Open rphmeier opened 7 years ago
@fubuloubu If your goal is to compile to WASM, I think that:
$ cargo check --target wasm32-unknown-unknown --no-default-features
would be a good starting point. Then fixing dependencies one-by-one to make sure they compile when targeting wasm (i.e. avoid threads, io, etc).
Oh, great tip! Thanks!
I have a smaller library to upgrade first, so this will get me there eventually.
@tomusdrw would it be okay to upgrade all uses of HashMap
to use BTreeMap
instead?
Edit: I'm working through the error list of doing this upgrade, down to some 36 errors from 300+, so making good progress!
We may also have to make a decision on what functionality we want to feature-gate to std
only. For instance, we almost definitely want to leave the transport traits, but the implementations for WebSockets, IPC, and http almost definitely require std
.
I just re-read that you want to use it inside substrate runtime. This will cause additional issues and require no_std
feature and depending on core/alloc
stuff.
Switching to BTreeMap
imho should be feature-gated as well, it can have pretty big performance impact.
Cool, well I'll see if I can get it working in a branch and will maybe submit a PR to figure out how to handle gating with no_std
. Sound like a good plan?
The other big issue I had is std::error::Error
/std::io::Error
. Not sure how best to handle this, but it doesn't look trivial to swap out from my limited knowledge.
I've been thinking about this a bit more, and it probably makes more sense if just the Web3-specific types are available as no_std, perhaps as a separate crate.
A great example of this is Bytes
, which I am using in the https://github.com/ethpm/ethpm-rs repo to serialize/deserialize ethPM packages. Other types would be very helpful as well.
Any progress on no_std support?
I would like to take a crack at this over the next few weeks, if possible. I eventually need to use this library in a Substrate runtime to have an Ethereum bridge to my chain.
@rphmeier @tomusdrw What do you think would be a good start to support this?