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 = [
"assert_matches",
"async-trait",
"bitvec",
"env_logger 0.9.3",
"frame-benchmarking",
"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 }
codec = { package = "parity-scale-codec", version = "3.6.1" }
parking_lot = "0.12.1"
bitvec = { version = "1.0.1", optional = true }
# Polkadot
polkadot-core-primitives = { path = "../../core-primitives" }
@@ -184,8 +185,8 @@ full-node = [
]
# Configure the native runtimes to use.
westend-native = ["westend-runtime", "westend-runtime-constants"]
rococo-native = ["rococo-runtime", "rococo-runtime-constants"]
westend-native = ["bitvec", "westend-runtime", "westend-runtime-constants"]
rococo-native = ["bitvec", "rococo-runtime", "rococo-runtime-constants"]
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(
) -> 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 {
validation_upgrade_cooldown: 2u32,
@@ -155,6 +157,9 @@ fn default_parachains_host_configuration(
max_candidate_depth: 3,
allowed_ancestry_len: 2,
},
node_features: bitvec::vec::BitVec::from_element(
1u8 << (FeatureIndex::ElasticScalingMVP as usize),
),
scheduler_params: SchedulerParams {
lookahead: 2,
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_system::pallet_prelude::*;
use primitives::{
collator_signature_payload, AvailabilityBitfield, BackedCandidate, CandidateCommitments,
CandidateDescriptor, CandidateHash, CollatorId, CollatorSignature, CommittedCandidateReceipt,
CompactStatement, CoreIndex, DisputeStatement, DisputeStatementSet, GroupIndex, HeadData,
Id as ParaId, IndexedVec, InherentData as ParachainsInherentData, InvalidDisputeStatementKind,
PersistedValidationData, SessionIndex, SigningContext, UncheckedSigned,
ValidDisputeStatementKind, ValidationCode, ValidatorId, ValidatorIndex, ValidityAttestation,
collator_signature_payload, vstaging::node_features::FeatureIndex, AvailabilityBitfield,
BackedCandidate, CandidateCommitments, CandidateDescriptor, CandidateHash, CollatorId,
CollatorSignature, CommittedCandidateReceipt, CompactStatement, CoreIndex, DisputeStatement,
DisputeStatementSet, GroupIndex, HeadData, Id as ParaId, IndexedVec,
InherentData as ParachainsInherentData, InvalidDisputeStatementKind, PersistedValidationData,
SessionIndex, SigningContext, UncheckedSigned, ValidDisputeStatementKind, ValidationCode,
ValidatorId, ValidatorIndex, ValidityAttestation,
};
use sp_core::{sr25519, H256};
use sp_runtime::{
@@ -509,7 +510,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
.iter()
.map(|(seed, num_votes)| {
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.
let collator_public = CollatorId::generate_pair(None);
@@ -586,11 +587,18 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
})
.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(
candidate,
validity_votes,
bitvec::bitvec![u8, bitvec::order::Lsb0; 1; group_validators.len()],
None,
core_idx,
)
})
.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
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
# 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.
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 };