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
+12 -7
View File
@@ -46,12 +46,12 @@ use pallet_session::historical as session_historical;
use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use primitives::{
slashing, AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash,
CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash,
Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce,
OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes,
SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
ValidatorSignature, PARACHAIN_KEY_TYPE_ID,
slashing, vstaging::NodeFeatures, AccountId, AccountIndex, Balance, BlockNumber,
CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState,
ExecutorParams, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage,
InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData,
PvfCheckStatement, ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode,
ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, PARACHAIN_KEY_TYPE_ID,
};
use runtime_common::{
assigned_slots, auctions, crowdloan,
@@ -1559,6 +1559,7 @@ pub mod migrations {
pallet_referenda::migration::v1::MigrateV0ToV1<Runtime, ()>,
pallet_nomination_pools::migration::versioned_migrations::V6ToV7<Runtime>,
pallet_grandpa::migrations::MigrateV4ToV5<Runtime>,
parachains_configuration::migration::v10::MigrateToV10<Runtime>,
);
}
@@ -1699,7 +1700,7 @@ sp_api::impl_runtime_apis! {
}
}
#[api_version(8)]
#[api_version(9)]
impl primitives::runtime_api::ParachainHost<Block, Hash, BlockNumber> for Runtime {
fn validators() -> Vec<ValidatorId> {
parachains_runtime_api_impl::validators::<Runtime>()
@@ -1846,6 +1847,10 @@ sp_api::impl_runtime_apis! {
fn disabled_validators() -> Vec<ValidatorIndex> {
parachains_staging_runtime_api_impl::disabled_validators::<Runtime>()
}
fn node_features() -> NodeFeatures {
parachains_staging_runtime_api_impl::node_features::<Runtime>()
}
}
impl beefy_primitives::BeefyApi<Block, BeefyId> for Runtime {