paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.com/
1.94k stars 710 forks source link

Support for Crate-Specific Features via Umbrella Dependency #5934

Open SailorSnoW opened 1 month ago

SailorSnoW commented 1 month ago

Is there an existing issue?

Experiencing problems? Have you tried our Stack Exchange first?

Motivation

While managing our dependencies through the Umbrella, we quickly encountered an issue where it seems we are unable to use internal features of the Umbrella's crates. (For instance, insecure_zero_edfrom pallet-balances, historical from pallet-session, etc.)

Request

Enable the use of specific crate features through the Umbrella.

Solution

Have any design choices been considered for this case? For example, we could import these features via the Umbrella by combining the crate name with the feature name, like so:

pallet-balances-insecure-zero-ed = [
    "pallet-balances?/insecure_zero_ed"
]

Are you willing to help with this request?

Maybe (please elaborate above)

ggwpez commented 1 month ago

Maybe as workaround you can try to enable the feature on the crate directly, since rust feature unification should then merge those. Just make sure to use resolver = 2 in your workspace.

pallet-balances = { version = "*", features = ["insecure_zero_ed"], default-features = false }

Not sure if the * will make cargo pick the same version as the umbrella, or if you have to specify it manually...

For more long term solution guess we could do the concatenation with the features? But it can also turn quite ugly. WDYT @kianenigma ?

SailorSnoW commented 1 month ago

Well, maybe we could simply do the same as the experimental feature and use only the feature name which will enable all crates having this feature name

https://github.com/paritytech/polkadot-sdk/blob/dada6cea6447ce2730a3f3b43a3b48b7a5c26cf6/umbrella/Cargo.toml#L525-L530

ggwpez commented 1 month ago

Depends on what features exactly. I assume that some of them would clash names, but for the big ones it should work.
What features do you need? insecure_zero_ed i guess, what else?
They can be added here and then in the zepter config:

https://github.com/paritytech/polkadot-sdk/blob/d73c56de36263b6c446910a4904368d827b753eb/scripts/generate-umbrella.py#L113

kianenigma commented 3 weeks ago

hmm this seems like an issue indeed.

Combining names seems like a time bomb, I would not try this.

For the ones that we have, we should indeed treat them like experimental and just expose them at the top level umbrella. It seems to be the best we can do atm.

Long term, I hope we can reduce the number of custom feature flag we have. They are not meant to be a gate for "experimental" stuff. So the feature "insecure_zero_ed" would overall go away.

SailorSnoW commented 2 weeks ago

Here is some features that seems important to us to use Umbrella for our runtimes which is currently missing:

kianenigma commented 2 weeks ago

@ggwpez can you see through with this please? It can probably be documented and contributed by someone else.