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

Fix Rust features #11976

Merged
merged 17 commits into from
Sep 14, 2022
Merged

Fix Rust features #11976

merged 17 commits into from
Sep 14, 2022

Conversation

ggwpez
Copy link
Member

@ggwpez ggwpez commented Aug 4, 2022

Problems & Fixes

Some crates do not compile on their own

Try cargo c -p pallet-alliance --features runtime-benchmarks, which does not work on Substrate master.
The fix is to always enable the std features of all non-optional dependencies that have a std feature.
There is no regression script provided by me but it could be done. Currently I am using scripts
to compile each crate on its own to see that they work with different feature sets.

runtime-benchmarks is enabled per default

Try cargo tree -e features | grep runtime-benchmarks to see which crates have the feature enabled
although --features runtime-benchmarks was never provided.
This comes from crates either: carelessly enabling it, or crates enabling it per default.
Fixed by checking the deps tree ensuring that it is never enabled per default.
I wrote a regression script which wraps that cargo tree command and can be in-cooperated into the
CI in a future MR.

pallet-bags-list-fuzzer requires runtime-benchmarks

Fixed by creating a dedicated fuzz feature which gates the required functions.

Polkadot companion: paritytech/polkadot#5983
Cumulus companion: paritytech/cumulus#1607

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
@ggwpez ggwpez added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Aug 4, 2022
@ggwpez ggwpez added A3-in_progress Pull request is in progress. No review needed at this stage. and removed A0-please_review Pull request needs code review. labels Aug 4, 2022
@shawntabrizi
Copy link
Member

@ggwpez you made a tool? share the link!

bin/node/runtime/Cargo.toml Outdated Show resolved Hide resolved
@bkchr
Copy link
Member

bkchr commented Aug 4, 2022

@ggwpez you made a tool? share the link!

https://github.com/hack-ink/subalfred

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
@ggwpez ggwpez changed the title Add std features to Cargo files [WIP] Add std features to Cargo files Aug 4, 2022
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
@gilescope
Copy link
Contributor

fyi there is progress being made on cargo fmt Cargo.toml. Very much still top of my xmas list this year: rust-lang/rustfmt#5240

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
The job name - cargo-check-benches
The job logs - https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1753530

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't look closely, but based on the description it all looks very good.

I have a similar request as well. If I create a new pallet now, and it has try-runtime feature, if I add it to a runtime and forgot to enable try-runtime, no normal compilation will work, but the try-runtime build will fail. Can you check for this as well? You can see a few instances of it in the diff of this PR: https://github.com/paritytech/substrate/pull/10174/files

@ggwpez ggwpez changed the title [WIP] Add std features to Cargo files Fix Rust features Aug 18, 2022
@ggwpez ggwpez added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Aug 18, 2022
@ggwpez ggwpez requested a review from bkchr August 25, 2022 09:26
@@ -116,6 +116,13 @@ substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-bu
default = ["std"]
with-tracing = ["frame-executive/with-tracing"]
std = [
"sp-sandbox/std",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just remove the unused depedency, then we don't need to add it here :P

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There also is cargo udeps which claims to find unused crates.
I will give it a try later.

Something makes the bench regression guard fail, maybe this?

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
This reverts commit f2cddfe.
Was already fixed, only needed a CI retry.

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
@ggwpez ggwpez added A8-mergeoncegreen and removed A0-please_review Pull request needs code review. labels Sep 13, 2022
@ggwpez
Copy link
Member Author

ggwpez commented Sep 14, 2022

bot merge

@paritytech-processbot paritytech-processbot bot merged commit dc22e48 into master Sep 14, 2022
@paritytech-processbot paritytech-processbot bot deleted the oty-enable-features branch September 14, 2022 16:31
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
* Add std feature

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Fix features

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* WIP

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Fix features

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Fmt

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Fix features

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Cleanup

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Impl function also in tests

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Make compile

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Fix sp-trie feature

Something makes the bench regression guard fail, maybe this?

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Add runtime-benchmarks feature to sc-service

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Revert "Fix sp-trie feature"

This reverts commit f2cddfe.
Was already fixed, only needed a CI retry.

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants