Nightly protocol features: compile time feature vs. runtime feature #4067
Replies: 4 comments 5 replies
-
I believe an issue with runtime features would be when we add public fields to structs we do still introduce a backward incompatible change that can't -exactly- be fixed by that. I would be interested in a solution for that. Working on the EVM protocol features now, we have ran into that issue already. However generally, I do like that approach as proposed by @matklad. |
Beta Was this translation helpful? Give feedback.
-
I want to second @joshuajbouw. With compile-time features, we can merge PRs into master and iterate there while not breaking the stable code and avoiding merge conflicts. nearcore is a network, not a standalone isolated tool like Rust compiler. It seems that runtime features will require quite some effort to land (increasing the number of merge conflicts one need to resolve while it is in development) |
Beta Was this translation helpful? Give feedback.
-
It seems to be orthogonal to runtime vs compile-time. I would argue that runtime features will require even more threading.
We will still need helpers to check if a given feature is enabled, so the ergonomics and IDE support is something that we may want to address separately.
I want us to keep in mind that "harder" is relative, and we seem to compare to the state where we did not have the features in the first place. Indeed, it has fewer knobs and whistles when there are no features in play, but I think it is going to be the same complexity either we have compile-time or runtime features. Though, Rust saves us with its compilation errors when we use compile-time features, so 1:0 to compile-time features in my opinion. |
Beta Was this translation helpful? Give feedback.
-
It just occurred to me that there's a third choice besides "use run-time detection" and "use cargo-features". We can be using non-features cfg flags. Ie, something like The problem here is that I don't know of a nice way to set such flags from CLI. Some options are:
Don't see an option which would be clearly better than today's situation though. |
Beta Was this translation helpful? Give feedback.
-
In near/NEPs#126, we discussed the use of rust compile time features to gate protocol changes that we would like to take more time to test and stabilize. Since then, we have moved to implementing all new protocol features behind rust features and only compile them when we enable
nightly_protocol_features
. After several months of working with this model, we have collected some feedback from developers who actively work on nearcore. While such paradigm serves its purpose of isolating new protocol features and allowing more flexibility in terms of releases, there are also some complaints about it:checked_feature
to reduce the amount of boilerplate code, it is still not very ergonomic to use. In addition, it does not always work well with IDEs.As @matklad mentioned in his comment, Rust compiler itself uses mostly runtime features instead of compile-time features and in the same comment, @matklad proposes to change to feature gating at runtime to reduce the complexity of the code and make it easier to implement new features. I would like to revive this discussion again in this thread. Please feel free to share your thoughts here!
Beta Was this translation helpful? Give feedback.
All reactions