Features

Check why and how a dependency in your workspace gets enabled. This is useful in cases where you encounter weird build errors which are caused by unintentional inclusion of dependencies or features.

Install

bash cargo install feature

Example - Feature Propagation Lint

Let's check that the runtime-benchmarks feature is properly passed down to all the dependencies of all crates in the workspace of [Cumulus]:

bash feature lint propagate-feature --manifest-path ../cumulus/Cargo.toml --feature runtime-benchmarks --workspace

The output reveals that there are a lot of crates that violate this assumption:

pre crate "asset-test-utils" feature "runtime-benchmarks" must exit because 1 dependencies have it: pallet-collator-selection crate "bridge-hub-kusama-runtime" feature "runtime-benchmarks" must propagate to: cumulus-pallet-parachain-system ... Generated 24 errors

Without the --workspace it even detects 243 violations. Automatic fixing will be helpful here (TBD).

Now you can verify this for the bridge-hub-kusama-runtime which is indeed missing the feature for cumulus-pallet-parachain-system while that is clearly providing this feature 🤔. There will probably be some false-positive/negatives currently, since I did not properly test it yet.

Example - Dependency tracing

Recently there was a build error in the Substrate master CI which was caused by a downstream dependency snow. To investigate this, it is useful to see how Substrate depends on it.

Let's find out how node-cli depends on snow:

bash feature trace --manifest-path substrate/Cargo.toml node-cli snow

output:

node-cli -> try-runtime-cli -> substrate-rpc-client -> sc-rpc-api ->sc-chain-spec -> sc-telemetry -> libp2p -> libp2p-webrtc -> libp2p-noise -> snow

So it comes from libp2p, okay. Good to know.

Roadmap