near / nearcore

Reference client for NEAR Protocol
https://near.org
GNU General Public License v3.0
2.31k stars 618 forks source link

Print features of dependency crates in `neard --version` #11176

Open jancionear opened 4 months ago

jancionear commented 4 months ago

https://github.com/near/nearcore/pull/11166 introduced printing enabled cargo features in the output of ./neard --version. For example:

$ cargo run -p neard --features statelessnet_protocol,new_epoch_sync -- --version
...
neard (release trunk) (build 1.36.1-489-gdf22f90b9) (rustc 1.77.0) (protocol 85) (db 39)
features: [default, json_rpc, near_epoch_sync_tool, new_epoch_sync, rosetta_rpc, statelessnet_protocol]

It prints the features enabled directly for neard, but it doesn't print the ones enabled for neard's dependencies, e.g nearcore. It would be nice to print the features of dependencies as well.

Recently we had an issue where nearcore/new_epoch_sync was getting enabled even though neard/new_epoch_sync wasn't enabled at all (zulip thread, pr with fix: https://github.com/near/nearcore/pull/11158).

Printing the features of dependencies would allow us to spot that the feature in nearcore is getting enabled and fix the problem immediately. Without that we had to spend a significant amount of time debugging why neard was behaving in a strange way.

nagisa commented 4 months ago

The only way I can think of would be to have a similar build.rs in all of the interesting crates and have those crates export a function/constant that describes the features it has been built with.

OR

Alternatively we could have one mini-crate that exports just such a constant and then defines all the different features that all the other crates would enable by a feature dependency. We could also appropriate e.g. near-primitives-core or some similar crate for this. And then use themis to ensure that we don't forget to maintain said property.