Description
This is a tracking issue to track the progress of no-std support for ibc-rs to close #29. The change set for PR #1109 is pretty broad, and as a result it is difficult to review and merge the PR all in one go. I would suggest that we split the changes into multiple smaller PRs, so that the changes can be incremental with the goal of eventually supporting no-std.
Based on the changes in PR #1109, I'd suggest we have separate PRs for the following changes:
-
Tracking issue for no-std compliance for dependencies in ibc-rs and tendermint-rs #1359
-
Full support of no_std in
tendermint
crate tendermint-rs#988 -
Separate generated code from
prost
andtonic
inproto-compiler
cosmos/ibc-proto-rs#7 -
Move out
tendermint::config
totendermint-config
crate tendermint-rs#986 -
tendermint-proto
usesstd
features in dependencies tendermint-rs#981 -
Use
core
andalloc
crates forno_std
compatibility (Take 2) tendermint-rs#993 -
Move
config
module out fromtendermint
into its own crate tendermint-rs#983 -
url
crate used bytendermint
does not support no_std tendermint-rs#985 -
tendermint
crate usesstd
features ined25519-dalek
tendermint-rs#992 -
Use
flex-error
to define error types (Use flex-error to define errors #988)- This is to replace
anomaly
for fine grained error handling. While not directly related to no-std, the PR removes majority use ofstd::error::Error
and allows different error tracers such asanyhow
,eyre
, or naiveStringTracer
to be used, depending on their support in no-std environment.
- This is to replace
-
Use
core
andalloc
crates in place ofstd
crate whenever possible (Usecore
andalloc
crates forno_std
compatibility #1156)- The crates
core
andalloc
can be accessed by both std and no-std code, and therefore do not require feature flag to switch between importing fromcore
/alloc
orstd
. - To use
alloc
in std mode, we just have to add anextern crate alloc
in the root module, and that is automatically linked by Rust in std mode. - There are still a small number of imports from
std
that are not available incore
noralloc
. In that case, the PR leaves the use ofstd
in those cases, and have them fixed in follow up PRs. - The changes to use
core
andalloc
can be done in a separate PR independent of other changes. While we cannot ensure that the change covers everything, this will reduce the number of changes required in subsequent PRs and make it easier for review.
- The crates
-
Use a wrapper struct for
Box<dyn std::error::Error>
for remaining errors not updated by Use flex-error to define errors #988.- PR Use flex-error to define errors #988 have removed most of the uses of
Box<dyn std::error::Error>
, however there are still a few places remaining that are still usingstd::error::Error
. - PR Add
no-std
support toibc
#1109 attempts to polyfillstd::error::Error
by aliasing it to aDummyError
struct in no-std mode. However doing so does not prevent dependencies from constructingBox<dyn std::error::Error>
, which would prevent no-std from being supported. On the other hand, if we have control of all places that produceBox<dyn std::error::Error>
, we can also modify them to return something other thanBox<dyn std::error::Error>
. - I'd propose that we define a type like
LegacyError
, which is either a newtype wrapper toBox<dyn std::error::Error>
in std mode, or a newtype wrapper toString
in no-std mode. By always using a newtype wrapper, we can avoid accidental implicit coercion fromBox<dyn std::error::Error>
toLegacyError
in std mode, which will prevent no-std mode to work. - There should be a Cargo separate feature flag to switch between the two modes ot
LegacyError
. The purpose is to be able to test the two modes ofLegacyError
without fully activating no-std. - This change can be done inside
AddUse flex-error to define errors #988, or a follow up PR tono-std
support toibc
#1109AddUse flex-error to define errors #988. It is also possible to make this change against master, although there will be much more changes needed.no-std
support toibc
#1109 - Update: This is no longer needed as all use of
std::error::Error
are now removed.
- PR Use flex-error to define errors #988 have removed most of the uses of
-
Find alternative crates that replace missing functionalities in
core
andalloc
.- There are still a small number of essential types like
SystemTime
that are provided bystd
, but not provided bycore
noralloc
. - PR Add
no-std
support toibc
#1109 attempts to polyfill the types likeSystemTime
inside no-std mode. However this makes it difficult to maintain two version of the code depending on the std/no-std mode. - Ideally we should instead try and find alternative crates that can work in both std and no-std mode.
- For example, we may want to investigate whether it is possible to use
chrono::DateTime
directly instead ofSystemTime
. If we can, then it would reduce our burden of having to maintain the code in different modes.
- There are still a small number of essential types like
-
Update
Cargo.toml
to use updated dependencies that have been published and support no-std, includingtendermint-rs
crates.- PR Add
no-std
support toibc
#1109 has a[patch.crates-io]
section that refers to upstream dependencies liketendermint-rs
that are also being patched to support no-std. This makes it difficult to review and merge the PR, because we cannot easily see what is being changed in the upstream dependencies. Even if the reviews pass, the PR cannot be merged because we cannot publish Cargo crates with git dependencies inside. - We should first make changes in ibc-rs that do not require upstream dependencies to be updated. Even if that do not result in supporting no-std in one go, making independent changes will help reduce the number of changes necessary when the dependencies are updated.
- The PR for updating upstream dependencies should be done after the other PRs for no-std have been merged, and also when the upstream dependencies have been published. Ideally this PR should have minimal changes, other than updating Cargo.toml.
- PR Add
-
Add Cargo feature flags to activate
#![no_std]
.- Other than the issues listed above, there might be other blockers that prevent no-std mode from being enabled. In such case, it is still better to merge the other PRs first, and only activate no-std when everything is fixed.
- I am listing this as a separate step, so that it does not become a blocker for the other PRs. The point is we do not need to have one or few big PRs that immediately pass when
#![no_std]
is enabled. - The priority for the other PRs is to continue to have ibc-rs work in std mode, and not be concerned with whether they compiles in no-std. We can still maintain our own private branches that activate no-std during development.
- Ideally, this final PR should have just few line changes to introduce the feature flags and
#![no_std]
. - Note that as mentioned in Use
#![no_std]
for ibc-proto crate #1164,#![no_std]
alone is still not sufficient for true no-std support, as dependencies may still usestd
behind the scene. The current known way to verify for true no-std support is to compile the crate with the targetwasm32-unknown-unknown
. - This is also the PR that enables the CI checks to ensure that no-std continues to be supported in the future.
For Admin Use
- Not duplicate issue
- Appropriate labels applied
- Appropriate milestone (priority) applied
- Appropriate contributors tagged
- Contributor assigned/self-assigned
Activity