-
Notifications
You must be signed in to change notification settings - Fork 109
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
feat: add no-std
to rollup-interface
#1077
Conversation
This commit introduces a `no-std` build for `rollup-interface`. This is required to create WASM modules for module implementations, having one use-case the web wallet. We follow a similar approach to `borsh` and create a `maybestd` module so dependencies can rely on that for fallback implementations of common stdlib components that are available either on `alloc` or commonly used crates. Most of the requirements exists on `alloc`, but we do have a couple of exceptions. The first is `HashMap`, that we fallback for `hashbrown` when `std` isn't available. We shouldn't expect issues from risc0 integration as `risc0` code will be compiled with `std`. The second is `Mutex`; for that, we fallback to `spin`, another common choice on the Rust ecosystem. Finally, this commit introduces a couple of changes on the root `Cargo.toml` to not use default-features for crates that offers `no-std` support.
Codecov Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I have some reservations mostly around three items:
sov_db
andsov_state_db
. Why isno_std
needed there?- We need an effective way to test that our dependencies are
no_std
as well. Runningcargo check
in CI forsov-rollup-interface
with a target that has nostd
support would be a good start. I see that there's a fewstd
dependencies that slipped in, it'll be way too easy for that to happen again even if we fix it in this PR without adding a CI check. - I would suggest we rely more on
alloc
for the types that it exposes, withoutmaybestd
. Namely,Arc
,Vec
,String
,Box
, etc..
Co-authored-by: Filippo Neysofu Costa <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sov-rollup-interface
is not no_std
-compatible yet because of its dependency tree, unfortunately. We'll also need some checks in CI for it. @vlopes11 how do you want to handle this? It doesn't feel right to merge no_std
support without actual no_std
support, but if that's what it takes to reduce merge conflicts I'm okay with it, assuming we'll have the bandwidth to work on these fixes ASAP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per our discussion on Slack, let's address the dependency tree problem (and CI) before merging
This commit introduces a
no-std
build forrollup-interface
. This is required to create WASM modules for module implementations, having one use-case the web wallet.We follow a similar approach to
borsh
and create amaybestd
module so dependencies can rely on that for fallback implementations of common stdlib components that are available either onalloc
or commonly used crates.Most of the requirements exists on
alloc
, but we do have a couple of exceptions. The first isHashMap
, that we fallback forhashbrown
whenstd
isn't available. We shouldn't expect issues from risc0 integration asrisc0
code will be compiled withstd
.The second is
Mutex
; for that, we fallback tospin
, another common choice on the Rust ecosystem.Finally, this commit introduces a couple of changes on the root
Cargo.toml
to not use default-features for crates that offersno-std
support.