Enable elastic scaling node feature in local testnets genesis (#3509)

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
This commit is contained in:
Andrei Sandu
2024-02-29 15:32:58 +02:00
committed by GitHub
parent c244a94e4a
commit 7f5d308d29
6 changed files with 27 additions and 58 deletions
Generated
+1
View File
@@ -13526,6 +13526,7 @@ version = "7.0.0"
dependencies = [ dependencies = [
"assert_matches", "assert_matches",
"async-trait", "async-trait",
"bitvec",
"env_logger 0.9.3", "env_logger 0.9.3",
"frame-benchmarking", "frame-benchmarking",
"frame-benchmarking-cli", "frame-benchmarking-cli",
+3 -2
View File
@@ -93,6 +93,7 @@ kvdb-rocksdb = { version = "0.19.0", optional = true }
parity-db = { version = "0.4.12", optional = true } parity-db = { version = "0.4.12", optional = true }
codec = { package = "parity-scale-codec", version = "3.6.1" } codec = { package = "parity-scale-codec", version = "3.6.1" }
parking_lot = "0.12.1" parking_lot = "0.12.1"
bitvec = { version = "1.0.1", optional = true }
# Polkadot # Polkadot
polkadot-core-primitives = { path = "../../core-primitives" } polkadot-core-primitives = { path = "../../core-primitives" }
@@ -184,8 +185,8 @@ full-node = [
] ]
# Configure the native runtimes to use. # Configure the native runtimes to use.
westend-native = ["westend-runtime", "westend-runtime-constants"] westend-native = ["bitvec", "westend-runtime", "westend-runtime-constants"]
rococo-native = ["rococo-runtime", "rococo-runtime-constants"] rococo-native = ["bitvec", "rococo-runtime", "rococo-runtime-constants"]
runtime-benchmarks = [ runtime-benchmarks = [
"frame-benchmarking-cli/runtime-benchmarks", "frame-benchmarking-cli/runtime-benchmarks",
+6 -1
View File
@@ -122,7 +122,9 @@ pub fn wococo_config() -> Result<RococoChainSpec, String> {
fn default_parachains_host_configuration( fn default_parachains_host_configuration(
) -> polkadot_runtime_parachains::configuration::HostConfiguration<polkadot_primitives::BlockNumber> ) -> polkadot_runtime_parachains::configuration::HostConfiguration<polkadot_primitives::BlockNumber>
{ {
use polkadot_primitives::{AsyncBackingParams, MAX_CODE_SIZE, MAX_POV_SIZE}; use polkadot_primitives::{
vstaging::node_features::FeatureIndex, AsyncBackingParams, MAX_CODE_SIZE, MAX_POV_SIZE,
};
polkadot_runtime_parachains::configuration::HostConfiguration { polkadot_runtime_parachains::configuration::HostConfiguration {
validation_upgrade_cooldown: 2u32, validation_upgrade_cooldown: 2u32,
@@ -155,6 +157,9 @@ fn default_parachains_host_configuration(
max_candidate_depth: 3, max_candidate_depth: 3,
allowed_ancestry_len: 2, allowed_ancestry_len: 2,
}, },
node_features: bitvec::vec::BitVec::from_element(
1u8 << (FeatureIndex::ElasticScalingMVP as usize),
),
scheduler_params: SchedulerParams { scheduler_params: SchedulerParams {
lookahead: 2, lookahead: 2,
group_rotation_frequency: 20, group_rotation_frequency: 20,
+16 -8
View File
@@ -25,12 +25,13 @@ use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec};
use frame_support::pallet_prelude::*; use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*; use frame_system::pallet_prelude::*;
use primitives::{ use primitives::{
collator_signature_payload, AvailabilityBitfield, BackedCandidate, CandidateCommitments, collator_signature_payload, vstaging::node_features::FeatureIndex, AvailabilityBitfield,
CandidateDescriptor, CandidateHash, CollatorId, CollatorSignature, CommittedCandidateReceipt, BackedCandidate, CandidateCommitments, CandidateDescriptor, CandidateHash, CollatorId,
CompactStatement, CoreIndex, DisputeStatement, DisputeStatementSet, GroupIndex, HeadData, CollatorSignature, CommittedCandidateReceipt, CompactStatement, CoreIndex, DisputeStatement,
Id as ParaId, IndexedVec, InherentData as ParachainsInherentData, InvalidDisputeStatementKind, DisputeStatementSet, GroupIndex, HeadData, Id as ParaId, IndexedVec,
PersistedValidationData, SessionIndex, SigningContext, UncheckedSigned, InherentData as ParachainsInherentData, InvalidDisputeStatementKind, PersistedValidationData,
ValidDisputeStatementKind, ValidationCode, ValidatorId, ValidatorIndex, ValidityAttestation, SessionIndex, SigningContext, UncheckedSigned, ValidDisputeStatementKind, ValidationCode,
ValidatorId, ValidatorIndex, ValidityAttestation,
}; };
use sp_core::{sr25519, H256}; use sp_core::{sr25519, H256};
use sp_runtime::{ use sp_runtime::{
@@ -509,7 +510,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
.iter() .iter()
.map(|(seed, num_votes)| { .map(|(seed, num_votes)| {
assert!(*num_votes <= validators.len() as u32); assert!(*num_votes <= validators.len() as u32);
let (para_id, _core_idx, group_idx) = self.create_indexes(*seed); let (para_id, core_idx, group_idx) = self.create_indexes(*seed);
// This generates a pair and adds it to the keystore, returning just the public. // This generates a pair and adds it to the keystore, returning just the public.
let collator_public = CollatorId::generate_pair(None); let collator_public = CollatorId::generate_pair(None);
@@ -586,11 +587,18 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
}) })
.collect(); .collect();
// Check if the elastic scaling bit is set, if so we need to supply the core index
// in the generated candidate.
let core_idx = configuration::Pallet::<T>::config()
.node_features
.get(FeatureIndex::ElasticScalingMVP as usize)
.map(|_the_bit| core_idx);
BackedCandidate::<T::Hash>::new( BackedCandidate::<T::Hash>::new(
candidate, candidate,
validity_votes, validity_votes,
bitvec::bitvec![u8, bitvec::order::Lsb0; 1; group_validators.len()], bitvec::bitvec![u8, bitvec::order::Lsb0; 1; group_validators.len()],
None, core_idx,
) )
}) })
.collect() .collect()
@@ -1,4 +1,4 @@
Description: Test that a paraid acquiring multiple cores does not brick itself if ElasticScalingMVP feature is enabled Description: Test that a paraid acquiring multiple cores does not brick itself if ElasticScalingMVP feature is enabled in genesis
Network: ./0012-elastic-scaling-mvp.toml Network: ./0012-elastic-scaling-mvp.toml
Creds: config Creds: config
@@ -15,14 +15,5 @@ alice: js-script ./0012-register-para.js return is 0 within 600 seconds
validator: reports substrate_block_height{status="finalized"} is at least 35 within 100 seconds validator: reports substrate_block_height{status="finalized"} is at least 35 within 100 seconds
# Parachain will now be stalled
validator: parachain 2000 block height is lower than 20 within 300 seconds
# Enable the ElasticScalingMVP node feature.
alice: js-script ./0012-enable-node-feature.js with "1" return is 0 within 600 seconds
# Wait two sessions for the config to be updated.
sleep 120 seconds
# Ensure parachain is now making progress. # Ensure parachain is now making progress.
validator: parachain 2000 block height is at least 30 within 200 seconds validator: parachain 2000 block height is at least 30 within 200 seconds
@@ -1,37 +0,0 @@
async function run(nodeName, networkInfo, index) {
const { wsUri, userDefinedTypes } = networkInfo.nodesByName[nodeName];
const api = await zombie.connect(wsUri, userDefinedTypes);
await zombie.util.cryptoWaitReady();
// account to submit tx
const keyring = new zombie.Keyring({ type: "sr25519" });
const alice = keyring.addFromUri("//Alice");
await new Promise(async (resolve, reject) => {
const unsub = await api.tx.sudo
.sudo(api.tx.configuration.setNodeFeature(Number(index), true))
.signAndSend(alice, ({ status, isError }) => {
if (status.isInBlock) {
console.log(
`Transaction included at blockhash ${status.asInBlock}`,
);
} else if (status.isFinalized) {
console.log(
`Transaction finalized at blockHash ${status.asFinalized}`,
);
unsub();
return resolve();
} else if (isError) {
console.log(`Transaction error`);
reject(`Transaction error`);
}
});
});
return 0;
}
module.exports = { run };