-
Notifications
You must be signed in to change notification settings - Fork 1.2k
add NodeFeatures field to HostConfiguration and runtime API #2177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
8aa7f3a
d88b791
61d5ad0
b4fcb1c
79bfc97
42c00b8
6e8e33d
4872169
4e2f764
72a71ff
b1abeb4
db20f6e
fd393d0
da7ce3a
6413b80
55adc2f
3d8d30f
d3b06b8
42cff85
9889c2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,10 +30,11 @@ use polkadot_node_subsystem::{ | |
| }; | ||
| use polkadot_node_subsystem_types::UnpinHandle; | ||
| use polkadot_primitives::{ | ||
| slashing, AsyncBackingParams, CandidateEvent, CandidateHash, CoreState, EncodeAs, | ||
| ExecutorParams, GroupIndex, GroupRotationInfo, Hash, IndexedVec, OccupiedCore, | ||
| ScrapedOnChainVotes, SessionIndex, SessionInfo, Signed, SigningContext, UncheckedSigned, | ||
| ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, LEGACY_MIN_BACKING_VOTES, | ||
| slashing, vstaging::ClientFeatures, AsyncBackingParams, CandidateEvent, CandidateHash, | ||
| CoreState, EncodeAs, ExecutorParams, GroupIndex, GroupRotationInfo, Hash, IndexedVec, | ||
| OccupiedCore, ScrapedOnChainVotes, SessionIndex, SessionInfo, Signed, SigningContext, | ||
| UncheckedSigned, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, | ||
| LEGACY_MIN_BACKING_VOTES, | ||
| }; | ||
|
|
||
| use crate::{ | ||
|
|
@@ -507,3 +508,27 @@ pub async fn request_min_backing_votes( | |
| min_backing_votes_res | ||
| } | ||
| } | ||
|
|
||
| /// Request the client features enabled in the runtime. | ||
| /// Prior to runtime API version 9, just return `None`. | ||
| pub async fn request_client_features( | ||
| parent: Hash, | ||
| sender: &mut impl overseer::SubsystemSender<RuntimeApiMessage>, | ||
| ) -> Result<Option<ClientFeatures>> { | ||
| let res = recv_runtime( | ||
| request_from_runtime(parent, sender, |tx| RuntimeApiRequest::ClientFeatures(tx)).await, | ||
| ) | ||
| .await; | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On session changes it would be a good idea to emit an warning to upgrade the node if not all bits make sense(at least a required feature we don't have)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that's doable if we want to be able to add new features without a runtime upgrade. If we want to emit warnings for new features that are added, they have to come via a runtime upgrade (which would defeat the purpose of what I've done with this PR so far in order to have seamless feature addition/enabling). I think it's best to leave it as it is
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes exactly, those are bits that only the client understands. This is just to inform the operator, that currently a client requirement is not fulfilled and a node upgrade is required.
No runtime upgrade is needed as the client will see a new
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense, I didn't fully get this from the beginning. As spoken on element, I'll add this on the next PR that uses this runtime API, as it'd be redundant right now. |
||
| if let Err(Error::RuntimeRequest(RuntimeApiError::NotSupported { .. })) = res { | ||
| gum::trace!( | ||
| target: LOG_TARGET, | ||
| ?parent, | ||
| "Querying the client features from the runtime is not supported by the current Runtime API", | ||
| ); | ||
|
|
||
| Ok(None) | ||
| } else { | ||
| res.map(Some) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need those to be able to change on a per block basis. We should make ClientFeatures session buffered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. please have a look