mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 16:57:58 +00:00
add NodeFeatures field to HostConfiguration and runtime API (#2177)
Adds a `NodeFeatures` bitfield value to the runtime `HostConfiguration`, with the purpose of coordinating the enabling of node-side features, such as: https://github.com/paritytech/polkadot-sdk/issues/628 and https://github.com/paritytech/polkadot-sdk/issues/598. These are features that require all validators enable them at the same time, assuming all/most nodes have upgraded their node versions. This PR doesn't add any feature yet. These are coming in future PRs. Also adds a runtime API for querying the state of the client features and an extrinsic for setting/unsetting a feature by its index in the bitfield. Note: originally part of: https://github.com/paritytech/polkadot-sdk/pull/1644, but posted as standalone to be reused by other PRs until the initial PR is merged
This commit is contained in:
@@ -30,8 +30,8 @@ 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,
|
||||
slashing, vstaging::NodeFeatures, 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,
|
||||
};
|
||||
@@ -507,3 +507,32 @@ pub async fn request_min_backing_votes(
|
||||
min_backing_votes_res
|
||||
}
|
||||
}
|
||||
|
||||
/// Request the node features enabled in the runtime.
|
||||
/// Pass in the session index for caching purposes, as it should only change on session boundaries.
|
||||
/// Prior to runtime API version 9, just return `None`.
|
||||
pub async fn request_node_features(
|
||||
parent: Hash,
|
||||
session_index: SessionIndex,
|
||||
sender: &mut impl overseer::SubsystemSender<RuntimeApiMessage>,
|
||||
) -> Result<Option<NodeFeatures>> {
|
||||
let res = recv_runtime(
|
||||
request_from_runtime(parent, sender, |tx| {
|
||||
RuntimeApiRequest::NodeFeatures(session_index, tx)
|
||||
})
|
||||
.await,
|
||||
)
|
||||
.await;
|
||||
|
||||
if let Err(Error::RuntimeRequest(RuntimeApiError::NotSupported { .. })) = res {
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?parent,
|
||||
"Querying the node features from the runtime is not supported by the current Runtime API",
|
||||
);
|
||||
|
||||
Ok(None)
|
||||
} else {
|
||||
res.map(Some)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user