-
Notifications
You must be signed in to change notification settings - Fork 359
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
Use #![no_std]
for ibc-proto crate
#1164
Conversation
Nice! Regarding the dependency problem, I guess this means that we need add a |
I also think it is possible that it is not necessary to change all the code to a type that is only possible under no_std, here toinc is doing rpc I think it is possible to use std directly here, at the time I was compiling and testing my branch was not changed here is also possible, because proto's other structure types are already supported by no_std. |
Hi Soares, AFAIK, the only way is to build the whole project then check for errors. We're following parity's best practices:
For a crate that uses the same rule, we can add it to |
I think that is doable, however that would still means that we would need to patch the generated prost files to switch between std and no-std mode. We could also consider submitting patches for @DaviRain-Su do you mean that the build in #1109 successfully compiles in Substrate environment? I am not familiar with Substrate, so is there any tools or steps to verify that a Rust library works in Substrate? My understanding is that the requirement for no-std is due to Substrate using WebAssembly. So what I currently know is to build it with the @en I'm not sure if the approach you suggested checks for true no-std support. FYIW, the PR here makes |
You said subsrate and I thought of it here because the proto didn't compile over at the time. Because of the socket2 problem. The same problem you are having here.
I agree. |
@soareschen You should also be able to use cross-rs to build for a |
40f1b0e
to
d7a9ab8
Compare
I have added a The With
Which shows that the check fails because I have also added a GitHub Actions workflow that runs the no-std check. Here is an example run. Obviously the CI is failing now because ibc-proto is not no-std-compliant. Before merging this, we will disable the check on |
I just try out a new approach which is to use the |
Let's wait for #1166 to merge first before we merge this. |
Alright then. I have removed the GitHub Actions workflow for now so that the CI can pass. I'm leaving the no-std-check crate there so that we can check for no-std compliance in future development. |
I think the code generated by prost here can be just under no_std, the standard library (std library) in rust is a superset of the core library (under no_std, e.g. |
This is likely not necessary. We can probably keep using |
It's also a good way to end |
I wonder if it is possible to decouple proto and grpc here, so that proto can support NO-STD, I am trying to modify it. |
@romac should we merge this first and then do the separation of generated code in another PR? I have filed cosmos/ibc-proto-rs#7 as a follow up. |
Agreed. Let's merge this once CI is green. |
#![no_std]
for ibc-proto crate
SWEEEEEEETTT!!! |
* Use #![no_std] for ibc-proto crate * Enable js feature in get_random to allow compilation in wasm * Add no-std compliance checking * Fix CI * Fix CI * Use Cargo nightly to check for use of std crate * Remove no-std GitHub workflow for now * Update Cargo.lock Co-authored-by: Romain Ruetschi <[email protected]>
Partially Closes: #1158
Description
This is a follow up on @romac's comment in #1156
I just realized
ibc-proto
crate do not use much of std features, and we can enable#![no_std]
for the crate rather easily without modifying the generated code. This PR does the fix separately from #1156.One thing I notice: even though the
ibc-proto
crate successfully compiles with#![no_std]
, it is in fact not fully no-std-compatible as at least one of its transitive dependencies,socket2
, does not work inno_std
. I could not find easy way to verify that other than buildingibc-proto
with the targetwasm32-unknown-unknown
:The crate
socket2
is imported viahyper
, which is used bytonic
. When inspecting thetonic
andsocket2
crate, I also find various uses ofstd::io
andstd::net
, which are not available inno_std
.This shows that supporting no_std is more tricky than just enabling the
#![no_std]
flag in our own crate. Theno_std
flag does not check on the compliance on dependencies, and I cannot find a good way to check on that other than building with the targetwasm32-unknown-unknown
. Other thantonic
, it is also not clear how many other dependencies we have are unsupported in the real no_std environment.@DaviRain-Su do you have any experience in how to verify if a crate truly support no-std environment?
For contributor use:
docs/
) and code comments.Files changed
in the Github PR explorer.