Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Effects and Interpretation of substrates std-feature flag #9597

Closed
mustermeiszer opened this issue Aug 20, 2021 · 7 comments
Closed

Effects and Interpretation of substrates std-feature flag #9597

mustermeiszer opened this issue Aug 20, 2021 · 7 comments

Comments

@mustermeiszer
Copy link
Contributor

Hi,

(when talking about std in the following I am referring to the substrate specific std-feature flag and not the standard runtime of rust)

I have a few questions regarding the std-feature flag and the consequences of it being activated or deactivated.
Not sure, if this is the right place for this. Thanks in advance for your help.

  • Does the feature flag indicated something like: "We are running in a no-wasm env"?
  • Is it possible to activate std it in a wasm build without letting the build fail?
  • Are there some (negative) consequences when using the std flag wrongly? (i.e. are there some assumptions made when this feature flag is active or not active)

Thanks again for your time!

@gui1117
Copy link
Contributor

gui1117 commented Aug 20, 2021

Does the feature flag indicated something like: "We are running in a no-wasm env"?

In substrate the wasm-runtime is built without std. Note that this is a choice, to keep the wasm-runtime as small as possible, but in general in rust it is possible to build a wasm binary with std enabled as far as I know.
I think in the codebase there is place where std is used to ensure it is not run in the wasm environment.

Also note that there was some thought given in the direction of removing the native runtime: #8893

Is it possible to activate std it in a wasm build without letting the build fail?

In general yes, but in substrate (and FRAME especially) I don't think it is possible to compile the wasm-runtime with std enabled.

@mustermeiszer
Copy link
Contributor Author

Sorry, to re-assure here: Are you talking about std of rust, or the std-feature flag of substrate?

@mustermeiszer mustermeiszer changed the title Effects and Interpretation of std-feature flag Effects and Interpretation of substrates std-feature flag Aug 20, 2021
@gui1117
Copy link
Contributor

gui1117 commented Aug 20, 2021

i don't see the difference between them. When we compile a crate without std feature, it is compiled without the rust standard library (or std of rust).
AFAIK we choose to compile the wasm-runtime without rust standard library to avoid having a big binary by using too much of it by mistake.

@mustermeiszer
Copy link
Contributor Author

mustermeiszer commented Aug 23, 2021

Mmh, okay, I see that. Then I have a question regarding some stuff that will not be available in wasm-env.

Is there another way to verify storage proofs on-chain?

@bkchr
Copy link
Member

bkchr commented Aug 23, 2021

@mustermeiszer you can use this function here: https://github.com/paritytech/substrate/blob/master/primitives/trie/src/lib.rs#L304

This is available in no_std.

@mustermeiszer
Copy link
Contributor Author

Thanks @bkchr.

@mustermeiszer
Copy link
Contributor Author

For me this is reasonably explained and solved. Will close this here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants