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:
Alin Dima
2023-11-14 20:48:32 +02:00
committed by GitHub
parent 31c38cea3d
commit fc12f435e3
25 changed files with 709 additions and 131 deletions
@@ -16,8 +16,8 @@
//! Put implementations of functions from staging APIs here.
use crate::shared;
use primitives::ValidatorIndex;
use crate::{configuration, initializer, shared};
use primitives::{vstaging::NodeFeatures, ValidatorIndex};
use sp_std::{collections::btree_map::BTreeMap, prelude::Vec};
/// Implementation for `DisabledValidators`
@@ -42,3 +42,8 @@ where
.filter_map(|v| reverse_index.get(v).cloned())
.collect()
}
/// Returns the current state of the node features.
pub fn node_features<T: initializer::Config>() -> NodeFeatures {
<configuration::Pallet<T>>::config().node_features
}